2016-09-27 22:01:08 +03:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2005-05-03 16:17:39 +04:00
|
|
|
#include "cmCTestSubmitHandler.h"
|
2016-04-29 16:40:20 +03:00
|
|
|
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmCTest.h"
|
2016-08-24 23:01:40 +03:00
|
|
|
#include "cmCTestCurl.h"
|
2015-01-14 18:54:25 +03:00
|
|
|
#include "cmCTestScriptHandler.h"
|
2016-08-24 23:01:40 +03:00
|
|
|
#include "cmCurl.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmGeneratedFileStream.h"
|
|
|
|
#include "cmState.h"
|
2003-01-07 07:07:24 +03:00
|
|
|
#include "cmSystemTools.h"
|
2010-06-03 18:34:34 +04:00
|
|
|
#include "cmXMLParser.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmake.h"
|
2003-01-07 07:07:24 +03:00
|
|
|
|
2016-08-24 23:01:40 +03:00
|
|
|
#include <cm_curl.h>
|
2015-01-14 18:54:25 +03:00
|
|
|
#include <cm_jsoncpp_reader.h>
|
2016-08-24 23:01:40 +03:00
|
|
|
#include <cm_jsoncpp_value.h>
|
|
|
|
#include <cmsys/Process.h>
|
|
|
|
#include <sstream>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2005-03-05 01:11:42 +03:00
|
|
|
|
2016-08-24 23:01:40 +03:00
|
|
|
#if defined(CTEST_USE_XMLRPC)
|
|
|
|
#include "cmVersion.h"
|
|
|
|
#include <cm_xmlrpc.h>
|
2003-01-08 06:24:45 +03:00
|
|
|
#include <sys/stat.h>
|
2016-08-24 23:01:40 +03:00
|
|
|
#endif
|
2003-01-08 06:24:45 +03:00
|
|
|
|
2009-09-04 22:00:26 +04:00
|
|
|
#define SUBMIT_TIMEOUT_IN_SECONDS_DEFAULT 120
|
|
|
|
|
2005-06-01 01:32:40 +04:00
|
|
|
typedef std::vector<char> cmCTestSubmitHandlerVectorOfChar;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
class cmCTestSubmitHandler::ResponseParser : public cmXMLParser
|
2010-06-03 18:34:34 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
ResponseParser() { this->Status = STATUS_OK; }
|
2016-06-27 22:25:27 +03:00
|
|
|
~ResponseParser() CM_OVERRIDE {}
|
2010-06-03 18:34:34 +04:00
|
|
|
|
|
|
|
public:
|
|
|
|
enum StatusType
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
2010-06-03 18:34:34 +04:00
|
|
|
STATUS_OK,
|
|
|
|
STATUS_WARNING,
|
|
|
|
STATUS_ERROR
|
2016-05-16 17:34:04 +03:00
|
|
|
};
|
2010-06-03 18:34:34 +04:00
|
|
|
|
|
|
|
StatusType Status;
|
|
|
|
std::string CDashVersion;
|
|
|
|
std::string Filename;
|
|
|
|
std::string MD5;
|
|
|
|
std::string Message;
|
|
|
|
|
|
|
|
private:
|
2010-06-03 21:27:26 +04:00
|
|
|
std::vector<char> CurrentValue;
|
|
|
|
|
|
|
|
std::string GetCurrentValue()
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
2010-06-03 21:27:26 +04:00
|
|
|
std::string val;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->CurrentValue.empty()) {
|
2010-06-03 21:52:48 +04:00
|
|
|
val.assign(&this->CurrentValue[0], this->CurrentValue.size());
|
2010-06-03 21:27:26 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return val;
|
|
|
|
}
|
2010-06-03 18:34:34 +04:00
|
|
|
|
2016-06-23 02:02:39 +03:00
|
|
|
void StartElement(const std::string& name, const char** atts) CM_OVERRIDE
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
2010-06-03 21:27:26 +04:00
|
|
|
this->CurrentValue.clear();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (name == "cdash") {
|
2010-06-03 18:34:34 +04:00
|
|
|
this->CDashVersion = this->FindAttribute(atts, "version");
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-06-03 18:34:34 +04:00
|
|
|
|
2016-06-23 02:02:39 +03:00
|
|
|
void CharacterDataHandler(const char* data, int length) CM_OVERRIDE
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
|
|
|
this->CurrentValue.insert(this->CurrentValue.end(), data, data + length);
|
|
|
|
}
|
2010-06-03 18:34:34 +04:00
|
|
|
|
2016-06-23 02:02:39 +03:00
|
|
|
void EndElement(const std::string& name) CM_OVERRIDE
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
|
|
|
if (name == "status") {
|
2010-06-03 21:27:26 +04:00
|
|
|
std::string status = cmSystemTools::UpperCase(this->GetCurrentValue());
|
2016-05-16 17:34:04 +03:00
|
|
|
if (status == "OK" || status == "SUCCESS") {
|
2010-06-03 18:34:34 +04:00
|
|
|
this->Status = STATUS_OK;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (status == "WARNING") {
|
2010-06-03 18:34:34 +04:00
|
|
|
this->Status = STATUS_WARNING;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2010-06-03 18:34:34 +04:00
|
|
|
this->Status = STATUS_ERROR;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (name == "filename") {
|
2010-06-03 21:27:26 +04:00
|
|
|
this->Filename = this->GetCurrentValue();
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (name == "md5") {
|
2010-06-03 21:27:26 +04:00
|
|
|
this->MD5 = this->GetCurrentValue();
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (name == "message") {
|
2010-06-03 21:27:26 +04:00
|
|
|
this->Message = this->GetCurrentValue();
|
2010-06-03 18:34:34 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-06-03 18:34:34 +04:00
|
|
|
};
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static size_t cmCTestSubmitHandlerWriteMemoryCallback(void* ptr, size_t size,
|
|
|
|
size_t nmemb, void* data)
|
2005-06-01 01:32:40 +04:00
|
|
|
{
|
2013-06-28 20:26:44 +04:00
|
|
|
int realsize = (int)(size * nmemb);
|
2005-06-01 01:32:40 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestSubmitHandlerVectorOfChar* vec =
|
|
|
|
static_cast<cmCTestSubmitHandlerVectorOfChar*>(data);
|
2005-06-01 01:32:40 +04:00
|
|
|
const char* chPtr = static_cast<char*>(ptr);
|
|
|
|
vec->insert(vec->end(), chPtr, chPtr + realsize);
|
|
|
|
|
|
|
|
return realsize;
|
|
|
|
}
|
|
|
|
|
2016-08-17 02:49:57 +03:00
|
|
|
static size_t cmCTestSubmitHandlerCurlDebugCallback(CURL* /*unused*/,
|
|
|
|
curl_infotype /*unused*/,
|
2016-05-16 17:34:04 +03:00
|
|
|
char* chPtr, size_t size,
|
|
|
|
void* data)
|
2005-06-02 22:48:10 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestSubmitHandlerVectorOfChar* vec =
|
|
|
|
static_cast<cmCTestSubmitHandlerVectorOfChar*>(data);
|
2005-06-02 22:48:10 +04:00
|
|
|
vec->insert(vec->end(), chPtr, chPtr + size);
|
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestSubmitHandler::cmCTestSubmitHandler()
|
|
|
|
: HTTPProxy()
|
|
|
|
, FTPProxy()
|
2003-01-15 06:10:47 +03:00
|
|
|
{
|
2009-01-27 18:58:25 +03:00
|
|
|
this->Initialize();
|
2009-01-15 21:24:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmCTestSubmitHandler::Initialize()
|
|
|
|
{
|
2009-01-12 18:38:27 +03:00
|
|
|
// We submit all available parts by default.
|
2016-05-16 17:34:04 +03:00
|
|
|
for (cmCTest::Part p = cmCTest::PartStart; p != cmCTest::PartCount;
|
|
|
|
p = cmCTest::Part(p + 1)) {
|
2009-01-12 18:38:27 +03:00
|
|
|
this->SubmitPart[p] = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-02-29 22:58:33 +03:00
|
|
|
this->CDash = false;
|
2009-12-11 22:10:37 +03:00
|
|
|
this->HasWarnings = false;
|
|
|
|
this->HasErrors = false;
|
2005-06-23 21:04:18 +04:00
|
|
|
this->Superclass::Initialize();
|
2006-03-10 23:03:09 +03:00
|
|
|
this->HTTPProxy = "";
|
|
|
|
this->HTTPProxyType = 0;
|
|
|
|
this->HTTPProxyAuth = "";
|
|
|
|
this->FTPProxy = "";
|
|
|
|
this->FTPProxyType = 0;
|
2016-06-27 23:44:16 +03:00
|
|
|
this->LogFile = CM_NULLPTR;
|
2009-02-03 19:52:54 +03:00
|
|
|
this->Files.clear();
|
2005-06-17 21:04:56 +04:00
|
|
|
}
|
|
|
|
|
2014-02-10 09:21:34 +04:00
|
|
|
bool cmCTestSubmitHandler::SubmitUsingFTP(const std::string& localprefix,
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::set<std::string>& files,
|
|
|
|
const std::string& remoteprefix,
|
|
|
|
const std::string& url)
|
2003-01-07 07:07:24 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
CURL* curl;
|
2003-01-08 06:24:45 +03:00
|
|
|
CURLcode res;
|
|
|
|
FILE* ftpfile;
|
2003-11-04 00:59:15 +03:00
|
|
|
char error_buffer[1024];
|
2003-01-08 06:24:45 +03:00
|
|
|
|
|
|
|
/* In windows, this will init the winsock stuff */
|
|
|
|
::curl_global_init(CURL_GLOBAL_ALL);
|
2003-05-02 21:54:05 +04:00
|
|
|
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTest::SetOfStrings::const_iterator file;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (file = files.begin(); file != files.end(); ++file) {
|
2003-02-07 19:03:44 +03:00
|
|
|
/* get a curl handle */
|
|
|
|
curl = curl_easy_init();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (curl) {
|
2003-02-07 19:03:44 +03:00
|
|
|
// Using proxy
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->FTPProxyType > 0) {
|
2006-03-10 23:03:09 +03:00
|
|
|
curl_easy_setopt(curl, CURLOPT_PROXY, this->FTPProxy.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (this->FTPProxyType) {
|
|
|
|
case 2:
|
|
|
|
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
|
2003-01-15 06:10:47 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2003-08-11 20:19:46 +04:00
|
|
|
|
2003-02-07 19:03:44 +03:00
|
|
|
// enable uploading
|
2009-09-04 22:00:26 +04:00
|
|
|
::curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
|
2009-09-02 01:23:50 +04:00
|
|
|
|
|
|
|
// if there is little to no activity for too long stop submitting
|
2009-09-04 22:00:26 +04:00
|
|
|
::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1);
|
|
|
|
::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME,
|
2016-05-16 17:34:04 +03:00
|
|
|
SUBMIT_TIMEOUT_IN_SECONDS_DEFAULT);
|
2009-09-02 01:23:50 +04:00
|
|
|
|
2009-09-04 22:00:26 +04:00
|
|
|
::curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
|
2003-08-11 20:19:46 +04:00
|
|
|
|
2014-02-10 09:21:34 +04:00
|
|
|
std::string local_file = *file;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::FileExists(local_file.c_str())) {
|
2005-07-18 20:53:48 +04:00
|
|
|
local_file = localprefix + "/" + *file;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
std::string upload_as =
|
|
|
|
url + "/" + remoteprefix + cmSystemTools::GetFilenameName(*file);
|
2014-07-15 21:11:18 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::FileExists(local_file.c_str())) {
|
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
|
|
|
" Cannot find file: " << local_file << std::endl);
|
2005-06-23 21:04:18 +04:00
|
|
|
::curl_easy_cleanup(curl);
|
2006-03-09 19:17:10 +03:00
|
|
|
::curl_global_cleanup();
|
2003-01-08 06:24:45 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-11-23 13:05:50 +03:00
|
|
|
unsigned long filelen = cmSystemTools::FileLength(local_file);
|
2003-01-08 06:24:45 +03:00
|
|
|
|
2014-10-15 16:54:05 +04:00
|
|
|
ftpfile = cmsys::SystemTools::Fopen(local_file, "rb");
|
2016-05-16 17:34:04 +03:00
|
|
|
*this->LogFile << "\tUpload file: " << local_file << " to " << upload_as
|
|
|
|
<< std::endl;
|
2015-02-17 00:02:14 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
" Upload file: " << local_file << " to "
|
|
|
|
<< upload_as << std::endl,
|
|
|
|
this->Quiet);
|
2003-01-08 06:24:45 +03:00
|
|
|
|
2005-06-02 22:48:10 +04:00
|
|
|
::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
|
|
|
|
|
2003-01-08 06:24:45 +03:00
|
|
|
// specify target
|
2016-05-16 17:34:04 +03:00
|
|
|
::curl_easy_setopt(curl, CURLOPT_URL, upload_as.c_str());
|
2003-08-11 20:19:46 +04:00
|
|
|
|
2003-01-08 06:24:45 +03:00
|
|
|
// now specify which file to upload
|
|
|
|
::curl_easy_setopt(curl, CURLOPT_INFILE, ftpfile);
|
|
|
|
|
|
|
|
// and give the size of the upload (optional)
|
2016-05-16 17:34:04 +03:00
|
|
|
::curl_easy_setopt(curl, CURLOPT_INFILESIZE, static_cast<long>(filelen));
|
2003-11-04 00:59:15 +03:00
|
|
|
|
2005-06-01 01:32:40 +04:00
|
|
|
// and give curl the buffer for errors
|
2003-11-04 00:59:15 +03:00
|
|
|
::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer);
|
2003-01-08 06:24:45 +03:00
|
|
|
|
2005-06-01 01:32:40 +04:00
|
|
|
// specify handler for output
|
2006-03-09 19:17:10 +03:00
|
|
|
::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestSubmitHandlerWriteMemoryCallback);
|
2006-03-09 19:17:10 +03:00
|
|
|
::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION,
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestSubmitHandlerCurlDebugCallback);
|
2005-06-01 01:32:40 +04:00
|
|
|
|
|
|
|
/* we pass our 'chunk' struct to the callback function */
|
|
|
|
cmCTestSubmitHandlerVectorOfChar chunk;
|
2005-06-02 22:48:10 +04:00
|
|
|
cmCTestSubmitHandlerVectorOfChar chunkDebug;
|
2016-05-16 17:34:04 +03:00
|
|
|
::curl_easy_setopt(curl, CURLOPT_FILE, (void*)&chunk);
|
|
|
|
::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void*)&chunkDebug);
|
2005-06-01 01:32:40 +04:00
|
|
|
|
2003-01-08 06:24:45 +03:00
|
|
|
// Now run off and do what you've been told!
|
|
|
|
res = ::curl_easy_perform(curl);
|
2005-06-01 01:32:40 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!chunk.empty()) {
|
2015-02-17 00:02:14 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, DEBUG, "CURL output: ["
|
2016-05-16 17:34:04 +03:00
|
|
|
<< cmCTestLogWrite(&*chunk.begin(), chunk.size())
|
|
|
|
<< "]" << std::endl,
|
|
|
|
this->Quiet);
|
|
|
|
}
|
|
|
|
if (!chunkDebug.empty()) {
|
|
|
|
cmCTestOptionalLog(
|
|
|
|
this->CTest, DEBUG, "CURL debug output: ["
|
|
|
|
<< cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]"
|
|
|
|
<< std::endl,
|
|
|
|
this->Quiet);
|
|
|
|
}
|
2005-06-01 01:32:40 +04:00
|
|
|
|
2003-01-08 06:24:45 +03:00
|
|
|
fclose(ftpfile);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (res) {
|
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, " Error when uploading file: "
|
|
|
|
<< local_file << std::endl);
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2016-05-16 17:34:04 +03:00
|
|
|
" Error message was: " << error_buffer << std::endl);
|
|
|
|
*this->LogFile << " Error when uploading file: " << local_file
|
2006-12-02 21:17:53 +03:00
|
|
|
<< std::endl
|
2016-05-16 17:34:04 +03:00
|
|
|
<< " Error message was: " << error_buffer << std::endl
|
2006-12-02 21:17:53 +03:00
|
|
|
<< " Curl output was: ";
|
|
|
|
// avoid dereference of empty vector
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!chunk.empty()) {
|
2006-12-02 21:17:53 +03:00
|
|
|
*this->LogFile << cmCTestLogWrite(&*chunk.begin(), chunk.size());
|
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: ["
|
2016-05-16 17:34:04 +03:00
|
|
|
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
|
|
|
|
<< std::endl);
|
|
|
|
}
|
2006-12-02 21:17:53 +03:00
|
|
|
*this->LogFile << std::endl;
|
2003-01-08 06:24:45 +03:00
|
|
|
::curl_easy_cleanup(curl);
|
2006-03-09 19:17:10 +03:00
|
|
|
::curl_global_cleanup();
|
2003-01-08 06:24:45 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2003-02-07 19:03:44 +03:00
|
|
|
// always cleanup
|
|
|
|
::curl_easy_cleanup(curl);
|
2015-02-17 00:02:14 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
" Uploaded: " + local_file << std::endl,
|
|
|
|
this->Quiet);
|
2003-01-07 07:07:24 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-09 19:17:10 +03:00
|
|
|
::curl_global_cleanup();
|
2003-01-08 06:24:45 +03:00
|
|
|
return true;
|
2003-01-15 06:10:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Uploading files is simpler
|
2014-02-10 09:21:34 +04:00
|
|
|
bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::set<std::string>& files,
|
|
|
|
const std::string& remoteprefix,
|
|
|
|
const std::string& url)
|
2003-01-15 06:10:47 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
CURL* curl;
|
2003-01-15 06:10:47 +03:00
|
|
|
CURLcode res;
|
|
|
|
FILE* ftpfile;
|
2004-04-01 23:11:17 +04:00
|
|
|
char error_buffer[1024];
|
2016-05-16 17:34:04 +03:00
|
|
|
struct curl_slist* headers =
|
2016-06-27 23:44:16 +03:00
|
|
|
::curl_slist_append(CM_NULLPTR, "Content-Type: text/xml");
|
2003-01-15 06:10:47 +03:00
|
|
|
|
|
|
|
/* In windows, this will init the winsock stuff */
|
|
|
|
::curl_global_init(CURL_GLOBAL_ALL);
|
2014-02-10 09:21:34 +04:00
|
|
|
std::string dropMethod(this->CTest->GetCTestConfiguration("DropMethod"));
|
|
|
|
std::string curlopt(this->CTest->GetCTestConfiguration("CurlOptions"));
|
2009-04-10 20:15:03 +04:00
|
|
|
std::vector<std::string> args;
|
2014-03-11 03:04:11 +04:00
|
|
|
cmSystemTools::ExpandListArgument(curlopt, args);
|
2009-04-10 20:15:03 +04:00
|
|
|
bool verifyPeerOff = false;
|
|
|
|
bool verifyHostOff = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::iterator i = args.begin(); i != args.end();
|
|
|
|
++i) {
|
|
|
|
if (*i == "CURLOPT_SSL_VERIFYPEER_OFF") {
|
2009-04-10 20:15:03 +04:00
|
|
|
verifyPeerOff = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (*i == "CURLOPT_SSL_VERIFYHOST_OFF") {
|
2009-04-10 20:15:03 +04:00
|
|
|
verifyHostOff = true;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-02-10 09:21:34 +04:00
|
|
|
std::string::size_type kk;
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTest::SetOfStrings::const_iterator file;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (file = files.begin(); file != files.end(); ++file) {
|
2003-01-16 20:30:02 +03:00
|
|
|
/* get a curl handle */
|
|
|
|
curl = curl_easy_init();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (curl) {
|
2015-01-22 18:15:31 +03:00
|
|
|
cmCurlSetCAInfo(curl);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (verifyPeerOff) {
|
2015-02-17 00:02:14 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
" Set CURLOPT_SSL_VERIFYPEER to off\n",
|
|
|
|
this->Quiet);
|
2009-04-10 20:15:03 +04:00
|
|
|
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (verifyHostOff) {
|
2015-02-17 00:02:14 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
" Set CURLOPT_SSL_VERIFYHOST to off\n",
|
|
|
|
this->Quiet);
|
2009-04-10 20:15:03 +04:00
|
|
|
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2003-01-16 20:30:02 +03:00
|
|
|
|
|
|
|
// Using proxy
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->HTTPProxyType > 0) {
|
2006-03-10 23:03:09 +03:00
|
|
|
curl_easy_setopt(curl, CURLOPT_PROXY, this->HTTPProxy.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (this->HTTPProxyType) {
|
|
|
|
case 2:
|
|
|
|
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
|
|
|
|
if (!this->HTTPProxyAuth.empty()) {
|
|
|
|
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD,
|
|
|
|
this->HTTPProxyAuth.c_str());
|
2004-11-24 17:25:32 +03:00
|
|
|
}
|
2003-01-15 06:10:47 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (this->CTest->ShouldUseHTTP10()) {
|
2009-12-11 22:10:37 +03:00
|
|
|
curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-12-11 22:10:37 +03:00
|
|
|
// enable HTTP ERROR parsing
|
|
|
|
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
|
2003-01-16 20:30:02 +03:00
|
|
|
/* enable uploading */
|
2009-09-04 22:00:26 +04:00
|
|
|
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
|
2003-01-16 20:30:02 +03:00
|
|
|
|
2009-09-02 01:23:50 +04:00
|
|
|
// if there is little to no activity for too long stop submitting
|
2009-09-04 22:00:26 +04:00
|
|
|
::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1);
|
|
|
|
::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME,
|
2016-05-16 17:34:04 +03:00
|
|
|
SUBMIT_TIMEOUT_IN_SECONDS_DEFAULT);
|
2009-09-02 01:23:50 +04:00
|
|
|
|
2003-01-16 20:30:02 +03:00
|
|
|
/* HTTP PUT please */
|
2005-06-02 22:48:10 +04:00
|
|
|
::curl_easy_setopt(curl, CURLOPT_PUT, 1);
|
|
|
|
::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
|
2003-01-16 20:30:02 +03:00
|
|
|
|
2015-10-08 00:51:26 +03:00
|
|
|
// Be sure to set Content-Type to satisfy fussy modsecurity rules
|
|
|
|
::curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
|
|
|
|
|
2014-02-10 09:21:34 +04:00
|
|
|
std::string local_file = *file;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::FileExists(local_file.c_str())) {
|
2005-07-18 20:53:48 +04:00
|
|
|
local_file = localprefix + "/" + *file;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
std::string remote_file =
|
|
|
|
remoteprefix + cmSystemTools::GetFilenameName(*file);
|
2004-04-01 23:11:17 +04:00
|
|
|
|
2014-03-11 16:35:32 +04:00
|
|
|
*this->LogFile << "\tUpload file: " << local_file << " to "
|
2016-05-16 17:34:04 +03:00
|
|
|
<< remote_file << std::endl;
|
2004-04-01 23:11:17 +04:00
|
|
|
|
2014-02-10 09:21:34 +04:00
|
|
|
std::string ofile = "";
|
2016-05-16 17:34:04 +03:00
|
|
|
for (kk = 0; kk < remote_file.size(); kk++) {
|
2003-01-16 20:30:02 +03:00
|
|
|
char c = remote_file[kk];
|
2005-06-24 17:41:01 +04:00
|
|
|
char hexCh[4] = { 0, 0, 0, 0 };
|
|
|
|
hexCh[0] = c;
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (c) {
|
|
|
|
case '+':
|
|
|
|
case '?':
|
|
|
|
case '/':
|
|
|
|
case '\\':
|
|
|
|
case '&':
|
|
|
|
case ' ':
|
|
|
|
case '=':
|
|
|
|
case '%':
|
|
|
|
sprintf(hexCh, "%%%02X", (int)c);
|
|
|
|
ofile.append(hexCh);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ofile.append(hexCh);
|
2003-01-16 20:30:02 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
std::string upload_as = url +
|
2016-05-24 22:24:10 +03:00
|
|
|
((url.find('?') == std::string::npos) ? '?' : '&') + "FileName=" +
|
2016-05-16 17:34:04 +03:00
|
|
|
ofile;
|
2003-01-16 20:30:02 +03:00
|
|
|
|
2010-06-03 21:27:26 +04:00
|
|
|
upload_as += "&MD5=";
|
2010-06-10 20:25:49 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::IsOn(this->GetOption("InternalTest"))) {
|
2010-06-10 20:25:49 +04:00
|
|
|
upload_as += "bad_md5sum";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2010-06-10 20:25:49 +04:00
|
|
|
char md5[33];
|
2014-03-11 03:04:11 +04:00
|
|
|
cmSystemTools::ComputeFileMD5(local_file, md5);
|
2010-06-10 20:25:49 +04:00
|
|
|
md5[32] = 0;
|
|
|
|
upload_as += md5;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-06-03 18:34:34 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::FileExists(local_file.c_str())) {
|
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
|
|
|
" Cannot find file: " << local_file << std::endl);
|
2005-06-23 21:04:18 +04:00
|
|
|
::curl_easy_cleanup(curl);
|
2015-10-08 00:51:26 +03:00
|
|
|
::curl_slist_free_all(headers);
|
2006-03-09 19:17:10 +03:00
|
|
|
::curl_global_cleanup();
|
2003-01-16 20:30:02 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-11-23 13:05:50 +03:00
|
|
|
unsigned long filelen = cmSystemTools::FileLength(local_file);
|
2003-01-16 20:30:02 +03:00
|
|
|
|
2014-10-15 16:54:05 +04:00
|
|
|
ftpfile = cmsys::SystemTools::Fopen(local_file, "rb");
|
2015-02-17 00:02:14 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
" Upload file: " << local_file << " to "
|
|
|
|
<< upload_as << " Size: "
|
|
|
|
<< filelen << std::endl,
|
|
|
|
this->Quiet);
|
2003-01-16 20:30:02 +03:00
|
|
|
|
2003-01-15 06:10:47 +03:00
|
|
|
// specify target
|
2016-05-16 17:34:04 +03:00
|
|
|
::curl_easy_setopt(curl, CURLOPT_URL, upload_as.c_str());
|
2003-01-15 06:10:47 +03:00
|
|
|
|
2003-01-16 20:30:02 +03:00
|
|
|
// now specify which file to upload
|
|
|
|
::curl_easy_setopt(curl, CURLOPT_INFILE, ftpfile);
|
|
|
|
|
|
|
|
// and give the size of the upload (optional)
|
2016-05-16 17:34:04 +03:00
|
|
|
::curl_easy_setopt(curl, CURLOPT_INFILESIZE, static_cast<long>(filelen));
|
2003-01-16 20:30:02 +03:00
|
|
|
|
2004-04-01 23:11:17 +04:00
|
|
|
// and give curl the buffer for errors
|
|
|
|
::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer);
|
|
|
|
|
2005-06-01 01:32:40 +04:00
|
|
|
// specify handler for output
|
2006-03-09 19:17:10 +03:00
|
|
|
::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestSubmitHandlerWriteMemoryCallback);
|
2006-03-09 19:17:10 +03:00
|
|
|
::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION,
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestSubmitHandlerCurlDebugCallback);
|
2005-06-01 01:32:40 +04:00
|
|
|
|
|
|
|
/* we pass our 'chunk' struct to the callback function */
|
|
|
|
cmCTestSubmitHandlerVectorOfChar chunk;
|
2005-06-02 22:48:10 +04:00
|
|
|
cmCTestSubmitHandlerVectorOfChar chunkDebug;
|
2016-05-16 17:34:04 +03:00
|
|
|
::curl_easy_setopt(curl, CURLOPT_FILE, (void*)&chunk);
|
|
|
|
::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void*)&chunkDebug);
|
2005-06-01 01:32:40 +04:00
|
|
|
|
2003-01-15 06:10:47 +03:00
|
|
|
// Now run off and do what you've been told!
|
|
|
|
res = ::curl_easy_perform(curl);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::IsOn(this->GetOption("InternalTest")) &&
|
|
|
|
cmSystemTools::VersionCompare(cmSystemTools::OP_LESS,
|
|
|
|
this->CTest->GetCDashVersion().c_str(),
|
|
|
|
"1.7")) {
|
2010-06-10 23:02:24 +04:00
|
|
|
// mock failure output for internal test case
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string mock_output =
|
|
|
|
"<cdash version=\"1.7.0\">\n"
|
2010-06-10 23:02:24 +04:00
|
|
|
" <status>ERROR</status>\n"
|
|
|
|
" <message>Checksum failed for file.</message>\n"
|
|
|
|
"</cdash>\n";
|
|
|
|
chunk.clear();
|
|
|
|
chunk.assign(mock_output.begin(), mock_output.end());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-06-10 23:02:24 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!chunk.empty()) {
|
2015-02-17 00:02:14 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, DEBUG, "CURL output: ["
|
2016-05-16 17:34:04 +03:00
|
|
|
<< cmCTestLogWrite(&*chunk.begin(), chunk.size())
|
|
|
|
<< "]" << std::endl,
|
|
|
|
this->Quiet);
|
2010-06-05 18:36:23 +04:00
|
|
|
this->ParseResponse(chunk);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!chunkDebug.empty()) {
|
|
|
|
cmCTestOptionalLog(
|
|
|
|
this->CTest, DEBUG, "CURL debug output: ["
|
|
|
|
<< cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]"
|
|
|
|
<< std::endl,
|
|
|
|
this->Quiet);
|
|
|
|
}
|
2010-06-05 18:36:23 +04:00
|
|
|
|
2010-07-13 00:48:38 +04:00
|
|
|
// If curl failed for any reason, or checksum fails, wait and retry
|
|
|
|
//
|
2016-05-16 17:34:04 +03:00
|
|
|
if (res != CURLE_OK || this->HasErrors) {
|
2016-06-27 23:44:16 +03:00
|
|
|
std::string retryDelay = this->GetOption("RetryDelay") == CM_NULLPTR
|
2016-05-16 17:34:04 +03:00
|
|
|
? ""
|
|
|
|
: this->GetOption("RetryDelay");
|
2016-06-27 23:44:16 +03:00
|
|
|
std::string retryCount = this->GetOption("RetryCount") == CM_NULLPTR
|
2016-05-16 17:34:04 +03:00
|
|
|
? ""
|
|
|
|
: this->GetOption("RetryCount");
|
|
|
|
|
|
|
|
int delay = retryDelay == ""
|
|
|
|
? atoi(this->CTest->GetCTestConfiguration("CTestSubmitRetryDelay")
|
|
|
|
.c_str())
|
|
|
|
: atoi(retryDelay.c_str());
|
|
|
|
int count = retryCount == ""
|
|
|
|
? atoi(this->CTest->GetCTestConfiguration("CTestSubmitRetryCount")
|
|
|
|
.c_str())
|
|
|
|
: atoi(retryCount.c_str());
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++) {
|
2015-02-17 00:02:14 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
" Submit failed, waiting " << delay
|
|
|
|
<< " seconds...\n",
|
|
|
|
this->Quiet);
|
2010-06-03 18:34:34 +04:00
|
|
|
|
2010-06-10 20:25:49 +04:00
|
|
|
double stop = cmSystemTools::GetTime() + delay;
|
2016-05-16 17:34:04 +03:00
|
|
|
while (cmSystemTools::GetTime() < stop) {
|
2010-06-10 20:25:49 +04:00
|
|
|
cmSystemTools::Delay(100);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-06-03 18:34:34 +04:00
|
|
|
|
2015-02-17 00:02:14 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
" Retry submission: Attempt "
|
|
|
|
<< (i + 1) << " of " << count << std::endl,
|
|
|
|
this->Quiet);
|
2010-06-03 18:34:34 +04:00
|
|
|
|
|
|
|
::fclose(ftpfile);
|
2014-10-15 16:54:05 +04:00
|
|
|
ftpfile = cmsys::SystemTools::Fopen(local_file, "rb");
|
2010-06-03 18:34:34 +04:00
|
|
|
::curl_easy_setopt(curl, CURLOPT_INFILE, ftpfile);
|
|
|
|
|
|
|
|
chunk.clear();
|
|
|
|
chunkDebug.clear();
|
2010-06-05 18:36:23 +04:00
|
|
|
this->HasErrors = false;
|
2010-06-03 18:34:34 +04:00
|
|
|
|
|
|
|
res = ::curl_easy_perform(curl);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!chunk.empty()) {
|
|
|
|
cmCTestOptionalLog(
|
|
|
|
this->CTest, DEBUG, "CURL output: ["
|
|
|
|
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
|
|
|
|
<< std::endl,
|
|
|
|
this->Quiet);
|
2010-06-05 18:36:23 +04:00
|
|
|
this->ParseResponse(chunk);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-06-05 18:36:23 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (res == CURLE_OK && !this->HasErrors) {
|
2010-06-03 18:34:34 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-06-03 18:34:34 +04:00
|
|
|
|
2003-01-16 20:30:02 +03:00
|
|
|
fclose(ftpfile);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (res) {
|
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, " Error when uploading file: "
|
|
|
|
<< local_file << std::endl);
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2016-05-16 17:34:04 +03:00
|
|
|
" Error message was: " << error_buffer << std::endl);
|
|
|
|
*this->LogFile << " Error when uploading file: " << local_file
|
2006-12-02 21:17:53 +03:00
|
|
|
<< std::endl
|
2011-03-11 16:04:58 +03:00
|
|
|
<< " Error message was: " << error_buffer
|
2006-12-02 21:17:53 +03:00
|
|
|
<< std::endl;
|
|
|
|
// avoid deref of begin for zero size array
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!chunk.empty()) {
|
2006-12-02 21:17:53 +03:00
|
|
|
*this->LogFile << " Curl output was: "
|
|
|
|
<< cmCTestLogWrite(&*chunk.begin(), chunk.size())
|
|
|
|
<< std::endl;
|
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: ["
|
2016-05-16 17:34:04 +03:00
|
|
|
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
|
|
|
|
<< std::endl);
|
|
|
|
}
|
2003-01-15 06:10:47 +03:00
|
|
|
::curl_easy_cleanup(curl);
|
2015-10-08 00:51:26 +03:00
|
|
|
::curl_slist_free_all(headers);
|
2006-03-09 19:17:10 +03:00
|
|
|
::curl_global_cleanup();
|
2003-01-15 06:10:47 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2003-01-16 20:30:02 +03:00
|
|
|
// always cleanup
|
|
|
|
::curl_easy_cleanup(curl);
|
2015-02-17 00:02:14 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
" Uploaded: " + local_file << std::endl,
|
|
|
|
this->Quiet);
|
2003-01-15 06:10:47 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-08 00:51:26 +03:00
|
|
|
::curl_slist_free_all(headers);
|
2006-03-09 19:17:10 +03:00
|
|
|
::curl_global_cleanup();
|
2003-01-15 06:10:47 +03:00
|
|
|
return true;
|
2003-01-07 07:07:24 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmCTestSubmitHandler::ParseResponse(
|
|
|
|
cmCTestSubmitHandlerVectorOfChar chunk)
|
2009-12-11 22:10:37 +03:00
|
|
|
{
|
|
|
|
std::string output = "";
|
2010-06-03 18:34:34 +04:00
|
|
|
output.append(chunk.begin(), chunk.end());
|
2009-12-11 22:10:37 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (output.find("<cdash") != output.npos) {
|
2010-06-03 18:34:34 +04:00
|
|
|
ResponseParser parser;
|
|
|
|
parser.Parse(output.c_str());
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (parser.Status != ResponseParser::STATUS_OK) {
|
2010-06-03 18:34:34 +04:00
|
|
|
this->HasErrors = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT,
|
|
|
|
" Submission failed: " << parser.Message << std::endl);
|
2010-06-03 18:34:34 +04:00
|
|
|
return;
|
2009-12-11 22:10:37 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-06-10 20:25:49 +04:00
|
|
|
output = cmSystemTools::UpperCase(output);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (output.find("WARNING") != std::string::npos) {
|
2010-06-10 20:25:49 +04:00
|
|
|
this->HasWarnings = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (output.find("ERROR") != std::string::npos) {
|
2010-06-10 20:25:49 +04:00
|
|
|
this->HasErrors = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-06-03 18:34:34 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->HasWarnings || this->HasErrors) {
|
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Server Response:\n"
|
|
|
|
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "\n");
|
|
|
|
}
|
2009-12-11 22:10:37 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmCTestSubmitHandler::TriggerUsingHTTP(const std::set<std::string>& files,
|
|
|
|
const std::string& remoteprefix,
|
|
|
|
const std::string& url)
|
2003-01-12 05:47:35 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
CURL* curl;
|
2004-04-01 23:11:17 +04:00
|
|
|
char error_buffer[1024];
|
2015-02-17 00:02:14 +03:00
|
|
|
|
2003-01-12 05:47:35 +03:00
|
|
|
/* In windows, this will init the winsock stuff */
|
|
|
|
::curl_global_init(CURL_GLOBAL_ALL);
|
2003-08-11 20:19:46 +04:00
|
|
|
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTest::SetOfStrings::const_iterator file;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (file = files.begin(); file != files.end(); ++file) {
|
2003-01-16 21:02:11 +03:00
|
|
|
/* get a curl handle */
|
|
|
|
curl = curl_easy_init();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (curl) {
|
2003-01-16 21:02:11 +03:00
|
|
|
// Using proxy
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->HTTPProxyType > 0) {
|
2006-03-10 23:03:09 +03:00
|
|
|
curl_easy_setopt(curl, CURLOPT_PROXY, this->HTTPProxy.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (this->HTTPProxyType) {
|
|
|
|
case 2:
|
|
|
|
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
|
|
|
|
if (!this->HTTPProxyAuth.empty()) {
|
|
|
|
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD,
|
|
|
|
this->HTTPProxyAuth.c_str());
|
2004-11-24 17:25:32 +03:00
|
|
|
}
|
2003-01-16 20:45:24 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2003-01-16 20:45:24 +03:00
|
|
|
|
2005-06-02 22:48:10 +04:00
|
|
|
::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
|
2004-04-01 23:11:17 +04:00
|
|
|
|
|
|
|
// and give curl the buffer for errors
|
|
|
|
::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer);
|
|
|
|
|
2005-06-01 01:32:40 +04:00
|
|
|
// specify handler for output
|
2006-03-09 19:17:10 +03:00
|
|
|
::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestSubmitHandlerWriteMemoryCallback);
|
2006-03-09 19:17:10 +03:00
|
|
|
::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION,
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestSubmitHandlerCurlDebugCallback);
|
2005-06-01 01:32:40 +04:00
|
|
|
|
|
|
|
/* we pass our 'chunk' struct to the callback function */
|
|
|
|
cmCTestSubmitHandlerVectorOfChar chunk;
|
2005-06-02 22:48:10 +04:00
|
|
|
cmCTestSubmitHandlerVectorOfChar chunkDebug;
|
2016-05-16 17:34:04 +03:00
|
|
|
::curl_easy_setopt(curl, CURLOPT_FILE, (void*)&chunk);
|
|
|
|
::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void*)&chunkDebug);
|
2005-06-01 01:32:40 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string rfile = remoteprefix + cmSystemTools::GetFilenameName(*file);
|
2014-02-10 09:21:34 +04:00
|
|
|
std::string ofile = "";
|
|
|
|
std::string::iterator kk;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (kk = rfile.begin(); kk < rfile.end(); ++kk) {
|
2005-06-23 21:04:18 +04:00
|
|
|
char c = *kk;
|
2005-06-24 17:41:01 +04:00
|
|
|
char hexCh[4] = { 0, 0, 0, 0 };
|
|
|
|
hexCh[0] = c;
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (c) {
|
|
|
|
case '+':
|
|
|
|
case '?':
|
|
|
|
case '/':
|
|
|
|
case '\\':
|
|
|
|
case '&':
|
|
|
|
case ' ':
|
|
|
|
case '=':
|
|
|
|
case '%':
|
|
|
|
sprintf(hexCh, "%%%02X", (int)c);
|
|
|
|
ofile.append(hexCh);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ofile.append(hexCh);
|
2003-01-12 05:47:35 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
std::string turl = url +
|
2016-05-24 22:24:10 +03:00
|
|
|
((url.find('?') == std::string::npos) ? '?' : '&') + "xmlfile=" +
|
2016-05-16 17:34:04 +03:00
|
|
|
ofile;
|
2014-03-11 16:35:32 +04:00
|
|
|
*this->LogFile << "Trigger url: " << turl << std::endl;
|
2015-02-17 00:02:14 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
" Trigger url: " << turl << std::endl, this->Quiet);
|
2009-03-31 23:24:50 +04:00
|
|
|
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
|
2003-01-12 05:47:35 +03:00
|
|
|
curl_easy_setopt(curl, CURLOPT_URL, turl.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
if (curl_easy_perform(curl)) {
|
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
|
|
|
" Error when triggering: " << turl << std::endl);
|
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
|
|
|
" Error message was: " << error_buffer << std::endl);
|
2010-07-02 18:58:00 +04:00
|
|
|
*this->LogFile << "\tTriggering failed with error: " << error_buffer
|
2006-12-02 21:17:53 +03:00
|
|
|
<< std::endl
|
2011-03-11 16:04:58 +03:00
|
|
|
<< " Error message was: " << error_buffer
|
2006-12-02 21:17:53 +03:00
|
|
|
<< std::endl;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!chunk.empty()) {
|
|
|
|
*this->LogFile << " Curl output was: "
|
|
|
|
<< cmCTestLogWrite(&*chunk.begin(), chunk.size())
|
|
|
|
<< std::endl;
|
2006-12-02 21:17:53 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: ["
|
2016-05-16 17:34:04 +03:00
|
|
|
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
|
|
|
|
<< std::endl);
|
|
|
|
}
|
2003-01-12 05:47:35 +03:00
|
|
|
::curl_easy_cleanup(curl);
|
2006-03-09 19:17:10 +03:00
|
|
|
::curl_global_cleanup();
|
2003-01-12 05:47:35 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-06-01 01:32:40 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!chunk.empty()) {
|
2015-02-17 00:02:14 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, DEBUG, "CURL output: ["
|
2016-05-16 17:34:04 +03:00
|
|
|
<< cmCTestLogWrite(&*chunk.begin(), chunk.size())
|
|
|
|
<< "]" << std::endl,
|
|
|
|
this->Quiet);
|
|
|
|
}
|
|
|
|
if (!chunkDebug.empty()) {
|
|
|
|
cmCTestOptionalLog(
|
|
|
|
this->CTest, DEBUG, "CURL debug output: ["
|
|
|
|
<< cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]"
|
|
|
|
<< std::endl,
|
|
|
|
this->Quiet);
|
|
|
|
}
|
2005-06-01 01:32:40 +04:00
|
|
|
|
2003-01-16 21:02:11 +03:00
|
|
|
// always cleanup
|
|
|
|
::curl_easy_cleanup(curl);
|
2015-02-17 00:02:14 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl,
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Quiet);
|
2003-01-12 05:47:35 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-09 19:17:10 +03:00
|
|
|
::curl_global_cleanup();
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
|
|
|
" Dart server triggered..." << std::endl, this->Quiet);
|
2003-01-12 05:47:35 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmCTestSubmitHandler::SubmitUsingSCP(const std::string& scp_command,
|
|
|
|
const std::string& localprefix,
|
|
|
|
const std::set<std::string>& files,
|
|
|
|
const std::string& remoteprefix,
|
|
|
|
const std::string& url)
|
2003-01-07 07:07:24 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (scp_command.empty() || localprefix.empty() || files.empty() ||
|
|
|
|
remoteprefix.empty() || url.empty()) {
|
2004-06-02 21:39:25 +04:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-02-17 00:02:14 +03:00
|
|
|
|
2004-06-02 21:39:25 +04:00
|
|
|
std::vector<const char*> argv;
|
|
|
|
argv.push_back(scp_command.c_str()); // Scp command
|
|
|
|
argv.push_back(scp_command.c_str()); // Dummy string for file
|
|
|
|
argv.push_back(scp_command.c_str()); // Dummy string for remote url
|
2016-06-27 23:44:16 +03:00
|
|
|
argv.push_back(CM_NULLPTR);
|
2004-06-02 21:39:25 +04:00
|
|
|
|
|
|
|
cmsysProcess* cp = cmsysProcess_New();
|
|
|
|
cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
|
2016-05-16 17:34:04 +03:00
|
|
|
// cmsysProcess_SetTimeout(cp, timeout);
|
2004-06-02 21:39:25 +04:00
|
|
|
|
|
|
|
int problems = 0;
|
|
|
|
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTest::SetOfStrings::const_iterator file;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (file = files.begin(); file != files.end(); ++file) {
|
2004-06-07 16:51:20 +04:00
|
|
|
int retVal;
|
|
|
|
|
2004-06-02 21:39:25 +04:00
|
|
|
std::string lfname = localprefix;
|
|
|
|
cmSystemTools::ConvertToUnixSlashes(lfname);
|
2005-06-23 21:04:18 +04:00
|
|
|
lfname += "/" + *file;
|
2004-06-02 21:39:25 +04:00
|
|
|
lfname = cmSystemTools::ConvertToOutputPath(lfname.c_str());
|
|
|
|
argv[1] = lfname.c_str();
|
2005-06-23 21:04:18 +04:00
|
|
|
std::string rfname = url + "/" + remoteprefix + *file;
|
2004-06-02 21:39:25 +04:00
|
|
|
argv[2] = rfname.c_str();
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Execute \""
|
|
|
|
<< argv[0] << "\" \"" << argv[1] << "\" \"" << argv[2]
|
|
|
|
<< "\"" << std::endl,
|
|
|
|
this->Quiet);
|
2006-03-10 23:03:09 +03:00
|
|
|
*this->LogFile << "Execute \"" << argv[0] << "\" \"" << argv[1] << "\" \""
|
2016-05-16 17:34:04 +03:00
|
|
|
<< argv[2] << "\"" << std::endl;
|
2005-07-06 23:11:38 +04:00
|
|
|
|
2004-06-02 21:39:25 +04:00
|
|
|
cmsysProcess_SetCommand(cp, &*argv.begin());
|
|
|
|
cmsysProcess_Execute(cp);
|
|
|
|
char* data;
|
|
|
|
int length;
|
2005-07-06 23:11:38 +04:00
|
|
|
|
2016-06-27 23:44:16 +03:00
|
|
|
while (cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR)) {
|
2015-02-17 00:02:14 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestLogWrite(data, length), this->Quiet);
|
|
|
|
}
|
2005-07-06 23:11:38 +04:00
|
|
|
|
2016-06-27 23:44:16 +03:00
|
|
|
cmsysProcess_WaitForExit(cp, CM_NULLPTR);
|
2005-07-06 23:11:38 +04:00
|
|
|
|
2004-06-02 21:39:25 +04:00
|
|
|
int result = cmsysProcess_GetState(cp);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (result == cmsysProcess_State_Exited) {
|
2004-06-02 21:39:25 +04:00
|
|
|
retVal = cmsysProcess_GetExitValue(cp);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (retVal != 0) {
|
2015-02-17 00:02:14 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
"\tSCP returned: " << retVal << std::endl,
|
|
|
|
this->Quiet);
|
2006-03-10 23:03:09 +03:00
|
|
|
*this->LogFile << "\tSCP returned: " << retVal << std::endl;
|
2016-05-16 17:34:04 +03:00
|
|
|
problems++;
|
2004-06-02 21:39:25 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (result == cmsysProcess_State_Exception) {
|
2004-06-02 21:39:25 +04:00
|
|
|
retVal = cmsysProcess_GetExitException(cp);
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
|
|
|
"\tThere was an exception: " << retVal << std::endl);
|
2006-03-10 23:03:09 +03:00
|
|
|
*this->LogFile << "\tThere was an exception: " << retVal << std::endl;
|
2016-05-16 17:34:04 +03:00
|
|
|
problems++;
|
|
|
|
} else if (result == cmsysProcess_State_Expired) {
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, "\tThere was a timeout"
|
2016-05-16 17:34:04 +03:00
|
|
|
<< std::endl);
|
2006-03-10 23:03:09 +03:00
|
|
|
*this->LogFile << "\tThere was a timeout" << std::endl;
|
2016-05-16 17:34:04 +03:00
|
|
|
problems++;
|
|
|
|
} else if (result == cmsysProcess_State_Error) {
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, "\tError executing SCP: "
|
2016-05-16 17:34:04 +03:00
|
|
|
<< cmsysProcess_GetErrorString(cp) << std::endl);
|
2006-03-10 23:03:09 +03:00
|
|
|
*this->LogFile << "\tError executing SCP: "
|
2016-05-16 17:34:04 +03:00
|
|
|
<< cmsysProcess_GetErrorString(cp) << std::endl;
|
|
|
|
problems++;
|
2004-06-02 21:39:25 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-06-02 21:39:25 +04:00
|
|
|
cmsysProcess_Delete(cp);
|
2016-06-02 00:29:53 +03:00
|
|
|
return problems == 0;
|
2003-01-07 07:07:24 +03:00
|
|
|
}
|
2005-03-05 01:11:42 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmCTestSubmitHandler::SubmitUsingCP(const std::string& localprefix,
|
|
|
|
const std::set<std::string>& files,
|
|
|
|
const std::string& remoteprefix,
|
|
|
|
const std::string& destination)
|
2009-03-31 23:24:50 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (localprefix.empty() || files.empty() || remoteprefix.empty() ||
|
|
|
|
destination.empty()) {
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
2011-03-11 16:04:58 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2009-03-31 23:24:50 +04:00
|
|
|
"Missing arguments for submit via cp:\n"
|
|
|
|
<< "\tlocalprefix: " << localprefix << "\n"
|
|
|
|
<< "\tNumber of files: " << files.size() << "\n"
|
|
|
|
<< "\tremoteprefix: " << remoteprefix << "\n"
|
|
|
|
<< "\tdestination: " << destination << std::endl);
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2009-03-31 23:24:50 +04:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-02-17 00:02:14 +03:00
|
|
|
|
2009-03-31 23:24:50 +04:00
|
|
|
cmCTest::SetOfStrings::const_iterator file;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (file = files.begin(); file != files.end(); ++file) {
|
2009-03-31 23:24:50 +04:00
|
|
|
std::string lfname = localprefix;
|
|
|
|
cmSystemTools::ConvertToUnixSlashes(lfname);
|
|
|
|
lfname += "/" + *file;
|
|
|
|
std::string rfname = destination + "/" + remoteprefix + *file;
|
2014-10-15 16:54:05 +04:00
|
|
|
cmSystemTools::CopyFileAlways(lfname, rfname);
|
2015-02-17 00:02:14 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Copy file: "
|
2016-05-16 17:34:04 +03:00
|
|
|
<< lfname << " to " << rfname << std::endl,
|
|
|
|
this->Quiet);
|
|
|
|
}
|
2009-03-31 23:24:50 +04:00
|
|
|
std::string tagDoneFile = destination + "/" + remoteprefix + "DONE";
|
2014-10-15 16:54:05 +04:00
|
|
|
cmSystemTools::Touch(tagDoneFile, true);
|
2009-03-31 23:24:50 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-06-11 19:24:56 +04:00
|
|
|
#if defined(CTEST_USE_XMLRPC)
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmCTestSubmitHandler::SubmitUsingXMLRPC(
|
|
|
|
const std::string& localprefix, const std::set<std::string>& files,
|
|
|
|
const std::string& remoteprefix, const std::string& url)
|
2005-03-05 01:11:42 +03:00
|
|
|
{
|
|
|
|
xmlrpc_env env;
|
2006-10-19 23:00:10 +04:00
|
|
|
char ctestString[] = "CTest";
|
|
|
|
std::string ctestVersionString = cmVersion::GetCMakeVersion();
|
|
|
|
char* ctestVersion = const_cast<char*>(ctestVersionString.c_str());
|
2005-05-27 02:15:41 +04:00
|
|
|
|
2014-02-10 09:21:34 +04:00
|
|
|
std::string realURL = url + "/" + remoteprefix + "/Command/";
|
2005-03-05 01:11:42 +03:00
|
|
|
|
|
|
|
/* Start up our XML-RPC client library. */
|
2006-10-19 23:00:10 +04:00
|
|
|
xmlrpc_client_init(XMLRPC_CLIENT_NO_FLAGS, ctestString, ctestVersion);
|
2005-03-05 01:11:42 +03:00
|
|
|
|
|
|
|
/* Initialize our error-handling environment. */
|
|
|
|
xmlrpc_env_init(&env);
|
|
|
|
|
|
|
|
/* Call the famous server at UserLand. */
|
2015-02-17 00:02:14 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " Submitting to: "
|
2016-06-07 00:53:32 +03:00
|
|
|
<< realURL << " (" << remoteprefix << ")" << std::endl,
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Quiet);
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTest::SetOfStrings::const_iterator file;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (file = files.begin(); file != files.end(); ++file) {
|
|
|
|
xmlrpc_value* result;
|
2005-03-06 16:51:08 +03:00
|
|
|
|
2014-02-10 09:21:34 +04:00
|
|
|
std::string local_file = *file;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::FileExists(local_file.c_str())) {
|
2005-07-18 20:53:48 +04:00
|
|
|
local_file = localprefix + "/" + *file;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
2016-06-07 00:53:32 +03:00
|
|
|
" Submit file: " << local_file << std::endl,
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Quiet);
|
2005-03-05 01:11:42 +03:00
|
|
|
struct stat st;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (::stat(local_file.c_str(), &st)) {
|
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2016-06-07 00:53:32 +03:00
|
|
|
" Cannot find file: " << local_file << std::endl);
|
2005-03-05 01:11:42 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-03-05 01:11:42 +03:00
|
|
|
|
2007-11-05 22:34:36 +03:00
|
|
|
// off_t can be bigger than size_t. fread takes size_t.
|
|
|
|
// make sure the file is not too big.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (static_cast<off_t>(static_cast<size_t>(st.st_size)) !=
|
|
|
|
static_cast<off_t>(st.st_size)) {
|
2016-06-07 00:53:32 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, " File too big: " << local_file
|
|
|
|
<< std::endl);
|
2007-11-05 22:34:36 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-11-05 22:34:36 +03:00
|
|
|
size_t fileSize = static_cast<size_t>(st.st_size);
|
2014-01-04 09:47:13 +04:00
|
|
|
FILE* fp = cmsys::SystemTools::Fopen(local_file.c_str(), "rb");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!fp) {
|
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2016-06-07 00:53:32 +03:00
|
|
|
" Cannot open file: " << local_file << std::endl);
|
2005-03-05 01:11:42 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-03-06 16:51:08 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
unsigned char* fileBuffer = new unsigned char[fileSize];
|
|
|
|
if (fread(fileBuffer, 1, fileSize, fp) != fileSize) {
|
|
|
|
delete[] fileBuffer;
|
2005-03-05 01:11:42 +03:00
|
|
|
fclose(fp);
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2016-06-07 00:53:32 +03:00
|
|
|
" Cannot read file: " << local_file << std::endl);
|
2005-03-06 16:51:08 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-03-05 01:11:42 +03:00
|
|
|
fclose(fp);
|
|
|
|
|
2006-10-19 23:00:10 +04:00
|
|
|
char remoteCommand[] = "Submit.put";
|
|
|
|
char* pRealURL = const_cast<char*>(realURL.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
result = xmlrpc_client_call(&env, pRealURL, remoteCommand, "(6)",
|
|
|
|
fileBuffer, (xmlrpc_int32)fileSize);
|
2005-03-05 01:11:42 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
delete[] fileBuffer;
|
2005-03-05 01:11:42 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (env.fault_occurred) {
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, " Submission problem: "
|
2016-05-16 17:34:04 +03:00
|
|
|
<< env.fault_string << " (" << env.fault_code << ")"
|
|
|
|
<< std::endl);
|
2005-03-05 01:11:42 +03:00
|
|
|
xmlrpc_env_clean(&env);
|
|
|
|
xmlrpc_client_cleanup();
|
2005-05-03 16:17:39 +04:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-03-05 01:11:42 +03:00
|
|
|
|
2005-03-06 16:51:08 +03:00
|
|
|
/* Dispose of our result value. */
|
|
|
|
xmlrpc_DECREF(result);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-03-05 01:11:42 +03:00
|
|
|
|
|
|
|
/* Clean up our error-handling environment. */
|
|
|
|
xmlrpc_env_clean(&env);
|
|
|
|
|
|
|
|
/* Shutdown our XML-RPC client library. */
|
|
|
|
xmlrpc_client_cleanup();
|
2005-05-03 16:17:39 +04:00
|
|
|
return true;
|
|
|
|
}
|
2009-06-11 19:24:56 +04:00
|
|
|
#else
|
2016-08-17 02:49:57 +03:00
|
|
|
bool cmCTestSubmitHandler::SubmitUsingXMLRPC(
|
|
|
|
std::string const& /*unused*/, std::set<std::string> const& /*unused*/,
|
|
|
|
std::string const& /*unused*/, std::string const& /*unused*/)
|
2009-06-11 19:24:56 +04:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif
|
2005-05-03 16:17:39 +04:00
|
|
|
|
2015-01-14 18:54:25 +03:00
|
|
|
void cmCTestSubmitHandler::ConstructCDashURL(std::string& dropMethod,
|
|
|
|
std::string& url)
|
|
|
|
{
|
|
|
|
dropMethod = this->CTest->GetCTestConfiguration("DropMethod");
|
|
|
|
url = dropMethod;
|
|
|
|
url += "://";
|
2016-05-27 00:05:30 +03:00
|
|
|
if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty()) {
|
2015-01-14 18:54:25 +03:00
|
|
|
url += this->CTest->GetCTestConfiguration("DropSiteUser");
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestOptionalLog(
|
|
|
|
this->CTest, HANDLER_OUTPUT,
|
|
|
|
this->CTest->GetCTestConfiguration("DropSiteUser").c_str(), this->Quiet);
|
2016-05-27 00:05:30 +03:00
|
|
|
if (!this->CTest->GetCTestConfiguration("DropSitePassword").empty()) {
|
2015-01-14 18:54:25 +03:00
|
|
|
url += ":" + this->CTest->GetCTestConfiguration("DropSitePassword");
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, ":******", this->Quiet);
|
2015-01-14 18:54:25 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
url += "@";
|
|
|
|
}
|
2015-01-14 18:54:25 +03:00
|
|
|
url += this->CTest->GetCTestConfiguration("DropSite") +
|
|
|
|
this->CTest->GetCTestConfiguration("DropLocation");
|
|
|
|
}
|
|
|
|
|
|
|
|
int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
|
|
|
|
std::string const& typeString)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (file.empty()) {
|
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, "Upload file not specified\n");
|
2015-01-15 23:23:07 +03:00
|
|
|
return -1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!cmSystemTools::FileExists(file)) {
|
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, "Upload file not found: '"
|
|
|
|
<< file << "'\n");
|
2015-01-14 18:54:25 +03:00
|
|
|
return -1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-01-14 18:54:25 +03:00
|
|
|
cmCTestCurl curl(this->CTest);
|
|
|
|
std::string curlopt(this->CTest->GetCTestConfiguration("CurlOptions"));
|
|
|
|
std::vector<std::string> args;
|
|
|
|
cmSystemTools::ExpandListArgument(curlopt, args);
|
|
|
|
curl.SetCurlOptions(args);
|
|
|
|
curl.SetTimeOutSeconds(SUBMIT_TIMEOUT_IN_SECONDS_DEFAULT);
|
|
|
|
std::string dropMethod;
|
|
|
|
std::string url;
|
|
|
|
this->ConstructCDashURL(dropMethod, url);
|
|
|
|
std::string::size_type pos = url.find("submit.php?");
|
2016-05-16 17:34:04 +03:00
|
|
|
url = url.substr(0, pos + 10);
|
|
|
|
if (!(dropMethod == "http" || dropMethod == "https")) {
|
2015-01-14 18:54:25 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
|
|
|
"Only http and https are supported for CDASH_UPLOAD\n");
|
|
|
|
return -1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-01-14 18:54:25 +03:00
|
|
|
char md5sum[33];
|
|
|
|
md5sum[32] = 0;
|
|
|
|
cmSystemTools::ComputeFileMD5(file, md5sum);
|
|
|
|
// 1. request the buildid and check to see if the file
|
|
|
|
// has already been uploaded
|
|
|
|
// TODO I added support for subproject. You would need to add
|
|
|
|
// a "&subproject=subprojectname" to the first POST.
|
|
|
|
cmCTestScriptHandler* ch =
|
|
|
|
static_cast<cmCTestScriptHandler*>(this->CTest->GetHandler("script"));
|
2016-05-16 17:34:04 +03:00
|
|
|
cmake* cm = ch->GetCMake();
|
2015-04-11 15:15:55 +03:00
|
|
|
const char* subproject = cm->GetState()->GetGlobalProperty("SubProject");
|
2015-01-15 23:23:07 +03:00
|
|
|
// TODO: Encode values for a URL instead of trusting caller.
|
2015-01-14 18:54:25 +03:00
|
|
|
std::ostringstream str;
|
|
|
|
str << "project="
|
2015-01-29 22:42:44 +03:00
|
|
|
<< curl.Escape(this->CTest->GetCTestConfiguration("ProjectName")) << "&";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (subproject) {
|
2015-01-29 22:42:44 +03:00
|
|
|
str << "subproject=" << curl.Escape(subproject) << "&";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-01-29 22:42:44 +03:00
|
|
|
str << "stamp=" << curl.Escape(this->CTest->GetCurrentTag()) << "-"
|
|
|
|
<< curl.Escape(this->CTest->GetTestModelString()) << "&"
|
|
|
|
<< "model=" << curl.Escape(this->CTest->GetTestModelString()) << "&"
|
|
|
|
<< "build="
|
|
|
|
<< curl.Escape(this->CTest->GetCTestConfiguration("BuildName")) << "&"
|
2016-05-16 17:34:04 +03:00
|
|
|
<< "site=" << curl.Escape(this->CTest->GetCTestConfiguration("Site"))
|
|
|
|
<< "&"
|
|
|
|
<< "track=" << curl.Escape(this->CTest->GetTestModelString()) << "&"
|
2015-01-14 18:54:25 +03:00
|
|
|
<< "starttime=" << (int)cmSystemTools::GetTime() << "&"
|
|
|
|
<< "endtime=" << (int)cmSystemTools::GetTime() << "&"
|
|
|
|
<< "datafilesmd5[0]=" << md5sum << "&"
|
2015-01-29 22:42:44 +03:00
|
|
|
<< "type=" << curl.Escape(typeString);
|
2015-01-14 18:54:25 +03:00
|
|
|
std::string fields = str.str();
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, DEBUG,
|
|
|
|
"fields: " << fields << "\nurl:" << url
|
|
|
|
<< "\nfile: " << file << "\n",
|
|
|
|
this->Quiet);
|
2015-01-14 18:54:25 +03:00
|
|
|
std::string response;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!curl.HttpRequest(url, fields, response)) {
|
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, "Error in HttpRequest\n"
|
|
|
|
<< response);
|
2015-01-14 18:54:25 +03:00
|
|
|
return -1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-02-17 00:02:14 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Request upload response: [" << response << "]\n",
|
|
|
|
this->Quiet);
|
2015-01-14 18:54:25 +03:00
|
|
|
Json::Value json;
|
|
|
|
Json::Reader reader;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!reader.parse(response, json)) {
|
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, "error parsing json string ["
|
|
|
|
<< response << "]\n"
|
|
|
|
<< reader.getFormattedErrorMessages() << "\n");
|
2015-01-14 18:54:25 +03:00
|
|
|
return -1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (json["status"].asInt() != 0) {
|
2015-01-14 18:54:25 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Bad status returned from CDash: " << json["status"].asInt());
|
2015-01-14 18:54:25 +03:00
|
|
|
return -1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (json["datafilesmd5"].isArray()) {
|
2015-01-14 18:54:25 +03:00
|
|
|
int datares = json["datafilesmd5"][0].asInt();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (datares == 1) {
|
2015-02-17 00:02:14 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
"File already exists on CDash, skip upload " << file
|
|
|
|
<< "\n",
|
|
|
|
this->Quiet);
|
2015-01-14 18:54:25 +03:00
|
|
|
return 0;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-01-14 18:54:25 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2016-05-16 17:34:04 +03:00
|
|
|
"bad datafilesmd5 value in response " << response << "\n");
|
2015-01-14 18:54:25 +03:00
|
|
|
return -1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-01-14 18:54:25 +03:00
|
|
|
|
|
|
|
std::string upload_as = cmSystemTools::GetFilenameName(file);
|
|
|
|
std::ostringstream fstr;
|
2015-01-29 22:42:44 +03:00
|
|
|
fstr << "type=" << curl.Escape(typeString) << "&"
|
2015-01-14 18:54:25 +03:00
|
|
|
<< "md5=" << md5sum << "&"
|
2015-01-29 22:42:44 +03:00
|
|
|
<< "filename=" << curl.Escape(upload_as) << "&"
|
2015-01-14 18:54:25 +03:00
|
|
|
<< "buildid=" << json["buildid"].asString();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!curl.UploadFile(file, url, fstr.str(), response)) {
|
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, "error uploading to CDash. "
|
|
|
|
<< file << " " << url << " " << fstr.str());
|
2015-01-14 18:54:25 +03:00
|
|
|
return -1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!reader.parse(response, json)) {
|
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, "error parsing json string ["
|
|
|
|
<< response << "]\n"
|
|
|
|
<< reader.getFormattedErrorMessages() << "\n");
|
2015-01-14 18:54:25 +03:00
|
|
|
return -1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-02-17 00:02:14 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Upload file response: [" << response << "]\n",
|
|
|
|
this->Quiet);
|
2015-01-14 18:54:25 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-05-03 16:17:39 +04:00
|
|
|
int cmCTestSubmitHandler::ProcessHandler()
|
|
|
|
{
|
2015-01-14 18:54:25 +03:00
|
|
|
const char* cdashUploadFile = this->GetOption("CDashUploadFile");
|
|
|
|
const char* cdashUploadType = this->GetOption("CDashUploadType");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cdashUploadFile && cdashUploadType) {
|
2015-01-15 23:23:07 +03:00
|
|
|
return this->HandleCDashUploadFile(cdashUploadFile, cdashUploadType);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-02-29 22:58:33 +03:00
|
|
|
std::string iscdash = this->CTest->GetCTestConfiguration("IsCDash");
|
|
|
|
// cdash does not need to trigger so just return true
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!iscdash.empty()) {
|
2008-02-29 22:58:33 +03:00
|
|
|
this->CDash = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-02-29 22:58:33 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& buildDirectory =
|
|
|
|
this->CTest->GetCTestConfiguration("BuildDirectory");
|
|
|
|
if (buildDirectory.empty()) {
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Cannot find BuildDirectory key in the DartConfiguration.tcl"
|
|
|
|
<< std::endl);
|
2005-05-03 16:17:39 +04:00
|
|
|
return -1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-05-03 16:17:39 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (getenv("HTTP_PROXY")) {
|
2006-03-10 23:03:09 +03:00
|
|
|
this->HTTPProxyType = 1;
|
|
|
|
this->HTTPProxy = getenv("HTTP_PROXY");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (getenv("HTTP_PROXY_PORT")) {
|
2006-03-10 23:03:09 +03:00
|
|
|
this->HTTPProxy += ":";
|
|
|
|
this->HTTPProxy += getenv("HTTP_PROXY_PORT");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (getenv("HTTP_PROXY_TYPE")) {
|
2014-02-10 09:21:34 +04:00
|
|
|
std::string type = getenv("HTTP_PROXY_TYPE");
|
2005-06-03 00:47:47 +04:00
|
|
|
// HTTP/SOCKS4/SOCKS5
|
2016-05-16 17:34:04 +03:00
|
|
|
if (type == "HTTP") {
|
2006-03-10 23:03:09 +03:00
|
|
|
this->HTTPProxyType = 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (type == "SOCKS4") {
|
2006-03-10 23:03:09 +03:00
|
|
|
this->HTTPProxyType = 2;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (type == "SOCKS5") {
|
2006-03-10 23:03:09 +03:00
|
|
|
this->HTTPProxyType = 3;
|
2005-06-03 00:47:47 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (getenv("HTTP_PROXY_USER")) {
|
2006-03-10 23:03:09 +03:00
|
|
|
this->HTTPProxyAuth = getenv("HTTP_PROXY_USER");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (getenv("HTTP_PROXY_PASSWD")) {
|
2006-03-10 23:03:09 +03:00
|
|
|
this->HTTPProxyAuth += ":";
|
|
|
|
this->HTTPProxyAuth += getenv("HTTP_PROXY_PASSWD");
|
2005-06-03 00:47:47 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-06-03 00:47:47 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (getenv("FTP_PROXY")) {
|
2006-03-10 23:03:09 +03:00
|
|
|
this->FTPProxyType = 1;
|
|
|
|
this->FTPProxy = getenv("FTP_PROXY");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (getenv("FTP_PROXY_PORT")) {
|
2006-03-10 23:03:09 +03:00
|
|
|
this->FTPProxy += ":";
|
|
|
|
this->FTPProxy += getenv("FTP_PROXY_PORT");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (getenv("FTP_PROXY_TYPE")) {
|
2014-02-10 09:21:34 +04:00
|
|
|
std::string type = getenv("FTP_PROXY_TYPE");
|
2005-06-03 00:47:47 +04:00
|
|
|
// HTTP/SOCKS4/SOCKS5
|
2016-05-16 17:34:04 +03:00
|
|
|
if (type == "HTTP") {
|
2006-03-10 23:03:09 +03:00
|
|
|
this->FTPProxyType = 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (type == "SOCKS4") {
|
2006-03-10 23:03:09 +03:00
|
|
|
this->FTPProxyType = 2;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (type == "SOCKS5") {
|
2006-03-10 23:03:09 +03:00
|
|
|
this->FTPProxyType = 3;
|
2005-06-03 00:47:47 +04:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-06-03 00:47:47 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->HTTPProxy.empty()) {
|
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
|
|
|
" Use HTTP Proxy: " << this->HTTPProxy << std::endl,
|
|
|
|
this->Quiet);
|
|
|
|
}
|
|
|
|
if (!this->FTPProxy.empty()) {
|
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
|
|
|
" Use FTP Proxy: " << this->FTPProxy << std::endl,
|
|
|
|
this->Quiet);
|
|
|
|
}
|
2005-05-03 16:17:39 +04:00
|
|
|
cmGeneratedFileStream ofs;
|
2005-06-23 21:04:18 +04:00
|
|
|
this->StartLogFile("Submit", ofs);
|
2005-05-03 16:17:39 +04:00
|
|
|
|
2009-02-03 19:52:54 +03:00
|
|
|
cmCTest::SetOfStrings files;
|
2005-05-03 16:17:39 +04:00
|
|
|
std::string prefix = this->GetSubmitResultsPrefix();
|
2009-02-03 19:52:54 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->Files.empty()) {
|
2009-02-04 20:38:03 +03:00
|
|
|
// Submit the explicitly selected files:
|
2009-02-03 19:52:54 +03:00
|
|
|
//
|
2014-11-25 18:33:00 +03:00
|
|
|
files.insert(this->Files.begin(), this->Files.end());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-02-03 19:52:54 +03:00
|
|
|
|
|
|
|
// Add to the list of files to submit from any selected, existing parts:
|
|
|
|
//
|
|
|
|
|
2005-05-03 16:17:39 +04:00
|
|
|
// TODO:
|
|
|
|
// Check if test is enabled
|
2009-02-03 19:52:54 +03:00
|
|
|
|
2009-01-12 18:37:55 +03:00
|
|
|
this->CTest->AddIfExists(cmCTest::PartUpdate, "Update.xml");
|
|
|
|
this->CTest->AddIfExists(cmCTest::PartConfigure, "Configure.xml");
|
|
|
|
this->CTest->AddIfExists(cmCTest::PartBuild, "Build.xml");
|
|
|
|
this->CTest->AddIfExists(cmCTest::PartTest, "Test.xml");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->CTest->AddIfExists(cmCTest::PartCoverage, "Coverage.xml")) {
|
2014-02-10 09:21:34 +04:00
|
|
|
std::vector<std::string> gfiles;
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string gpath =
|
|
|
|
buildDirectory + "/Testing/" + this->CTest->GetCurrentTag();
|
2005-05-03 16:17:39 +04:00
|
|
|
std::string::size_type glen = gpath.size() + 1;
|
|
|
|
gpath = gpath + "/CoverageLog*";
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, DEBUG,
|
|
|
|
"Globbing for: " << gpath << std::endl, this->Quiet);
|
|
|
|
if (cmSystemTools::SimpleGlob(gpath, gfiles, 1)) {
|
2005-05-03 16:17:39 +04:00
|
|
|
size_t cc;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (cc = 0; cc < gfiles.size(); cc++) {
|
2005-05-03 16:17:39 +04:00
|
|
|
gfiles[cc] = gfiles[cc].substr(glen);
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, DEBUG,
|
|
|
|
"Glob file: " << gfiles[cc] << std::endl,
|
|
|
|
this->Quiet);
|
2009-01-12 18:37:55 +03:00
|
|
|
this->CTest->AddSubmitFile(cmCTest::PartCoverage, gfiles[cc].c_str());
|
2005-05-03 16:17:39 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, "Problem globbing" << std::endl);
|
2005-05-03 16:17:39 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-01-12 18:37:55 +03:00
|
|
|
this->CTest->AddIfExists(cmCTest::PartMemCheck, "DynamicAnalysis.xml");
|
|
|
|
this->CTest->AddIfExists(cmCTest::PartMemCheck, "Purify.xml");
|
|
|
|
this->CTest->AddIfExists(cmCTest::PartNotes, "Notes.xml");
|
2011-02-18 20:11:51 +03:00
|
|
|
this->CTest->AddIfExists(cmCTest::PartUpload, "Upload.xml");
|
2009-01-12 18:37:55 +03:00
|
|
|
|
|
|
|
// Query parts for files to submit.
|
2016-05-16 17:34:04 +03:00
|
|
|
for (cmCTest::Part p = cmCTest::PartStart; p != cmCTest::PartCount;
|
|
|
|
p = cmCTest::Part(p + 1)) {
|
2009-01-12 18:38:27 +03:00
|
|
|
// Skip parts we are not submitting.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->SubmitPart[p]) {
|
2009-01-12 18:38:27 +03:00
|
|
|
continue;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-01-12 18:38:27 +03:00
|
|
|
|
|
|
|
// Submit files from this part.
|
2009-01-12 18:37:55 +03:00
|
|
|
std::vector<std::string> const& pfiles = this->CTest->GetSubmitFiles(p);
|
2014-11-25 18:33:00 +03:00
|
|
|
files.insert(pfiles.begin(), pfiles.end());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-06-23 21:04:18 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (ofs) {
|
2005-05-03 16:17:39 +04:00
|
|
|
ofs << "Upload files:" << std::endl;
|
|
|
|
int cnt = 0;
|
2009-01-12 18:37:55 +03:00
|
|
|
cmCTest::SetOfStrings::iterator it;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (it = files.begin(); it != files.end(); ++it) {
|
2014-03-11 16:35:32 +04:00
|
|
|
ofs << cnt << "\t" << *it << std::endl;
|
2016-05-16 17:34:04 +03:00
|
|
|
cnt++;
|
2005-05-03 16:17:39 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-02-17 00:02:14 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "Submit files (using "
|
2016-05-16 17:34:04 +03:00
|
|
|
<< this->CTest->GetCTestConfiguration("DropMethod")
|
|
|
|
<< ")" << std::endl,
|
|
|
|
this->Quiet);
|
2006-04-28 19:59:31 +04:00
|
|
|
const char* specificTrack = this->CTest->GetSpecificTrack();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (specificTrack) {
|
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
|
|
|
" Send to track: " << specificTrack << std::endl,
|
|
|
|
this->Quiet);
|
|
|
|
}
|
2005-05-03 16:17:39 +04:00
|
|
|
this->SetLogFile(&ofs);
|
2009-02-03 19:52:54 +03:00
|
|
|
|
2014-02-10 09:21:34 +04:00
|
|
|
std::string dropMethod(this->CTest->GetCTestConfiguration("DropMethod"));
|
2009-02-03 19:52:54 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (dropMethod == "" || dropMethod == "ftp") {
|
2005-05-03 16:17:39 +04:00
|
|
|
ofs << "Using drop method: FTP" << std::endl;
|
2015-02-17 00:02:14 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
" Using FTP submit method" << std::endl
|
|
|
|
<< " Drop site: ftp://",
|
|
|
|
this->Quiet);
|
2005-05-03 16:17:39 +04:00
|
|
|
std::string url = "ftp://";
|
2006-03-09 19:17:10 +03:00
|
|
|
url += cmCTest::MakeURLSafe(
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CTest->GetCTestConfiguration("DropSiteUser")) +
|
|
|
|
":" + cmCTest::MakeURLSafe(
|
|
|
|
this->CTest->GetCTestConfiguration("DropSitePassword")) +
|
|
|
|
"@" + this->CTest->GetCTestConfiguration("DropSite") +
|
|
|
|
cmCTest::MakeURLSafe(this->CTest->GetCTestConfiguration("DropLocation"));
|
|
|
|
if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty()) {
|
|
|
|
cmCTestOptionalLog(
|
|
|
|
this->CTest, HANDLER_OUTPUT,
|
|
|
|
this->CTest->GetCTestConfiguration("DropSiteUser").c_str(),
|
|
|
|
this->Quiet);
|
|
|
|
if (!this->CTest->GetCTestConfiguration("DropSitePassword").empty()) {
|
2015-02-17 00:02:14 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, ":******",
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Quiet);
|
2005-06-16 21:18:21 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "@", this->Quiet);
|
|
|
|
}
|
2015-02-17 00:02:14 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CTest->GetCTestConfiguration("DropSite")
|
|
|
|
<< this->CTest->GetCTestConfiguration("DropLocation")
|
|
|
|
<< std::endl,
|
|
|
|
this->Quiet);
|
|
|
|
if (!this->SubmitUsingFTP(buildDirectory + "/Testing/" +
|
|
|
|
this->CTest->GetCurrentTag(),
|
|
|
|
files, prefix, url)) {
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2016-05-16 17:34:04 +03:00
|
|
|
" Problems when submitting via FTP" << std::endl);
|
2005-06-16 21:18:21 +04:00
|
|
|
ofs << " Problems when submitting via FTP" << std::endl;
|
2005-05-03 16:17:39 +04:00
|
|
|
return -1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!this->CDash) {
|
|
|
|
cmCTestOptionalLog(
|
|
|
|
this->CTest, HANDLER_OUTPUT, " Using HTTP trigger method"
|
|
|
|
<< std::endl
|
|
|
|
<< " Trigger site: "
|
|
|
|
<< this->CTest->GetCTestConfiguration("TriggerSite") << std::endl,
|
|
|
|
this->Quiet);
|
|
|
|
if (!this->TriggerUsingHTTP(
|
|
|
|
files, prefix,
|
|
|
|
this->CTest->GetCTestConfiguration("TriggerSite"))) {
|
2008-02-29 22:58:33 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
|
|
|
" Problems when triggering via HTTP" << std::endl);
|
|
|
|
ofs << " Problems when triggering via HTTP" << std::endl;
|
|
|
|
return -1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-02-17 00:02:14 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
" Submission successful" << std::endl, this->Quiet);
|
2008-02-29 22:58:33 +03:00
|
|
|
ofs << " Submission successful" << std::endl;
|
|
|
|
return 0;
|
2005-05-03 16:17:39 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (dropMethod == "http" || dropMethod == "https") {
|
2009-03-12 21:54:00 +03:00
|
|
|
std::string url = dropMethod;
|
|
|
|
url += "://";
|
2009-04-11 17:29:27 +04:00
|
|
|
ofs << "Using drop method: " << dropMethod << std::endl;
|
2015-02-17 00:02:14 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
" Using HTTP submit method" << std::endl
|
|
|
|
<< " Drop site:" << url,
|
|
|
|
this->Quiet);
|
|
|
|
if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty()) {
|
2006-03-10 23:03:09 +03:00
|
|
|
url += this->CTest->GetCTestConfiguration("DropSiteUser");
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestOptionalLog(
|
|
|
|
this->CTest, HANDLER_OUTPUT,
|
2015-02-17 00:02:14 +03:00
|
|
|
this->CTest->GetCTestConfiguration("DropSiteUser").c_str(),
|
|
|
|
this->Quiet);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->CTest->GetCTestConfiguration("DropSitePassword").empty()) {
|
2006-03-10 23:03:09 +03:00
|
|
|
url += ":" + this->CTest->GetCTestConfiguration("DropSitePassword");
|
2015-02-17 00:02:14 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, ":******",
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Quiet);
|
|
|
|
}
|
2005-05-03 16:17:39 +04:00
|
|
|
url += "@";
|
2015-02-17 00:02:14 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "@", this->Quiet);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
url += this->CTest->GetCTestConfiguration("DropSite") +
|
|
|
|
this->CTest->GetCTestConfiguration("DropLocation");
|
2015-02-17 00:02:14 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CTest->GetCTestConfiguration("DropSite")
|
|
|
|
<< this->CTest->GetCTestConfiguration("DropLocation")
|
|
|
|
<< std::endl,
|
|
|
|
this->Quiet);
|
|
|
|
if (!this->SubmitUsingHTTP(buildDirectory + "/Testing/" +
|
|
|
|
this->CTest->GetCurrentTag(),
|
|
|
|
files, prefix, url)) {
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2016-05-16 17:34:04 +03:00
|
|
|
" Problems when submitting via HTTP" << std::endl);
|
2005-06-16 21:18:21 +04:00
|
|
|
ofs << " Problems when submitting via HTTP" << std::endl;
|
2005-05-03 16:17:39 +04:00
|
|
|
return -1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!this->CDash) {
|
|
|
|
cmCTestOptionalLog(
|
|
|
|
this->CTest, HANDLER_OUTPUT, " Using HTTP trigger method"
|
|
|
|
<< std::endl
|
|
|
|
<< " Trigger site: "
|
|
|
|
<< this->CTest->GetCTestConfiguration("TriggerSite") << std::endl,
|
|
|
|
this->Quiet);
|
|
|
|
if (!this->TriggerUsingHTTP(
|
|
|
|
files, prefix,
|
|
|
|
this->CTest->GetCTestConfiguration("TriggerSite"))) {
|
2008-02-29 22:58:33 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
|
|
|
" Problems when triggering via HTTP" << std::endl);
|
|
|
|
ofs << " Problems when triggering via HTTP" << std::endl;
|
|
|
|
return -1;
|
2005-05-03 16:17:39 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (this->HasErrors) {
|
2009-12-11 22:10:37 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Errors occurred during "
|
2016-05-16 17:34:04 +03:00
|
|
|
"submission."
|
|
|
|
<< std::endl);
|
2009-12-11 22:10:37 +03:00
|
|
|
ofs << " Errors occurred during submission. " << std::endl;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
|
|
|
cmCTestOptionalLog(
|
|
|
|
this->CTest, HANDLER_OUTPUT, " Submission successful"
|
|
|
|
<< (this->HasWarnings ? ", with warnings." : "") << std::endl,
|
2015-02-17 00:02:14 +03:00
|
|
|
this->Quiet);
|
2016-05-16 17:34:04 +03:00
|
|
|
ofs << " Submission successful"
|
|
|
|
<< (this->HasWarnings ? ", with warnings." : "") << std::endl;
|
|
|
|
}
|
2009-12-11 22:10:37 +03:00
|
|
|
|
2005-05-03 16:17:39 +04:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (dropMethod == "xmlrpc") {
|
2009-06-11 19:24:56 +04:00
|
|
|
#if defined(CTEST_USE_XMLRPC)
|
2005-05-03 16:17:39 +04:00
|
|
|
ofs << "Using drop method: XML-RPC" << std::endl;
|
2015-02-17 00:02:14 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
" Using XML-RPC submit method" << std::endl,
|
|
|
|
this->Quiet);
|
2006-03-10 23:03:09 +03:00
|
|
|
std::string url = this->CTest->GetCTestConfiguration("DropSite");
|
|
|
|
prefix = this->CTest->GetCTestConfiguration("DropLocation");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->SubmitUsingXMLRPC(buildDirectory + "/Testing/" +
|
|
|
|
this->CTest->GetCurrentTag(),
|
|
|
|
files, prefix, url)) {
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2016-05-16 17:34:04 +03:00
|
|
|
" Problems when submitting via XML-RPC" << std::endl);
|
2005-06-16 21:18:21 +04:00
|
|
|
ofs << " Problems when submitting via XML-RPC" << std::endl;
|
2005-05-03 16:17:39 +04:00
|
|
|
return -1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
|
|
|
" Submission successful" << std::endl, this->Quiet);
|
2005-06-16 21:18:21 +04:00
|
|
|
ofs << " Submission successful" << std::endl;
|
2005-05-03 16:17:39 +04:00
|
|
|
return 0;
|
2009-06-11 19:24:56 +04:00
|
|
|
#else
|
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
|
|
|
" Submission method \"xmlrpc\" not compiled into CTest!"
|
2016-05-16 17:34:04 +03:00
|
|
|
<< std::endl);
|
2009-06-11 19:24:56 +04:00
|
|
|
return -1;
|
|
|
|
#endif
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (dropMethod == "scp") {
|
2005-05-03 16:17:39 +04:00
|
|
|
std::string url;
|
2005-07-06 23:11:38 +04:00
|
|
|
std::string oldWorkingDirectory;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty()) {
|
2006-03-10 23:03:09 +03:00
|
|
|
url += this->CTest->GetCTestConfiguration("DropSiteUser") + "@";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
url += this->CTest->GetCTestConfiguration("DropSite") + ":" +
|
|
|
|
this->CTest->GetCTestConfiguration("DropLocation");
|
2005-05-03 16:17:39 +04:00
|
|
|
|
2005-07-06 23:11:38 +04:00
|
|
|
// change to the build directory so that we can uses a relative path
|
|
|
|
// on windows since scp dosn't support "c:" a drive in the path
|
|
|
|
oldWorkingDirectory = cmSystemTools::GetCurrentWorkingDirectory();
|
2014-10-15 16:54:05 +04:00
|
|
|
cmSystemTools::ChangeDirectory(buildDirectory);
|
2005-07-06 23:11:38 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->SubmitUsingSCP(this->CTest->GetCTestConfiguration("ScpCommand"),
|
|
|
|
"Testing/" + this->CTest->GetCurrentTag(), files,
|
|
|
|
prefix, url)) {
|
2014-10-15 16:54:05 +04:00
|
|
|
cmSystemTools::ChangeDirectory(oldWorkingDirectory);
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2016-05-16 17:34:04 +03:00
|
|
|
" Problems when submitting via SCP" << std::endl);
|
2005-06-16 21:18:21 +04:00
|
|
|
ofs << " Problems when submitting via SCP" << std::endl;
|
2005-05-03 16:17:39 +04:00
|
|
|
return -1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-10-15 16:54:05 +04:00
|
|
|
cmSystemTools::ChangeDirectory(oldWorkingDirectory);
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
|
|
|
" Submission successful" << std::endl, this->Quiet);
|
2005-06-16 21:18:21 +04:00
|
|
|
ofs << " Submission successful" << std::endl;
|
2005-06-24 21:29:22 +04:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (dropMethod == "cp") {
|
|
|
|
std::string location = this->CTest->GetCTestConfiguration("DropLocation");
|
2009-03-31 23:24:50 +04:00
|
|
|
|
|
|
|
// change to the build directory so that we can uses a relative path
|
|
|
|
// on windows since scp dosn't support "c:" a drive in the path
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string oldWorkingDirectory =
|
|
|
|
cmSystemTools::GetCurrentWorkingDirectory();
|
2014-10-15 16:54:05 +04:00
|
|
|
cmSystemTools::ChangeDirectory(buildDirectory);
|
2015-02-17 00:02:14 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
" Change directory: " << buildDirectory << std::endl,
|
|
|
|
this->Quiet);
|
|
|
|
|
|
|
|
if (!this->SubmitUsingCP("Testing/" + this->CTest->GetCurrentTag(), files,
|
|
|
|
prefix, location)) {
|
2014-10-15 16:54:05 +04:00
|
|
|
cmSystemTools::ChangeDirectory(oldWorkingDirectory);
|
2009-03-31 23:24:50 +04:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2016-05-16 17:34:04 +03:00
|
|
|
" Problems when submitting via CP" << std::endl);
|
2009-03-31 23:24:50 +04:00
|
|
|
ofs << " Problems when submitting via cp" << std::endl;
|
|
|
|
return -1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-10-15 16:54:05 +04:00
|
|
|
cmSystemTools::ChangeDirectory(oldWorkingDirectory);
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
|
|
|
" Submission successful" << std::endl, this->Quiet);
|
2009-03-31 23:24:50 +04:00
|
|
|
ofs << " Submission successful" << std::endl;
|
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-07-06 23:11:38 +04:00
|
|
|
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, " Unknown submission method: \""
|
2016-05-16 17:34:04 +03:00
|
|
|
<< dropMethod << "\"" << std::endl);
|
2005-05-03 16:17:39 +04:00
|
|
|
return -1;
|
2005-03-05 01:11:42 +03:00
|
|
|
}
|
2005-05-03 16:17:39 +04:00
|
|
|
|
|
|
|
std::string cmCTestSubmitHandler::GetSubmitResultsPrefix()
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string buildname =
|
|
|
|
cmCTest::SafeBuildIdField(this->CTest->GetCTestConfiguration("BuildName"));
|
|
|
|
std::string name = this->CTest->GetCTestConfiguration("Site") + "___" +
|
|
|
|
buildname + "___" + this->CTest->GetCurrentTag() + "-" +
|
2006-03-10 23:03:09 +03:00
|
|
|
this->CTest->GetTestModelString() + "___XML___";
|
2005-05-03 16:17:39 +04:00
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2009-01-12 18:38:27 +03:00
|
|
|
void cmCTestSubmitHandler::SelectParts(std::set<cmCTest::Part> const& parts)
|
|
|
|
{
|
|
|
|
// Check whether each part is selected.
|
2016-05-16 17:34:04 +03:00
|
|
|
for (cmCTest::Part p = cmCTest::PartStart; p != cmCTest::PartCount;
|
|
|
|
p = cmCTest::Part(p + 1)) {
|
2009-01-14 17:51:58 +03:00
|
|
|
this->SubmitPart[p] =
|
|
|
|
(std::set<cmCTest::Part>::const_iterator(parts.find(p)) != parts.end());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-01-12 18:38:27 +03:00
|
|
|
}
|
2009-02-03 19:52:54 +03:00
|
|
|
|
|
|
|
void cmCTestSubmitHandler::SelectFiles(cmCTest::SetOfStrings const& files)
|
|
|
|
{
|
2014-11-25 18:33:00 +03:00
|
|
|
this->Files.insert(files.begin(), files.end());
|
2009-02-03 19:52:54 +03:00
|
|
|
}
|