ENH: Add logging of submitting
This commit is contained in:
parent
3e0817eb55
commit
dd9241121d
|
@ -142,6 +142,8 @@ bool cmCTestSubmit::SubmitUsingFTP(const cmStdString& localprefix,
|
|||
}
|
||||
|
||||
ftpfile = ::fopen(local_file.c_str(), "rb");
|
||||
*m_LogFile << "\tUpload file: " << local_file.c_str() << " to "
|
||||
<< upload_as.c_str() << std::endl;
|
||||
if ( m_Verbose )
|
||||
{
|
||||
std::cout << " Upload file: " << local_file.c_str() << " to "
|
||||
|
@ -170,6 +172,8 @@ bool cmCTestSubmit::SubmitUsingFTP(const cmStdString& localprefix,
|
|||
{
|
||||
std::cout << " Error when uploading file: " << local_file.c_str() << std::endl;
|
||||
std::cout << " Error message was: " << error_buffer << std::endl;
|
||||
*m_LogFile << " Error when uploading file: " << local_file.c_str() << std::endl
|
||||
<< " Error message was: " << error_buffer << std::endl;
|
||||
::curl_easy_cleanup(curl);
|
||||
::curl_global_cleanup();
|
||||
return false;
|
||||
|
@ -192,6 +196,7 @@ bool cmCTestSubmit::SubmitUsingHTTP(const cmStdString& localprefix,
|
|||
CURL *curl;
|
||||
CURLcode res;
|
||||
FILE* ftpfile;
|
||||
char error_buffer[1024];
|
||||
|
||||
/* In windows, this will init the winsock stuff */
|
||||
::curl_global_init(CURL_GLOBAL_ALL);
|
||||
|
@ -233,6 +238,10 @@ bool cmCTestSubmit::SubmitUsingHTTP(const cmStdString& localprefix,
|
|||
|
||||
cmStdString local_file = localprefix + "/" + files[cc];
|
||||
cmStdString remote_file = remoteprefix + files[cc];
|
||||
|
||||
*m_LogFile << "\tUpload file: " << local_file.c_str() << " to "
|
||||
<< remote_file.c_str() << std::endl;
|
||||
|
||||
cmStdString ofile = "";
|
||||
for ( kk = 0; kk < remote_file.size(); kk ++ )
|
||||
{
|
||||
|
@ -281,6 +290,9 @@ bool cmCTestSubmit::SubmitUsingHTTP(const cmStdString& localprefix,
|
|||
// and give the size of the upload (optional)
|
||||
::curl_easy_setopt(curl, CURLOPT_INFILESIZE, static_cast<long>(st.st_size));
|
||||
|
||||
// and give curl the buffer for errors
|
||||
::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer);
|
||||
|
||||
// Now run off and do what you've been told!
|
||||
res = ::curl_easy_perform(curl);
|
||||
|
||||
|
@ -288,6 +300,8 @@ bool cmCTestSubmit::SubmitUsingHTTP(const cmStdString& localprefix,
|
|||
if ( res )
|
||||
{
|
||||
std::cout << " Error when uploading file: " << local_file.c_str() << std::endl;
|
||||
*m_LogFile << " Error when uploading file: " << local_file.c_str() << std::endl
|
||||
<< " Error message was: " << error_buffer << std::endl;
|
||||
::curl_easy_cleanup(curl);
|
||||
::curl_global_cleanup();
|
||||
return false;
|
||||
|
@ -306,6 +320,7 @@ bool cmCTestSubmit::TriggerUsingHTTP(const std::vector<cmStdString>& files,
|
|||
const cmStdString& url)
|
||||
{
|
||||
CURL *curl;
|
||||
char error_buffer[1024];
|
||||
|
||||
/* In windows, this will init the winsock stuff */
|
||||
::curl_global_init(CURL_GLOBAL_ALL);
|
||||
|
@ -339,6 +354,10 @@ bool cmCTestSubmit::TriggerUsingHTTP(const std::vector<cmStdString>& files,
|
|||
{
|
||||
::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
|
||||
}
|
||||
|
||||
// and give curl the buffer for errors
|
||||
::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer);
|
||||
|
||||
cmStdString file = remoteprefix + files[cc];
|
||||
cmStdString ofile = "";
|
||||
for ( kk = 0; kk < file.size(); kk ++ )
|
||||
|
@ -364,6 +383,7 @@ bool cmCTestSubmit::TriggerUsingHTTP(const std::vector<cmStdString>& files,
|
|||
}
|
||||
}
|
||||
cmStdString turl = url + "?xmlfile=" + ofile;
|
||||
*m_LogFile << "Trigger url: " << turl.c_str() << std::endl;
|
||||
if ( m_Verbose )
|
||||
{
|
||||
std::cout << " Trigger url: " << turl.c_str() << std::endl;
|
||||
|
@ -372,6 +392,7 @@ bool cmCTestSubmit::TriggerUsingHTTP(const std::vector<cmStdString>& files,
|
|||
if ( curl_easy_perform(curl) )
|
||||
{
|
||||
std::cout << " Error when triggering: " << turl.c_str() << std::endl;
|
||||
*m_LogFile << "\tTrigerring failed with error: " << error_buffer << std::endl;
|
||||
::curl_easy_cleanup(curl);
|
||||
::curl_global_cleanup();
|
||||
return false;
|
||||
|
|
|
@ -29,7 +29,7 @@ class cmCTestSubmit
|
|||
{
|
||||
public:
|
||||
cmCTestSubmit();
|
||||
~cmCTestSubmit() {}
|
||||
~cmCTestSubmit() { m_LogFile = 0; }
|
||||
|
||||
/**
|
||||
* Set verbosity of send
|
||||
|
@ -37,6 +37,8 @@ public:
|
|||
void SetVerbose(bool i) { m_Verbose = i; }
|
||||
void VerboseOn() { this->SetVerbose(1); }
|
||||
void VerboseOff() { this->SetVerbose(0); }
|
||||
|
||||
void SetLogFile(std::ostream* ost) { m_LogFile = ost; }
|
||||
|
||||
/**
|
||||
* Submit file using various ways
|
||||
|
@ -59,11 +61,12 @@ public:
|
|||
const cmStdString& url);
|
||||
|
||||
private:
|
||||
cmStdString m_HTTPProxy;
|
||||
int m_HTTPProxyType;
|
||||
cmStdString m_FTPProxy;
|
||||
int m_FTPProxyType;
|
||||
bool m_Verbose;
|
||||
cmStdString m_HTTPProxy;
|
||||
int m_HTTPProxyType;
|
||||
cmStdString m_FTPProxy;
|
||||
int m_FTPProxyType;
|
||||
bool m_Verbose;
|
||||
std::ostream* m_LogFile;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2442,6 +2442,9 @@ int cmCTest::TestDirectory(bool memcheck)
|
|||
|
||||
int cmCTest::SubmitResults()
|
||||
{
|
||||
std::ofstream ofs;
|
||||
this->OpenOutputFile("Temporary", "LastSubmit.log", ofs);
|
||||
|
||||
cmCTest::tm_VectorOfStrings files;
|
||||
std::string prefix = this->GetSubmitResultsPrefix();
|
||||
// TODO:
|
||||
|
@ -2497,11 +2500,25 @@ int cmCTest::SubmitResults()
|
|||
{
|
||||
files.push_back("Notes.xml");
|
||||
}
|
||||
|
||||
if ( ofs )
|
||||
{
|
||||
ofs << "Upload files:" << std::endl;
|
||||
int cnt = 0;
|
||||
cmCTest::tm_VectorOfStrings::iterator it;
|
||||
for ( it = files.begin(); it != files.end(); ++ it )
|
||||
{
|
||||
ofs << cnt << "\t" << it->c_str() << std::endl;
|
||||
cnt ++;
|
||||
}
|
||||
}
|
||||
cmCTestSubmit submit;
|
||||
submit.SetVerbose(m_Verbose);
|
||||
submit.SetLogFile(&ofs);
|
||||
if ( m_DartConfiguration["DropMethod"] == "" ||
|
||||
m_DartConfiguration["DropMethod"] == "ftp" )
|
||||
{
|
||||
ofs << "Using drop method: FTP" << std::endl;
|
||||
std::cout << " Using FTP submit method" << std::endl;
|
||||
std::string url = "ftp://";
|
||||
url += cmCTest::MakeURLSafe(m_DartConfiguration["DropSiteUser"]) + ":" +
|
||||
|
@ -2512,18 +2529,22 @@ int cmCTest::SubmitResults()
|
|||
files, prefix, url) )
|
||||
{
|
||||
std::cerr << " Problems when submitting via FTP" << std::endl;
|
||||
ofs << " Problems when submitting via FTP" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
if ( !submit.TriggerUsingHTTP(files, prefix, m_DartConfiguration["TriggerSite"]) )
|
||||
{
|
||||
std::cerr << " Problems when triggering via HTTP" << std::endl;
|
||||
ofs << " Problems when triggering via HTTP" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
std::cout << " Submission successfull" << std::endl;
|
||||
ofs << " Submission succesfull" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
else if ( m_DartConfiguration["DropMethod"] == "http" )
|
||||
{
|
||||
ofs << "Using drop method: HTTP" << std::endl;
|
||||
std::cout << " Using HTTP submit method" << std::endl;
|
||||
std::string url = "http://";
|
||||
if ( m_DartConfiguration["DropSiteUser"].size() > 0 )
|
||||
|
@ -2539,19 +2560,23 @@ int cmCTest::SubmitResults()
|
|||
if ( !submit.SubmitUsingHTTP(m_ToplevelPath+"/Testing/"+m_CurrentTag, files, prefix, url) )
|
||||
{
|
||||
std::cerr << " Problems when submitting via HTTP" << std::endl;
|
||||
ofs << " Problems when submitting via HTTP" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
if ( !submit.TriggerUsingHTTP(files, prefix, m_DartConfiguration["TriggerSite"]) )
|
||||
{
|
||||
std::cerr << " Problems when triggering via HTTP" << std::endl;
|
||||
ofs << " Problems when triggering via HTTP" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
std::cout << " Submission successfull" << std::endl;
|
||||
ofs << " Submission succesfull" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "SCP submit not yet implemented" << std::endl;
|
||||
ofs << "SCP submit not yet implemented" << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue