2003-01-07 07:07:24 +03:00
|
|
|
/*=========================================================================
|
|
|
|
|
2003-08-11 20:19:46 +04:00
|
|
|
Program: CMake - Cross-Platform Makefile Generator
|
|
|
|
Module: $RCSfile$
|
|
|
|
Language: C++
|
|
|
|
Date: $Date$
|
|
|
|
Version: $Revision$
|
2003-01-07 07:07:24 +03:00
|
|
|
|
2003-08-11 20:19:46 +04:00
|
|
|
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
|
|
|
|
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
|
2003-01-07 07:07:24 +03:00
|
|
|
|
2006-03-09 19:17:10 +03:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
2003-08-11 20:19:46 +04:00
|
|
|
PURPOSE. See the above copyright notices for more information.
|
2003-01-07 07:07:24 +03:00
|
|
|
|
|
|
|
=========================================================================*/
|
2005-05-03 16:17:39 +04:00
|
|
|
#include "cmCTestSubmitHandler.h"
|
2003-01-07 07:07:24 +03:00
|
|
|
|
|
|
|
#include "cmSystemTools.h"
|
2005-03-05 01:11:42 +03:00
|
|
|
#include "cmVersion.h"
|
2005-05-03 16:17:39 +04:00
|
|
|
#include "cmGeneratedFileStream.h"
|
|
|
|
#include "cmCTest.h"
|
2003-01-07 07:07:24 +03:00
|
|
|
|
2004-06-02 21:39:25 +04:00
|
|
|
#include <cmsys/Process.h>
|
2005-03-05 01:11:42 +03:00
|
|
|
#include <cmsys/Base64.h>
|
2005-05-03 16:17:39 +04:00
|
|
|
|
|
|
|
// For XML-RPC submission
|
2005-03-05 01:11:42 +03:00
|
|
|
#include "xmlrpc.h"
|
|
|
|
#include "xmlrpc_client.h"
|
|
|
|
|
2005-05-03 16:17:39 +04:00
|
|
|
// For curl submission
|
2005-06-24 17:06:26 +04:00
|
|
|
#include "cmcurl/curl/curl.h"
|
2005-03-05 01:11:42 +03:00
|
|
|
|
2003-01-08 06:24:45 +03:00
|
|
|
#include <sys/stat.h>
|
|
|
|
|
2005-06-01 01:32:40 +04:00
|
|
|
typedef std::vector<char> cmCTestSubmitHandlerVectorOfChar;
|
|
|
|
|
|
|
|
static size_t
|
2006-03-09 19:17:10 +03:00
|
|
|
cmCTestSubmitHandlerWriteMemoryCallback(void *ptr, size_t size, size_t nmemb,
|
|
|
|
void *data)
|
2005-06-01 01:32:40 +04:00
|
|
|
{
|
|
|
|
register int realsize = size * nmemb;
|
|
|
|
|
2006-03-09 19:17:10 +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;
|
|
|
|
}
|
|
|
|
|
2005-06-02 22:48:10 +04:00
|
|
|
static size_t
|
2006-03-09 19:17:10 +03:00
|
|
|
cmCTestSubmitHandlerCurlDebugCallback(CURL *, curl_infotype, char *chPtr,
|
|
|
|
size_t size, void *data)
|
2005-06-02 22:48:10 +04:00
|
|
|
{
|
2006-03-09 19:17:10 +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;
|
|
|
|
}
|
|
|
|
|
2005-03-05 01:11:42 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestSubmitHandler::cmCTestSubmitHandler() : HTTPProxy(), FTPProxy()
|
2003-01-15 06:10:47 +03:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
this->HTTPProxy = "";
|
|
|
|
this->HTTPProxyType = 0;
|
|
|
|
this->HTTPProxyAuth = "";
|
2005-06-03 00:47:47 +04:00
|
|
|
|
2006-03-10 23:03:09 +03:00
|
|
|
this->FTPProxy = "";
|
|
|
|
this->FTPProxyType = 0;
|
2003-01-15 06:10:47 +03:00
|
|
|
}
|
|
|
|
|
2005-03-05 01:11:42 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2005-06-17 21:04:56 +04:00
|
|
|
void cmCTestSubmitHandler::Initialize()
|
|
|
|
{
|
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;
|
|
|
|
this->LogFile = 0;
|
2005-06-17 21:04:56 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2006-03-09 19:17:10 +03:00
|
|
|
bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix,
|
2005-06-23 21:04:18 +04:00
|
|
|
const std::set<cmStdString>& files,
|
2006-03-09 19:17:10 +03:00
|
|
|
const cmStdString& remoteprefix,
|
2003-12-16 01:26:00 +03:00
|
|
|
const cmStdString& url)
|
2003-01-07 07:07:24 +03:00
|
|
|
{
|
2003-01-08 06:24:45 +03:00
|
|
|
CURL *curl;
|
|
|
|
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;
|
2005-06-23 21:04:18 +04:00
|
|
|
for ( file = files.begin(); file != files.end(); ++file )
|
2003-01-07 07:07:24 +03:00
|
|
|
{
|
2003-02-07 19:03:44 +03:00
|
|
|
/* get a curl handle */
|
|
|
|
curl = curl_easy_init();
|
2006-03-09 19:17:10 +03:00
|
|
|
if(curl)
|
2003-01-15 06:10:47 +03:00
|
|
|
{
|
2003-02-07 19:03:44 +03:00
|
|
|
// Using proxy
|
2006-03-10 23:03:09 +03:00
|
|
|
if ( this->FTPProxyType > 0 )
|
2003-01-15 06:10:47 +03:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
curl_easy_setopt(curl, CURLOPT_PROXY, this->FTPProxy.c_str());
|
|
|
|
switch (this->FTPProxyType)
|
2003-02-07 19:03:44 +03:00
|
|
|
{
|
2003-08-11 20:19:46 +04:00
|
|
|
case 2:
|
|
|
|
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
|
|
|
|
break;
|
|
|
|
default:
|
2006-03-09 19:17:10 +03:00
|
|
|
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
|
2003-02-07 19:03:44 +03:00
|
|
|
}
|
2003-01-15 06:10:47 +03:00
|
|
|
}
|
2003-08-11 20:19:46 +04:00
|
|
|
|
2003-02-07 19:03:44 +03:00
|
|
|
// enable uploading
|
2004-10-05 18:13:51 +04:00
|
|
|
::curl_easy_setopt(curl, CURLOPT_UPLOAD, 1) ;
|
2003-08-11 20:19:46 +04:00
|
|
|
|
2005-07-18 20:53:48 +04:00
|
|
|
cmStdString local_file = *file;
|
|
|
|
if ( !cmSystemTools::FileExists(local_file.c_str()) )
|
|
|
|
{
|
|
|
|
local_file = localprefix + "/" + *file;
|
|
|
|
}
|
2006-03-09 19:17:10 +03:00
|
|
|
cmStdString upload_as
|
|
|
|
= url + "/" + remoteprefix + cmSystemTools::GetFilenameName(*file);
|
2003-08-11 20:19:46 +04:00
|
|
|
|
2003-01-08 06:24:45 +03:00
|
|
|
struct stat st;
|
|
|
|
if ( ::stat(local_file.c_str(), &st) )
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot find file: "
|
2006-03-09 19:17:10 +03:00
|
|
|
<< local_file.c_str() << 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
ftpfile = ::fopen(local_file.c_str(), "rb");
|
2006-03-10 23:03:09 +03:00
|
|
|
*this->LogFile << "\tUpload file: " << local_file.c_str() << " to "
|
2004-04-01 23:11:17 +04:00
|
|
|
<< upload_as.c_str() << std::endl;
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Upload file: "
|
2006-03-09 19:17:10 +03:00
|
|
|
<< local_file.c_str() << " to "
|
2005-06-01 01:32:40 +04:00
|
|
|
<< upload_as.c_str() << std::endl);
|
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
|
|
|
|
::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)
|
2006-03-09 19:17:10 +03:00
|
|
|
::curl_easy_setopt(curl, CURLOPT_INFILESIZE,
|
|
|
|
static_cast<long>(st.st_size));
|
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,
|
|
|
|
cmCTestSubmitHandlerWriteMemoryCallback);
|
|
|
|
::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION,
|
|
|
|
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;
|
2005-06-01 01:32:40 +04:00
|
|
|
::curl_easy_setopt(curl, CURLOPT_FILE, (void *)&chunk);
|
2005-06-02 22:48:10 +04:00
|
|
|
::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
|
|
|
|
2006-03-01 20:50:03 +03:00
|
|
|
if ( chunk.size() > 0 )
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, DEBUG, "CURL output: ["
|
2006-03-09 19:17:10 +03:00
|
|
|
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
|
|
|
|
<< std::endl);
|
2006-03-01 20:50:03 +03:00
|
|
|
}
|
|
|
|
if ( chunkDebug.size() > 0 )
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, DEBUG, "CURL debug output: ["
|
2006-03-09 19:17:10 +03:00
|
|
|
<< cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]"
|
|
|
|
<< std::endl);
|
2006-03-01 20:50:03 +03:00
|
|
|
}
|
2005-06-01 01:32:40 +04:00
|
|
|
|
2003-01-08 06:24:45 +03:00
|
|
|
fclose(ftpfile);
|
|
|
|
if ( res )
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
|
|
|
" Error when uploading file: "
|
2006-03-09 19:17:10 +03:00
|
|
|
<< local_file.c_str() << std::endl);
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, " Error message was: "
|
2006-03-09 19:17:10 +03:00
|
|
|
<< error_buffer << std::endl);
|
2006-03-10 23:03:09 +03:00
|
|
|
*this->LogFile << " Error when uploading file: "
|
|
|
|
<< local_file.c_str()
|
2006-03-09 19:17:10 +03:00
|
|
|
<< std::endl
|
2005-06-16 21:18:21 +04:00
|
|
|
<< " Error message was: " << error_buffer << std::endl
|
2006-03-09 19:17:10 +03:00
|
|
|
<< " Curl output was: "
|
|
|
|
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl;
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: ["
|
2006-03-09 19:17:10 +03:00
|
|
|
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
|
|
|
|
<< 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;
|
|
|
|
}
|
2003-02-07 19:03:44 +03:00
|
|
|
// always cleanup
|
|
|
|
::curl_easy_cleanup(curl);
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Uploaded: " + local_file
|
2006-03-09 19:17:10 +03:00
|
|
|
<< std::endl);
|
2003-01-08 06:24:45 +03:00
|
|
|
}
|
2003-01-07 07:07:24 +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
|
|
|
}
|
|
|
|
|
2005-03-05 01:11:42 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2003-01-15 06:10:47 +03:00
|
|
|
// Uploading files is simpler
|
2006-03-09 19:17:10 +03:00
|
|
|
bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix,
|
2005-06-23 21:04:18 +04:00
|
|
|
const std::set<cmStdString>& files,
|
2006-03-09 19:17:10 +03:00
|
|
|
const cmStdString& remoteprefix,
|
2003-12-16 01:26:00 +03:00
|
|
|
const cmStdString& url)
|
2003-01-15 06:10:47 +03:00
|
|
|
{
|
|
|
|
CURL *curl;
|
|
|
|
CURLcode res;
|
|
|
|
FILE* ftpfile;
|
2004-04-01 23:11:17 +04:00
|
|
|
char error_buffer[1024];
|
2003-01-15 06:10:47 +03:00
|
|
|
|
|
|
|
/* In windows, this will init the winsock stuff */
|
|
|
|
::curl_global_init(CURL_GLOBAL_ALL);
|
|
|
|
|
2005-06-23 21:04:18 +04:00
|
|
|
cmStdString::size_type kk;
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTest::SetOfStrings::const_iterator file;
|
2005-06-23 21:04:18 +04:00
|
|
|
for ( file = files.begin(); file != files.end(); ++file )
|
2003-01-15 06:10:47 +03:00
|
|
|
{
|
2003-01-16 20:30:02 +03:00
|
|
|
/* get a curl handle */
|
|
|
|
curl = curl_easy_init();
|
2006-03-09 19:17:10 +03:00
|
|
|
if(curl)
|
2003-01-15 06:10:47 +03:00
|
|
|
{
|
2003-01-16 20:30:02 +03:00
|
|
|
|
|
|
|
// Using proxy
|
2006-03-10 23:03:09 +03:00
|
|
|
if ( this->HTTPProxyType > 0 )
|
2003-01-15 06:10:47 +03:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
curl_easy_setopt(curl, CURLOPT_PROXY, this->HTTPProxy.c_str());
|
|
|
|
switch (this->HTTPProxyType)
|
2003-01-16 20:30:02 +03:00
|
|
|
{
|
2003-08-11 20:19:46 +04:00
|
|
|
case 2:
|
|
|
|
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
|
|
|
|
break;
|
|
|
|
default:
|
2004-11-24 17:25:32 +03:00
|
|
|
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
|
2006-03-10 23:03:09 +03:00
|
|
|
if (this->HTTPProxyAuth.size() > 0)
|
2004-11-24 17:25:32 +03:00
|
|
|
{
|
|
|
|
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD,
|
2006-03-10 23:03:09 +03:00
|
|
|
this->HTTPProxyAuth.c_str());
|
2004-11-24 17:25:32 +03:00
|
|
|
}
|
2003-01-16 20:30:02 +03:00
|
|
|
}
|
2003-01-15 06:10:47 +03:00
|
|
|
}
|
|
|
|
|
2003-01-16 20:30:02 +03:00
|
|
|
/* enable uploading */
|
2004-10-05 18:13:51 +04:00
|
|
|
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1) ;
|
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
|
|
|
|
2005-07-18 20:53:48 +04:00
|
|
|
cmStdString local_file = *file;
|
|
|
|
if ( !cmSystemTools::FileExists(local_file.c_str()) )
|
|
|
|
{
|
|
|
|
local_file = localprefix + "/" + *file;
|
|
|
|
}
|
2006-03-09 19:17:10 +03:00
|
|
|
cmStdString remote_file
|
|
|
|
= remoteprefix + cmSystemTools::GetFilenameName(*file);
|
2004-04-01 23:11:17 +04:00
|
|
|
|
2006-03-10 23:03:09 +03:00
|
|
|
*this->LogFile << "\tUpload file: " << local_file.c_str() << " to "
|
2004-04-01 23:11:17 +04:00
|
|
|
<< remote_file.c_str() << std::endl;
|
|
|
|
|
2003-12-16 01:26:00 +03:00
|
|
|
cmStdString ofile = "";
|
2003-01-16 20:30:02 +03:00
|
|
|
for ( kk = 0; kk < remote_file.size(); kk ++ )
|
|
|
|
{
|
|
|
|
char c = remote_file[kk];
|
2005-06-24 17:41:01 +04:00
|
|
|
char hexCh[4] = { 0, 0, 0, 0 };
|
|
|
|
hexCh[0] = c;
|
2003-01-16 20:30:02 +03:00
|
|
|
switch ( c )
|
|
|
|
{
|
2003-08-11 20:19:46 +04:00
|
|
|
case '+':
|
|
|
|
case '?':
|
|
|
|
case '/':
|
|
|
|
case '\\':
|
|
|
|
case '&':
|
|
|
|
case ' ':
|
|
|
|
case '=':
|
|
|
|
case '%':
|
2005-06-24 17:41:01 +04:00
|
|
|
sprintf(hexCh, "%%%02X", (int)c);
|
|
|
|
ofile.append(hexCh);
|
2003-08-11 20:19:46 +04:00
|
|
|
break;
|
2006-03-09 19:17:10 +03:00
|
|
|
default:
|
2005-06-24 17:41:01 +04:00
|
|
|
ofile.append(hexCh);
|
2003-01-16 20:30:02 +03:00
|
|
|
}
|
|
|
|
}
|
2006-03-09 19:17:10 +03:00
|
|
|
cmStdString upload_as
|
|
|
|
= url + ((url.find("?",0) == cmStdString::npos) ? "?" : "&")
|
2004-07-27 16:49:04 +04:00
|
|
|
+ "FileName=" + ofile;
|
2003-01-16 20:30:02 +03:00
|
|
|
|
|
|
|
struct stat st;
|
|
|
|
if ( ::stat(local_file.c_str(), &st) )
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot find file: "
|
2006-03-09 19:17:10 +03:00
|
|
|
<< local_file.c_str() << 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-16 20:30:02 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ftpfile = ::fopen(local_file.c_str(), "rb");
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Upload file: "
|
2006-03-09 19:17:10 +03:00
|
|
|
<< local_file.c_str() << " to "
|
2005-06-01 01:32:40 +04:00
|
|
|
<< upload_as.c_str() << " Size: " << st.st_size << std::endl);
|
2003-01-16 20:30:02 +03:00
|
|
|
|
2003-08-11 20:19:46 +04:00
|
|
|
|
2003-01-15 06:10:47 +03:00
|
|
|
// specify target
|
|
|
|
::curl_easy_setopt(curl,CURLOPT_URL, upload_as.c_str());
|
|
|
|
|
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)
|
2006-03-09 19:17:10 +03:00
|
|
|
::curl_easy_setopt(curl, CURLOPT_INFILESIZE,
|
|
|
|
static_cast<long>(st.st_size));
|
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,
|
|
|
|
cmCTestSubmitHandlerWriteMemoryCallback);
|
|
|
|
::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION,
|
|
|
|
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;
|
2005-06-01 01:32:40 +04:00
|
|
|
::curl_easy_setopt(curl, CURLOPT_FILE, (void *)&chunk);
|
2005-06-02 22:48:10 +04:00
|
|
|
::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);
|
|
|
|
|
2006-03-01 20:50:03 +03:00
|
|
|
if ( chunk.size() > 0 )
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, DEBUG, "CURL output: ["
|
2006-03-09 19:17:10 +03:00
|
|
|
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
|
|
|
|
<< std::endl);
|
2006-03-01 20:50:03 +03:00
|
|
|
}
|
|
|
|
if ( chunkDebug.size() > 0 )
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, DEBUG, "CURL debug output: ["
|
2006-03-09 19:17:10 +03:00
|
|
|
<< cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]"
|
|
|
|
<< std::endl);
|
2006-03-01 20:50:03 +03:00
|
|
|
}
|
2005-06-01 01:32:40 +04:00
|
|
|
|
2003-01-16 20:30:02 +03:00
|
|
|
fclose(ftpfile);
|
2003-01-15 06:10:47 +03:00
|
|
|
if ( res )
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
|
|
|
" Error when uploading file: "
|
2006-03-09 19:17:10 +03:00
|
|
|
<< local_file.c_str() << std::endl);
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, " Error message was: "
|
2006-03-09 19:17:10 +03:00
|
|
|
<< error_buffer << std::endl);
|
2006-03-10 23:03:09 +03:00
|
|
|
*this->LogFile << " Error when uploading file: "
|
|
|
|
<< local_file.c_str()
|
2006-03-09 19:17:10 +03:00
|
|
|
<< std::endl
|
2005-06-16 21:18:21 +04:00
|
|
|
<< " Error message was: " << error_buffer << std::endl
|
2006-03-09 19:17:10 +03:00
|
|
|
<< " Curl output was: "
|
|
|
|
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl;
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: ["
|
2006-03-09 19:17:10 +03:00
|
|
|
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
|
|
|
|
<< std::endl);
|
2003-01-15 06:10:47 +03:00
|
|
|
::curl_easy_cleanup(curl);
|
2006-03-09 19:17:10 +03:00
|
|
|
::curl_global_cleanup();
|
2003-01-15 06:10:47 +03:00
|
|
|
return false;
|
|
|
|
}
|
2003-01-16 20:30:02 +03:00
|
|
|
// always cleanup
|
|
|
|
::curl_easy_cleanup(curl);
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Uploaded: " + local_file
|
2006-03-09 19:17:10 +03:00
|
|
|
<< std::endl);
|
2003-01-15 06:10:47 +03:00
|
|
|
}
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2005-03-05 01:11:42 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2006-03-09 19:17:10 +03:00
|
|
|
bool cmCTestSubmitHandler::TriggerUsingHTTP(
|
|
|
|
const std::set<cmStdString>& files,
|
|
|
|
const cmStdString& remoteprefix,
|
2003-12-16 01:26:00 +03:00
|
|
|
const cmStdString& url)
|
2003-01-12 05:47:35 +03:00
|
|
|
{
|
|
|
|
CURL *curl;
|
2004-04-01 23:11:17 +04:00
|
|
|
char error_buffer[1024];
|
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;
|
2005-06-23 21:04:18 +04:00
|
|
|
for ( file = files.begin(); file != files.end(); ++file )
|
2003-01-12 05:47:35 +03:00
|
|
|
{
|
2003-01-16 21:02:11 +03:00
|
|
|
/* get a curl handle */
|
|
|
|
curl = curl_easy_init();
|
2006-03-09 19:17:10 +03:00
|
|
|
if(curl)
|
2003-01-16 20:45:24 +03:00
|
|
|
{
|
2003-01-16 21:02:11 +03:00
|
|
|
// Using proxy
|
2006-03-10 23:03:09 +03:00
|
|
|
if ( this->HTTPProxyType > 0 )
|
2003-01-16 20:45:24 +03:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
curl_easy_setopt(curl, CURLOPT_PROXY, this->HTTPProxy.c_str());
|
|
|
|
switch (this->HTTPProxyType)
|
2003-01-16 21:02:11 +03:00
|
|
|
{
|
2003-08-11 20:19:46 +04:00
|
|
|
case 2:
|
|
|
|
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
|
|
|
|
break;
|
|
|
|
default:
|
2006-03-09 19:17:10 +03:00
|
|
|
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
|
2006-03-10 23:03:09 +03:00
|
|
|
if (this->HTTPProxyAuth.size() > 0)
|
2004-11-24 17:25:32 +03:00
|
|
|
{
|
|
|
|
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD,
|
2006-03-10 23:03:09 +03:00
|
|
|
this->HTTPProxyAuth.c_str());
|
2004-11-24 17:25:32 +03:00
|
|
|
}
|
2003-01-16 21:02:11 +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,
|
|
|
|
cmCTestSubmitHandlerWriteMemoryCallback);
|
|
|
|
::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION,
|
|
|
|
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;
|
2005-06-01 01:32:40 +04:00
|
|
|
::curl_easy_setopt(curl, CURLOPT_FILE, (void *)&chunk);
|
2005-06-02 22:48:10 +04:00
|
|
|
::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void *)&chunkDebug);
|
2005-06-01 01:32:40 +04:00
|
|
|
|
2006-03-09 19:17:10 +03:00
|
|
|
cmStdString rfile
|
|
|
|
= remoteprefix + cmSystemTools::GetFilenameName(*file);
|
2003-12-16 01:26:00 +03:00
|
|
|
cmStdString ofile = "";
|
2005-06-23 21:04:18 +04:00
|
|
|
cmStdString::iterator kk;
|
|
|
|
for ( kk = rfile.begin(); kk < rfile.end(); ++ kk)
|
2003-01-12 05:47:35 +03:00
|
|
|
{
|
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;
|
2003-01-12 05:47:35 +03:00
|
|
|
switch ( c )
|
|
|
|
{
|
2003-08-11 20:19:46 +04:00
|
|
|
case '+':
|
|
|
|
case '?':
|
|
|
|
case '/':
|
|
|
|
case '\\':
|
|
|
|
case '&':
|
|
|
|
case ' ':
|
|
|
|
case '=':
|
|
|
|
case '%':
|
2005-06-24 17:41:01 +04:00
|
|
|
sprintf(hexCh, "%%%02X", (int)c);
|
|
|
|
ofile.append(hexCh);
|
2003-08-11 20:19:46 +04:00
|
|
|
break;
|
2006-03-09 19:17:10 +03:00
|
|
|
default:
|
2005-06-24 17:41:01 +04:00
|
|
|
ofile.append(hexCh);
|
2003-01-12 05:47:35 +03:00
|
|
|
}
|
|
|
|
}
|
2006-03-09 19:17:10 +03:00
|
|
|
cmStdString turl
|
|
|
|
= url + ((url.find("?",0) == cmStdString::npos) ? "?" : "&")
|
2004-07-27 16:49:04 +04:00
|
|
|
+ "xmlfile=" + ofile;
|
2006-03-10 23:03:09 +03:00
|
|
|
*this->LogFile << "Trigger url: " << turl.c_str() << std::endl;
|
|
|
|
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Trigger url: "
|
2006-03-09 19:17:10 +03:00
|
|
|
<< turl.c_str() << std::endl);
|
2003-01-12 05:47:35 +03:00
|
|
|
curl_easy_setopt(curl, CURLOPT_URL, turl.c_str());
|
2003-05-28 17:21:37 +04:00
|
|
|
if ( curl_easy_perform(curl) )
|
2003-01-12 05:47:35 +03:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, " Error when triggering: "
|
2006-03-09 19:17:10 +03:00
|
|
|
<< turl.c_str() << std::endl);
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, " Error message was: "
|
2006-03-09 19:17:10 +03:00
|
|
|
<< error_buffer << std::endl);
|
2006-03-10 23:03:09 +03:00
|
|
|
*this->LogFile << "\tTrigerring failed with error: " << error_buffer
|
2006-03-09 19:17:10 +03:00
|
|
|
<< std::endl
|
2005-06-16 21:18:21 +04:00
|
|
|
<< " Error message was: " << error_buffer << std::endl
|
2006-03-09 19:17:10 +03:00
|
|
|
<< " Curl output was: "
|
|
|
|
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl;
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: ["
|
2006-03-09 19:17:10 +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;
|
|
|
|
}
|
2005-06-01 01:32:40 +04:00
|
|
|
|
2006-03-01 20:50:03 +03:00
|
|
|
if ( chunk.size() > 0 )
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, DEBUG, "CURL output: ["
|
2006-03-09 19:17:10 +03:00
|
|
|
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
|
|
|
|
<< std::endl);
|
2006-03-01 20:50:03 +03:00
|
|
|
}
|
|
|
|
if ( chunkDebug.size() > 0 )
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, DEBUG, "CURL debug output: ["
|
2006-03-09 19:17:10 +03:00
|
|
|
<< cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size())
|
|
|
|
<< "]" << std::endl);
|
2006-03-01 20:50:03 +03:00
|
|
|
}
|
2005-06-01 01:32:40 +04:00
|
|
|
|
2003-01-16 21:02:11 +03:00
|
|
|
// always cleanup
|
|
|
|
::curl_easy_cleanup(curl);
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl);
|
2003-01-12 05:47:35 +03:00
|
|
|
}
|
|
|
|
}
|
2006-03-09 19:17:10 +03:00
|
|
|
::curl_global_cleanup();
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Dart server triggered..."
|
2006-03-09 19:17:10 +03:00
|
|
|
<< std::endl);
|
2003-01-12 05:47:35 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2005-03-05 01:11:42 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2005-05-03 16:17:39 +04:00
|
|
|
bool cmCTestSubmitHandler::SubmitUsingSCP(
|
2006-03-09 19:17:10 +03:00
|
|
|
const cmStdString& scp_command,
|
|
|
|
const cmStdString& localprefix,
|
2005-06-23 21:04:18 +04:00
|
|
|
const std::set<cmStdString>& files,
|
2006-03-09 19:17:10 +03:00
|
|
|
const cmStdString& remoteprefix,
|
2004-06-02 21:39:25 +04:00
|
|
|
const cmStdString& url)
|
2003-01-07 07:07:24 +03:00
|
|
|
{
|
2004-06-02 21:39:25 +04:00
|
|
|
if ( !scp_command.size() || !localprefix.size() ||
|
|
|
|
!files.size() || !remoteprefix.size() || !url.size() )
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
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
|
|
|
|
argv.push_back(0);
|
|
|
|
|
|
|
|
cmsysProcess* cp = cmsysProcess_New();
|
|
|
|
cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
|
|
|
|
//cmsysProcess_SetTimeout(cp, timeout);
|
|
|
|
|
|
|
|
int problems = 0;
|
|
|
|
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTest::SetOfStrings::const_iterator file;
|
2005-06-23 21:04:18 +04:00
|
|
|
for ( file = files.begin(); file != files.end(); ++file )
|
2004-06-02 21:39:25 +04:00
|
|
|
{
|
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();
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Execute \"" << argv[0]
|
2006-03-09 19:17:10 +03:00
|
|
|
<< "\" \"" << argv[1] << "\" \""
|
2005-06-01 01:32:40 +04:00
|
|
|
<< argv[2] << "\"" << std::endl);
|
2006-03-10 23:03:09 +03:00
|
|
|
*this->LogFile << "Execute \"" << argv[0] << "\" \"" << argv[1] << "\" \""
|
2004-06-02 21:39:25 +04: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
|
|
|
|
2004-06-02 21:39:25 +04:00
|
|
|
while(cmsysProcess_WaitForData(cp, &data, &length, 0))
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
2006-03-09 19:17:10 +03:00
|
|
|
cmCTestLogWrite(data, length));
|
2004-06-02 21:39:25 +04:00
|
|
|
}
|
2005-07-06 23:11:38 +04:00
|
|
|
|
2004-06-02 21:39:25 +04:00
|
|
|
cmsysProcess_WaitForExit(cp, 0);
|
2005-07-06 23:11:38 +04:00
|
|
|
|
2004-06-02 21:39:25 +04:00
|
|
|
int result = cmsysProcess_GetState(cp);
|
|
|
|
|
|
|
|
if(result == cmsysProcess_State_Exited)
|
|
|
|
{
|
|
|
|
retVal = cmsysProcess_GetExitValue(cp);
|
|
|
|
if ( retVal != 0 )
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "\tSCP returned: "
|
2006-03-09 19:17:10 +03:00
|
|
|
<< retVal << std::endl);
|
2006-03-10 23:03:09 +03:00
|
|
|
*this->LogFile << "\tSCP returned: " << retVal << std::endl;
|
2004-06-02 21:39:25 +04:00
|
|
|
problems ++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(result == cmsysProcess_State_Exception)
|
|
|
|
{
|
|
|
|
retVal = cmsysProcess_GetExitException(cp);
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, "\tThere was an exception: "
|
2006-03-09 19:17:10 +03:00
|
|
|
<< retVal << std::endl);
|
2006-03-10 23:03:09 +03:00
|
|
|
*this->LogFile << "\tThere was an exception: " << retVal << std::endl;
|
2004-06-02 21:39:25 +04: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"
|
2006-03-09 19:17:10 +03:00
|
|
|
<< std::endl);
|
2006-03-10 23:03:09 +03:00
|
|
|
*this->LogFile << "\tThere was a timeout" << std::endl;
|
2004-06-02 21:39:25 +04:00
|
|
|
problems ++;
|
2006-03-09 19:17:10 +03:00
|
|
|
}
|
2004-06-02 21:39:25 +04:00
|
|
|
else if(result == cmsysProcess_State_Error)
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, "\tError executing SCP: "
|
2005-06-01 01:32:40 +04:00
|
|
|
<< cmsysProcess_GetErrorString(cp) << std::endl);
|
2006-03-10 23:03:09 +03:00
|
|
|
*this->LogFile << "\tError executing SCP: "
|
2004-06-02 21:39:25 +04:00
|
|
|
<< cmsysProcess_GetErrorString(cp) << std::endl;
|
|
|
|
problems ++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cmsysProcess_Delete(cp);
|
|
|
|
if ( problems )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2003-01-07 07:07:24 +03:00
|
|
|
}
|
2005-03-05 01:11:42 +03:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2006-03-09 19:17:10 +03:00
|
|
|
bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix,
|
2005-06-23 21:04:18 +04:00
|
|
|
const std::set<cmStdString>& files,
|
2006-03-09 19:17:10 +03:00
|
|
|
const cmStdString& remoteprefix,
|
2005-03-05 01:11:42 +03:00
|
|
|
const cmStdString& url)
|
|
|
|
{
|
|
|
|
xmlrpc_env env;
|
|
|
|
std::string ctestVersion = cmVersion::GetCMakeVersion();
|
2005-05-27 02:15:41 +04:00
|
|
|
|
|
|
|
cmStdString realURL = url + "/" + remoteprefix + "/Command/";
|
2005-03-05 01:11:42 +03:00
|
|
|
|
|
|
|
/* Start up our XML-RPC client library. */
|
|
|
|
xmlrpc_client_init(XMLRPC_CLIENT_NO_FLAGS, "CTest", ctestVersion.c_str());
|
|
|
|
|
|
|
|
/* Initialize our error-handling environment. */
|
|
|
|
xmlrpc_env_init(&env);
|
|
|
|
|
|
|
|
/* Call the famous server at UserLand. */
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Submitting to: "
|
2006-03-09 19:17:10 +03:00
|
|
|
<< realURL.c_str() << " (" << remoteprefix.c_str() << ")" << std::endl);
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTest::SetOfStrings::const_iterator file;
|
2005-06-23 21:04:18 +04:00
|
|
|
for ( file = files.begin(); file != files.end(); ++file )
|
2005-03-05 01:11:42 +03:00
|
|
|
{
|
2005-03-06 16:51:08 +03:00
|
|
|
xmlrpc_value *result;
|
|
|
|
|
2005-07-18 20:53:48 +04:00
|
|
|
cmStdString local_file = *file;
|
|
|
|
if ( !cmSystemTools::FileExists(local_file.c_str()) )
|
|
|
|
{
|
|
|
|
local_file = localprefix + "/" + *file;
|
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Submit file: "
|
2006-03-09 19:17:10 +03:00
|
|
|
<< local_file.c_str() << std::endl);
|
2005-03-05 01:11:42 +03:00
|
|
|
struct stat st;
|
|
|
|
if ( ::stat(local_file.c_str(), &st) )
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot find file: "
|
2006-03-09 19:17:10 +03:00
|
|
|
<< local_file.c_str() << std::endl);
|
2005-03-05 01:11:42 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t fileSize = st.st_size;
|
2005-06-02 17:35:51 +04:00
|
|
|
FILE* fp = fopen(local_file.c_str(), "rb");
|
2005-03-05 01:11:42 +03:00
|
|
|
if ( !fp )
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot open file: "
|
2006-03-09 19:17:10 +03:00
|
|
|
<< local_file.c_str() << std::endl);
|
2005-03-05 01:11:42 +03:00
|
|
|
return false;
|
|
|
|
}
|
2005-03-06 16:51:08 +03:00
|
|
|
|
2005-03-05 01:11:42 +03:00
|
|
|
unsigned char *fileBuffer = new unsigned char[fileSize];
|
|
|
|
if ( fread(fileBuffer, 1, fileSize, fp) != fileSize )
|
|
|
|
{
|
|
|
|
delete [] fileBuffer;
|
|
|
|
fclose(fp);
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot read file: "
|
2006-03-09 19:17:10 +03:00
|
|
|
<< local_file.c_str() << std::endl);
|
2005-03-06 16:51:08 +03:00
|
|
|
return false;
|
2005-03-05 01:11:42 +03:00
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
|
2005-05-27 02:15:41 +04:00
|
|
|
std::string remoteCommand = "Submit.put";
|
|
|
|
result = xmlrpc_client_call(&env, realURL.c_str(),
|
2005-03-05 01:11:42 +03:00
|
|
|
remoteCommand.c_str(),
|
2005-03-10 02:06:26 +03:00
|
|
|
"(6)", fileBuffer, (xmlrpc_int32)fileSize );
|
2005-03-05 01:11:42 +03:00
|
|
|
|
|
|
|
delete [] fileBuffer;
|
|
|
|
|
|
|
|
if ( env.fault_occurred )
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, " Submission problem: "
|
2006-03-09 19:17:10 +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;
|
2005-03-05 01:11:42 +03:00
|
|
|
}
|
|
|
|
|
2005-03-06 16:51:08 +03:00
|
|
|
/* Dispose of our result value. */
|
|
|
|
xmlrpc_DECREF(result);
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
int cmCTestSubmitHandler::ProcessHandler()
|
|
|
|
{
|
2006-03-09 19:17:10 +03:00
|
|
|
const std::string &buildDirectory
|
2006-03-10 23:03:09 +03:00
|
|
|
= this->CTest->GetCTestConfiguration("BuildDirectory");
|
2005-05-03 16:17:39 +04:00
|
|
|
if ( buildDirectory.size() == 0 )
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2006-03-09 19:17:10 +03:00
|
|
|
"Cannot find BuildDirectory key in the DartConfiguration.tcl"
|
|
|
|
<< std::endl);
|
2005-05-03 16:17:39 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2005-06-03 00:47:47 +04:00
|
|
|
if ( getenv("HTTP_PROXY") )
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
this->HTTPProxyType = 1;
|
|
|
|
this->HTTPProxy = getenv("HTTP_PROXY");
|
2005-06-03 00:47:47 +04:00
|
|
|
if ( getenv("HTTP_PROXY_PORT") )
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
this->HTTPProxy += ":";
|
|
|
|
this->HTTPProxy += getenv("HTTP_PROXY_PORT");
|
2005-06-03 00:47:47 +04:00
|
|
|
}
|
|
|
|
if ( getenv("HTTP_PROXY_TYPE") )
|
|
|
|
{
|
|
|
|
cmStdString type = getenv("HTTP_PROXY_TYPE");
|
|
|
|
// HTTP/SOCKS4/SOCKS5
|
|
|
|
if ( type == "HTTP" )
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
this->HTTPProxyType = 1;
|
2005-06-03 00:47:47 +04:00
|
|
|
}
|
|
|
|
else if ( type == "SOCKS4" )
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
this->HTTPProxyType = 2;
|
2005-06-03 00:47:47 +04:00
|
|
|
}
|
|
|
|
else if ( type == "SOCKS5" )
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
this->HTTPProxyType = 3;
|
2005-06-03 00:47:47 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( getenv("HTTP_PROXY_USER") )
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
this->HTTPProxyAuth = getenv("HTTP_PROXY_USER");
|
2005-06-03 00:47:47 +04: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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( getenv("FTP_PROXY") )
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
this->FTPProxyType = 1;
|
|
|
|
this->FTPProxy = getenv("FTP_PROXY");
|
2005-06-03 00:47:47 +04:00
|
|
|
if ( getenv("FTP_PROXY_PORT") )
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
this->FTPProxy += ":";
|
|
|
|
this->FTPProxy += getenv("FTP_PROXY_PORT");
|
2005-06-03 00:47:47 +04:00
|
|
|
}
|
|
|
|
if ( getenv("FTP_PROXY_TYPE") )
|
|
|
|
{
|
|
|
|
cmStdString type = getenv("FTP_PROXY_TYPE");
|
|
|
|
// HTTP/SOCKS4/SOCKS5
|
|
|
|
if ( type == "HTTP" )
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
this->FTPProxyType = 1;
|
2005-06-03 00:47:47 +04:00
|
|
|
}
|
|
|
|
else if ( type == "SOCKS4" )
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
this->FTPProxyType = 2;
|
2005-06-03 00:47:47 +04:00
|
|
|
}
|
|
|
|
else if ( type == "SOCKS5" )
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
this->FTPProxyType = 3;
|
2005-06-03 00:47:47 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-10 23:03:09 +03:00
|
|
|
if ( this->HTTPProxy.size() > 0 )
|
2005-06-03 00:47:47 +04:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Use HTTP Proxy: "
|
|
|
|
<< this->HTTPProxy << std::endl);
|
2005-06-03 00:47:47 +04:00
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
if ( this->FTPProxy.size() > 0 )
|
2005-06-03 00:47:47 +04:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Use FTP Proxy: "
|
|
|
|
<< this->FTPProxy << std::endl);
|
2005-06-03 00:47:47 +04:00
|
|
|
}
|
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
|
|
|
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTest::SetOfStrings files;
|
2005-05-03 16:17:39 +04:00
|
|
|
std::string prefix = this->GetSubmitResultsPrefix();
|
|
|
|
// TODO:
|
|
|
|
// Check if test is enabled
|
2006-03-10 23:03:09 +03:00
|
|
|
this->CTest->AddIfExists(files, "Update.xml");
|
|
|
|
this->CTest->AddIfExists(files, "Configure.xml");
|
|
|
|
this->CTest->AddIfExists(files, "Build.xml");
|
|
|
|
this->CTest->AddIfExists(files, "Test.xml");
|
|
|
|
if ( this->CTest->AddIfExists(files, "Coverage.xml") )
|
2005-05-03 16:17:39 +04:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTest::VectorOfStrings gfiles;
|
2006-03-09 19:17:10 +03:00
|
|
|
std::string gpath
|
2006-03-10 23:03:09 +03:00
|
|
|
= buildDirectory + "/Testing/" + this->CTest->GetCurrentTag();
|
2005-05-03 16:17:39 +04:00
|
|
|
std::string::size_type glen = gpath.size() + 1;
|
|
|
|
gpath = gpath + "/CoverageLog*";
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, DEBUG, "Globbing for: " << gpath.c_str()
|
2006-03-09 19:17:10 +03:00
|
|
|
<< std::endl);
|
2005-05-03 16:17:39 +04:00
|
|
|
if ( cmSystemTools::SimpleGlob(gpath, gfiles, 1) )
|
|
|
|
{
|
|
|
|
size_t cc;
|
|
|
|
for ( cc = 0; cc < gfiles.size(); cc ++ )
|
|
|
|
{
|
|
|
|
gfiles[cc] = gfiles[cc].substr(glen);
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, DEBUG, "Glob file: " << gfiles[cc].c_str()
|
2006-03-09 19:17:10 +03:00
|
|
|
<< std::endl);
|
2005-06-23 21:04:18 +04:00
|
|
|
files.insert(gfiles[cc]);
|
2005-05-03 16:17:39 +04: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
|
|
|
}
|
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
this->CTest->AddIfExists(files, "DynamicAnalysis.xml");
|
|
|
|
this->CTest->AddIfExists(files, "Purify.xml");
|
|
|
|
this->CTest->AddIfExists(files, "Notes.xml");
|
2005-05-03 16:17:39 +04:00
|
|
|
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTest::SetOfStrings::iterator it;
|
|
|
|
for ( it = this->CTest->GetSubmitFiles()->begin();
|
|
|
|
it != this->CTest->GetSubmitFiles()->end();
|
2005-06-23 21:04:18 +04:00
|
|
|
++ it )
|
|
|
|
{
|
|
|
|
files.insert(files.end(), *it);
|
|
|
|
}
|
|
|
|
|
2005-05-03 16:17:39 +04:00
|
|
|
if ( ofs )
|
|
|
|
{
|
|
|
|
ofs << "Upload files:" << std::endl;
|
|
|
|
int cnt = 0;
|
|
|
|
for ( it = files.begin(); it != files.end(); ++ it )
|
|
|
|
{
|
|
|
|
ofs << cnt << "\t" << it->c_str() << std::endl;
|
|
|
|
cnt ++;
|
|
|
|
}
|
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, "Submit files (using "
|
|
|
|
<< this->CTest->GetCTestConfiguration("DropMethod") << ")"
|
2005-06-01 01:32:40 +04:00
|
|
|
<< std::endl);
|
2005-05-03 16:17:39 +04:00
|
|
|
this->SetLogFile(&ofs);
|
2006-03-10 23:03:09 +03:00
|
|
|
if ( this->CTest->GetCTestConfiguration("DropMethod") == "" ||
|
|
|
|
this->CTest->GetCTestConfiguration("DropMethod") == "ftp" )
|
2005-05-03 16:17:39 +04:00
|
|
|
{
|
|
|
|
ofs << "Using drop method: FTP" << std::endl;
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Using FTP submit method"
|
2006-03-09 19:17:10 +03:00
|
|
|
<< std::endl
|
2005-06-16 21:18:21 +04:00
|
|
|
<< " Drop site: ftp://");
|
2005-05-03 16:17:39 +04:00
|
|
|
std::string url = "ftp://";
|
2006-03-09 19:17:10 +03:00
|
|
|
url += cmCTest::MakeURLSafe(
|
2006-03-10 23:03:09 +03:00
|
|
|
this->CTest->GetCTestConfiguration("DropSiteUser")) + ":" +
|
|
|
|
cmCTest::MakeURLSafe(this->CTest->GetCTestConfiguration(
|
2006-03-09 19:17:10 +03:00
|
|
|
"DropSitePassword")) + "@" +
|
2006-03-10 23:03:09 +03:00
|
|
|
this->CTest->GetCTestConfiguration("DropSite") +
|
|
|
|
cmCTest::MakeURLSafe(
|
|
|
|
this->CTest->GetCTestConfiguration("DropLocation"));
|
|
|
|
if ( this->CTest->GetCTestConfiguration("DropSiteUser").size() > 0 )
|
2005-06-16 21:18:21 +04:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT,
|
|
|
|
this->CTest->GetCTestConfiguration(
|
2006-03-09 19:17:10 +03:00
|
|
|
"DropSiteUser").c_str());
|
2006-03-10 23:03:09 +03:00
|
|
|
if ( this->CTest->GetCTestConfiguration("DropSitePassword").size() > 0 )
|
2005-06-16 21:18:21 +04:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, ":******");
|
2005-06-16 21:18:21 +04:00
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, "@");
|
2005-06-16 21:18:21 +04:00
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT,
|
|
|
|
this->CTest->GetCTestConfiguration("DropSite")
|
|
|
|
<< this->CTest->GetCTestConfiguration("DropLocation") << std::endl);
|
2006-03-09 19:17:10 +03:00
|
|
|
if ( !this->SubmitUsingFTP(buildDirectory + "/Testing/"
|
2006-03-10 23:03:09 +03:00
|
|
|
+ this->CTest->GetCurrentTag(),
|
2005-05-03 16:17:39 +04:00
|
|
|
files, prefix, url) )
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
|
|
|
" Problems when submitting via FTP"
|
2006-03-09 19:17:10 +03:00
|
|
|
<< 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;
|
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Using HTTP trigger method"
|
2006-03-09 19:17:10 +03:00
|
|
|
<< std::endl
|
2006-03-10 23:03:09 +03:00
|
|
|
<< " Trigger site: "
|
|
|
|
<< this->CTest->GetCTestConfiguration("TriggerSite")
|
2006-03-09 19:17:10 +03:00
|
|
|
<< std::endl);
|
|
|
|
if ( !this->TriggerUsingHTTP(files, prefix,
|
2006-03-10 23:03:09 +03:00
|
|
|
this->CTest->GetCTestConfiguration("TriggerSite")) )
|
2005-05-03 16:17:39 +04:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2006-03-09 19:17:10 +03:00
|
|
|
" Problems when triggering via HTTP" << std::endl);
|
2005-06-16 21:18:21 +04:00
|
|
|
ofs << " Problems when triggering via HTTP" << std::endl;
|
2005-05-03 16:17:39 +04:00
|
|
|
return -1;
|
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Submission successful"
|
2006-03-09 19:17:10 +03:00
|
|
|
<< std::endl);
|
2005-06-16 21:18:21 +04:00
|
|
|
ofs << " Submission successful" << std::endl;
|
2005-05-03 16:17:39 +04:00
|
|
|
return 0;
|
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
else if ( this->CTest->GetCTestConfiguration("DropMethod") == "http" )
|
2005-05-03 16:17:39 +04:00
|
|
|
{
|
|
|
|
ofs << "Using drop method: HTTP" << std::endl;
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Using HTTP submit method"
|
2006-03-09 19:17:10 +03:00
|
|
|
<< std::endl
|
2005-06-16 21:18:21 +04:00
|
|
|
<< " Drop site: http://");
|
2005-05-03 16:17:39 +04:00
|
|
|
std::string url = "http://";
|
2006-03-10 23:03:09 +03:00
|
|
|
if ( this->CTest->GetCTestConfiguration("DropSiteUser").size() > 0 )
|
2005-05-03 16:17:39 +04:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
url += this->CTest->GetCTestConfiguration("DropSiteUser");
|
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT,
|
|
|
|
this->CTest->GetCTestConfiguration("DropSiteUser").c_str());
|
|
|
|
if ( this->CTest->GetCTestConfiguration("DropSitePassword").size() > 0 )
|
2005-05-03 16:17:39 +04:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
url += ":" + this->CTest->GetCTestConfiguration("DropSitePassword");
|
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, ":******");
|
2005-05-03 16:17:39 +04:00
|
|
|
}
|
|
|
|
url += "@";
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, "@");
|
2005-05-03 16:17:39 +04:00
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
url += this->CTest->GetCTestConfiguration("DropSite") +
|
|
|
|
this->CTest->GetCTestConfiguration("DropLocation");
|
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT,
|
|
|
|
this->CTest->GetCTestConfiguration("DropSite")
|
|
|
|
<< this->CTest->GetCTestConfiguration("DropLocation") << std::endl);
|
2006-03-09 19:17:10 +03:00
|
|
|
if ( !this->SubmitUsingHTTP(buildDirectory + "/Testing/" +
|
2006-03-10 23:03:09 +03:00
|
|
|
this->CTest->GetCurrentTag(), files, prefix, url) )
|
2005-05-03 16:17:39 +04:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2006-03-09 19:17:10 +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;
|
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Using HTTP trigger method"
|
2006-03-09 19:17:10 +03:00
|
|
|
<< std::endl
|
2006-03-10 23:03:09 +03:00
|
|
|
<< " Trigger site: "
|
|
|
|
<< this->CTest->GetCTestConfiguration("TriggerSite")
|
2006-03-09 19:17:10 +03:00
|
|
|
<< std::endl);
|
|
|
|
if ( !this->TriggerUsingHTTP(files, prefix,
|
2006-03-10 23:03:09 +03:00
|
|
|
this->CTest->GetCTestConfiguration("TriggerSite")) )
|
2005-05-03 16:17:39 +04:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2006-03-09 19:17:10 +03:00
|
|
|
" Problems when triggering via HTTP" << std::endl);
|
2005-06-16 21:18:21 +04:00
|
|
|
ofs << " Problems when triggering via HTTP" << std::endl;
|
2005-05-03 16:17:39 +04:00
|
|
|
return -1;
|
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Submission successful"
|
2006-03-09 19:17:10 +03:00
|
|
|
<< std::endl);
|
2005-06-16 21:18:21 +04:00
|
|
|
ofs << " Submission successful" << std::endl;
|
2005-05-03 16:17:39 +04:00
|
|
|
return 0;
|
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
else if ( this->CTest->GetCTestConfiguration("DropMethod") == "xmlrpc" )
|
2005-05-03 16:17:39 +04:00
|
|
|
{
|
|
|
|
ofs << "Using drop method: XML-RPC" << std::endl;
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Using XML-RPC submit method"
|
2006-03-09 19:17:10 +03:00
|
|
|
<< std::endl);
|
2006-03-10 23:03:09 +03:00
|
|
|
std::string url = this->CTest->GetCTestConfiguration("DropSite");
|
|
|
|
prefix = this->CTest->GetCTestConfiguration("DropLocation");
|
2006-03-09 19:17:10 +03:00
|
|
|
if ( !this->SubmitUsingXMLRPC(buildDirectory + "/Testing/" +
|
2006-03-10 23:03:09 +03:00
|
|
|
this->CTest->GetCurrentTag(), files, prefix, url) )
|
2005-05-03 16:17:39 +04:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2006-03-09 19:17:10 +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;
|
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Submission successful"
|
2006-03-09 19:17:10 +03:00
|
|
|
<< std::endl);
|
2005-06-16 21:18:21 +04:00
|
|
|
ofs << " Submission successful" << std::endl;
|
2005-05-03 16:17:39 +04:00
|
|
|
return 0;
|
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
else if ( this->CTest->GetCTestConfiguration("DropMethod") == "scp" )
|
2005-05-03 16:17:39 +04:00
|
|
|
{
|
|
|
|
std::string url;
|
2005-07-06 23:11:38 +04:00
|
|
|
std::string oldWorkingDirectory;
|
2006-03-10 23:03:09 +03:00
|
|
|
if ( this->CTest->GetCTestConfiguration("DropSiteUser").size() > 0 )
|
2005-05-03 16:17:39 +04:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
url += this->CTest->GetCTestConfiguration("DropSiteUser") + "@";
|
2005-05-03 16:17:39 +04: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();
|
|
|
|
cmSystemTools::ChangeDirectory(buildDirectory.c_str());
|
|
|
|
|
2006-03-10 23:03:09 +03:00
|
|
|
if ( !this->SubmitUsingSCP(
|
|
|
|
this->CTest->GetCTestConfiguration("ScpCommand"),
|
|
|
|
"Testing/"+this->CTest->GetCurrentTag(), files, prefix, url) )
|
2005-05-03 16:17:39 +04:00
|
|
|
{
|
2005-07-06 23:11:38 +04:00
|
|
|
cmSystemTools::ChangeDirectory(oldWorkingDirectory.c_str());
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
|
|
|
" Problems when submitting via SCP"
|
2006-03-09 19:17:10 +03:00
|
|
|
<< 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;
|
|
|
|
}
|
2005-07-06 23:11:38 +04:00
|
|
|
cmSystemTools::ChangeDirectory(oldWorkingDirectory.c_str());
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Submission successful"
|
2006-03-09 19:17:10 +03:00
|
|
|
<< std::endl);
|
2005-06-16 21:18:21 +04:00
|
|
|
ofs << " Submission successful" << std::endl;
|
2005-06-24 21:29:22 +04:00
|
|
|
return 0;
|
2005-05-03 16:17:39 +04: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: \""
|
|
|
|
<< this->CTest->GetCTestConfiguration("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()
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
std::string name = this->CTest->GetCTestConfiguration("Site") +
|
|
|
|
"___" + this->CTest->GetCTestConfiguration("BuildName") +
|
|
|
|
"___" + this->CTest->GetCurrentTag() + "-" +
|
|
|
|
this->CTest->GetTestModelString() + "___XML___";
|
2005-05-03 16:17:39 +04:00
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
|