blob: cf1d1b9c7a0e3a87d99ea59a8dd26722035ddab7 [file] [log] [blame]
Alkis Evlogimenos2e142f52004-01-07 01:48:26 +00001#!/usr/bin/perl -w
Chris Lattner4c7e3032003-01-20 06:11:03 +00002#
3# Program: NightlyTest.pl
4#
5# Synopsis: Perform a series of tests which are designed to be run nightly.
6# This is used to keep track of the status of the LLVM tree, tracking
7# regressions and performance changes. This generates one web page a
8# day which can be used to access this information.
9#
Brian Gaekeb3dab902003-10-11 05:34:00 +000010# Syntax: NightlyTest.pl [OPTIONS] [CVSROOT BUILDDIR WEBDIR]
11# where
12# OPTIONS may include one or more of the following:
13# -nocheckout Do not create, checkout, update, or configure
14# the source tree.
15# -noremove Do not remove the BUILDDIR after it has been built.
Chris Lattner4d00fde2004-05-28 20:30:23 +000016# -nofeaturetests Do not run the feature tests.
17# -noregressiontests Do not run the regression tests.
Brian Gaekeb3dab902003-10-11 05:34:00 +000018# -notest Do not even attempt to run the test programs. Implies
19# -norunningtests.
20# -norunningtests Do not run the Olden benchmark suite with
21# LARGE_PROBLEM_SIZE enabled.
22# -parallel Run two parallel jobs with GNU Make.
Chris Lattnerbb0aca52003-12-19 03:47:31 +000023# -enable-linscan Enable linearscan tests
Chris Lattner4d00fde2004-05-28 20:30:23 +000024# -verbose Turn on some debug output
25# -debug Print information useful only to maintainers of this script.
Chris Lattnerbb0aca52003-12-19 03:47:31 +000026#
Brian Gaekeb3dab902003-10-11 05:34:00 +000027# CVSROOT is the CVS repository from which the tree will be checked out,
28# specified either in the full :method:user@host:/dir syntax, or
29# just /dir if using a local repo.
30# BUILDDIR is the directory where sources for this test run will be checked out
31# AND objects for this test run will be built. This directory MUST NOT
32# exist before the script is run; it will be created by the cvs checkout
33# process and erased (unless -noremove is specified; see above.)
34# WEBDIR is the directory into which the test results web page will be written,
35# AND in which the "index.html" is assumed to be a symlink to the most recent
36# copy of the results. This directory MUST exist before the script is run.
Chris Lattner4c7e3032003-01-20 06:11:03 +000037#
38use POSIX qw(strftime);
39
Brian Gaekeb3dab902003-10-11 05:34:00 +000040my $HOME = $ENV{'HOME'};
41my $CVSRootDir = $ENV{'CVSROOT'};
Chris Lattner9d13efa2003-10-14 01:22:08 +000042 $CVSRootDir = "/home/vadve/shared/PublicCVS"
Chris Lattner4d00fde2004-05-28 20:30:23 +000043 unless $CVSRootDir;
44my $BuildDir = $ENV{'BUILDDIR'};
45 $BuildDir = "$HOME/buildtest"
46 unless $BuildDir;
47my $WebDir = $ENV{'WEBDIR'};
48 $WebDir = "$HOME/cvs/testresults-X86"
49 unless $WebDir;
Chris Lattner2f8cb572003-01-20 18:05:27 +000050
51# Calculate the date prefix...
52@TIME = localtime;
53my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
54my $DateString = strftime "%B %d, %Y", localtime;
55
Chris Lattnerb3440302003-01-22 16:14:05 +000056sub ReadFile {
Chris Lattner196a14a2003-08-19 15:08:34 +000057 undef $/;
Chris Lattnerb3440302003-01-22 16:14:05 +000058 if (open (FILE, $_[0])) {
59 my $Ret = <FILE>;
60 close FILE;
61 return $Ret;
62 } else {
63 print "Could not open file '$_[0]' for reading!";
64 return "";
65 }
66}
67
Chris Lattner2f8cb572003-01-20 18:05:27 +000068sub WriteFile { # (filename, contents)
69 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!";
70 print FILE $_[1];
71 close FILE;
72}
73
74sub GetRegex { # (Regex with ()'s, value)
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +000075 $_[1] =~ /$_[0]/m;
Chris Lattner08e24762003-08-19 18:35:03 +000076 if (defined($1)) {
77 return $1;
78 }
79 return "?";
Chris Lattner2f8cb572003-01-20 18:05:27 +000080}
81
82sub AddPreTag { # Add pre tags around nonempty list, or convert to "none"
83 $_ = shift;
Chris Lattner1cbc0a62003-01-20 19:18:44 +000084 if (length) { return "<ul><pre>$_</pre></ul>"; } else { "<b>none</b><br>"; }
Chris Lattner2f8cb572003-01-20 18:05:27 +000085}
86
87sub GetDir {
88 my $Suffix = shift;
89 opendir DH, $WebDir;
90 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
91 closedir DH;
92 return @Result;
93}
94
95# DiffFiles - Diff the current version of the file against the last version of
96# the file, reporting things added and removed. This is used to report, for
97# example, added and removed warnings. This returns a pair (added, removed)
98#
99sub DiffFiles {
100 my $Suffix = shift;
101 my @Others = GetDir $Suffix;
102 if (@Others == 0) { # No other files? We added all entries...
103 return (`cat $WebDir/$DATE$Suffix`, "");
104 }
105 # Diff the files now...
106 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
107 my $Added = join "\n", grep /^</, @Diffs;
108 my $Removed = join "\n", grep /^>/, @Diffs;
Chris Lattner1cbc0a62003-01-20 19:18:44 +0000109 $Added =~ s/^< //gm;
110 $Removed =~ s/^> //gm;
Chris Lattner2f8cb572003-01-20 18:05:27 +0000111 return ($Added, $Removed);
112}
113
Chris Lattner196a14a2003-08-19 15:08:34 +0000114# FormatTime - Convert a time from 1m23.45 into 83.45
115sub FormatTime {
116 my $Time = shift;
117 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
118 $Time = sprintf("%7.4f", $1*60.0+$2);
119 }
120 return $Time;
121}
122
Chris Lattner2f8cb572003-01-20 18:05:27 +0000123
Chris Lattner4c7e3032003-01-20 06:11:03 +0000124# Command line argument settings...
125my $NOCHECKOUT = 0;
126my $NOREMOVE = 0;
Chris Lattner4d00fde2004-05-28 20:30:23 +0000127my $NOFEATURES = 0;
128my $NOREGRESSIONS = 0;
Chris Lattnerb3440302003-01-22 16:14:05 +0000129my $NOTEST = 0;
Chris Lattner08e24762003-08-19 18:35:03 +0000130my $NORUNNINGTESTS = 0;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000131my $MAKEOPTS = "";
Chris Lattnerbb0aca52003-12-19 03:47:31 +0000132my $ENABLELINEARSCAN = "";
Chris Lattner4d00fde2004-05-28 20:30:23 +0000133my $VERBOSE = 0;
134my $DEBUG = 0;
Brian Gaekeb3dab902003-10-11 05:34:00 +0000135
Chris Lattner4c7e3032003-01-20 06:11:03 +0000136# Parse arguments...
137while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
138 shift;
139 last if /^--$/; # Stop processing arguments on --
140
141 # List command line options here...
Chris Lattner08e24762003-08-19 18:35:03 +0000142 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
143 if (/^-noremove$/) { $NOREMOVE = 1; next; }
Chris Lattner4d00fde2004-05-28 20:30:23 +0000144 if (/^-nofeaturetests$/) { $NOFEATURES = 1; next; }
145 if (/^-noregressiontests$/){ $NOREGRESSIONS = 1; next; }
Chris Lattner08e24762003-08-19 18:35:03 +0000146 if (/^-notest$/) { $NOTEST = 1; $NORUNNINGTESTS = 1; next; }
147 if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
148 if (/^-parallel$/) { $MAKEOPTS = "-j2 -l3.0"; next; }
Chris Lattner370e8092003-12-19 19:48:43 +0000149 if (/^-enable-linscan$/) { $ENABLELINEARSCAN = "ENABLE_LINEARSCAN=1"; next; }
Chris Lattner4d00fde2004-05-28 20:30:23 +0000150 if (/^-verbose$/) { $VERBOSE = 1; next; }
151 if (/^-debug$/) { $DEBUG = 1; next; }
Chris Lattner4c7e3032003-01-20 06:11:03 +0000152
153 print "Unknown option: $_ : ignoring!\n";
154}
155
Chris Lattner2f8cb572003-01-20 18:05:27 +0000156die "Must specify 0 or 3 options!" if (@ARGV != 0 and @ARGV != 3);
Chris Lattner4c7e3032003-01-20 06:11:03 +0000157
Chris Lattner4c7e3032003-01-20 06:11:03 +0000158if (@ARGV == 3) {
159 $CVSRootDir = $ARGV[0];
160 $BuildDir = $ARGV[1];
161 $WebDir = $ARGV[2];
162}
163
Chris Lattner4d00fde2004-05-28 20:30:23 +0000164
Misha Brukman1b366892003-07-07 21:27:40 +0000165my $Template = "$BuildDir/llvm/utils/NightlyTestTemplate.html";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000166my $Prefix = "$WebDir/$DATE";
167
Chris Lattner4d00fde2004-05-28 20:30:23 +0000168if ($VERBOSE) {
169 print "INITIALIZED\n";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000170 print "CVS Root = $CVSRootDir\n";
171 print "BuildDir = $BuildDir\n";
172 print "WebDir = $WebDir\n";
173 print "Prefix = $Prefix\n";
174}
175
Chris Lattnerb3440302003-01-22 16:14:05 +0000176
177#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000178# Create the CVS repository directory
Chris Lattnerb3440302003-01-22 16:14:05 +0000179#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000180if (!$NOCHECKOUT) {
Chris Lattner4d00fde2004-05-28 20:30:23 +0000181 if (-d $BuildDir) {
182 if (!$NOREMOVE) {
Reid Spencer542e8592004-05-30 00:17:47 +0000183 system "rm -rf $BuildDir";
Chris Lattner4d00fde2004-05-28 20:30:23 +0000184 } else {
185 die "CVS checkout directory $BuildDir already exists!";
186 }
187 }
Misha Brukman1b366892003-07-07 21:27:40 +0000188 mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000189}
Misha Brukman1b366892003-07-07 21:27:40 +0000190chdir $BuildDir or die "Could not change to CVS checkout directory $BuildDir!";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000191
Chris Lattnerb3440302003-01-22 16:14:05 +0000192
193#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000194# Check out the llvm tree, saving CVS messages to the cvs log...
Chris Lattnerb3440302003-01-22 16:14:05 +0000195#
Brian Gaekeb3dab902003-10-11 05:34:00 +0000196$CVSOPT = "";
197$CVSOPT = "-z3" if $CVSRootDir =~ /^:ext:/; # Use compression if going over ssh.
Chris Lattner4d00fde2004-05-28 20:30:23 +0000198if (!$NOCHECKOUT) {
199 if ( $VERBOSE ) { print "CHECKOUT STAGE\n"; }
200 system "(time -p cvs $CVSOPT -d $CVSRootDir co llvm) > $Prefix-CVS-Log.txt 2>&1";
201}
Chris Lattner4c7e3032003-01-20 06:11:03 +0000202
203chdir "llvm" or die "Could not change into llvm directory!";
204
Chris Lattner4d00fde2004-05-28 20:30:23 +0000205if (!$NOCHECKOUT) {
206 if ( $VERBOSE ) { print "UPDATE STAGE\n"; }
207 system "cvs update -P -d > /dev/null 2>&1" ;
208}
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000209
Chris Lattner4c7e3032003-01-20 06:11:03 +0000210# Read in the HTML template file...
Chris Lattnerb3440302003-01-22 16:14:05 +0000211my $TemplateContents = ReadFile $Template;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000212
Chris Lattnerb3440302003-01-22 16:14:05 +0000213
214#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000215# Get some static statistics about the current state of CVS
Chris Lattnerb3440302003-01-22 16:14:05 +0000216#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000217my $CVSCheckoutTime = GetRegex "([0-9.]+)", `grep '^real' $Prefix-CVS-Log.txt`;
Brian Gaekeac5d96b2003-12-01 05:31:12 +0000218my $NumFilesInCVS = `egrep '^U' $Prefix-CVS-Log.txt | wc -l` + 0;
219my $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $Prefix-CVS-Log.txt | wc -l` + 0;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000220$LOC = GetRegex "([0-9]+) +total", `wc -l \`utils/getsrcs.sh\` | grep total`;
221
Chris Lattnerb3440302003-01-22 16:14:05 +0000222#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000223# Build the entire tree, saving build messages to the build log
Chris Lattnerb3440302003-01-22 16:14:05 +0000224#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000225if (!$NOCHECKOUT) {
Chris Lattner4d00fde2004-05-28 20:30:23 +0000226 if ( $VERBOSE ) { print "CONFIGURE STAGE\n"; }
Misha Brukman8e9554a2003-08-14 15:26:28 +0000227 system "(time -p ./configure --enable-jit --enable-spec --with-objroot=.) > $Prefix-Build-Log.txt 2>&1";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000228
Chris Lattner4d00fde2004-05-28 20:30:23 +0000229 if ( $VERBOSE ) { print "BUILD STAGE\n"; }
Chris Lattner4c7e3032003-01-20 06:11:03 +0000230 # Build the entire tree, capturing the output into $Prefix-Build-Log.txt
Chris Lattner42815c82003-07-01 16:02:00 +0000231 system "(time -p gmake $MAKEOPTS) >> $Prefix-Build-Log.txt 2>&1";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000232}
233
Chris Lattnerb3440302003-01-22 16:14:05 +0000234
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000235sub GetRegexNum {
236 my ($Regex, $Num, $Regex2, $File) = @_;
237 my @Items = split "\n", `grep '$Regex' $File`;
238 return GetRegex $Regex2, $Items[$Num];
239}
240
Chris Lattnerb3440302003-01-22 16:14:05 +0000241#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000242# Get some statistics about the build...
Chris Lattnerb3440302003-01-22 16:14:05 +0000243#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000244my @Linked = split '\n', `grep Linking $Prefix-Build-Log.txt`;
245my $NumExecutables = scalar(grep(/executable/, @Linked));
246my $NumLibraries = scalar(grep(!/executable/, @Linked));
247my $NumObjects = `grep '^Compiling' $Prefix-Build-Log.txt | wc -l` + 0;
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000248
249my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$Prefix-Build-Log.txt";
250my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$Prefix-Build-Log.txt";
Chris Lattner00d7af62003-08-18 14:07:03 +0000251my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000252my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$Prefix-Build-Log.txt";
253
254my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$Prefix-Build-Log.txt";
255my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$Prefix-Build-Log.txt";
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000256my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000257my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$Prefix-Build-Log.txt";
258
Chris Lattnerb3440302003-01-22 16:14:05 +0000259my $BuildError = "";
Chris Lattner338dd7e2003-09-23 20:33:04 +0000260if (`grep '^gmake[^:]*: .*Error' $Prefix-Build-Log.txt | wc -l` + 0 ||
Chris Lattnerccee2962003-09-23 22:02:01 +0000261 `grep '^gmake: \*\*\*.*Stop.' $Prefix-Build-Log.txt | wc -l`+0) {
Misha Brukman71b0a312003-08-21 20:22:52 +0000262 $BuildError = "<h3><font color='red'>Build error: compilation " .
263 "<a href=\"$DATE-Build-Log.txt\">aborted</a></font></h3>";
Chris Lattnerbe197872003-10-19 16:54:00 +0000264 print "BUILD ERROR\n";
Chris Lattnerb3440302003-01-22 16:14:05 +0000265}
Chris Lattner4c7e3032003-01-20 06:11:03 +0000266
Chris Lattner4d00fde2004-05-28 20:30:23 +0000267sub GetQMTestResults { # (filename)
268 my ($filename) = @_;
269 my @lines;
270 my $firstline;
271 $/ = "\n"; #Make sure we're going line at a time.
272 if (open SRCHFILE, $filename) {
Reid Spencer542e8592004-05-30 00:17:47 +0000273 # Skip stuff before ---TEST RESULTS
Chris Lattner4d00fde2004-05-28 20:30:23 +0000274 while ( <SRCHFILE> ) {
275 if ( m/^--- TEST RESULTS/ ) {
276 push(@lines, $_); last;
277 }
278 }
Reid Spencer542e8592004-05-30 00:17:47 +0000279 # Process test results
Chris Lattner4d00fde2004-05-28 20:30:23 +0000280 while ( <SRCHFILE> ) {
281 if ( length($_) > 1 ) {
Reid Spencer542e8592004-05-30 00:17:47 +0000282 if ( ! m/: PASS[ ]*$/ &&
283 ! m/^ qmtest.target:/ &&
284 ! m/^ local/ &&
285 ! m/^gmake:/ ) {
Chris Lattner4d00fde2004-05-28 20:30:23 +0000286 push(@lines,$_);
287 }
288 }
289 }
290 close SRCHFILE;
291 }
292 my $content = join("",@lines);
293 return "<pre>\n@lines</pre>\n";
294}
295
296
297# Get results of feature tests.
298my $FeatureTestResults; # String containing the results of the feature tests
299my $FeatureTime; # System+CPU Time for feature tests
300my $FeatureWallTime; # Wall Clock Time for feature tests
301if (!$NOFEATURES) {
302 if ( $VERBOSE ) { print "FEATURE TEST STAGE\n"; }
303 my $feature_output = "$Prefix-FeatureTests-Log.txt";
304
305 # Run the feature tests so we can summarize the results
306 system "(time -p gmake -C test Feature.t) > $feature_output 2>&1";
307
308 # Extract test results
309 $FeatureTestResults = GetQMTestResults("$feature_output");
310
311 # Extract time of feature tests
312 my $FeatureTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$feature_output";
313 my $FeatureTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$feature_output";
314 $FeatureTime = $FeatureTimeU+$FeatureTimeS; # FeatureTime = User+System
315 $FeatureWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$feature_output";
316 # Run the regression tests so we can summarize the results
317} else {
318 $FeatureTestResults = "Skipped by user choice.";
319 $FeatureTime = "0.0";
320 $FeatureWallTime = "0.0";
321}
322
323if (!$NOREGRESSIONS) {
324 if ( $VERBOSE ) { print "REGRESSION TEST STAGE\n"; }
325 my $regression_output = "$Prefix-RegressionTests-Log.txt";
326
327 # Run the regression tests so we can summarize the results
328 system "(time -p gmake -C test Regression.t) > $regression_output 2>&1";
329
330 # Extract test results
331 $RegressionTestResults = GetQMTestResults("$regression_output");
332
333 # Extract time of regressions tests
334 my $RegressionTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$regression_output";
335 my $RegressionTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$regression_output";
336 $RegressionTime = $RegressionTimeU+$RegressionTimeS; # RegressionTime = User+System
337 $RegressionWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$regression_output";
338} else {
339 $RegressionTestResults = "Skipped by user choice.";
340 $RegressionTime = "0.0";
341 $RegressionWallTime = "0.0";
342}
343
344if ($DEBUG) {
345 print $FeatureTestResults;
346 print $RegressionTestResults;
347}
348
349if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
Chris Lattnerb3440302003-01-22 16:14:05 +0000350#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000351# Get warnings from the build
Chris Lattnerb3440302003-01-22 16:14:05 +0000352#
Misha Brukman1b366892003-07-07 21:27:40 +0000353my @Warn = split "\n", `egrep 'warning:|Entering dir' $Prefix-Build-Log.txt`;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000354my @Warnings;
355my $CurDir = "";
356
357foreach $Warning (@Warn) {
358 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
359 $CurDir = $1; # Keep track of directory warning is in...
Misha Brukman8e9554a2003-08-14 15:26:28 +0000360 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { # Remove buildir prefix if included
Chris Lattner4c7e3032003-01-20 06:11:03 +0000361 $CurDir = $1;
362 }
363 } else {
364 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
365 }
366}
Chris Lattner1cbc0a62003-01-20 19:18:44 +0000367my $WarningsFile = join "\n", @Warnings;
368my $WarningsList = AddPreTag $WarningsFile;
369$WarningsFile =~ s/:[0-9]+:/::/g;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000370
Chris Lattner2f8cb572003-01-20 18:05:27 +0000371# Emit the warnings file, so we can diff...
372WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
373my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000374
Chris Lattner9efd7f42003-10-18 19:31:39 +0000375# Output something to stdout if something has changed
376print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
377print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
378
Chris Lattnerbe197872003-10-19 16:54:00 +0000379$WarningsAdded = AddPreTag $WarningsAdded;
380$WarningsRemoved = AddPreTag $WarningsRemoved;
Chris Lattnerb3440302003-01-22 16:14:05 +0000381
382#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000383# Get some statistics about CVS commits over the current day...
Chris Lattnerb3440302003-01-22 16:14:05 +0000384#
Chris Lattner4d00fde2004-05-28 20:30:23 +0000385if ($VERBOSE) { print "CVS HISTORY ANALYSIS STAGE\n"; }
Chris Lattner4c7e3032003-01-20 06:11:03 +0000386@CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
387#print join "\n", @CVSHistory; print "\n";
388
389# Extract some information from the CVS history... use a hash so no duplicate
390# stuff is stored.
Misha Brukman1b366892003-07-07 21:27:40 +0000391my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
Chris Lattner4c7e3032003-01-20 06:11:03 +0000392
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000393my $DateRE = "[-:0-9 ]+\\+[0-9]+";
394
Chris Lattner4c7e3032003-01-20 06:11:03 +0000395# Loop over every record from the CVS history, filling in the hashes.
396foreach $File (@CVSHistory) {
397 my ($Type, $Date, $UID, $Rev, $Filename);
Misha Brukman8e9554a2003-08-14 15:26:28 +0000398 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
Chris Lattner4c7e3032003-01-20 06:11:03 +0000399 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
Chris Lattnerd56147d2004-01-12 16:55:30 +0000400 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
401 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
Misha Brukman1b366892003-07-07 21:27:40 +0000402 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000403 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
Chris Lattner4c7e3032003-01-20 06:11:03 +0000404 } else {
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000405 print "UNMATCHABLE: $File\n";
406 }
407 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
408
409 if ($Filename =~ /^llvm/) {
410 if ($Type eq 'M') { # Modified
411 $ModifiedFiles{$Filename} = 1;
412 $UsersCommitted{$UID} = 1;
413 } elsif ($Type eq 'A') { # Added
414 $AddedFiles{$Filename} = 1;
415 $UsersCommitted{$UID} = 1;
416 } elsif ($Type eq 'R') { # Removed
417 $RemovedFiles{$Filename} = 1;
418 $UsersCommitted{$UID} = 1;
419 } else {
420 $UsersUpdated{$UID} = 1;
421 }
Chris Lattner4c7e3032003-01-20 06:11:03 +0000422 }
423}
424
Chris Lattner1cbc0a62003-01-20 19:18:44 +0000425my $UserCommitList = join "\n", keys %UsersCommitted;
426my $UserUpdateList = join "\n", keys %UsersUpdated;
Chris Lattnerc9cdadf2003-08-06 16:02:50 +0000427my $AddedFilesList = AddPreTag join "\n", sort keys %AddedFiles;
428my $ModifiedFilesList = AddPreTag join "\n", sort keys %ModifiedFiles;
429my $RemovedFilesList = AddPreTag join "\n", sort keys %RemovedFiles;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000430
Chris Lattnerec0e3742003-02-28 20:30:20 +0000431my $TestError = 1;
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000432my $SingleSourceProgramsTable;
433my $MultiSourceProgramsTable;
Chris Lattnereac3cdc2003-08-21 15:55:26 +0000434my $ExternalProgramsTable;
Chris Lattnerb3440302003-01-22 16:14:05 +0000435
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000436
437sub TestDirectory {
438 my $SubDir = shift;
439
440 chdir "test/Programs/$SubDir" or
441 die "Could not change into test/Programs/$SubDir testdir!";
Chris Lattnerec0e3742003-02-28 20:30:20 +0000442
443 # Run the programs tests... creating a report.nightly.html file
444 if (!$NOTEST) {
Chris Lattnerbb0aca52003-12-19 03:47:31 +0000445 system "gmake -k $MAKEOPTS $ENABLELINEARSCAN report.nightly.html "
446 . "TEST=nightly > $Prefix-$SubDir-ProgramTest.txt 2>&1";
Chris Lattnerec0e3742003-02-28 20:30:20 +0000447 } else {
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000448 system "gunzip $Prefix-$SubDir-ProgramTest.txt.gz";
Chris Lattnerec0e3742003-02-28 20:30:20 +0000449 }
450
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000451 my $ProgramsTable;
Chris Lattnerc7294152003-08-20 15:44:33 +0000452 if (`grep '^gmake[^:]: .*Error' $Prefix-$SubDir-ProgramTest.txt | wc -l` + 0){
Chris Lattnerec0e3742003-02-28 20:30:20 +0000453 $TestError = 1;
Chris Lattner2e8be142003-05-10 21:40:10 +0000454 $ProgramsTable = "<font color=white><h2>Error running tests!</h2></font>";
Chris Lattnerbe197872003-10-19 16:54:00 +0000455 print "ERROR TESTING\n";
Chris Lattnerc7294152003-08-20 15:44:33 +0000456 } elsif (`grep '^gmake[^:]: .*No rule to make target' $Prefix-$SubDir-ProgramTest.txt | wc -l` + 0) {
Chris Lattner6e51bfa2003-05-11 15:23:10 +0000457 $TestError = 1;
458 $ProgramsTable =
459 "<font color=white><h2>Makefile error running tests!</h2></font>";
Chris Lattnerbe197872003-10-19 16:54:00 +0000460 print "ERROR TESTING\n";
Chris Lattner6e51bfa2003-05-11 15:23:10 +0000461 } else {
Chris Lattnerec0e3742003-02-28 20:30:20 +0000462 $TestError = 0;
463 $ProgramsTable = ReadFile "report.nightly.html";
464
465 #
466 # Create a list of the tests which were run...
467 #
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000468 system "egrep 'TEST-(PASS|FAIL)' < $Prefix-$SubDir-ProgramTest.txt "
469 . "| sort > $Prefix-$SubDir-Tests.txt";
Chris Lattnerec0e3742003-02-28 20:30:20 +0000470 }
471
472 # Compress the test output
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000473 system "gzip -f $Prefix-$SubDir-ProgramTest.txt";
474 chdir "../../.." or die "Cannot return to parent directory!";
475 return $ProgramsTable;
476}
477
Chris Lattner196a14a2003-08-19 15:08:34 +0000478# If we build the tree successfully, run the nightly programs tests...
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000479if ($BuildError eq "") {
Chris Lattner4d00fde2004-05-28 20:30:23 +0000480 if ( $VERBOSE ) {
481 print "SingleSource TEST STAGE\n";
482 }
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000483 $SingleSourceProgramsTable = TestDirectory("SingleSource");
Chris Lattner4d00fde2004-05-28 20:30:23 +0000484 if ( $VERBOSE ) {
485 print "MultiSource TEST STAGE\n";
486 }
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000487 $MultiSourceProgramsTable = TestDirectory("MultiSource");
Chris Lattner4d00fde2004-05-28 20:30:23 +0000488 if ( $VERBOSE ) {
489 print "External TEST STAGE\n";
490 }
Chris Lattnereac3cdc2003-08-21 15:55:26 +0000491 $ExternalProgramsTable = TestDirectory("External");
Chris Lattnerf5a6ab92003-08-18 15:11:13 +0000492 system "cat $Prefix-SingleSource-Tests.txt $Prefix-MultiSource-Tests.txt ".
Chris Lattnereac3cdc2003-08-21 15:55:26 +0000493 " $Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
Chris Lattner5d6c4382003-01-23 19:31:28 +0000494}
Chris Lattnerb3440302003-01-22 16:14:05 +0000495
Chris Lattner4d00fde2004-05-28 20:30:23 +0000496if ( $VERBOSE ) {
497 print "TEST INFORMATION COLLECTION STAGE\n";
498}
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000499my ($TestsAdded, $TestsRemoved, $TestsFixed, $TestsBroken) = ("","","","");
500
Chris Lattnerec0e3742003-02-28 20:30:20 +0000501if ($TestError) {
502 $TestsAdded = "<b>error testing</b><br>";
503 $TestsRemoved = "<b>error testing</b><br>";
504 $TestsFixed = "<b>error testing</b><br>";
505 $TestsBroken = "<b>error testing</b><br>";
506} else {
507 my ($RTestsAdded, $RTestsRemoved) = DiffFiles "-Tests.txt";
508
509 my @RawTestsAddedArray = split '\n', $RTestsAdded;
510 my @RawTestsRemovedArray = split '\n', $RTestsRemoved;
511
512 my %OldTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
513 @RawTestsRemovedArray;
514 my %NewTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
515 @RawTestsAddedArray;
516
517 foreach $Test (keys %NewTests) {
518 if (!exists $OldTests{$Test}) { # TestAdded if in New but not old
519 $TestsAdded = "$TestsAdded$Test\n";
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000520 } else {
Chris Lattnerec0e3742003-02-28 20:30:20 +0000521 if ($OldTests{$Test} =~ /TEST-PASS/) { # Was the old one a pass?
522 $TestsBroken = "$TestsBroken$Test\n"; # New one must be a failure
523 } else {
524 $TestsFixed = "$TestsFixed$Test\n"; # No, new one is a pass.
525 }
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000526 }
527 }
Chris Lattnerec0e3742003-02-28 20:30:20 +0000528 foreach $Test (keys %OldTests) { # TestRemoved if in Old but not New
529 $TestsRemoved = "$TestsRemoved$Test\n" if (!exists $NewTests{$Test});
530 }
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000531
Chris Lattner91480ff2003-10-21 15:47:31 +0000532 print "\nTESTS ADDED: \n\n$TestsAdded\n\n" if (length $TestsAdded);
533 print "\nTESTS REMOVED:\n\n$TestsRemoved\n\n" if (length $TestsRemoved);
534 print "\nTESTS FIXED: \n\n$TestsFixed\n\n" if (length $TestsFixed);
535 print "\nTESTS BROKEN: \n\n$TestsBroken\n\n" if (length $TestsBroken);
Chris Lattnerbe197872003-10-19 16:54:00 +0000536
Chris Lattnerec0e3742003-02-28 20:30:20 +0000537 $TestsAdded = AddPreTag $TestsAdded;
538 $TestsRemoved = AddPreTag $TestsRemoved;
539 $TestsFixed = AddPreTag $TestsFixed;
540 $TestsBroken = AddPreTag $TestsBroken;
541}
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000542
Chris Lattner9efd7f42003-10-18 19:31:39 +0000543
Chris Lattner196a14a2003-08-19 15:08:34 +0000544# If we built the tree successfully, runs of the Olden suite with
545# LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
546if ($BuildError eq "") {
Chris Lattner08e24762003-08-19 18:35:03 +0000547 my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
Chris Lattner196a14a2003-08-19 15:08:34 +0000548 $MachCodeSize) = ("","","","","","","");
Chris Lattner08e24762003-08-19 18:35:03 +0000549 if (!$NORUNNINGTESTS) {
Chris Lattner8f9c4bd2003-09-14 06:00:49 +0000550 chdir "test/Programs/MultiSource/Benchmarks/Olden" or die "Olden tests moved?";
Chris Lattner196a14a2003-08-19 15:08:34 +0000551
552 # Clean out previous results...
553 system "gmake $MAKEOPTS clean > /dev/null 2>&1";
554
555 # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE enabled!
Chris Lattner3e457f72003-10-28 18:37:24 +0000556 system "gmake -k $MAKEOPTS report.nightly.raw.out TEST=nightly " .
Chris Lattner196a14a2003-08-19 15:08:34 +0000557 " LARGE_PROBLEM_SIZE=1 > /dev/null 2>&1";
558 system "cp report.nightly.raw.out $Prefix-Olden-tests.txt";
559 } else {
560 system "gunzip $Prefix-Olden-tests.txt.gz";
561 }
562
563 # Now we know we have $Prefix-Olden-tests.txt as the raw output file. Split
564 # it up into records and read the useful information.
Chris Lattner08e24762003-08-19 18:35:03 +0000565 my @Records = split />>> ========= /, ReadFile "$Prefix-Olden-tests.txt";
Chris Lattner196a14a2003-08-19 15:08:34 +0000566 shift @Records; # Delete the first (garbage) record
567
568 # Loop over all of the records, summarizing them into rows for the running
569 # totals file.
570 my $WallTimeRE = "[A-Za-z0-9.: ]+\\(([0-9.]+) wall clock";
571 foreach $Rec (@Records) {
Chris Lattner08e24762003-08-19 18:35:03 +0000572 my $rNATTime = GetRegex 'TEST-RESULT-nat-time: real\s*([.0-9m]+)', $Rec;
573 my $rCBETime = GetRegex 'TEST-RESULT-cbe-time: real\s*([.0-9m]+)', $Rec;
574 my $rLLCTime = GetRegex 'TEST-RESULT-llc-time: real\s*([.0-9m]+)', $Rec;
575 my $rJITTime = GetRegex 'TEST-RESULT-jit-time: real\s*([.0-9m]+)', $Rec;
Chris Lattner196a14a2003-08-19 15:08:34 +0000576 my $rOptTime = GetRegex "TEST-RESULT-compile: $WallTimeRE", $Rec;
577 my $rBytecodeSize = GetRegex 'TEST-RESULT-compile: *([0-9]+)', $Rec;
578 my $rMachCodeSize = GetRegex 'TEST-RESULT-jit-machcode: *([0-9]+).*bytes of machine code', $Rec;
579
580 $NATTime .= " " . FormatTime($rNATTime);
581 $CBETime .= " " . FormatTime($rCBETime);
582 $LLCTime .= " " . FormatTime($rLLCTime);
583 $JITTime .= " " . FormatTime($rJITTime);
584 $OptTime .= " $rOptTime";
Chris Lattner08e24762003-08-19 18:35:03 +0000585 $BytecodeSize .= " $rBytecodeSize";
586 $MachCodeSize .= " $rMachCodeSize";
Chris Lattner196a14a2003-08-19 15:08:34 +0000587 }
588
589 # Now that we have all of the numbers we want, add them to the running totals
590 # files.
Chris Lattner08e24762003-08-19 18:35:03 +0000591 AddRecord($NATTime, "running_Olden_nat_time.txt");
Chris Lattner196a14a2003-08-19 15:08:34 +0000592 AddRecord($CBETime, "running_Olden_cbe_time.txt");
593 AddRecord($LLCTime, "running_Olden_llc_time.txt");
594 AddRecord($JITTime, "running_Olden_jit_time.txt");
595 AddRecord($OptTime, "running_Olden_opt_time.txt");
596 AddRecord($BytecodeSize, "running_Olden_bytecode.txt");
597 AddRecord($MachCodeSize, "running_Olden_machcode.txt");
Chris Lattner08e24762003-08-19 18:35:03 +0000598
599 system "gzip -f $Prefix-Olden-tests.txt";
Chris Lattner196a14a2003-08-19 15:08:34 +0000600}
601
602
603
604
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000605#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000606# Get a list of the previous days that we can link to...
Chris Lattnerb3440302003-01-22 16:14:05 +0000607#
Chris Lattner2f8cb572003-01-20 18:05:27 +0000608my @PrevDays = map {s/.html//; $_} GetDir ".html";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000609
610splice @PrevDays, 20; # Trim down list to something reasonable...
611
612my $PrevDaysList = # Format list for sidebar
613 join "\n ", map { "<a href=\"$_.html\">$_</a><br>" } @PrevDays;
614
Chris Lattnerc75b14e2003-08-18 20:07:54 +0000615#
616# Start outputing files into the web directory
617#
618chdir $WebDir or die "Could not change into web directory!";
619
620# Add information to the files which accumulate information for graphs...
621AddRecord($LOC, "running_loc.txt");
622AddRecord($BuildTime, "running_build_time.txt");
623
Chris Lattner4d00fde2004-05-28 20:30:23 +0000624if ( $VERBOSE ) {
625 print "GRAPH GENERATION STAGE\n";
626}
Chris Lattnerc75b14e2003-08-18 20:07:54 +0000627#
628# Rebuild the graphs now...
629#
Brian Gaekeb3dab902003-10-11 05:34:00 +0000630$GNUPLOT = "/usr/dcs/software/supported/bin/gnuplot";
631$GNUPLOT = "gnuplot" if ! -x $GNUPLOT;
632$PlotScriptFilename = "$BuildDir/llvm/utils/NightlyTest.gnuplot";
633system ($GNUPLOT, $PlotScriptFilename);
Chris Lattnerb3440302003-01-22 16:14:05 +0000634
Chris Lattner4c7e3032003-01-20 06:11:03 +0000635#
636# Remove the cvs tree...
637#
638system "rm -rf $BuildDir" if (!$NOCHECKOUT and !$NOREMOVE);
639
Chris Lattnerb3440302003-01-22 16:14:05 +0000640#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000641# Print out information...
Chris Lattnerb3440302003-01-22 16:14:05 +0000642#
Chris Lattner4d00fde2004-05-28 20:30:23 +0000643if ($VERBOSE) {
Chris Lattner4c7e3032003-01-20 06:11:03 +0000644 print "DateString: $DateString\n";
645 print "CVS Checkout: $CVSCheckoutTime seconds\n";
646 print "Files/Dirs/LOC in CVS: $NumFilesInCVS/$NumDirsInCVS/$LOC\n";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000647 print "Build Time: $BuildTime seconds\n";
Chris Lattner4d00fde2004-05-28 20:30:23 +0000648 print "Feature Test Time: $FeatureTime seconds\n";
649 print "Regression Test Time: $RegressionTime seconds\n";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000650 print "Libraries/Executables/Objects built: $NumLibraries/$NumExecutables/$NumObjects\n";
651
652 print "WARNINGS:\n $WarningsList\n";
653
Chris Lattner4c7e3032003-01-20 06:11:03 +0000654 print "Users committed: $UserCommitList\n";
655 print "Added Files: \n $AddedFilesList\n";
656 print "Modified Files: \n $ModifiedFilesList\n";
657 print "Removed Files: \n $RemovedFilesList\n";
658
659 print "Previous Days =\n $PrevDaysList\n";
660}
661
Chris Lattnerb3440302003-01-22 16:14:05 +0000662
Chris Lattner2f8cb572003-01-20 18:05:27 +0000663#
664# Output the files...
665#
666
Chris Lattner4d00fde2004-05-28 20:30:23 +0000667if ( $VERBOSE ) {
668 print "OUTPUT STAGE\n";
669}
Chris Lattner2f8cb572003-01-20 18:05:27 +0000670# Main HTML file...
Chris Lattner4c7e3032003-01-20 06:11:03 +0000671my $Output;
672eval "\$Output = <<ENDOFFILE;$TemplateContents\nENDOFFILE\n";
Chris Lattner2f8cb572003-01-20 18:05:27 +0000673WriteFile "$DATE.html", $Output;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000674
675# Change the index.html symlink...
676system "ln -sf $DATE.html index.html";
677
678sub AddRecord {
679 my ($Val, $Filename) = @_;
680 my @Records;
Chris Lattner196a14a2003-08-19 15:08:34 +0000681 if (open FILE, "$WebDir/$Filename") {
Chris Lattner4c7e3032003-01-20 06:11:03 +0000682 @Records = grep !/$DATE/, split "\n", <FILE>;
683 close FILE;
684 }
685 push @Records, "$DATE: $Val";
Chris Lattner08e24762003-08-19 18:35:03 +0000686 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000687 return @Records;
688}