cmCTestSubmitHandler.cxx 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc.
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmCTestSubmitHandler.h"
  11. #include "cmCTestScriptHandler.h"
  12. #include "cmake.h"
  13. #include "cmSystemTools.h"
  14. #include "cmVersion.h"
  15. #include "cmGeneratedFileStream.h"
  16. #include "cmCTest.h"
  17. #include "cmXMLParser.h"
  18. #include "cmState.h"
  19. #include <cmsys/Process.h>
  20. #include <cmsys/Base64.h>
  21. // For XML-RPC submission
  22. #include "cm_xmlrpc.h"
  23. #include <cm_jsoncpp_reader.h>
  24. // For curl submission
  25. #include "cmCurl.h"
  26. #include "cmCTestCurl.h"
  27. #include <sys/stat.h>
  28. #define SUBMIT_TIMEOUT_IN_SECONDS_DEFAULT 120
  29. typedef std::vector<char> cmCTestSubmitHandlerVectorOfChar;
  30. //----------------------------------------------------------------------------
  31. class cmCTestSubmitHandler::ResponseParser: public cmXMLParser
  32. {
  33. public:
  34. ResponseParser() { this->Status = STATUS_OK; }
  35. ~ResponseParser() {}
  36. public:
  37. enum StatusType
  38. {
  39. STATUS_OK,
  40. STATUS_WARNING,
  41. STATUS_ERROR
  42. };
  43. StatusType Status;
  44. std::string CDashVersion;
  45. std::string Filename;
  46. std::string MD5;
  47. std::string Message;
  48. private:
  49. std::vector<char> CurrentValue;
  50. std::string GetCurrentValue()
  51. {
  52. std::string val;
  53. if(!this->CurrentValue.empty())
  54. {
  55. val.assign(&this->CurrentValue[0], this->CurrentValue.size());
  56. }
  57. return val;
  58. }
  59. virtual void StartElement(const std::string& name, const char** atts)
  60. {
  61. this->CurrentValue.clear();
  62. if(name == "cdash")
  63. {
  64. this->CDashVersion = this->FindAttribute(atts, "version");
  65. }
  66. }
  67. virtual void CharacterDataHandler(const char* data, int length)
  68. {
  69. this->CurrentValue.insert(this->CurrentValue.end(), data, data+length);
  70. }
  71. virtual void EndElement(const std::string& name)
  72. {
  73. if(name == "status")
  74. {
  75. std::string status = cmSystemTools::UpperCase(this->GetCurrentValue());
  76. if(status == "OK" || status == "SUCCESS")
  77. {
  78. this->Status = STATUS_OK;
  79. }
  80. else if(status == "WARNING")
  81. {
  82. this->Status = STATUS_WARNING;
  83. }
  84. else
  85. {
  86. this->Status = STATUS_ERROR;
  87. }
  88. }
  89. else if(name == "filename")
  90. {
  91. this->Filename = this->GetCurrentValue();
  92. }
  93. else if(name == "md5")
  94. {
  95. this->MD5 = this->GetCurrentValue();
  96. }
  97. else if(name == "message")
  98. {
  99. this->Message = this->GetCurrentValue();
  100. }
  101. }
  102. };
  103. static size_t
  104. cmCTestSubmitHandlerWriteMemoryCallback(void *ptr, size_t size, size_t nmemb,
  105. void *data)
  106. {
  107. int realsize = (int)(size * nmemb);
  108. cmCTestSubmitHandlerVectorOfChar *vec
  109. = static_cast<cmCTestSubmitHandlerVectorOfChar*>(data);
  110. const char* chPtr = static_cast<char*>(ptr);
  111. vec->insert(vec->end(), chPtr, chPtr + realsize);
  112. return realsize;
  113. }
  114. static size_t
  115. cmCTestSubmitHandlerCurlDebugCallback(CURL *, curl_infotype, char *chPtr,
  116. size_t size, void *data)
  117. {
  118. cmCTestSubmitHandlerVectorOfChar *vec
  119. = static_cast<cmCTestSubmitHandlerVectorOfChar*>(data);
  120. vec->insert(vec->end(), chPtr, chPtr + size);
  121. return size;
  122. }
  123. //----------------------------------------------------------------------------
  124. cmCTestSubmitHandler::cmCTestSubmitHandler() : HTTPProxy(), FTPProxy()
  125. {
  126. this->Initialize();
  127. }
  128. //----------------------------------------------------------------------------
  129. void cmCTestSubmitHandler::Initialize()
  130. {
  131. // We submit all available parts by default.
  132. for(cmCTest::Part p = cmCTest::PartStart;
  133. p != cmCTest::PartCount; p = cmCTest::Part(p+1))
  134. {
  135. this->SubmitPart[p] = true;
  136. }
  137. this->CDash = false;
  138. this->HasWarnings = false;
  139. this->HasErrors = false;
  140. this->Superclass::Initialize();
  141. this->HTTPProxy = "";
  142. this->HTTPProxyType = 0;
  143. this->HTTPProxyAuth = "";
  144. this->FTPProxy = "";
  145. this->FTPProxyType = 0;
  146. this->LogFile = 0;
  147. this->Files.clear();
  148. }
  149. //----------------------------------------------------------------------------
  150. bool cmCTestSubmitHandler::SubmitUsingFTP(const std::string& localprefix,
  151. const std::set<std::string>& files,
  152. const std::string& remoteprefix,
  153. const std::string& url)
  154. {
  155. CURL *curl;
  156. CURLcode res;
  157. FILE* ftpfile;
  158. char error_buffer[1024];
  159. /* In windows, this will init the winsock stuff */
  160. ::curl_global_init(CURL_GLOBAL_ALL);
  161. cmCTest::SetOfStrings::const_iterator file;
  162. for ( file = files.begin(); file != files.end(); ++file )
  163. {
  164. /* get a curl handle */
  165. curl = curl_easy_init();
  166. if(curl)
  167. {
  168. // Using proxy
  169. if ( this->FTPProxyType > 0 )
  170. {
  171. curl_easy_setopt(curl, CURLOPT_PROXY, this->FTPProxy.c_str());
  172. switch (this->FTPProxyType)
  173. {
  174. case 2:
  175. curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
  176. break;
  177. case 3:
  178. curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
  179. break;
  180. default:
  181. curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
  182. }
  183. }
  184. // enable uploading
  185. ::curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
  186. // if there is little to no activity for too long stop submitting
  187. ::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1);
  188. ::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME,
  189. SUBMIT_TIMEOUT_IN_SECONDS_DEFAULT);
  190. ::curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
  191. std::string local_file = *file;
  192. if ( !cmSystemTools::FileExists(local_file.c_str()) )
  193. {
  194. local_file = localprefix + "/" + *file;
  195. }
  196. std::string upload_as
  197. = url + "/" + remoteprefix + cmSystemTools::GetFilenameName(*file);
  198. if ( !cmSystemTools::FileExists(local_file.c_str()) )
  199. {
  200. cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot find file: "
  201. << local_file << std::endl);
  202. ::curl_easy_cleanup(curl);
  203. ::curl_global_cleanup();
  204. return false;
  205. }
  206. unsigned long filelen = cmSystemTools::FileLength(local_file);
  207. ftpfile = cmsys::SystemTools::Fopen(local_file, "rb");
  208. *this->LogFile << "\tUpload file: " << local_file << " to "
  209. << upload_as << std::endl;
  210. cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
  211. " Upload file: " << local_file << " to " << upload_as << std::endl,
  212. this->Quiet);
  213. ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
  214. // specify target
  215. ::curl_easy_setopt(curl,CURLOPT_URL, upload_as.c_str());
  216. // now specify which file to upload
  217. ::curl_easy_setopt(curl, CURLOPT_INFILE, ftpfile);
  218. // and give the size of the upload (optional)
  219. ::curl_easy_setopt(curl, CURLOPT_INFILESIZE,
  220. static_cast<long>(filelen));
  221. // and give curl the buffer for errors
  222. ::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer);
  223. // specify handler for output
  224. ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
  225. cmCTestSubmitHandlerWriteMemoryCallback);
  226. ::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION,
  227. cmCTestSubmitHandlerCurlDebugCallback);
  228. /* we pass our 'chunk' struct to the callback function */
  229. cmCTestSubmitHandlerVectorOfChar chunk;
  230. cmCTestSubmitHandlerVectorOfChar chunkDebug;
  231. ::curl_easy_setopt(curl, CURLOPT_FILE, (void *)&chunk);
  232. ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void *)&chunkDebug);
  233. // Now run off and do what you've been told!
  234. res = ::curl_easy_perform(curl);
  235. if (!chunk.empty())
  236. {
  237. cmCTestOptionalLog(this->CTest, DEBUG, "CURL output: ["
  238. << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
  239. << std::endl, this->Quiet);
  240. }
  241. if (!chunkDebug.empty())
  242. {
  243. cmCTestOptionalLog(this->CTest, DEBUG, "CURL debug output: ["
  244. << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]"
  245. << std::endl, this->Quiet);
  246. }
  247. fclose(ftpfile);
  248. if ( res )
  249. {
  250. cmCTestLog(this->CTest, ERROR_MESSAGE,
  251. " Error when uploading file: "
  252. << local_file << std::endl);
  253. cmCTestLog(this->CTest, ERROR_MESSAGE, " Error message was: "
  254. << error_buffer << std::endl);
  255. *this->LogFile << " Error when uploading file: "
  256. << local_file
  257. << std::endl
  258. << " Error message was: "
  259. << error_buffer << std::endl
  260. << " Curl output was: ";
  261. // avoid dereference of empty vector
  262. if(!chunk.empty())
  263. {
  264. *this->LogFile << cmCTestLogWrite(&*chunk.begin(), chunk.size());
  265. cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: ["
  266. << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
  267. << std::endl);
  268. }
  269. *this->LogFile << std::endl;
  270. ::curl_easy_cleanup(curl);
  271. ::curl_global_cleanup();
  272. return false;
  273. }
  274. // always cleanup
  275. ::curl_easy_cleanup(curl);
  276. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
  277. " Uploaded: " + local_file << std::endl, this->Quiet);
  278. }
  279. }
  280. ::curl_global_cleanup();
  281. return true;
  282. }
  283. //----------------------------------------------------------------------------
  284. // Uploading files is simpler
  285. bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
  286. const std::set<std::string>& files,
  287. const std::string& remoteprefix,
  288. const std::string& url)
  289. {
  290. CURL *curl;
  291. CURLcode res;
  292. FILE* ftpfile;
  293. char error_buffer[1024];
  294. struct curl_slist *headers = ::curl_slist_append(NULL,
  295. "Content-Type: text/xml");
  296. /* In windows, this will init the winsock stuff */
  297. ::curl_global_init(CURL_GLOBAL_ALL);
  298. std::string dropMethod(this->CTest->GetCTestConfiguration("DropMethod"));
  299. std::string curlopt(this->CTest->GetCTestConfiguration("CurlOptions"));
  300. std::vector<std::string> args;
  301. cmSystemTools::ExpandListArgument(curlopt, args);
  302. bool verifyPeerOff = false;
  303. bool verifyHostOff = false;
  304. for( std::vector<std::string>::iterator i = args.begin();
  305. i != args.end(); ++i)
  306. {
  307. if(*i == "CURLOPT_SSL_VERIFYPEER_OFF")
  308. {
  309. verifyPeerOff = true;
  310. }
  311. if(*i == "CURLOPT_SSL_VERIFYHOST_OFF")
  312. {
  313. verifyHostOff = true;
  314. }
  315. }
  316. std::string::size_type kk;
  317. cmCTest::SetOfStrings::const_iterator file;
  318. for ( file = files.begin(); file != files.end(); ++file )
  319. {
  320. /* get a curl handle */
  321. curl = curl_easy_init();
  322. if(curl)
  323. {
  324. cmCurlSetCAInfo(curl);
  325. if(verifyPeerOff)
  326. {
  327. cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
  328. " Set CURLOPT_SSL_VERIFYPEER to off\n", this->Quiet);
  329. curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
  330. }
  331. if(verifyHostOff)
  332. {
  333. cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
  334. " Set CURLOPT_SSL_VERIFYHOST to off\n", this->Quiet);
  335. curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
  336. }
  337. // Using proxy
  338. if ( this->HTTPProxyType > 0 )
  339. {
  340. curl_easy_setopt(curl, CURLOPT_PROXY, this->HTTPProxy.c_str());
  341. switch (this->HTTPProxyType)
  342. {
  343. case 2:
  344. curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
  345. break;
  346. case 3:
  347. curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
  348. break;
  349. default:
  350. curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
  351. if (!this->HTTPProxyAuth.empty())
  352. {
  353. curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD,
  354. this->HTTPProxyAuth.c_str());
  355. }
  356. }
  357. }
  358. if(this->CTest->ShouldUseHTTP10())
  359. {
  360. curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
  361. }
  362. // enable HTTP ERROR parsing
  363. curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
  364. /* enable uploading */
  365. curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
  366. // if there is little to no activity for too long stop submitting
  367. ::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1);
  368. ::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME,
  369. SUBMIT_TIMEOUT_IN_SECONDS_DEFAULT);
  370. /* HTTP PUT please */
  371. ::curl_easy_setopt(curl, CURLOPT_PUT, 1);
  372. ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
  373. // Be sure to set Content-Type to satisfy fussy modsecurity rules
  374. ::curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
  375. std::string local_file = *file;
  376. if ( !cmSystemTools::FileExists(local_file.c_str()) )
  377. {
  378. local_file = localprefix + "/" + *file;
  379. }
  380. std::string remote_file
  381. = remoteprefix + cmSystemTools::GetFilenameName(*file);
  382. *this->LogFile << "\tUpload file: " << local_file << " to "
  383. << remote_file << std::endl;
  384. std::string ofile = "";
  385. for ( kk = 0; kk < remote_file.size(); kk ++ )
  386. {
  387. char c = remote_file[kk];
  388. char hexCh[4] = { 0, 0, 0, 0 };
  389. hexCh[0] = c;
  390. switch ( c )
  391. {
  392. case '+':
  393. case '?':
  394. case '/':
  395. case '\\':
  396. case '&':
  397. case ' ':
  398. case '=':
  399. case '%':
  400. sprintf(hexCh, "%%%02X", (int)c);
  401. ofile.append(hexCh);
  402. break;
  403. default:
  404. ofile.append(hexCh);
  405. }
  406. }
  407. std::string upload_as
  408. = url + ((url.find("?",0) == std::string::npos) ? "?" : "&")
  409. + "FileName=" + ofile;
  410. upload_as += "&MD5=";
  411. if(cmSystemTools::IsOn(this->GetOption("InternalTest")))
  412. {
  413. upload_as += "bad_md5sum";
  414. }
  415. else
  416. {
  417. char md5[33];
  418. cmSystemTools::ComputeFileMD5(local_file, md5);
  419. md5[32] = 0;
  420. upload_as += md5;
  421. }
  422. if( !cmSystemTools::FileExists(local_file.c_str()) )
  423. {
  424. cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot find file: "
  425. << local_file << std::endl);
  426. ::curl_easy_cleanup(curl);
  427. ::curl_slist_free_all(headers);
  428. ::curl_global_cleanup();
  429. return false;
  430. }
  431. unsigned long filelen = cmSystemTools::FileLength(local_file);
  432. ftpfile = cmsys::SystemTools::Fopen(local_file, "rb");
  433. cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
  434. " Upload file: " << local_file << " to "
  435. << upload_as << " Size: " << filelen << std::endl, this->Quiet);
  436. // specify target
  437. ::curl_easy_setopt(curl,CURLOPT_URL, upload_as.c_str());
  438. // now specify which file to upload
  439. ::curl_easy_setopt(curl, CURLOPT_INFILE, ftpfile);
  440. // and give the size of the upload (optional)
  441. ::curl_easy_setopt(curl, CURLOPT_INFILESIZE,
  442. static_cast<long>(filelen));
  443. // and give curl the buffer for errors
  444. ::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer);
  445. // specify handler for output
  446. ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
  447. cmCTestSubmitHandlerWriteMemoryCallback);
  448. ::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION,
  449. cmCTestSubmitHandlerCurlDebugCallback);
  450. /* we pass our 'chunk' struct to the callback function */
  451. cmCTestSubmitHandlerVectorOfChar chunk;
  452. cmCTestSubmitHandlerVectorOfChar chunkDebug;
  453. ::curl_easy_setopt(curl, CURLOPT_FILE, (void *)&chunk);
  454. ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void *)&chunkDebug);
  455. // Now run off and do what you've been told!
  456. res = ::curl_easy_perform(curl);
  457. if(cmSystemTools::IsOn(this->GetOption("InternalTest")) &&
  458. cmSystemTools::VersionCompare(cmSystemTools::OP_LESS,
  459. this->CTest->GetCDashVersion().c_str(), "1.7"))
  460. {
  461. // mock failure output for internal test case
  462. std::string mock_output = "<cdash version=\"1.7.0\">\n"
  463. " <status>ERROR</status>\n"
  464. " <message>Checksum failed for file.</message>\n"
  465. "</cdash>\n";
  466. chunk.clear();
  467. chunk.assign(mock_output.begin(), mock_output.end());
  468. }
  469. if (!chunk.empty())
  470. {
  471. cmCTestOptionalLog(this->CTest, DEBUG, "CURL output: ["
  472. << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
  473. << std::endl, this->Quiet);
  474. this->ParseResponse(chunk);
  475. }
  476. if (!chunkDebug.empty())
  477. {
  478. cmCTestOptionalLog(this->CTest, DEBUG, "CURL debug output: ["
  479. << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]"
  480. << std::endl, this->Quiet);
  481. }
  482. // If curl failed for any reason, or checksum fails, wait and retry
  483. //
  484. if(res != CURLE_OK || this->HasErrors)
  485. {
  486. std::string retryDelay = this->GetOption("RetryDelay") == NULL ?
  487. "" : this->GetOption("RetryDelay");
  488. std::string retryCount = this->GetOption("RetryCount") == NULL ?
  489. "" : this->GetOption("RetryCount");
  490. int delay = retryDelay == "" ? atoi(this->CTest->GetCTestConfiguration(
  491. "CTestSubmitRetryDelay").c_str()) : atoi(retryDelay.c_str());
  492. int count = retryCount == "" ? atoi(this->CTest->GetCTestConfiguration(
  493. "CTestSubmitRetryCount").c_str()) : atoi(retryCount.c_str());
  494. for(int i = 0; i < count; i++)
  495. {
  496. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
  497. " Submit failed, waiting " << delay << " seconds...\n",
  498. this->Quiet);
  499. double stop = cmSystemTools::GetTime() + delay;
  500. while(cmSystemTools::GetTime() < stop)
  501. {
  502. cmSystemTools::Delay(100);
  503. }
  504. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
  505. " Retry submission: Attempt " << (i + 1) << " of "
  506. << count << std::endl, this->Quiet);
  507. ::fclose(ftpfile);
  508. ftpfile = cmsys::SystemTools::Fopen(local_file, "rb");
  509. ::curl_easy_setopt(curl, CURLOPT_INFILE, ftpfile);
  510. chunk.clear();
  511. chunkDebug.clear();
  512. this->HasErrors = false;
  513. res = ::curl_easy_perform(curl);
  514. if (!chunk.empty())
  515. {
  516. cmCTestOptionalLog(this->CTest, DEBUG, "CURL output: ["
  517. << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
  518. << std::endl, this->Quiet);
  519. this->ParseResponse(chunk);
  520. }
  521. if(res == CURLE_OK && !this->HasErrors)
  522. {
  523. break;
  524. }
  525. }
  526. }
  527. fclose(ftpfile);
  528. if ( res )
  529. {
  530. cmCTestLog(this->CTest, ERROR_MESSAGE,
  531. " Error when uploading file: "
  532. << local_file << std::endl);
  533. cmCTestLog(this->CTest, ERROR_MESSAGE, " Error message was: "
  534. << error_buffer << std::endl);
  535. *this->LogFile << " Error when uploading file: "
  536. << local_file
  537. << std::endl
  538. << " Error message was: " << error_buffer
  539. << std::endl;
  540. // avoid deref of begin for zero size array
  541. if(!chunk.empty())
  542. {
  543. *this->LogFile << " Curl output was: "
  544. << cmCTestLogWrite(&*chunk.begin(), chunk.size())
  545. << std::endl;
  546. cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: ["
  547. << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
  548. << std::endl);
  549. }
  550. ::curl_easy_cleanup(curl);
  551. ::curl_slist_free_all(headers);
  552. ::curl_global_cleanup();
  553. return false;
  554. }
  555. // always cleanup
  556. ::curl_easy_cleanup(curl);
  557. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
  558. " Uploaded: " + local_file << std::endl, this->Quiet);
  559. }
  560. }
  561. ::curl_slist_free_all(headers);
  562. ::curl_global_cleanup();
  563. return true;
  564. }
  565. //----------------------------------------------------------------------------
  566. void cmCTestSubmitHandler
  567. ::ParseResponse(cmCTestSubmitHandlerVectorOfChar chunk)
  568. {
  569. std::string output = "";
  570. output.append(chunk.begin(), chunk.end());
  571. if(output.find("<cdash") != output.npos)
  572. {
  573. ResponseParser parser;
  574. parser.Parse(output.c_str());
  575. if(parser.Status != ResponseParser::STATUS_OK)
  576. {
  577. this->HasErrors = true;
  578. cmCTestLog(this->CTest, HANDLER_OUTPUT, " Submission failed: " <<
  579. parser.Message << std::endl);
  580. return;
  581. }
  582. }
  583. output = cmSystemTools::UpperCase(output);
  584. if(output.find("WARNING") != std::string::npos)
  585. {
  586. this->HasWarnings = true;
  587. }
  588. if(output.find("ERROR") != std::string::npos)
  589. {
  590. this->HasErrors = true;
  591. }
  592. if(this->HasWarnings || this->HasErrors)
  593. {
  594. cmCTestLog(this->CTest, HANDLER_OUTPUT, " Server Response:\n" <<
  595. cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "\n");
  596. }
  597. }
  598. //----------------------------------------------------------------------------
  599. bool cmCTestSubmitHandler::TriggerUsingHTTP(
  600. const std::set<std::string>& files,
  601. const std::string& remoteprefix,
  602. const std::string& url)
  603. {
  604. CURL *curl;
  605. char error_buffer[1024];
  606. /* In windows, this will init the winsock stuff */
  607. ::curl_global_init(CURL_GLOBAL_ALL);
  608. cmCTest::SetOfStrings::const_iterator file;
  609. for ( file = files.begin(); file != files.end(); ++file )
  610. {
  611. /* get a curl handle */
  612. curl = curl_easy_init();
  613. if(curl)
  614. {
  615. // Using proxy
  616. if ( this->HTTPProxyType > 0 )
  617. {
  618. curl_easy_setopt(curl, CURLOPT_PROXY, this->HTTPProxy.c_str());
  619. switch (this->HTTPProxyType)
  620. {
  621. case 2:
  622. curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
  623. break;
  624. case 3:
  625. curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
  626. break;
  627. default:
  628. curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
  629. if (!this->HTTPProxyAuth.empty())
  630. {
  631. curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD,
  632. this->HTTPProxyAuth.c_str());
  633. }
  634. }
  635. }
  636. ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
  637. // and give curl the buffer for errors
  638. ::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer);
  639. // specify handler for output
  640. ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
  641. cmCTestSubmitHandlerWriteMemoryCallback);
  642. ::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION,
  643. cmCTestSubmitHandlerCurlDebugCallback);
  644. /* we pass our 'chunk' struct to the callback function */
  645. cmCTestSubmitHandlerVectorOfChar chunk;
  646. cmCTestSubmitHandlerVectorOfChar chunkDebug;
  647. ::curl_easy_setopt(curl, CURLOPT_FILE, (void *)&chunk);
  648. ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void *)&chunkDebug);
  649. std::string rfile
  650. = remoteprefix + cmSystemTools::GetFilenameName(*file);
  651. std::string ofile = "";
  652. std::string::iterator kk;
  653. for ( kk = rfile.begin(); kk < rfile.end(); ++ kk)
  654. {
  655. char c = *kk;
  656. char hexCh[4] = { 0, 0, 0, 0 };
  657. hexCh[0] = c;
  658. switch ( c )
  659. {
  660. case '+':
  661. case '?':
  662. case '/':
  663. case '\\':
  664. case '&':
  665. case ' ':
  666. case '=':
  667. case '%':
  668. sprintf(hexCh, "%%%02X", (int)c);
  669. ofile.append(hexCh);
  670. break;
  671. default:
  672. ofile.append(hexCh);
  673. }
  674. }
  675. std::string turl
  676. = url + ((url.find("?",0) == std::string::npos) ? "?" : "&")
  677. + "xmlfile=" + ofile;
  678. *this->LogFile << "Trigger url: " << turl << std::endl;
  679. cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
  680. " Trigger url: " << turl << std::endl, this->Quiet);
  681. curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
  682. curl_easy_setopt(curl, CURLOPT_URL, turl.c_str());
  683. if ( curl_easy_perform(curl) )
  684. {
  685. cmCTestLog(this->CTest, ERROR_MESSAGE, " Error when triggering: "
  686. << turl << std::endl);
  687. cmCTestLog(this->CTest, ERROR_MESSAGE, " Error message was: "
  688. << error_buffer << std::endl);
  689. *this->LogFile << "\tTriggering failed with error: " << error_buffer
  690. << std::endl
  691. << " Error message was: " << error_buffer
  692. << std::endl;
  693. if(!chunk.empty())
  694. {
  695. *this->LogFile
  696. << " Curl output was: "
  697. << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl;
  698. cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: ["
  699. << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
  700. << std::endl);
  701. }
  702. ::curl_easy_cleanup(curl);
  703. ::curl_global_cleanup();
  704. return false;
  705. }
  706. if (!chunk.empty())
  707. {
  708. cmCTestOptionalLog(this->CTest, DEBUG, "CURL output: ["
  709. << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
  710. << std::endl, this->Quiet);
  711. }
  712. if (!chunkDebug.empty())
  713. {
  714. cmCTestOptionalLog(this->CTest, DEBUG, "CURL debug output: ["
  715. << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size())
  716. << "]" << std::endl, this->Quiet);
  717. }
  718. // always cleanup
  719. ::curl_easy_cleanup(curl);
  720. cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl,
  721. this->Quiet);
  722. }
  723. }
  724. ::curl_global_cleanup();
  725. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " Dart server triggered..."
  726. << std::endl, this->Quiet);
  727. return true;
  728. }
  729. //----------------------------------------------------------------------------
  730. bool cmCTestSubmitHandler::SubmitUsingSCP(
  731. const std::string& scp_command,
  732. const std::string& localprefix,
  733. const std::set<std::string>& files,
  734. const std::string& remoteprefix,
  735. const std::string& url)
  736. {
  737. if ( scp_command.empty() || localprefix.empty() ||
  738. files.empty() || remoteprefix.empty() || url.empty() )
  739. {
  740. return 0;
  741. }
  742. std::vector<const char*> argv;
  743. argv.push_back(scp_command.c_str()); // Scp command
  744. argv.push_back(scp_command.c_str()); // Dummy string for file
  745. argv.push_back(scp_command.c_str()); // Dummy string for remote url
  746. argv.push_back(0);
  747. cmsysProcess* cp = cmsysProcess_New();
  748. cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
  749. //cmsysProcess_SetTimeout(cp, timeout);
  750. int problems = 0;
  751. cmCTest::SetOfStrings::const_iterator file;
  752. for ( file = files.begin(); file != files.end(); ++file )
  753. {
  754. int retVal;
  755. std::string lfname = localprefix;
  756. cmSystemTools::ConvertToUnixSlashes(lfname);
  757. lfname += "/" + *file;
  758. lfname = cmSystemTools::ConvertToOutputPath(lfname.c_str());
  759. argv[1] = lfname.c_str();
  760. std::string rfname = url + "/" + remoteprefix + *file;
  761. argv[2] = rfname.c_str();
  762. cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
  763. "Execute \"" << argv[0] << "\" \"" << argv[1] << "\" \""
  764. << argv[2] << "\"" << std::endl, this->Quiet);
  765. *this->LogFile << "Execute \"" << argv[0] << "\" \"" << argv[1] << "\" \""
  766. << argv[2] << "\"" << std::endl;
  767. cmsysProcess_SetCommand(cp, &*argv.begin());
  768. cmsysProcess_Execute(cp);
  769. char* data;
  770. int length;
  771. while(cmsysProcess_WaitForData(cp, &data, &length, 0))
  772. {
  773. cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
  774. cmCTestLogWrite(data, length), this->Quiet);
  775. }
  776. cmsysProcess_WaitForExit(cp, 0);
  777. int result = cmsysProcess_GetState(cp);
  778. if(result == cmsysProcess_State_Exited)
  779. {
  780. retVal = cmsysProcess_GetExitValue(cp);
  781. if ( retVal != 0 )
  782. {
  783. cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
  784. "\tSCP returned: " << retVal << std::endl, this->Quiet);
  785. *this->LogFile << "\tSCP returned: " << retVal << std::endl;
  786. problems ++;
  787. }
  788. }
  789. else if(result == cmsysProcess_State_Exception)
  790. {
  791. retVal = cmsysProcess_GetExitException(cp);
  792. cmCTestLog(this->CTest, ERROR_MESSAGE, "\tThere was an exception: "
  793. << retVal << std::endl);
  794. *this->LogFile << "\tThere was an exception: " << retVal << std::endl;
  795. problems ++;
  796. }
  797. else if(result == cmsysProcess_State_Expired)
  798. {
  799. cmCTestLog(this->CTest, ERROR_MESSAGE, "\tThere was a timeout"
  800. << std::endl);
  801. *this->LogFile << "\tThere was a timeout" << std::endl;
  802. problems ++;
  803. }
  804. else if(result == cmsysProcess_State_Error)
  805. {
  806. cmCTestLog(this->CTest, ERROR_MESSAGE, "\tError executing SCP: "
  807. << cmsysProcess_GetErrorString(cp) << std::endl);
  808. *this->LogFile << "\tError executing SCP: "
  809. << cmsysProcess_GetErrorString(cp) << std::endl;
  810. problems ++;
  811. }
  812. }
  813. cmsysProcess_Delete(cp);
  814. if ( problems )
  815. {
  816. return false;
  817. }
  818. return true;
  819. }
  820. //----------------------------------------------------------------------------
  821. bool cmCTestSubmitHandler::SubmitUsingCP(
  822. const std::string& localprefix,
  823. const std::set<std::string>& files,
  824. const std::string& remoteprefix,
  825. const std::string& destination)
  826. {
  827. if ( localprefix.empty() ||
  828. files.empty() || remoteprefix.empty() || destination.empty() )
  829. {
  830. cmCTestLog(this->CTest, ERROR_MESSAGE,
  831. "Missing arguments for submit via cp:\n"
  832. << "\tlocalprefix: " << localprefix << "\n"
  833. << "\tNumber of files: " << files.size() << "\n"
  834. << "\tremoteprefix: " << remoteprefix << "\n"
  835. << "\tdestination: " << destination << std::endl);
  836. return 0;
  837. }
  838. cmCTest::SetOfStrings::const_iterator file;
  839. bool problems = false;
  840. for ( file = files.begin(); file != files.end(); ++file )
  841. {
  842. std::string lfname = localprefix;
  843. cmSystemTools::ConvertToUnixSlashes(lfname);
  844. lfname += "/" + *file;
  845. std::string rfname = destination + "/" + remoteprefix + *file;
  846. cmSystemTools::CopyFileAlways(lfname, rfname);
  847. cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Copy file: "
  848. << lfname << " to "
  849. << rfname << std::endl, this->Quiet);
  850. }
  851. std::string tagDoneFile = destination + "/" + remoteprefix + "DONE";
  852. cmSystemTools::Touch(tagDoneFile, true);
  853. if ( problems )
  854. {
  855. return false;
  856. }
  857. return true;
  858. }
  859. //----------------------------------------------------------------------------
  860. #if defined(CTEST_USE_XMLRPC)
  861. bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const std::string& localprefix,
  862. const std::set<std::string>& files,
  863. const std::string& remoteprefix,
  864. const std::string& url)
  865. {
  866. xmlrpc_env env;
  867. char ctestString[] = "CTest";
  868. std::string ctestVersionString = cmVersion::GetCMakeVersion();
  869. char* ctestVersion = const_cast<char*>(ctestVersionString.c_str());
  870. std::string realURL = url + "/" + remoteprefix + "/Command/";
  871. /* Start up our XML-RPC client library. */
  872. xmlrpc_client_init(XMLRPC_CLIENT_NO_FLAGS, ctestString, ctestVersion);
  873. /* Initialize our error-handling environment. */
  874. xmlrpc_env_init(&env);
  875. /* Call the famous server at UserLand. */
  876. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " Submitting to: "
  877. << realURL.c_str() << " (" << remoteprefix.c_str() << ")" << std::endl,
  878. this->Quiet);
  879. cmCTest::SetOfStrings::const_iterator file;
  880. for ( file = files.begin(); file != files.end(); ++file )
  881. {
  882. xmlrpc_value *result;
  883. std::string local_file = *file;
  884. if ( !cmSystemTools::FileExists(local_file.c_str()) )
  885. {
  886. local_file = localprefix + "/" + *file;
  887. }
  888. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " Submit file: "
  889. << local_file.c_str() << std::endl, this->Quiet);
  890. struct stat st;
  891. if ( ::stat(local_file.c_str(), &st) )
  892. {
  893. cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot find file: "
  894. << local_file.c_str() << std::endl);
  895. return false;
  896. }
  897. // off_t can be bigger than size_t. fread takes size_t.
  898. // make sure the file is not too big.
  899. if(static_cast<off_t>(static_cast<size_t>(st.st_size)) !=
  900. static_cast<off_t>(st.st_size))
  901. {
  902. cmCTestLog(this->CTest, ERROR_MESSAGE, " File too big: "
  903. << local_file.c_str() << std::endl);
  904. return false;
  905. }
  906. size_t fileSize = static_cast<size_t>(st.st_size);
  907. FILE* fp = cmsys::SystemTools::Fopen(local_file.c_str(), "rb");
  908. if ( !fp )
  909. {
  910. cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot open file: "
  911. << local_file.c_str() << std::endl);
  912. return false;
  913. }
  914. unsigned char *fileBuffer = new unsigned char[fileSize];
  915. if ( fread(fileBuffer, 1, fileSize, fp) != fileSize )
  916. {
  917. delete [] fileBuffer;
  918. fclose(fp);
  919. cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot read file: "
  920. << local_file.c_str() << std::endl);
  921. return false;
  922. }
  923. fclose(fp);
  924. char remoteCommand[] = "Submit.put";
  925. char* pRealURL = const_cast<char*>(realURL.c_str());
  926. result = xmlrpc_client_call(&env, pRealURL, remoteCommand,
  927. "(6)", fileBuffer, (xmlrpc_int32)fileSize );
  928. delete [] fileBuffer;
  929. if ( env.fault_occurred )
  930. {
  931. cmCTestLog(this->CTest, ERROR_MESSAGE, " Submission problem: "
  932. << env.fault_string << " (" << env.fault_code << ")" << std::endl);
  933. xmlrpc_env_clean(&env);
  934. xmlrpc_client_cleanup();
  935. return false;
  936. }
  937. /* Dispose of our result value. */
  938. xmlrpc_DECREF(result);
  939. }
  940. /* Clean up our error-handling environment. */
  941. xmlrpc_env_clean(&env);
  942. /* Shutdown our XML-RPC client library. */
  943. xmlrpc_client_cleanup();
  944. return true;
  945. }
  946. #else
  947. bool cmCTestSubmitHandler::SubmitUsingXMLRPC(std::string const&,
  948. std::set<std::string> const&,
  949. std::string const&,
  950. std::string const&)
  951. {
  952. return false;
  953. }
  954. #endif
  955. void cmCTestSubmitHandler::ConstructCDashURL(std::string& dropMethod,
  956. std::string& url)
  957. {
  958. dropMethod = this->CTest->GetCTestConfiguration("DropMethod");
  959. url = dropMethod;
  960. url += "://";
  961. if ( this->CTest->GetCTestConfiguration("DropSiteUser").size() > 0 )
  962. {
  963. url += this->CTest->GetCTestConfiguration("DropSiteUser");
  964. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
  965. this->CTest->GetCTestConfiguration("DropSiteUser").c_str(),
  966. this->Quiet);
  967. if ( this->CTest->GetCTestConfiguration("DropSitePassword").size() > 0 )
  968. {
  969. url += ":" + this->CTest->GetCTestConfiguration("DropSitePassword");
  970. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, ":******",
  971. this->Quiet);
  972. }
  973. url += "@";
  974. }
  975. url += this->CTest->GetCTestConfiguration("DropSite") +
  976. this->CTest->GetCTestConfiguration("DropLocation");
  977. }
  978. int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
  979. std::string const& typeString)
  980. {
  981. if (file.empty())
  982. {
  983. cmCTestLog(this->CTest, ERROR_MESSAGE,
  984. "Upload file not specified\n");
  985. return -1;
  986. }
  987. if (!cmSystemTools::FileExists(file))
  988. {
  989. cmCTestLog(this->CTest, ERROR_MESSAGE,
  990. "Upload file not found: '" << file << "'\n");
  991. return -1;
  992. }
  993. cmCTestCurl curl(this->CTest);
  994. std::string curlopt(this->CTest->GetCTestConfiguration("CurlOptions"));
  995. std::vector<std::string> args;
  996. cmSystemTools::ExpandListArgument(curlopt, args);
  997. curl.SetCurlOptions(args);
  998. curl.SetTimeOutSeconds(SUBMIT_TIMEOUT_IN_SECONDS_DEFAULT);
  999. std::string dropMethod;
  1000. std::string url;
  1001. this->ConstructCDashURL(dropMethod, url);
  1002. std::string::size_type pos = url.find("submit.php?");
  1003. url = url.substr(0, pos+10);
  1004. if ( ! (dropMethod == "http" || dropMethod == "https" ) )
  1005. {
  1006. cmCTestLog(this->CTest, ERROR_MESSAGE,
  1007. "Only http and https are supported for CDASH_UPLOAD\n");
  1008. return -1;
  1009. }
  1010. char md5sum[33];
  1011. md5sum[32] = 0;
  1012. cmSystemTools::ComputeFileMD5(file, md5sum);
  1013. // 1. request the buildid and check to see if the file
  1014. // has already been uploaded
  1015. // TODO I added support for subproject. You would need to add
  1016. // a "&subproject=subprojectname" to the first POST.
  1017. cmCTestScriptHandler* ch =
  1018. static_cast<cmCTestScriptHandler*>(this->CTest->GetHandler("script"));
  1019. cmake* cm = ch->GetCMake();
  1020. const char* subproject = cm->GetState()->GetGlobalProperty("SubProject");
  1021. // TODO: Encode values for a URL instead of trusting caller.
  1022. std::ostringstream str;
  1023. str << "project="
  1024. << curl.Escape(this->CTest->GetCTestConfiguration("ProjectName")) << "&";
  1025. if(subproject)
  1026. {
  1027. str << "subproject=" << curl.Escape(subproject) << "&";
  1028. }
  1029. str << "stamp=" << curl.Escape(this->CTest->GetCurrentTag()) << "-"
  1030. << curl.Escape(this->CTest->GetTestModelString()) << "&"
  1031. << "model=" << curl.Escape(this->CTest->GetTestModelString()) << "&"
  1032. << "build="
  1033. << curl.Escape(this->CTest->GetCTestConfiguration("BuildName")) << "&"
  1034. << "site="
  1035. << curl.Escape(this->CTest->GetCTestConfiguration("Site")) << "&"
  1036. << "track="
  1037. << curl.Escape(this->CTest->GetTestModelString()) << "&"
  1038. << "starttime=" << (int)cmSystemTools::GetTime() << "&"
  1039. << "endtime=" << (int)cmSystemTools::GetTime() << "&"
  1040. << "datafilesmd5[0]=" << md5sum << "&"
  1041. << "type=" << curl.Escape(typeString);
  1042. std::string fields = str.str();
  1043. cmCTestOptionalLog(this->CTest, DEBUG, "fields: " << fields << "\nurl:"
  1044. << url << "\nfile: " << file << "\n", this->Quiet);
  1045. std::string response;
  1046. if(!curl.HttpRequest(url, fields, response))
  1047. {
  1048. cmCTestLog(this->CTest, ERROR_MESSAGE,
  1049. "Error in HttpRequest\n" << response);
  1050. return -1;
  1051. }
  1052. cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
  1053. "Request upload response: [" << response << "]\n", this->Quiet);
  1054. Json::Value json;
  1055. Json::Reader reader;
  1056. if(!reader.parse(response, json))
  1057. {
  1058. cmCTestLog(this->CTest, ERROR_MESSAGE,
  1059. "error parsing json string [" << response << "]\n"
  1060. << reader.getFormattedErrorMessages() << "\n");
  1061. return -1;
  1062. }
  1063. if(json["status"].asInt() != 0)
  1064. {
  1065. cmCTestLog(this->CTest, ERROR_MESSAGE,
  1066. "Bad status returned from CDash: "
  1067. << json["status"].asInt());
  1068. return -1;
  1069. }
  1070. if(json["datafilesmd5"].isArray())
  1071. {
  1072. int datares = json["datafilesmd5"][0].asInt();
  1073. if(datares == 1)
  1074. {
  1075. cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
  1076. "File already exists on CDash, skip upload " << file << "\n",
  1077. this->Quiet);
  1078. return 0;
  1079. }
  1080. }
  1081. else
  1082. {
  1083. cmCTestLog(this->CTest, ERROR_MESSAGE,
  1084. "bad datafilesmd5 value in response "
  1085. << response << "\n");
  1086. return -1;
  1087. }
  1088. std::string upload_as = cmSystemTools::GetFilenameName(file);
  1089. std::ostringstream fstr;
  1090. fstr << "type=" << curl.Escape(typeString) << "&"
  1091. << "md5=" << md5sum << "&"
  1092. << "filename=" << curl.Escape(upload_as) << "&"
  1093. << "buildid=" << json["buildid"].asString();
  1094. if(!curl.UploadFile(file, url, fstr.str(), response))
  1095. {
  1096. cmCTestLog(this->CTest, ERROR_MESSAGE,
  1097. "error uploading to CDash. "
  1098. << file << " " << url << " " << fstr.str());
  1099. return -1;
  1100. }
  1101. if(!reader.parse(response, json))
  1102. {
  1103. cmCTestLog(this->CTest, ERROR_MESSAGE,
  1104. "error parsing json string [" << response << "]\n"
  1105. << reader.getFormattedErrorMessages() << "\n");
  1106. return -1;
  1107. }
  1108. cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
  1109. "Upload file response: [" << response << "]\n", this->Quiet );
  1110. return 0;
  1111. }
  1112. //----------------------------------------------------------------------------
  1113. int cmCTestSubmitHandler::ProcessHandler()
  1114. {
  1115. const char* cdashUploadFile = this->GetOption("CDashUploadFile");
  1116. const char* cdashUploadType = this->GetOption("CDashUploadType");
  1117. if(cdashUploadFile && cdashUploadType)
  1118. {
  1119. return this->HandleCDashUploadFile(cdashUploadFile, cdashUploadType);
  1120. }
  1121. std::string iscdash = this->CTest->GetCTestConfiguration("IsCDash");
  1122. // cdash does not need to trigger so just return true
  1123. if(!iscdash.empty())
  1124. {
  1125. this->CDash = true;
  1126. }
  1127. const std::string &buildDirectory
  1128. = this->CTest->GetCTestConfiguration("BuildDirectory");
  1129. if (buildDirectory.empty())
  1130. {
  1131. cmCTestLog(this->CTest, ERROR_MESSAGE,
  1132. "Cannot find BuildDirectory key in the DartConfiguration.tcl"
  1133. << std::endl);
  1134. return -1;
  1135. }
  1136. if ( getenv("HTTP_PROXY") )
  1137. {
  1138. this->HTTPProxyType = 1;
  1139. this->HTTPProxy = getenv("HTTP_PROXY");
  1140. if ( getenv("HTTP_PROXY_PORT") )
  1141. {
  1142. this->HTTPProxy += ":";
  1143. this->HTTPProxy += getenv("HTTP_PROXY_PORT");
  1144. }
  1145. if ( getenv("HTTP_PROXY_TYPE") )
  1146. {
  1147. std::string type = getenv("HTTP_PROXY_TYPE");
  1148. // HTTP/SOCKS4/SOCKS5
  1149. if ( type == "HTTP" )
  1150. {
  1151. this->HTTPProxyType = 1;
  1152. }
  1153. else if ( type == "SOCKS4" )
  1154. {
  1155. this->HTTPProxyType = 2;
  1156. }
  1157. else if ( type == "SOCKS5" )
  1158. {
  1159. this->HTTPProxyType = 3;
  1160. }
  1161. }
  1162. if ( getenv("HTTP_PROXY_USER") )
  1163. {
  1164. this->HTTPProxyAuth = getenv("HTTP_PROXY_USER");
  1165. }
  1166. if ( getenv("HTTP_PROXY_PASSWD") )
  1167. {
  1168. this->HTTPProxyAuth += ":";
  1169. this->HTTPProxyAuth += getenv("HTTP_PROXY_PASSWD");
  1170. }
  1171. }
  1172. if ( getenv("FTP_PROXY") )
  1173. {
  1174. this->FTPProxyType = 1;
  1175. this->FTPProxy = getenv("FTP_PROXY");
  1176. if ( getenv("FTP_PROXY_PORT") )
  1177. {
  1178. this->FTPProxy += ":";
  1179. this->FTPProxy += getenv("FTP_PROXY_PORT");
  1180. }
  1181. if ( getenv("FTP_PROXY_TYPE") )
  1182. {
  1183. std::string type = getenv("FTP_PROXY_TYPE");
  1184. // HTTP/SOCKS4/SOCKS5
  1185. if ( type == "HTTP" )
  1186. {
  1187. this->FTPProxyType = 1;
  1188. }
  1189. else if ( type == "SOCKS4" )
  1190. {
  1191. this->FTPProxyType = 2;
  1192. }
  1193. else if ( type == "SOCKS5" )
  1194. {
  1195. this->FTPProxyType = 3;
  1196. }
  1197. }
  1198. }
  1199. if (!this->HTTPProxy.empty())
  1200. {
  1201. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " Use HTTP Proxy: "
  1202. << this->HTTPProxy << std::endl, this->Quiet);
  1203. }
  1204. if (!this->FTPProxy.empty())
  1205. {
  1206. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " Use FTP Proxy: "
  1207. << this->FTPProxy << std::endl, this->Quiet);
  1208. }
  1209. cmGeneratedFileStream ofs;
  1210. this->StartLogFile("Submit", ofs);
  1211. cmCTest::SetOfStrings files;
  1212. std::string prefix = this->GetSubmitResultsPrefix();
  1213. if (!this->Files.empty())
  1214. {
  1215. // Submit the explicitly selected files:
  1216. //
  1217. files.insert(this->Files.begin(), this->Files.end());
  1218. }
  1219. // Add to the list of files to submit from any selected, existing parts:
  1220. //
  1221. // TODO:
  1222. // Check if test is enabled
  1223. this->CTest->AddIfExists(cmCTest::PartUpdate, "Update.xml");
  1224. this->CTest->AddIfExists(cmCTest::PartConfigure, "Configure.xml");
  1225. this->CTest->AddIfExists(cmCTest::PartBuild, "Build.xml");
  1226. this->CTest->AddIfExists(cmCTest::PartTest, "Test.xml");
  1227. if(this->CTest->AddIfExists(cmCTest::PartCoverage, "Coverage.xml"))
  1228. {
  1229. std::vector<std::string> gfiles;
  1230. std::string gpath
  1231. = buildDirectory + "/Testing/" + this->CTest->GetCurrentTag();
  1232. std::string::size_type glen = gpath.size() + 1;
  1233. gpath = gpath + "/CoverageLog*";
  1234. cmCTestOptionalLog(this->CTest, DEBUG, "Globbing for: " << gpath
  1235. << std::endl, this->Quiet);
  1236. if ( cmSystemTools::SimpleGlob(gpath, gfiles, 1) )
  1237. {
  1238. size_t cc;
  1239. for ( cc = 0; cc < gfiles.size(); cc ++ )
  1240. {
  1241. gfiles[cc] = gfiles[cc].substr(glen);
  1242. cmCTestOptionalLog(this->CTest, DEBUG, "Glob file: " << gfiles[cc]
  1243. << std::endl, this->Quiet);
  1244. this->CTest->AddSubmitFile(cmCTest::PartCoverage, gfiles[cc].c_str());
  1245. }
  1246. }
  1247. else
  1248. {
  1249. cmCTestLog(this->CTest, ERROR_MESSAGE, "Problem globbing" << std::endl);
  1250. }
  1251. }
  1252. this->CTest->AddIfExists(cmCTest::PartMemCheck, "DynamicAnalysis.xml");
  1253. this->CTest->AddIfExists(cmCTest::PartMemCheck, "Purify.xml");
  1254. this->CTest->AddIfExists(cmCTest::PartNotes, "Notes.xml");
  1255. this->CTest->AddIfExists(cmCTest::PartUpload, "Upload.xml");
  1256. // Query parts for files to submit.
  1257. for(cmCTest::Part p = cmCTest::PartStart;
  1258. p != cmCTest::PartCount; p = cmCTest::Part(p+1))
  1259. {
  1260. // Skip parts we are not submitting.
  1261. if(!this->SubmitPart[p])
  1262. {
  1263. continue;
  1264. }
  1265. // Submit files from this part.
  1266. std::vector<std::string> const& pfiles = this->CTest->GetSubmitFiles(p);
  1267. files.insert(pfiles.begin(), pfiles.end());
  1268. }
  1269. if ( ofs )
  1270. {
  1271. ofs << "Upload files:" << std::endl;
  1272. int cnt = 0;
  1273. cmCTest::SetOfStrings::iterator it;
  1274. for ( it = files.begin(); it != files.end(); ++ it )
  1275. {
  1276. ofs << cnt << "\t" << *it << std::endl;
  1277. cnt ++;
  1278. }
  1279. }
  1280. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "Submit files (using "
  1281. << this->CTest->GetCTestConfiguration("DropMethod") << ")"
  1282. << std::endl, this->Quiet);
  1283. const char* specificTrack = this->CTest->GetSpecificTrack();
  1284. if ( specificTrack )
  1285. {
  1286. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " Send to track: "
  1287. << specificTrack << std::endl, this->Quiet);
  1288. }
  1289. this->SetLogFile(&ofs);
  1290. std::string dropMethod(this->CTest->GetCTestConfiguration("DropMethod"));
  1291. if ( dropMethod == "" || dropMethod == "ftp" )
  1292. {
  1293. ofs << "Using drop method: FTP" << std::endl;
  1294. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
  1295. " Using FTP submit method" << std::endl << " Drop site: ftp://",
  1296. this->Quiet);
  1297. std::string url = "ftp://";
  1298. url += cmCTest::MakeURLSafe(
  1299. this->CTest->GetCTestConfiguration("DropSiteUser")) + ":" +
  1300. cmCTest::MakeURLSafe(this->CTest->GetCTestConfiguration(
  1301. "DropSitePassword")) + "@" +
  1302. this->CTest->GetCTestConfiguration("DropSite") +
  1303. cmCTest::MakeURLSafe(
  1304. this->CTest->GetCTestConfiguration("DropLocation"));
  1305. if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty())
  1306. {
  1307. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
  1308. this->CTest->GetCTestConfiguration(
  1309. "DropSiteUser").c_str(), this->Quiet);
  1310. if (!this->CTest->GetCTestConfiguration("DropSitePassword").empty())
  1311. {
  1312. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, ":******",
  1313. this->Quiet);
  1314. }
  1315. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "@", this->Quiet);
  1316. }
  1317. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
  1318. this->CTest->GetCTestConfiguration("DropSite")
  1319. << this->CTest->GetCTestConfiguration("DropLocation") << std::endl,
  1320. this->Quiet);
  1321. if ( !this->SubmitUsingFTP(buildDirectory + "/Testing/"
  1322. + this->CTest->GetCurrentTag(),
  1323. files, prefix, url) )
  1324. {
  1325. cmCTestLog(this->CTest, ERROR_MESSAGE,
  1326. " Problems when submitting via FTP"
  1327. << std::endl);
  1328. ofs << " Problems when submitting via FTP" << std::endl;
  1329. return -1;
  1330. }
  1331. if(!this->CDash)
  1332. {
  1333. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
  1334. " Using HTTP trigger method"
  1335. << std::endl
  1336. << " Trigger site: "
  1337. << this->CTest->GetCTestConfiguration("TriggerSite")
  1338. << std::endl, this->Quiet);
  1339. if ( !this->
  1340. TriggerUsingHTTP(files, prefix,
  1341. this->CTest->GetCTestConfiguration("TriggerSite")))
  1342. {
  1343. cmCTestLog(this->CTest, ERROR_MESSAGE,
  1344. " Problems when triggering via HTTP" << std::endl);
  1345. ofs << " Problems when triggering via HTTP" << std::endl;
  1346. return -1;
  1347. }
  1348. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
  1349. " Submission successful" << std::endl, this->Quiet);
  1350. ofs << " Submission successful" << std::endl;
  1351. return 0;
  1352. }
  1353. }
  1354. else if ( dropMethod == "http" || dropMethod == "https" )
  1355. {
  1356. std::string url = dropMethod;
  1357. url += "://";
  1358. ofs << "Using drop method: " << dropMethod << std::endl;
  1359. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
  1360. " Using HTTP submit method" << std::endl << " Drop site:" << url,
  1361. this->Quiet);
  1362. if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty())
  1363. {
  1364. url += this->CTest->GetCTestConfiguration("DropSiteUser");
  1365. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
  1366. this->CTest->GetCTestConfiguration("DropSiteUser").c_str(),
  1367. this->Quiet);
  1368. if (!this->CTest->GetCTestConfiguration("DropSitePassword").empty())
  1369. {
  1370. url += ":" + this->CTest->GetCTestConfiguration("DropSitePassword");
  1371. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, ":******",
  1372. this->Quiet);
  1373. }
  1374. url += "@";
  1375. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "@", this->Quiet);
  1376. }
  1377. url += this->CTest->GetCTestConfiguration("DropSite") +
  1378. this->CTest->GetCTestConfiguration("DropLocation");
  1379. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
  1380. this->CTest->GetCTestConfiguration("DropSite")
  1381. << this->CTest->GetCTestConfiguration("DropLocation") << std::endl,
  1382. this->Quiet);
  1383. if ( !this->SubmitUsingHTTP(buildDirectory + "/Testing/" +
  1384. this->CTest->GetCurrentTag(), files, prefix, url) )
  1385. {
  1386. cmCTestLog(this->CTest, ERROR_MESSAGE,
  1387. " Problems when submitting via HTTP" << std::endl);
  1388. ofs << " Problems when submitting via HTTP" << std::endl;
  1389. return -1;
  1390. }
  1391. if(!this->CDash)
  1392. {
  1393. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
  1394. " Using HTTP trigger method" << std::endl << " Trigger site: "
  1395. << this->CTest->GetCTestConfiguration("TriggerSite")
  1396. << std::endl, this->Quiet);
  1397. if ( !this->
  1398. TriggerUsingHTTP(files, prefix,
  1399. this->CTest->GetCTestConfiguration("TriggerSite")))
  1400. {
  1401. cmCTestLog(this->CTest, ERROR_MESSAGE,
  1402. " Problems when triggering via HTTP" << std::endl);
  1403. ofs << " Problems when triggering via HTTP" << std::endl;
  1404. return -1;
  1405. }
  1406. }
  1407. if(this->HasErrors)
  1408. {
  1409. cmCTestLog(this->CTest, HANDLER_OUTPUT, " Errors occurred during "
  1410. "submission." << std::endl);
  1411. ofs << " Errors occurred during submission. " << std::endl;
  1412. }
  1413. else
  1414. {
  1415. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
  1416. " Submission successful" <<
  1417. (this->HasWarnings ? ", with warnings." : "") << std::endl,
  1418. this->Quiet);
  1419. ofs << " Submission successful" <<
  1420. (this->HasWarnings ? ", with warnings." : "") << std::endl;
  1421. }
  1422. return 0;
  1423. }
  1424. else if ( dropMethod == "xmlrpc" )
  1425. {
  1426. #if defined(CTEST_USE_XMLRPC)
  1427. ofs << "Using drop method: XML-RPC" << std::endl;
  1428. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
  1429. " Using XML-RPC submit method" << std::endl, this->Quiet);
  1430. std::string url = this->CTest->GetCTestConfiguration("DropSite");
  1431. prefix = this->CTest->GetCTestConfiguration("DropLocation");
  1432. if ( !this->SubmitUsingXMLRPC(buildDirectory + "/Testing/" +
  1433. this->CTest->GetCurrentTag(), files, prefix, url) )
  1434. {
  1435. cmCTestLog(this->CTest, ERROR_MESSAGE,
  1436. " Problems when submitting via XML-RPC" << std::endl);
  1437. ofs << " Problems when submitting via XML-RPC" << std::endl;
  1438. return -1;
  1439. }
  1440. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " Submission successful"
  1441. << std::endl, this->Quiet);
  1442. ofs << " Submission successful" << std::endl;
  1443. return 0;
  1444. #else
  1445. cmCTestLog(this->CTest, ERROR_MESSAGE,
  1446. " Submission method \"xmlrpc\" not compiled into CTest!"
  1447. << std::endl);
  1448. return -1;
  1449. #endif
  1450. }
  1451. else if ( dropMethod == "scp" )
  1452. {
  1453. std::string url;
  1454. std::string oldWorkingDirectory;
  1455. if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty())
  1456. {
  1457. url += this->CTest->GetCTestConfiguration("DropSiteUser") + "@";
  1458. }
  1459. url += this->CTest->GetCTestConfiguration("DropSite") + ":" +
  1460. this->CTest->GetCTestConfiguration("DropLocation");
  1461. // change to the build directory so that we can uses a relative path
  1462. // on windows since scp dosn't support "c:" a drive in the path
  1463. oldWorkingDirectory = cmSystemTools::GetCurrentWorkingDirectory();
  1464. cmSystemTools::ChangeDirectory(buildDirectory);
  1465. if ( !this->SubmitUsingSCP(
  1466. this->CTest->GetCTestConfiguration("ScpCommand"),
  1467. "Testing/"+this->CTest->GetCurrentTag(), files, prefix, url) )
  1468. {
  1469. cmSystemTools::ChangeDirectory(oldWorkingDirectory);
  1470. cmCTestLog(this->CTest, ERROR_MESSAGE,
  1471. " Problems when submitting via SCP"
  1472. << std::endl);
  1473. ofs << " Problems when submitting via SCP" << std::endl;
  1474. return -1;
  1475. }
  1476. cmSystemTools::ChangeDirectory(oldWorkingDirectory);
  1477. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " Submission successful"
  1478. << std::endl, this->Quiet);
  1479. ofs << " Submission successful" << std::endl;
  1480. return 0;
  1481. }
  1482. else if ( dropMethod == "cp" )
  1483. {
  1484. std::string location
  1485. = this->CTest->GetCTestConfiguration("DropLocation");
  1486. // change to the build directory so that we can uses a relative path
  1487. // on windows since scp dosn't support "c:" a drive in the path
  1488. std::string
  1489. oldWorkingDirectory = cmSystemTools::GetCurrentWorkingDirectory();
  1490. cmSystemTools::ChangeDirectory(buildDirectory);
  1491. cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
  1492. " Change directory: " << buildDirectory << std::endl, this->Quiet);
  1493. if ( !this->SubmitUsingCP(
  1494. "Testing/"+this->CTest->GetCurrentTag(),
  1495. files,
  1496. prefix,
  1497. location) )
  1498. {
  1499. cmSystemTools::ChangeDirectory(oldWorkingDirectory);
  1500. cmCTestLog(this->CTest, ERROR_MESSAGE,
  1501. " Problems when submitting via CP"
  1502. << std::endl);
  1503. ofs << " Problems when submitting via cp" << std::endl;
  1504. return -1;
  1505. }
  1506. cmSystemTools::ChangeDirectory(oldWorkingDirectory);
  1507. cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " Submission successful"
  1508. << std::endl, this->Quiet);
  1509. ofs << " Submission successful" << std::endl;
  1510. return 0;
  1511. }
  1512. cmCTestLog(this->CTest, ERROR_MESSAGE, " Unknown submission method: \""
  1513. << dropMethod << "\"" << std::endl);
  1514. return -1;
  1515. }
  1516. //----------------------------------------------------------------------------
  1517. std::string cmCTestSubmitHandler::GetSubmitResultsPrefix()
  1518. {
  1519. std::string buildname = cmCTest::SafeBuildIdField(
  1520. this->CTest->GetCTestConfiguration("BuildName"));
  1521. std::string name = this->CTest->GetCTestConfiguration("Site") +
  1522. "___" + buildname +
  1523. "___" + this->CTest->GetCurrentTag() + "-" +
  1524. this->CTest->GetTestModelString() + "___XML___";
  1525. return name;
  1526. }
  1527. //----------------------------------------------------------------------------
  1528. void cmCTestSubmitHandler::SelectParts(std::set<cmCTest::Part> const& parts)
  1529. {
  1530. // Check whether each part is selected.
  1531. for(cmCTest::Part p = cmCTest::PartStart;
  1532. p != cmCTest::PartCount; p = cmCTest::Part(p+1))
  1533. {
  1534. this->SubmitPart[p] =
  1535. (std::set<cmCTest::Part>::const_iterator(parts.find(p)) != parts.end());
  1536. }
  1537. }
  1538. //----------------------------------------------------------------------------
  1539. void cmCTestSubmitHandler::SelectFiles(cmCTest::SetOfStrings const& files)
  1540. {
  1541. this->Files.insert(files.begin(), files.end());
  1542. }