cmCTestSubmitHandler.cxx 55 KB

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