Răsfoiți Sursa

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
Zack Galbreath 2 ani în urmă
părinte
comite
b7c871f745
2 a modificat fișierele cu 13 adăugiri și 10 ștergeri
  1. 12 9
      Source/CTest/cmCTestSubmitHandler.cxx
  2. 1 1
      Tests/CMakeLists.txt

+ 12 - 9
Source/CTest/cmCTestSubmitHandler.cxx

@@ -142,7 +142,6 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(
   const std::string& remoteprefix, const std::string& url)
   const std::string& remoteprefix, const std::string& url)
 {
 {
   CURL* curl;
   CURL* curl;
-  CURLcode res;
   FILE* ftpfile;
   FILE* ftpfile;
   char error_buffer[1024];
   char error_buffer[1024];
   // Set Content-Type to satisfy fussy modsecurity rules.
   // Set Content-Type to satisfy fussy modsecurity rules.
@@ -210,8 +209,6 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(
       if (this->CTest->ShouldUseHTTP10()) {
       if (this->CTest->ShouldUseHTTP10()) {
         curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
         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 */
       /* enable uploading */
       curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
       curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
 
 
@@ -285,7 +282,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(
       upload_as += "&MD5=";
       upload_as += "&MD5=";
 
 
       if (cmIsOn(this->GetOption("InternalTest"))) {
       if (cmIsOn(this->GetOption("InternalTest"))) {
-        upload_as += "bad_md5sum";
+        upload_as += "ffffffffffffffffffffffffffffffff";
       } else {
       } else {
         upload_as +=
         upload_as +=
           cmSystemTools::ComputeFileHash(local_file, cmCryptoHash::AlgoMD5);
           cmSystemTools::ComputeFileHash(local_file, cmCryptoHash::AlgoMD5);
@@ -337,7 +334,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(
       ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &chunkDebug);
       ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &chunkDebug);
 
 
       // Now run off and do what you've been told!
       // Now run off and do what you've been told!
-      res = ::curl_easy_perform(curl);
+      ::curl_easy_perform(curl);
 
 
       if (!chunk.empty()) {
       if (!chunk.empty()) {
         cmCTestOptionalLog(this->CTest, DEBUG,
         cmCTestOptionalLog(this->CTest, DEBUG,
@@ -358,7 +355,11 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(
 
 
       // If curl failed for any reason, or checksum fails, wait and retry
       // 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 retryDelay = *this->GetOption("RetryDelay");
         std::string retryCount = *this->GetOption("RetryCount");
         std::string retryCount = *this->GetOption("RetryCount");
 
 
@@ -396,7 +397,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(
           chunkDebug.clear();
           chunkDebug.clear();
           this->HasErrors = false;
           this->HasErrors = false;
 
 
-          res = ::curl_easy_perform(curl);
+          ::curl_easy_perform(curl);
 
 
           if (!chunk.empty()) {
           if (!chunk.empty()) {
             cmCTestOptionalLog(this->CTest, DEBUG,
             cmCTestOptionalLog(this->CTest, DEBUG,
@@ -407,14 +408,16 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(
             this->ParseResponse(chunk);
             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;
             break;
           }
           }
         }
         }
       }
       }
 
 
       fclose(ftpfile);
       fclose(ftpfile);
-      if (res) {
+      if (!successful_submission) {
         cmCTestLog(this->CTest, ERROR_MESSAGE,
         cmCTestLog(this->CTest, ERROR_MESSAGE,
                    "   Error when uploading file: " << local_file
                    "   Error when uploading file: " << local_file
                                                     << std::endl);
                                                     << std::endl);

+ 1 - 1
Tests/CMakeLists.txt

@@ -3304,7 +3304,7 @@ if(BUILD_TESTING)
       "${CMake_BINARY_DIR}/Tests/CTestTestChecksum/testOutput.log"
       "${CMake_BINARY_DIR}/Tests/CTestTestChecksum/testOutput.log"
       )
       )
     set_tests_properties(CTestTestChecksum PROPERTIES PASS_REGULAR_EXPRESSION
     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
     # these tests take a long time, make sure they have it
     # if timeouts have not already been set
     # if timeouts have not already been set