diff options
author | Zack Galbreath <zack.galbreath@kitware.com> | 2023-07-24 14:00:11 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-07-25 13:09:56 (GMT) |
commit | b7c871f7459ef18f863d8fea15eae7e7f85a9d34 (patch) | |
tree | 15e3166e9af0d262e2b92cd793bb739a422e3cab | |
parent | eace51a20cc9597878e92d96da97492af99d95c1 (diff) | |
download | CMake-b7c871f7459ef18f863d8fea15eae7e7f85a9d34.zip CMake-b7c871f7459ef18f863d8fea15eae7e7f85a9d34.tar.gz CMake-b7c871f7459ef18f863d8fea15eae7e7f85a9d34.tar.bz2 |
ctest: Update ctest_submit for CDash behavior change
open.cdash.org was recently upgraded in preparation for the release of
CDash v3.2.0. This upgrade brought a change in behavior where CDash now
responds with HTTP 400 (bad request) rather than HTTP 200 (OK) for MD5
checksum mismatches during submission time.
This commit removes our usage of CURLOPT_FAILONERROR in
cmCTestSubmitHandler.cxx This was necessary to pass along the contents
of the request body ("md5 mismatch") in cases where the web server
(CDash) responds with an error status (400).
Fixes: #25121
-rw-r--r-- | Source/CTest/cmCTestSubmitHandler.cxx | 21 | ||||
-rw-r--r-- | Tests/CMakeLists.txt | 2 |
2 files changed, 13 insertions, 10 deletions
diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 3ff8c8f..9161515 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -142,7 +142,6 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP( const std::string& remoteprefix, const std::string& url) { CURL* curl; - CURLcode res; FILE* ftpfile; char error_buffer[1024]; // Set Content-Type to satisfy fussy modsecurity rules. @@ -210,8 +209,6 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP( if (this->CTest->ShouldUseHTTP10()) { curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); } - // enable HTTP ERROR parsing - curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1); /* enable uploading */ curl_easy_setopt(curl, CURLOPT_UPLOAD, 1); @@ -285,7 +282,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP( upload_as += "&MD5="; if (cmIsOn(this->GetOption("InternalTest"))) { - upload_as += "bad_md5sum"; + upload_as += "ffffffffffffffffffffffffffffffff"; } else { upload_as += cmSystemTools::ComputeFileHash(local_file, cmCryptoHash::AlgoMD5); @@ -337,7 +334,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP( ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &chunkDebug); // Now run off and do what you've been told! - res = ::curl_easy_perform(curl); + ::curl_easy_perform(curl); if (!chunk.empty()) { cmCTestOptionalLog(this->CTest, DEBUG, @@ -358,7 +355,11 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP( // If curl failed for any reason, or checksum fails, wait and retry // - if (res != CURLE_OK || this->HasErrors) { + long response_code; + curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code); + bool successful_submission = response_code == 200; + + if (!successful_submission || this->HasErrors) { std::string retryDelay = *this->GetOption("RetryDelay"); std::string retryCount = *this->GetOption("RetryCount"); @@ -396,7 +397,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP( chunkDebug.clear(); this->HasErrors = false; - res = ::curl_easy_perform(curl); + ::curl_easy_perform(curl); if (!chunk.empty()) { cmCTestOptionalLog(this->CTest, DEBUG, @@ -407,14 +408,16 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP( this->ParseResponse(chunk); } - if (res == CURLE_OK && !this->HasErrors) { + curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code); + if (response_code == 200 && !this->HasErrors) { + successful_submission = true; break; } } } fclose(ftpfile); - if (res) { + if (!successful_submission) { cmCTestLog(this->CTest, ERROR_MESSAGE, " Error when uploading file: " << local_file << std::endl); diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index c22f704..09dfa7b 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -3304,7 +3304,7 @@ if(BUILD_TESTING) "${CMake_BINARY_DIR}/Tests/CTestTestChecksum/testOutput.log" ) set_tests_properties(CTestTestChecksum PROPERTIES PASS_REGULAR_EXPRESSION - "Submission failed: Checksum failed for file") + "md5 mismatch") # these tests take a long time, make sure they have it # if timeouts have not already been set |