ENH: Cleanup output even more

This commit is contained in:
Andy Cedilnik 2005-06-02 14:48:10 -04:00
parent 6a19668513
commit 19b5c93ca2

View File

@ -47,6 +47,15 @@ cmCTestSubmitHandlerWriteMemoryCallback(void *ptr, size_t size, size_t nmemb, vo
return realsize; return realsize;
} }
static size_t
cmCTestSubmitHandlerCurlDebugCallback(CURL *, curl_infotype, char *chPtr, size_t size, void *data)
{
cmCTestSubmitHandlerVectorOfChar *vec = static_cast<cmCTestSubmitHandlerVectorOfChar*>(data);
vec->insert(vec->end(), chPtr, chPtr + size);
return size;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmCTestSubmitHandler::cmCTestSubmitHandler() : m_HTTPProxy(), m_FTPProxy() cmCTestSubmitHandler::cmCTestSubmitHandler() : m_HTTPProxy(), m_FTPProxy()
{ {
@ -184,11 +193,8 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix,
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " Upload file: " << local_file.c_str() << " to " cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " Upload file: " << local_file.c_str() << " to "
<< upload_as.c_str() << std::endl); << upload_as.c_str() << std::endl);
::curl_easy_setopt(curl, CURLOPT_VERBOSE, 0);
if ( m_HandlerVerbose )
{
::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
}
// specify target // specify target
::curl_easy_setopt(curl,CURLOPT_URL, upload_as.c_str()); ::curl_easy_setopt(curl,CURLOPT_URL, upload_as.c_str());
@ -203,16 +209,21 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix,
// specify handler for output // specify handler for output
::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cmCTestSubmitHandlerWriteMemoryCallback); ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cmCTestSubmitHandlerWriteMemoryCallback);
::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, cmCTestSubmitHandlerCurlDebugCallback);
/* we pass our 'chunk' struct to the callback function */ /* we pass our 'chunk' struct to the callback function */
cmCTestSubmitHandlerVectorOfChar chunk; cmCTestSubmitHandlerVectorOfChar chunk;
cmCTestSubmitHandlerVectorOfChar chunkDebug;
::curl_easy_setopt(curl, CURLOPT_FILE, (void *)&chunk); ::curl_easy_setopt(curl, CURLOPT_FILE, (void *)&chunk);
::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void *)&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); res = ::curl_easy_perform(curl);
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "CURL output: [" cmCTestLog(m_CTest, DEBUG, "CURL output: ["
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" << std::endl); << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" << std::endl);
cmCTestLog(m_CTest, DEBUG, "CURL debug output: ["
<< cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]" << std::endl);
fclose(ftpfile); fclose(ftpfile);
if ( res ) if ( res )
@ -286,12 +297,8 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix,
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1) ; curl_easy_setopt(curl, CURLOPT_UPLOAD, 1) ;
/* HTTP PUT please */ /* HTTP PUT please */
curl_easy_setopt(curl, CURLOPT_PUT, 1); ::curl_easy_setopt(curl, CURLOPT_PUT, 1);
::curl_easy_setopt(curl, CURLOPT_VERBOSE, 0);
if ( m_HandlerVerbose )
{
::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
}
cmStdString local_file = localprefix + "/" + files[cc]; cmStdString local_file = localprefix + "/" + files[cc];
cmStdString remote_file = remoteprefix + files[cc]; cmStdString remote_file = remoteprefix + files[cc];
@ -351,16 +358,21 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix,
// specify handler for output // specify handler for output
::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cmCTestSubmitHandlerWriteMemoryCallback); ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cmCTestSubmitHandlerWriteMemoryCallback);
::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, cmCTestSubmitHandlerCurlDebugCallback);
/* we pass our 'chunk' struct to the callback function */ /* we pass our 'chunk' struct to the callback function */
cmCTestSubmitHandlerVectorOfChar chunk; cmCTestSubmitHandlerVectorOfChar chunk;
cmCTestSubmitHandlerVectorOfChar chunkDebug;
::curl_easy_setopt(curl, CURLOPT_FILE, (void *)&chunk); ::curl_easy_setopt(curl, CURLOPT_FILE, (void *)&chunk);
::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void *)&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); res = ::curl_easy_perform(curl);
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "CURL output: [" cmCTestLog(m_CTest, DEBUG, "CURL output: ["
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" << std::endl); << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" << std::endl);
cmCTestLog(m_CTest, DEBUG, "CURL debug output: ["
<< cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]" << std::endl);
fclose(ftpfile); fclose(ftpfile);
if ( res ) if ( res )
@ -425,21 +437,20 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(const std::vector<cmStdString>& file
} }
} }
::curl_easy_setopt(curl, CURLOPT_VERBOSE, 0);
if ( m_HandlerVerbose )
{
::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
}
// and give curl the buffer for errors // and give curl the buffer for errors
::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer); ::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer);
// specify handler for output // specify handler for output
::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cmCTestSubmitHandlerWriteMemoryCallback); ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cmCTestSubmitHandlerWriteMemoryCallback);
::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, cmCTestSubmitHandlerCurlDebugCallback);
/* we pass our 'chunk' struct to the callback function */ /* we pass our 'chunk' struct to the callback function */
cmCTestSubmitHandlerVectorOfChar chunk; cmCTestSubmitHandlerVectorOfChar chunk;
cmCTestSubmitHandlerVectorOfChar chunkDebug;
::curl_easy_setopt(curl, CURLOPT_FILE, (void *)&chunk); ::curl_easy_setopt(curl, CURLOPT_FILE, (void *)&chunk);
::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void *)&chunkDebug);
cmStdString file = remoteprefix + files[cc]; cmStdString file = remoteprefix + files[cc];
cmStdString ofile = ""; cmStdString ofile = "";
@ -485,8 +496,10 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(const std::vector<cmStdString>& file
return false; return false;
} }
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "CURL output: [" cmCTestLog(m_CTest, DEBUG, "CURL output: ["
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" << std::endl); << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" << std::endl);
cmCTestLog(m_CTest, DEBUG, "CURL debug output: ["
<< cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]" << std::endl);
// always cleanup // always cleanup
::curl_easy_cleanup(curl); ::curl_easy_cleanup(curl);