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.

540 lines
16 KiB

  1. #
  2. # created: 5/4/99, a-jbilas
  3. # modified:
  4. #
  5. if (!$__IITBUILDPM ) { use iit::build; } #TODO: <- fix dependencies so only iit::env is needed
  6. use Win32::OLE;
  7. ####################################################################################
  8. # BeginBVT()
  9. # Performs startup tasks for beginning a BVT script
  10. # a-jbilas, 06/09/99 - created
  11. ####################################################################################
  12. sub BeginBVT
  13. {
  14. # our way of doing set local (reset at EndBuild())
  15. $sOldPath = $PATH;
  16. $sOldInclude = $INCLUDE;
  17. $sOldLib = $LIB;
  18. # combine all parameters into one big list of allowed arguments
  19. push(@lAllowedArgs, @lAllowedModifiers);
  20. push(@lAllowedArgs, @lAllowedLanguages);
  21. push(@lAllowedArgs, @lAllowedBuilds);
  22. push(@lAllowedArgs, @lAllowedComponents);
  23. # parse the args and put the results in @lArgs (ParseArgs also sets $sBVTBuildNumber automagically)
  24. BuildAcceleratorLists();
  25. @lArgs = ParseArgs(@_);
  26. # much of this stuff is duplicated from BeginBuild() (which we can't use because it does too
  27. # many build specific routines)
  28. $bNoCopy = IsMemberOf("NOCOPY", @lArgs);
  29. $nTimePasses = 10; # if TIME param passed, the average of this number of passes will be recorded
  30. $bErrorConcat = 1; # activate manual error handling
  31. $strBuildMsg .= "<! ".$sShortBuildName." ".$nScriptStartTime." SUMMARY ENTRY POINT >\n";
  32. if (IsMemberOf("VERBOSE", @lArgs))
  33. {
  34. $DEBUG = 1; #TODO: change all refs to this flag to $bVerbose
  35. $bVerbose = 1;
  36. }
  37. $bLocal = IsMemberOf("LOCAL", @lArgs);
  38. # buildnumber was set by SetLocalGlobalsAndBegin() and/or ParseArgs()
  39. if ($sBuildNumber eq "0000")
  40. {
  41. PrintL("\nNo build number specified, assuming today's build\n", PL_NOLOG);
  42. $sBuildNumber = GetBuildNumber();
  43. }
  44. if (lc($USERNAME) eq $sOfficialBuildAccount || IsMemberOf("OFFICIAL", @lArgs))
  45. {
  46. $bOfficialBuild = 1;
  47. $sDropDir =~ s/\\0000\\/\\$sBuildNumber\\/; #set the drop dir location for official build
  48. $sLogDropDir =~ s/0000/$sBuildNumber/; #set the drop dir location for official build
  49. $sRemoteBuildLog =~ s/0000/$sBuildNumber/; #set the log name for official build
  50. $sBuildLog =~ s/0000/$sBuildNumber/; #set the log name for official build
  51. if (!IsMemberOf(@lArgs, "QUIET") && IsMemberOf(@lAllowedArgs, "QUIET"))
  52. {
  53. push(@lArgs, "QUIET");
  54. }
  55. }
  56. else
  57. {
  58. $bOfficialBuild = 0;
  59. $sDropDir =~ s/$sRootDropDir/$sTestRootDropDir/;
  60. $sLogDropDir = $sLogDir;
  61. $sRemoteBuildLog = $sBuildLog;
  62. $sRootDropDir = $sTestRootDropDir;
  63. }
  64. @lModifiers = Intersect(*lAllowedModifiers, *lArgs);
  65. # intersect the @lArgs with each 'Allowed' list to categorize the parameters we need to support
  66. if (IsMemberOf("ALLCOMP", @lModifiers))
  67. {
  68. @lComponents = @lAllowedComponents;
  69. }
  70. else
  71. {
  72. @lComponents = Intersect(*lAllowedComponents, *lArgs);
  73. if (@lComponents == ())
  74. {
  75. PrintL("\nNo build types specified, assuming $lAllowedComponents[0] component\n");
  76. @lComponents = ($lAllowedComponents[0]);
  77. }
  78. }
  79. @lBuilds = Intersect(*lAllowedBuilds, *lArgs);
  80. if (@lBuilds == ())
  81. {
  82. PrintL("\nNo build types specified, assuming $lAllowedBuilds[0] buildtype\n");
  83. @lBuilds = ($lAllowedBuilds[0]);
  84. }
  85. if (IsMemberOf("ALLLANG", @lModifiers))
  86. {
  87. @lLanguages = @lAllowedLanguages;
  88. }
  89. else
  90. {
  91. @lLanguages = Intersect(*lAllowedLanguages, *lArgs);
  92. if (@lLanguages == () && (@lAllowedLanguages != ()))
  93. {
  94. PrintL("\nNo languages specified, assuming ".$shtolonglang{lc($lAllowedLanguages[0])}." language\n");
  95. @lLanguages = ($lAllowedLanguages[0]);
  96. }
  97. }
  98. # open the log file
  99. # the BVT log name contains the build number (so that multiple builds may be run from the same directory)
  100. # leave the BVT log in the current working directory
  101. EchoedUnlink($sMailfile, $sVarsLog, $sTyposLog, $sSyncLog, $sUpdateLog, $sBuildLog);
  102. $fhBuildLog = StartLog($sBuildLog, 1, ($bOfficialBuild && $bWin98));
  103. OutputHeader($nLoggingMode);
  104. if (defined &BeginBVTCustom)
  105. {
  106. return(BeginBVTCustom() && $rc);
  107. }
  108. else
  109. {
  110. return($rc);
  111. }
  112. }
  113. ####################################################################################
  114. # EndBVT()
  115. # Performs cleanup tasks for ending a BVT script
  116. # a-jbilas, 06/09/99 - created
  117. ####################################################################################
  118. sub EndBVT()
  119. {
  120. if (defined &EndBVTCustom)
  121. {
  122. EndBVTCustom();
  123. }
  124. OutputFooter($nLoggingMode);
  125. $strBuildMsg .= "<\/body>";
  126. if ($nBVTFailureCount)
  127. {
  128. print("\nOne or more BVTs failed\n");
  129. }
  130. else
  131. {
  132. print("\nAll BVTs PASS!\n");
  133. }
  134. $fhMailFile = OpenFile($sMailfile, "write");
  135. if ($fhMailFile)
  136. {
  137. my($tmpBuildMsg) = $strBuildMsg;
  138. my($replStr) = "<BR><BR><b><font size=5>".$sBuildName." ".BuildCodeToHTML($bcStatus)."<\/b>".
  139. " - <a href=\"".TranslateToHTTP($sRemoteBuildLog)."\">Log<\/a><\/font><BR><BR>";
  140. $strBuildMsg =~ s/<\! $sShortBuildName $nScriptStartTime SUMMARY ENTRY POINT >/$replStr/;
  141. $fhMailFile->print($strBuildMsg);
  142. CloseFile($fhMailFile);
  143. $strBuildMsg = $tmpBuildMsg;
  144. }
  145. CloseFile($fhBuildLog);
  146. if ($nLoggingMode == 2)
  147. {
  148. InsertSummaryIntoLog($sBuildLog);
  149. }
  150. if (!$bNoCopy && ($sRemoteBuildLog ne "") & $bOfficialBuild)
  151. {
  152. if (!CopyLogs())
  153. {
  154. PrintL("Warning: ".$sShortBuildName." log failed to copy\n", PL_MSGONLY);
  155. }
  156. }
  157. if (!$bOfficialBuild && !IsMemberOf("QUIET", @lArgs))
  158. {
  159. PrintL("\n - Launching BVT log (use 'QUIET' option next time to skip)\n");
  160. Execute($sBuildLog);
  161. PrintL("\n");
  162. }
  163. }
  164. sub StartLog($;$$)
  165. {
  166. my($logname, $useDHTML, $updateTOC) = @_;
  167. $fhNewLog = OpenFile($_[0], "write");
  168. if (!$fhNewLog)
  169. {
  170. PrintL("Could not open ".$logname.", logging for this session will be disabled\n\n", PL_BIGERROR);
  171. return("");
  172. }
  173. elsif ($useDHTML)
  174. {
  175. $fhNewLog->print(GetAllTextFromFile($sDHTMLIncFile)."\n\n<html>\n");
  176. if ($strBuildMsg !~ /<! DHTML ACTIVATION SCRIPT >/)
  177. {
  178. PrintL("<! DHTML ACTIVATION SCRIPT >".GetAllTextFromFile($sDHTMLIncFile)
  179. ."<! END DHTML ACTIVATION SCRIPT >", PL_MSGONLY);
  180. }
  181. $bDHTMLActive = 1;
  182. if ($_[2])
  183. {
  184. UpdateLogTOC($sRemoteTOC, $sBuildLog);
  185. }
  186. }
  187. return($fhNewLog);
  188. }
  189. ####################################################################################
  190. # DoBVTs()
  191. # Do the BVTs
  192. # a-jbilas, 06/09/99 - created
  193. ####################################################################################
  194. sub DoBVTs
  195. {
  196. # define and categorize all supported parameters
  197. # each category must have at least one option selected to run a BVT (except @lAllowedModifiers and @lAllowedLanguages))
  198. SetBVTDependentVars(); # we really shouldn't be calling this yet, but we need to init the component list
  199. foreach $component (keys(%hStandardBVTs))
  200. {
  201. push(@lAllowedComponents, $component);
  202. }
  203. %hOptionDescription = (%hOptionDescription,
  204. # <----------------------------- SCREEN WIDTH ------------------------------------->
  205. ("Local" => " get files from local SLM project"),
  206. ("SMoke" => " include smoketests - smoketests failures will not fail runbvt"),
  207. ("SMokeOnly" => "run only smoketests - smoketests failures will fail runbvt"));
  208. $sBuildName = "BVT";
  209. $nBVTFailureCount = 0;
  210. $sExcelPerfDoc = $sLogDropDir."\\performance\\".$sShortBuildName."perf.xls";
  211. $sExcelPerfDocWWW = $sLogDropDir."\\performance\\".$sShortBuildName."perf.recorded.xls";
  212. local($bLocal) = 0; # use local copies of files (see hash table above)
  213. BeginBVT(@_);
  214. if (@lLanguages == ())
  215. {
  216. @lLanguages = ("");
  217. }
  218. # run the BVTs
  219. foreach $language (@lLanguages)
  220. {
  221. foreach $component (@lComponents)
  222. {
  223. foreach $buildType (@lBuilds)
  224. {
  225. my($bBVTRC) = 1;
  226. if (!IsMemberOf("SMOKEONLY", @lArgs))
  227. {
  228. $bBVTRC = RunBVTSingle(\%hStandardBVTs, $component, $shtolonglang{lc($language)}, $buildType);
  229. }
  230. if (($bBVTRC && IsMemberOf("SMOKE", @lArgs)) || IsMemberOf("SMOKEONLY", @lArgs))
  231. {
  232. my($ret) = RunBVTSingle(\%hSmokeBVTs, $component, $shtolonglang{lc($language)}, $buildType);
  233. if (!$ret && IsMemberOf("SMOKEONLY", @lArgs))
  234. {
  235. $bBVTRC = 0;
  236. }
  237. }
  238. if (!$bBVTRC)
  239. {
  240. $bcStatus |= BC_FAILED;
  241. }
  242. }
  243. }
  244. }
  245. EndBVT();
  246. return(!($bcStatus & BC_FAILED));
  247. }
  248. sub RunBVTSingle
  249. {
  250. # shared 'global' variables between build functions
  251. local($hConfig, $sBVTComponent, $sBVTLanguage, $sBVTType) = @_;
  252. local($sBVTBuildNumber) = $sBuildNumber;
  253. local($bCopyFailed) = 0;
  254. local($nDiffNumber) = 0;
  255. local($rc) = 1;
  256. local($sShBVTLanguage) = $longtoshlang{lc($sBVTLanguage)};
  257. local(@lNeededFiles) = (); #files that are needed to run BVT
  258. local(@lCopiedFiles) = (); #needed files that were copied to run BVT
  259. ResetError(); # reset the error buffer
  260. $strLanguage = $sShBVTLanguage; # BVTCompare() support
  261. if ($sBVTBuildNumber eq GetBuildNumber())
  262. {
  263. $sBVTBuildNumber = GetBuildNumber($hConfig->{$sBVTComponent}->{"BuildStartYear"});
  264. }
  265. SetBVTDependentVars();
  266. # just to make refs a bit less painful (for new refs: hComponent->{"Element"})
  267. local(*hComponent) = $hConfig->{$sBVTComponent};
  268. $sDropDir = hComponent->{"RemoteSrcDir"};
  269. # check to see if we should attempt to run the BVT
  270. if ($hConfig->{$sBVTComponent} eq "")
  271. {
  272. PrintL("Component does not exist: ".$sBVTComponent, PL_VERBOSE);
  273. return(1);
  274. }
  275. if ((!IsMemberOf($sShBVTLanguage, split(/ +/, hComponent->{"Languages"}))) && (split(/ +/, hComponent->{"Languages"}) != ()))
  276. {
  277. PrintL("\nLanguage ".$sBVTLanguage." not supported for component ".hComponent->{"Name"}." skipping BVT\n\n", PL_VERBOSE);
  278. return(1); # do not error
  279. }
  280. if (!$bLocal && !$bNoCopy && ($sDropDir ne "") && !IsDirectory($sDropDir))
  281. {
  282. PrintL(hComponent->{"Name"}." ".$sBVTLanguage." ".$sBVTType." build #".$sBVTBuildNumber
  283. ." does not exist on server, cannot process BVT\n", PL_BIGWARNING);
  284. PrintMsgBlock($sDropDir." does not exist\n");
  285. return(1); # new behavior (06/99) -> don't fail the bvt if not exist (sometimes we don't build on purpose)
  286. }
  287. PrintL("\n".hComponent->{"Name"}." BVT (".$sBVTLanguage." ".$sBVTType.", Build #".$sBVTBuildNumber.
  288. ($bLocal ? " *LOCAL*" : "").")\n", PL_SUBHEADER);
  289. PrintL(("-" x 80)."\n\n", PL_SUBHEADER);
  290. BEGIN_DHTML_NODE("(click to expand)");
  291. $bNothingDone = 0; # (we're starting to do stuff)
  292. if ($bcStatus & BC_NOTHINGDONE)
  293. {
  294. $bcStatus -= BC_NOTHINGDONE;
  295. }
  296. # ************************* COPY PHASE *************************
  297. # build a list of our current component's needed files
  298. my($rc) = 1;
  299. if ($bLocal && !$bNoCopy)
  300. {
  301. foreach $file (split(/ +/, hComponent->{"LocalInputFiles"}))
  302. {
  303. push(@lNeededFiles, $PROJROOT."\\".$file);
  304. }
  305. foreach $file (split(/ +/, hComponent->{"SLMInputFiles"}))
  306. {
  307. push(@lNeededFiles, $PROJROOT."\\".$file);
  308. }
  309. foreach $file (split(/ +/, hComponent->{"ExternalFiles"}))
  310. {
  311. push(@lNeededFiles, $file);
  312. }
  313. foreach $file (@lNeededFiles)
  314. {
  315. # if the file is already there, use the existing one; if not, copy and remember it
  316. # so that we can delete it later
  317. if (!-e RemovePath($file))
  318. {
  319. $rc = EchoedCopy($file) && $rc;
  320. SetReadOnly(RemovePath($file), 0);
  321. push(@lCopiedFiles, $file);
  322. }
  323. else
  324. {
  325. PrintL("Using local copy of ".RemovePath($file)." (delete to run clean BVT)\n", PL_WARNING);
  326. }
  327. }
  328. }
  329. elsif (!$bNoCopy)
  330. {
  331. foreach $file (split(/ +/, hComponent->{"RemoteInputFiles"}))
  332. {
  333. push(@lNeededFiles, hComponent->{"RemoteSrcDir"}."\\".$file);
  334. }
  335. foreach $file (split(/ +/, hComponent->{"SLMInputFiles"}))
  336. {
  337. if (-e $sArchivedSrcDir."\\".$sBVTBuildNumber."\\".$file)
  338. {
  339. push(@lNeededFiles, $sArchivedSrcDir."\\".$sBVTBuildNumber."\\".$file);
  340. }
  341. else
  342. {
  343. push(@lNeededFiles, $sSLMServerRoot."\\".$file);
  344. }
  345. }
  346. foreach $file (split(/ +/, hComponent->{"ExternalFiles"}))
  347. {
  348. push(@lNeededFiles, $file);
  349. }
  350. foreach $file (@lNeededFiles)
  351. {
  352. if (!-e RemovePath($file))
  353. {
  354. $rc = EchoedCopy($file) && $rc;
  355. SetReadOnly(RemovePath($file), 0);
  356. push(@lCopiedFiles, $file);
  357. }
  358. else
  359. {
  360. PrintL("Warning: Using local copy of ".$file." (delete to run clean BVT)\n", PL_WARNING);
  361. }
  362. }
  363. }
  364. # ************************* BVT-EXECUTION PHASE *************************
  365. my $startTime = time();
  366. if ($rc)
  367. {
  368. foreach $component (keys(%$hConfig))
  369. {
  370. if ($sBVTComponent eq $component)
  371. {
  372. local(*BVTFunction) = hComponent->{"Function"};
  373. $rc = BVTFunction();
  374. }
  375. }
  376. }
  377. my($bvtTime) = FmtDeltaTime(time() - $startTime);
  378. if (!$rc)
  379. {
  380. ++$nBVTFailureCount;
  381. }
  382. # backup failed BVT files in subdir for future reference
  383. if (!$rc && !$bNoCopy)
  384. {
  385. PrintL("\n".'BVT failed, saving BVT failure src files in '.cwd().'\BVTFail'.$nBVTFailureCount."\n\n", PL_ERROR);
  386. Delnode('BVTFail'.$nBVTFailureCount);
  387. EchoedMkdir('BVTFail'.$nBVTFailureCount);
  388. foreach $file (@lNeededFiles)
  389. {
  390. if (-e RemovePath($file))
  391. {
  392. EchoedCopy(RemovePath($file), 'BVTFail'.$nBVTFailureCount."\\".RemovePath($file));
  393. }
  394. else
  395. {
  396. PrintL("Warning: ".RemovePath($file)." in \@lNeededFiles does not exist, clean up your list\n",
  397. PL_WARNING | PL_VERBOSE);
  398. }
  399. }
  400. foreach $file (split(/ +/, hComponent->{"OutputFiles"}))
  401. {
  402. if (-e RemovePath($file))
  403. {
  404. EchoedCopy(RemovePath($file), 'BVTFail'.$nBVTFailureCount."\\".RemovePath($file));
  405. }
  406. else
  407. {
  408. PrintL("Warning: ".RemovePath($file)." in \"OutputFiles\" does not exist, clean up your list\n",
  409. PL_WARNING | PL_VERBOSE);
  410. }
  411. }
  412. }
  413. # ************************* CLEAN-UP PHASE *************************
  414. if (!$bNoCopy)
  415. {
  416. foreach $file (@lCopiedFiles)
  417. {
  418. if (RemovePath($file) !~ /(\\|\/)/i) # just to make sure (we don't want to delete anything off the servers)
  419. {
  420. EchoedUnlink(RemovePath($file));
  421. }
  422. }
  423. foreach $file (split(/ +/, hComponent->{"OutputFiles"}))
  424. {
  425. EchoedUnlink($file);
  426. }
  427. }
  428. END_DHTML_NODE();
  429. PrintL("\n");
  430. if ($rc)
  431. {
  432. PrintLTip($sBVTLanguage." ".hComponent->{"Name"}." ".ucfirst(lc($sBVTType))." BVT Succeeded\n\n",
  433. "BVT Execution Time: ".$bvtTime,
  434. PL_MSG | PL_GREEN | PL_FLUSH);
  435. if ($ERROR ne "")
  436. {
  437. PrintMsgBlock($ERROR);
  438. }
  439. }
  440. else
  441. {
  442. PrintLTip($sBVTLanguage." ".hComponent->{"Name"}." ".ucfirst(lc($sBVTType))." BVT FAILED\n\n",
  443. "BVT Execution Time: ".$bvtTime,
  444. PL_BIGERROR | PL_FLUSH);
  445. PrintMsgBlock($ERROR);
  446. }
  447. return($rc);
  448. }
  449. $__NLGBVTPM = 1;
  450. 1;