Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

550 lines
16 KiB

  1. #
  2. # created: 11/26/99, a-jbilas
  3. # modified:
  4. #
  5. if (!$__SPGBUILDPM ) { use spg::build; } #TODO: <- fix dependencies so only spg::env is needed
  6. if (!$__IITBVTPM ) { use iit::bvt; }
  7. if (!$__SPGBVTFILESPM ) { use spg::bvtfiles; }
  8. sub BeginBVTCustom
  9. {
  10. BEGIN_NON_CRITICAL_SECTION(); # don't output tons of errors to buildmsg
  11. Execute("kill tux.exe", 0, 0, 1);
  12. Execute("kill sapisvr.exe", 0, 0, 1);
  13. $sBVTResultsFile = "bvt".$sBuildNumber.".txt";
  14. EchoedUnlink($sBVTResultsFile);
  15. }
  16. sub EndBVTCustom()
  17. {
  18. my ($tmpStrBuildMsg) = $strBuildMsg;
  19. $strBuildMsg = "";
  20. my ($nBVTTotal) = 0;
  21. foreach $suite (keys(%hBVTTotal))
  22. {
  23. $nBVTTotal += %hBVTTotal->{$suite};
  24. }
  25. my ($nBVTPassed) = 0;
  26. my ($nBVTPassedPercent) = 0;
  27. foreach $suite (keys(%hBVTPass))
  28. {
  29. $nBVTPassed += %hBVTPass->{$suite};
  30. }
  31. my ($nBVTFailed) = 0;
  32. my ($nBVTFailedPercent) = 0;
  33. foreach $suite (keys(%hBVTFailed))
  34. {
  35. $nBVTFailed += %hBVTFailed->{$suite};
  36. }
  37. my ($nBVTKilled) = 0;
  38. my ($nBVTKilledPercent) = 0;
  39. foreach $suite (keys(%hBVTKilled))
  40. {
  41. $nBVTKilled += %hBVTKilled->{$suite};
  42. }
  43. my ($nBVTAborted) = 0;
  44. my ($nBVTAbortedPercent) = 0;
  45. foreach $suite (keys(%hBVTAborted))
  46. {
  47. $nBVTAborted += %hBVTAborted->{$suite};
  48. }
  49. my ($nBVTSkipped) = 0;
  50. my ($nBVTSkippedPercent) = 0;
  51. foreach $suite (keys(%hBVTSkipped))
  52. {
  53. $nBVTSkipped += %hBVTSkipped->{$suite};
  54. }
  55. if ($nBVTTotal != 0)
  56. {
  57. $nBVTPassedPercent = ($nBVTPassed * 100) / $nBVTTotal;
  58. $nBVTPassedPercent =~ s/(\.\d).*/$1/;
  59. $g_nBVTPassedPercent = $nBVTPassedPercent;
  60. $nBVTFailedPercent = ($nBVTFailed * 100) / $nBVTTotal;
  61. $nBVTFailedPercent =~ s/(\.\d).*/$1/;
  62. $nBVTKilledPercent = ($nBVTKilled * 100) / $nBVTTotal;
  63. $nBVTKilledPercent =~ s/(\.\d).*/$1/;
  64. $nBVTAbortedPercent = ($nBVTAborted * 100) / $nBVTTotal;
  65. $nBVTAbortedPercent =~ s/(\.\d).*/$1/;
  66. $nBVTSkippedPercent = ($nBVTSkipped * 100) / $nBVTTotal;
  67. $nBVTSkippedPercent =~ s/(\.\d).*/$1/;
  68. }
  69. $strBuildMsg .= "<! ".$sShortBuildName." ".$nScriptStartTime." SUMMARY ENTRY POINT >\n";
  70. PrintL("<! BEGIN TABLE SUMMARY >\n<table cellspacing=3 cellpadding=2 border=4>\n<tr>\n"
  71. ."<td><b>Total BVTs Passed</b></td>"
  72. ."<td bgcolor=".($nBVTPassedPercent > 60 ? "green" : "red").">",
  73. PL_MSG | PL_NOSTD);
  74. PrintLTip("<b>".$nBVTPassedPercent."%</b>", $nBVTPassed." of ".$nBVTTotal, PL_MSG | PL_NOSTD | PL_MSGCONCAT);
  75. PrintL("</td>"
  76. ."</tr>",
  77. PL_MSG | PL_NOSTD | PL_MSGCONCAT);
  78. if ($nBVTFailedPercent)
  79. {
  80. PrintL("<tr>"
  81. ."<td><b>Total BVTs Failed</b></td>"
  82. ."<td bgcolor=red>",
  83. PL_MSG | PL_NOSTD | PL_MSGCONCAT);
  84. PrintLTip("<b>".$nBVTFailedPercent."%</b>", $nBVTFailed." of ".$nBVTTotal, PL_MSG | PL_NOSTD | PL_MSGCONCAT);
  85. PrintL("</td>"
  86. ."</tr>",
  87. PL_MSG | PL_NOSTD | PL_MSGCONCAT);
  88. }
  89. if ($nBVTKilledPercent)
  90. {
  91. PrintL("<tr>"
  92. ."<td><b>Total BVTs Killed</b></td>"
  93. ."<td bgcolor=red>",
  94. PL_MSG | PL_NOSTD | PL_MSGCONCAT);
  95. PrintLTip("<b>".$nBVTKilledPercent."%</b>", $nBVTKilled." of ".$nBVTTotal, PL_MSG | PL_NOSTD | PL_MSGCONCAT);
  96. PrintL("</td>"
  97. ."</tr>",
  98. PL_MSG | PL_NOSTD | PL_MSGCONCAT);
  99. }
  100. if ($nBVTAbortedPercent)
  101. {
  102. PrintL("<tr>"
  103. ."<td><b>Total BVTs Aborted</b></td>"
  104. ."<td bgcolor=red>",
  105. PL_MSG | PL_NOSTD | PL_MSGCONCAT);
  106. PrintLTip("<b>".$nBVTAbortedPercent."%</b>", $nBVTAborted." of ".$nBVTTotal, PL_MSG | PL_NOSTD | PL_MSGCONCAT);
  107. PrintL("</td>"
  108. ."</tr>",
  109. PL_MSG | PL_NOSTD | PL_MSGCONCAT);
  110. }
  111. if ($nBVTSkippedPercent)
  112. {
  113. PrintL("<tr>"
  114. ."<td><b>Total BVTs Skipped</b></td>"
  115. ."<td bgcolor=red>",
  116. PL_MSG | PL_NOSTD | PL_MSGCONCAT);
  117. PrintLTip("<b>".$nBVTSkippedPercent."%</b>", $nBVTSkipped." of ".$nBVTTotal, PL_MSG | PL_NOSTD | PL_MSGCONCAT);
  118. PrintL("</td>"
  119. ."</tr>",
  120. PL_MSG | PL_NOSTD | PL_MSGCONCAT);
  121. }
  122. PrintL("</table>\n<! END TABLE SUMMARY >\n<BR>", PL_MSG | PL_NOSTD | PL_MSGCONCAT);
  123. $strBuildMsg .= $tmpStrBuildMsg;
  124. if (IsMemberOf("FAILMAIL", @lArgs))
  125. {
  126. foreach $alias (keys(%hMailText))
  127. {
  128. PrintL(" - Sending BVT breakage mail to ".($bOfficialBuild ? $alias : $USERNAME)."\n", PL_BLUE);
  129. %hMailText->{$alias} =~ s/\n/<BR>\n/g;
  130. SendHtmlMail(($bOfficialBuild ? $alias : $USERNAME),
  131. "SAPI5 ".$sBuildNumber." BVT Failure Notification (user ".$alias.")",
  132. "<BR><BR><h3>The following BVT errors were encountered during the nightly build :</h3>"
  133. .'<a href="'.TranslateToHTTP($sDropDir."\\release\\bvt\\".PROC."\\bvtresults".$sBuildNumber.".txt").'">'
  134. ."(view full Tux log)</a><BR><BR>\n".%hMailText->{$alias});
  135. }
  136. }
  137. if ($bOfficialBuild && !$bNoCopy)
  138. {
  139. EchoedMkdir($sDropDir."\\release\\bvt\\".PROC);
  140. EchoedCopy($sBVTResultsFile, $sDropDir."\\release\\bvt\\".PROC."\\bvtresults".$sBuildNumber.".txt");
  141. }
  142. END_NON_CRITICAL_SECTION();
  143. }
  144. sub ParseTuxFile
  145. {
  146. my ($bTestArea);
  147. my ($sDLLName);
  148. my (@lTests);
  149. my ($fhTuxFile) = OpenFile($_[0], "r");
  150. while ($fhTuxFile && !$fhTuxFile->eof())
  151. {
  152. my ($curline) = $fhTuxFile->getline();
  153. if ($curline =~ /\.dll$/)
  154. {
  155. chomp($curline);
  156. $curline =~ s/^[^=]*=//;
  157. $sDLLName = $curline;
  158. if (lc($SAPIROOT) ne "d:\\sapi5")
  159. {
  160. $sDLLName =~ s/d:\\sapi5/$SAPIROOT/;
  161. }
  162. }
  163. elsif ($curline =~ /^\[Tests\]/)
  164. {
  165. $bTestArea = 1;
  166. }
  167. elsif ($bTestArea && ($curline =~ /^\[/))
  168. {
  169. $bTestArea = 0;
  170. }
  171. elsif ($bTestArea)
  172. {
  173. chomp($curline);
  174. $curline =~ s/^[^,]*,//;
  175. if ($curline ne "")
  176. {
  177. push(@lTests, $curline);
  178. }
  179. }
  180. }
  181. CloseFile($fhTuxFile);
  182. return($sDLLName, \@lTests);
  183. }
  184. # in:
  185. # [str] dll name
  186. # [str] test number
  187. # [str] log file
  188. sub RunTux($$$)
  189. {
  190. my($pTux) = SpawnProcess(cwd()."\\tux.exe", "-d ".$_[0]." -x ".$_[1]." -f ".$_[2]);
  191. if ($pTux)
  192. {
  193. $pTux->Wait($nTuxTimeout * 1000);
  194. if (IsProcessRunning($pTux))
  195. {
  196. $pTux->Kill(1);
  197. Execute("kill tux.exe", 0, 0, 1);
  198. Execute("kill sapisvr.exe", 0, 0, 1);
  199. use integer;
  200. PrintL($bvt." BVT still running after ".($nTuxTimeout)." seconds, killed\n\n", PL_RED | PL_BOLD);
  201. return(-1);
  202. }
  203. return(1);
  204. }
  205. else
  206. {
  207. PrintL("Couldn't run tux.exe for ".$bvt." (fail)\n", PL_ERROR);
  208. return(0);
  209. }
  210. }
  211. sub ParseTuxLog($)
  212. {
  213. my ($nPassed, $nTotal);
  214. my (%hFailed, %hSkipped, %hAborted);
  215. my (%hTestText);
  216. my ($sTestText, $sTestID, $sTestName);
  217. my ($bTestFailed, $bInGroup);
  218. my ($fhLog) = OpenFile($_[0], "r");
  219. while ($fhLog && !$fhLog->eof())
  220. {
  221. my ($sCurText) = $fhLog->getline();
  222. if ($sCurText =~ /^BEGIN GROUP/)
  223. {
  224. $bInGroup = 1;
  225. }
  226. elsif ($sCurText =~ /^END GROUP/)
  227. {
  228. $bInGroup = 0;
  229. %hTestText->{$sTestID} = $sTestText;
  230. $sTestText = "";
  231. $sTestID = "";
  232. $sTestName = "";
  233. $bTestFailed = 0;
  234. }
  235. elsif ($bInGroup)
  236. {
  237. if ($sCurText =~ /^\*\*\* Result:\s+/)
  238. {
  239. if ($sCurText =~ /Aborted/)
  240. {
  241. PrintL("Test ".$sTestName." Aborted\n\n", PL_RED | PL_BOLD);
  242. %hAborted->{$sTestID} = $sTestName;
  243. }
  244. elsif ($sCurText =~ /Failed/)
  245. {
  246. PrintL("Test ".$sTestName." Failed\n\n", PL_RED | PL_BOLD);
  247. %hFailed->{$sTestID} = $sTestName;
  248. }
  249. elsif ($sCurText =~ /Skipped/)
  250. {
  251. PrintL("Test ".$sTestName." Skipped\n\n", PL_RED | PL_BOLD);
  252. %hSkipped->{$sTestID} = $sTestName;
  253. }
  254. elsif ($sCurText =~ /Passed/)
  255. {
  256. PrintL("Test ".$sTestName." Passed\n\n", PL_GREEN | PL_BOLD);
  257. ++$nPassed;
  258. }
  259. ++$nTotal;
  260. }
  261. elsif ($sCurText =~ /^\*\*\* Test Name:/)
  262. {
  263. $sTestName = $sCurText;
  264. $sTestName =~ s/^\*\*\* Test Name:\s*//;
  265. chomp($sTestName);
  266. }
  267. elsif ($sCurText =~ /^\*\*\* Test ID:/)
  268. {
  269. $sTestID = $sCurText;
  270. $sTestID =~ s/^\*\*\* Test ID:\s*//;
  271. chomp($sTestID);
  272. }
  273. $sTestText .= $sCurText;
  274. }
  275. }
  276. CloseFile($fhLog);
  277. return($nPassed, $nTotal, \%hSkipped, \%hFailed, \%hAborted, \%hTestText);
  278. }
  279. sub DoTuxSuite($)
  280. {
  281. my ($sDLLName, $plTests) = ParseTuxFile($_[0].".tux");
  282. my ($nSuitePassed, $nSuiteTotal);
  283. my (@lSuiteKilled, %hSuiteFailed, %hSuiteSkipped, %hSuiteAborted);
  284. my (%hMailText, %hTestText);
  285. my ($sSuiteBVTLog) = $_[0]."results.txt";
  286. unlink($sSuiteBVTLog);
  287. foreach $test (@{$plTests})
  288. {
  289. my ($sSingleBVTLog) = "temp".$test.".txt";
  290. unlink($sSingleBVTLog);
  291. my ($tuxcode) = RunTux($sDLLName, $test, $sSingleBVTLog);
  292. if ($tuxcode == -1)
  293. {
  294. push(@lSuiteKilled, $test);
  295. ++$nSuiteTotal;
  296. }
  297. elsif ($tuxcode == 0)
  298. {
  299. %hSuiteSkipped->{$test} = "<unknown>";
  300. ++$nSuiteTotal;
  301. }
  302. else
  303. {
  304. my ($nPassed, $nTotal, $phSkipped, $phFailed, $phAborted, $phTestText) = ParseTuxLog($sSingleBVTLog);
  305. foreach $key (keys(%{$phFailed}))
  306. {
  307. %hSuiteFailed->{$key} = $phFailed->{$key};
  308. }
  309. foreach $key (keys(%{$phSkipped}))
  310. {
  311. %hSuiteSkipped->{$key} = $phSkipped->{$key};
  312. }
  313. foreach $key (keys(%{$phAborted}))
  314. {
  315. %hSuiteAborted->{$key} = $phAborted->{$key};
  316. }
  317. $nSuitePassed += $nPassed;
  318. $nSuiteTotal += $nTotal;
  319. foreach $test (keys(%{$phTestText}))
  320. {
  321. %hTestText->{$test} = $phTestText->{$test};
  322. PrintToFile($sSuiteBVTLog, %hTestText->{$test}."\n");
  323. }
  324. }
  325. unlink($sSingleBVTLog);
  326. }
  327. my (%hNull) = ();
  328. my ($phMailList) = \%hNull;
  329. if (-e $_[0].".txt")
  330. {
  331. $phMailList = GetBVTContacts($_[0]);
  332. }
  333. foreach $test (keys(%hSuiteFailed), keys(%hSuiteAborted), keys(%hSuiteSkipped))
  334. {
  335. if (scalar($phMailList->{$test}))
  336. {
  337. foreach $alias (@{$phMailList->{$test}})
  338. {
  339. %hMailText->{$alias} .= "\n<B>Test #".$test.", ".$_[0]." FAILED :</B>\n\n"
  340. .%hTestText->{$test}."\n\n";
  341. }
  342. }
  343. else
  344. {
  345. %hMailText->{"sapitest"} .= "\n<B>Test #".$test.", ".$_[0]." FAILED :</B>\n\n"
  346. .%hTestText->{$test}."\n\n";
  347. }
  348. }
  349. if (scalar(keys(%hSuiteFailed)))
  350. {
  351. PrintL("Warning : Failed Tests : ", PL_SETERROR | PL_MSGCONCAT);
  352. my ($bComma) = 0;
  353. foreach $key (keys(%hSuiteFailed))
  354. {
  355. PrintLTip(($bComma ? ", " : "").$key, %hSuiteFailed->{$key}, PL_SETERROR | PL_MSGCONCAT);
  356. $bComma = 1;
  357. }
  358. PrintL("\n", PL_SETERROR | PL_MSGCONCAT);
  359. }
  360. if (scalar(keys(%hSuiteSkipped)))
  361. {
  362. PrintL("Warning : Skipped Tests : ", PL_SETERROR | PL_MSGCONCAT);
  363. my ($bComma) = 0;
  364. foreach $key (keys(%hSuiteSkipped))
  365. {
  366. PrintLTip(($bComma ? ", " : "").$key, %hSuiteSkipped->{$key}, PL_SETERROR | PL_MSGCONCAT);
  367. $bComma = 1;
  368. }
  369. PrintL("\n", PL_SETERROR | PL_MSGCONCAT);
  370. }
  371. if (scalar(keys(%hSuiteAborted)))
  372. {
  373. PrintL("Warning : Aborted Tests : ", PL_SETERROR | PL_MSGCONCAT);
  374. my ($bComma) = 0;
  375. foreach $key (keys(%hSuiteAborted))
  376. {
  377. PrintLTip(($bComma ? ", " : "").$key, %hSuiteAborted->{$key}, PL_SETERROR | PL_MSGCONCAT);
  378. $bComma = 1;
  379. }
  380. PrintL("\n", PL_SETERROR | PL_MSGCONCAT);
  381. }
  382. if (scalar(@lSuiteKilled))
  383. {
  384. PrintL("Warning : Killed Tests : ".join(", ", @lSuiteKilled)."\n", PL_SETERROR);
  385. }
  386. my ($nSuitePercent) = 0;
  387. if ($nSuiteTotal != 0)
  388. {
  389. use integer;
  390. $nSuitePercent = ($nSuitePassed * 100) / $nSuiteTotal;
  391. }
  392. PrintLTip("Percent Passed : ".$nSuitePercent."%", $nSuitePassed." of ".$nSuiteTotal, PL_SETERROR);
  393. PrintL("\n", PL_SETERROR);
  394. return($nSuitePassed, $nSuiteTotal, \@lSuiteKilled, \%hSuiteFailed, \%hSuiteSkipped, \%hSuiteAborted, \%hMailText);
  395. }
  396. sub GetBVTContacts
  397. {
  398. my (%hRet) = ();
  399. my ($fhContacts) = OpenFile($_[0].".txt", "r");
  400. while ($fhContacts && !$fhContacts->eof())
  401. {
  402. my ($contline) = $fhContacts->getline();
  403. chomp($contline);
  404. my ($test, $contacts) = split(":", $contline, 2);
  405. if ($contacts ne "")
  406. {
  407. %hRet->{$test} = [split(",", $contacts)];
  408. }
  409. }
  410. CloseFile($fhContacts);
  411. return(\%hRet);
  412. }
  413. sub TallyTuxResults
  414. {
  415. my ($sBVTName, $nSuitePassed, $nSuiteTotal, $plSuiteKilled, $phSuiteFailed, $phSuiteSkipped, $phSuiteAborted, $phMailText) = @_;
  416. %hBVTPass->{$sBVTName} = $nSuitePassed;
  417. %hBVTTotal->{$sBVTName} = $nSuiteTotal;
  418. %hBVTFailed->{$sBVTName} = scalar(keys(%{$phSuiteFailed}));
  419. %hBVTKilled->{$sBVTName} = scalar(@{$plSuiteKilled});
  420. %hBVTAborted->{$sBVTName} = scalar(keys(%{$phSuiteAborted}));
  421. %hBVTSkipped->{$sBVTName} = scalar(keys(%{$phSuiteSkipped}));
  422. foreach $alias (keys(%{$phMailText}))
  423. {
  424. %hMailText->{$alias} .= $phMailText->{$alias};
  425. }
  426. if (-e $sBVTResultsFile)
  427. {
  428. Append($sBVTResultsFile, $sBVTName."results.txt");
  429. }
  430. else
  431. {
  432. EchoedCopy($sBVTName."results.txt", $sBVTResultsFile);
  433. }
  434. return($nSuitePassed > 0);
  435. }
  436. sub RunBVTTTS
  437. {
  438. return(TallyTuxResults("ttssapibvt", DoTuxSuite("ttssapibvt")));
  439. }
  440. sub RunBVTSR
  441. {
  442. return(TallyTuxResults("srsapibvt", DoTuxSuite("srsapibvt")));
  443. }
  444. sub RunBVTSHSR
  445. {
  446. return(TallyTuxResults("shsrsapibvt", DoTuxSuite("shsrsapibvt")));
  447. }
  448. sub RunBVTLex
  449. {
  450. return(TallyTuxResults("lexsapibvt", DoTuxSuite("lexsapibvt")));
  451. }
  452. sub RunBVTRM
  453. {
  454. return(TallyTuxResults("rmsapibvt", DoTuxSuite("rmsapibvt")));
  455. }
  456. sub RunBVTGramComp
  457. {
  458. return(TallyTuxResults("gramcompbvt", DoTuxSuite("gramcompbvt")));
  459. }
  460. sub RunBVTCFGENG
  461. {
  462. return(TallyTuxResults("cfgengbvt", DoTuxSuite("cfgengbvt")));
  463. }
  464. sub RunBVTAM
  465. {
  466. return(TallyTuxResults("amsapibvt", DoTuxSuite("amsapibvt")));
  467. }
  468. sub RunBVTSRENG
  469. {
  470. return(TallyTuxResults("srengbvt", DoTuxSuite("srengbvt")));
  471. }
  472. sub RunBVTSDK
  473. {
  474. EchoedUnlink("sdkbvt.ini");
  475. PrintL(" - Generating new sdkbvt.ini\n", PL_BLUE);
  476. PrintToFile("sdkbvt.ini",
  477. "CLID = {BD04FA51-7F95-47DF-8CBA-01BA0ECD4ED1}".
  478. "LogLocation = \\BVT\\".
  479. "BuildNum = ".$sBVTBuildNumber.
  480. "VersionYear = 1999".
  481. "Product = SAPI 5.0".
  482. "DefaultLocation = \\\\b11nlbuilds\\sapi5\\");
  483. return(Execute("mtrun sdkbvt.pc6"));
  484. }
  485. $__SPGBVTPM = 1;
  486. 1;