blob: f34c3f696e8c6b6e755f7bb173e5837b11cde9bb [file] [log] [blame]
Alkis Evlogimenos8b9d36e2004-01-07 01:48:26 +00001#!/usr/bin/perl -w
Chris Lattner6a36dc62003-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 Gaeke91d16b32003-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 Lattnera9e9d2c2004-05-28 20:30:23 +000016# -nofeaturetests Do not run the feature tests.
17# -noregressiontests Do not run the regression tests.
Brian Gaeke91d16b32003-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 Lattner8f668f262003-12-19 03:47:31 +000023# -enable-linscan Enable linearscan tests
Chris Lattnera9e9d2c2004-05-28 20:30:23 +000024# -verbose Turn on some debug output
25# -debug Print information useful only to maintainers of this script.
Chris Lattner8f668f262003-12-19 03:47:31 +000026#
Brian Gaeke91d16b32003-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 Lattner6a36dc62003-01-20 06:11:03 +000037#
38use POSIX qw(strftime);
39
Brian Gaeke91d16b32003-10-11 05:34:00 +000040my $HOME = $ENV{'HOME'};
41my $CVSRootDir = $ENV{'CVSROOT'};
Chris Lattner4b9c23a2003-10-14 01:22:08 +000042 $CVSRootDir = "/home/vadve/shared/PublicCVS"
Chris Lattnera9e9d2c2004-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 Lattner3dc06172003-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 Lattner85d79a02003-01-22 16:14:05 +000056sub ReadFile {
Chris Lattnerd1fc00d2003-08-19 15:08:34 +000057 undef $/;
Chris Lattner85d79a02003-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 Lattner3dc06172003-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 Lattner34debbf2003-01-22 20:35:59 +000075 $_[1] =~ /$_[0]/m;
Chris Lattner05c8f642003-08-19 18:35:03 +000076 if (defined($1)) {
77 return $1;
78 }
79 return "?";
Chris Lattner3dc06172003-01-20 18:05:27 +000080}
81
82sub AddPreTag { # Add pre tags around nonempty list, or convert to "none"
83 $_ = shift;
Chris Lattner7f90f612003-01-20 19:18:44 +000084 if (length) { return "<ul><pre>$_</pre></ul>"; } else { "<b>none</b><br>"; }
Chris Lattner3dc06172003-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 Lattner7f90f612003-01-20 19:18:44 +0000109 $Added =~ s/^< //gm;
110 $Removed =~ s/^> //gm;
Chris Lattner3dc06172003-01-20 18:05:27 +0000111 return ($Added, $Removed);
112}
113
Chris Lattnerd1fc00d2003-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 Lattner3dc06172003-01-20 18:05:27 +0000123
Chris Lattner6a36dc62003-01-20 06:11:03 +0000124# Command line argument settings...
125my $NOCHECKOUT = 0;
126my $NOREMOVE = 0;
Chris Lattnera9e9d2c2004-05-28 20:30:23 +0000127my $NOFEATURES = 0;
128my $NOREGRESSIONS = 0;
Chris Lattner85d79a02003-01-22 16:14:05 +0000129my $NOTEST = 0;
Chris Lattner05c8f642003-08-19 18:35:03 +0000130my $NORUNNINGTESTS = 0;
Chris Lattner6a36dc62003-01-20 06:11:03 +0000131my $MAKEOPTS = "";
Chris Lattner8f668f262003-12-19 03:47:31 +0000132my $ENABLELINEARSCAN = "";
Chris Lattnera9e9d2c2004-05-28 20:30:23 +0000133my $VERBOSE = 0;
134my $DEBUG = 0;
Brian Gaeke91d16b32003-10-11 05:34:00 +0000135
Chris Lattner6a36dc62003-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 Lattner05c8f642003-08-19 18:35:03 +0000142 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
143 if (/^-noremove$/) { $NOREMOVE = 1; next; }
Chris Lattnera9e9d2c2004-05-28 20:30:23 +0000144 if (/^-nofeaturetests$/) { $NOFEATURES = 1; next; }
145 if (/^-noregressiontests$/){ $NOREGRESSIONS = 1; next; }
Chris Lattner05c8f642003-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 Lattner80a45082003-12-19 19:48:43 +0000149 if (/^-enable-linscan$/) { $ENABLELINEARSCAN = "ENABLE_LINEARSCAN=1"; next; }
Chris Lattnera9e9d2c2004-05-28 20:30:23 +0000150 if (/^-verbose$/) { $VERBOSE = 1; next; }
151 if (/^-debug$/) { $DEBUG = 1; next; }
Chris Lattner6a36dc62003-01-20 06:11:03 +0000152
153 print "Unknown option: $_ : ignoring!\n";
154}
155
Chris Lattner3dc06172003-01-20 18:05:27 +0000156die "Must specify 0 or 3 options!" if (@ARGV != 0 and @ARGV != 3);
Chris Lattner6a36dc62003-01-20 06:11:03 +0000157
Chris Lattner6a36dc62003-01-20 06:11:03 +0000158if (@ARGV == 3) {
159 $CVSRootDir = $ARGV[0];
160 $BuildDir = $ARGV[1];
161 $WebDir = $ARGV[2];
162}
163
Chris Lattnera9e9d2c2004-05-28 20:30:23 +0000164
Misha Brukman6aa98682003-07-07 21:27:40 +0000165my $Template = "$BuildDir/llvm/utils/NightlyTestTemplate.html";
Chris Lattner6a36dc62003-01-20 06:11:03 +0000166my $Prefix = "$WebDir/$DATE";
167
Chris Lattnera9e9d2c2004-05-28 20:30:23 +0000168if ($VERBOSE) {
169 print "INITIALIZED\n";
Chris Lattner6a36dc62003-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 Lattner85d79a02003-01-22 16:14:05 +0000176
177#
Chris Lattner6a36dc62003-01-20 06:11:03 +0000178# Create the CVS repository directory
Chris Lattner85d79a02003-01-22 16:14:05 +0000179#
Chris Lattner6a36dc62003-01-20 06:11:03 +0000180if (!$NOCHECKOUT) {
Chris Lattnera9e9d2c2004-05-28 20:30:23 +0000181 if (-d $BuildDir) {
182 if (!$NOREMOVE) {
Reid Spencer3b430222004-05-30 00:17:47 +0000183 system "rm -rf $BuildDir";
Chris Lattnera9e9d2c2004-05-28 20:30:23 +0000184 } else {
185 die "CVS checkout directory $BuildDir already exists!";
186 }
187 }
Misha Brukman6aa98682003-07-07 21:27:40 +0000188 mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
Chris Lattner6a36dc62003-01-20 06:11:03 +0000189}
Misha Brukman6aa98682003-07-07 21:27:40 +0000190chdir $BuildDir or die "Could not change to CVS checkout directory $BuildDir!";
Chris Lattner6a36dc62003-01-20 06:11:03 +0000191
Chris Lattner85d79a02003-01-22 16:14:05 +0000192
193#
Chris Lattner6a36dc62003-01-20 06:11:03 +0000194# Check out the llvm tree, saving CVS messages to the cvs log...
Chris Lattner85d79a02003-01-22 16:14:05 +0000195#
Brian Gaeke91d16b32003-10-11 05:34:00 +0000196$CVSOPT = "";
197$CVSOPT = "-z3" if $CVSRootDir =~ /^:ext:/; # Use compression if going over ssh.
Chris Lattnera9e9d2c2004-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 Lattner6a36dc62003-01-20 06:11:03 +0000202
203chdir "llvm" or die "Could not change into llvm directory!";
204
Chris Lattnera9e9d2c2004-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 Lattner34debbf2003-01-22 20:35:59 +0000209
Chris Lattner6a36dc62003-01-20 06:11:03 +0000210# Read in the HTML template file...
Chris Lattner85d79a02003-01-22 16:14:05 +0000211my $TemplateContents = ReadFile $Template;
Chris Lattner6a36dc62003-01-20 06:11:03 +0000212
Chris Lattner85d79a02003-01-22 16:14:05 +0000213
214#
Chris Lattner6a36dc62003-01-20 06:11:03 +0000215# Get some static statistics about the current state of CVS
Chris Lattner85d79a02003-01-22 16:14:05 +0000216#
Chris Lattner6a36dc62003-01-20 06:11:03 +0000217my $CVSCheckoutTime = GetRegex "([0-9.]+)", `grep '^real' $Prefix-CVS-Log.txt`;
Brian Gaekefed9ed92003-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 Lattner6a36dc62003-01-20 06:11:03 +0000220$LOC = GetRegex "([0-9]+) +total", `wc -l \`utils/getsrcs.sh\` | grep total`;
221
Chris Lattner85d79a02003-01-22 16:14:05 +0000222#
Chris Lattner6a36dc62003-01-20 06:11:03 +0000223# Build the entire tree, saving build messages to the build log
Chris Lattner85d79a02003-01-22 16:14:05 +0000224#
Chris Lattner6a36dc62003-01-20 06:11:03 +0000225if (!$NOCHECKOUT) {
Chris Lattnera9e9d2c2004-05-28 20:30:23 +0000226 if ( $VERBOSE ) { print "CONFIGURE STAGE\n"; }
Misha Brukman2b6d3382003-08-14 15:26:28 +0000227 system "(time -p ./configure --enable-jit --enable-spec --with-objroot=.) > $Prefix-Build-Log.txt 2>&1";
Chris Lattner6a36dc62003-01-20 06:11:03 +0000228
Chris Lattnera9e9d2c2004-05-28 20:30:23 +0000229 if ( $VERBOSE ) { print "BUILD STAGE\n"; }
Chris Lattner6a36dc62003-01-20 06:11:03 +0000230 # Build the entire tree, capturing the output into $Prefix-Build-Log.txt
Chris Lattnerf5410e82003-07-01 16:02:00 +0000231 system "(time -p gmake $MAKEOPTS) >> $Prefix-Build-Log.txt 2>&1";
Chris Lattner6a36dc62003-01-20 06:11:03 +0000232}
233
Chris Lattner85d79a02003-01-22 16:14:05 +0000234
Chris Lattnerf5ba14b2003-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 Lattner85d79a02003-01-22 16:14:05 +0000241#
Chris Lattner6a36dc62003-01-20 06:11:03 +0000242# Get some statistics about the build...
Chris Lattner85d79a02003-01-22 16:14:05 +0000243#
Chris Lattner6a36dc62003-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 Lattnerf5ba14b2003-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 Lattner688d99f2003-08-18 14:07:03 +0000251my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
Chris Lattnerf5ba14b2003-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 Lattner34debbf2003-01-22 20:35:59 +0000256my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
Chris Lattnerf5ba14b2003-08-18 06:05:21 +0000257my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$Prefix-Build-Log.txt";
258
Chris Lattner85d79a02003-01-22 16:14:05 +0000259my $BuildError = "";
Chris Lattnerd7e18982003-09-23 20:33:04 +0000260if (`grep '^gmake[^:]*: .*Error' $Prefix-Build-Log.txt | wc -l` + 0 ||
Chris Lattner8560a062003-09-23 22:02:01 +0000261 `grep '^gmake: \*\*\*.*Stop.' $Prefix-Build-Log.txt | wc -l`+0) {
Misha Brukman71a1ba62003-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 Lattnereb9d2152003-10-19 16:54:00 +0000264 print "BUILD ERROR\n";
Chris Lattner85d79a02003-01-22 16:14:05 +0000265}
Chris Lattner6a36dc62003-01-20 06:11:03 +0000266
Chris Lattnera9e9d2c2004-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 Spencer3b430222004-05-30 00:17:47 +0000273 # Skip stuff before ---TEST RESULTS
Chris Lattnera9e9d2c2004-05-28 20:30:23 +0000274 while ( <SRCHFILE> ) {
Reid Spencer8ac57712004-05-31 20:59:55 +0000275 if ( m/^--- TEST RESULTS/ ) { last; }
Chris Lattnera9e9d2c2004-05-28 20:30:23 +0000276 }
Reid Spencer3b430222004-05-30 00:17:47 +0000277 # Process test results
Reid Spencer8ac57712004-05-31 20:59:55 +0000278 push(@lines,"<h3>TEST RESULTS</h3><ol><li>\n");
279 my $first_list = 1;
280 my $should_break = 1;
Chris Lattnera9e9d2c2004-05-28 20:30:23 +0000281 while ( <SRCHFILE> ) {
282 if ( length($_) > 1 ) {
Reid Spencer8ac57712004-05-31 20:59:55 +0000283 chomp($_);
284 if ( ! m/: PASS[ ]*$/ &&
285 ! m/^ qmtest.target:/ &&
286 ! m/^ local/ &&
287 ! m/^gmake:/ ) {
288 if ( m/: XFAIL/ || m/: XPASS/ || m/: FAIL/ ) {
289 if ( $first_list ) {
290 $first_list = 0;
291 $should_break = 1;
292 push(@lines,"<b>$_</b><br/>\n");
293 } else {
294 push(@lines,"</li><li><b>$_</b><br/>\n");
295 }
296 } elsif ( m/^--- STATISTICS/ ) {
297 if ( $first_list ) { push(@lines,"<b>PERFECT!</b>"); }
298 push(@lines,"</li></ol><h3>STATISTICS</h3><pre>\n");
299 $should_break = 0;
300 } elsif ( m/^--- TESTS WITH/ ) {
301 $should_break = 1;
302 $first_list = 1;
303 push(@lines,"</pre><h3>TESTS WITH UNEXPECTED RESULTS</h3><ol><li>\n");
304 } elsif ( m/^real / ) {
305 last;
306 } else {
307 if ( $should_break ) {
308 push(@lines,"$_<br/>\n");
309 } else {
310 push(@lines,"$_\n");
311 }
312 }
Chris Lattnera9e9d2c2004-05-28 20:30:23 +0000313 }
314 }
315 }
316 close SRCHFILE;
317 }
318 my $content = join("",@lines);
Reid Spencer8ac57712004-05-31 20:59:55 +0000319 return "$content</pre>\n";
Chris Lattnera9e9d2c2004-05-28 20:30:23 +0000320}
321
Chris Lattnera9e9d2c2004-05-28 20:30:23 +0000322# Get results of feature tests.
323my $FeatureTestResults; # String containing the results of the feature tests
324my $FeatureTime; # System+CPU Time for feature tests
325my $FeatureWallTime; # Wall Clock Time for feature tests
326if (!$NOFEATURES) {
327 if ( $VERBOSE ) { print "FEATURE TEST STAGE\n"; }
328 my $feature_output = "$Prefix-FeatureTests-Log.txt";
329
330 # Run the feature tests so we can summarize the results
331 system "(time -p gmake -C test Feature.t) > $feature_output 2>&1";
332
333 # Extract test results
334 $FeatureTestResults = GetQMTestResults("$feature_output");
335
336 # Extract time of feature tests
337 my $FeatureTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$feature_output";
338 my $FeatureTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$feature_output";
339 $FeatureTime = $FeatureTimeU+$FeatureTimeS; # FeatureTime = User+System
340 $FeatureWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$feature_output";
341 # Run the regression tests so we can summarize the results
342} else {
343 $FeatureTestResults = "Skipped by user choice.";
344 $FeatureTime = "0.0";
345 $FeatureWallTime = "0.0";
346}
347
348if (!$NOREGRESSIONS) {
349 if ( $VERBOSE ) { print "REGRESSION TEST STAGE\n"; }
350 my $regression_output = "$Prefix-RegressionTests-Log.txt";
351
352 # Run the regression tests so we can summarize the results
353 system "(time -p gmake -C test Regression.t) > $regression_output 2>&1";
354
355 # Extract test results
356 $RegressionTestResults = GetQMTestResults("$regression_output");
357
358 # Extract time of regressions tests
359 my $RegressionTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$regression_output";
360 my $RegressionTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$regression_output";
361 $RegressionTime = $RegressionTimeU+$RegressionTimeS; # RegressionTime = User+System
362 $RegressionWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$regression_output";
363} else {
364 $RegressionTestResults = "Skipped by user choice.";
365 $RegressionTime = "0.0";
366 $RegressionWallTime = "0.0";
367}
368
369if ($DEBUG) {
370 print $FeatureTestResults;
371 print $RegressionTestResults;
372}
373
374if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
Chris Lattner85d79a02003-01-22 16:14:05 +0000375#
Chris Lattner6a36dc62003-01-20 06:11:03 +0000376# Get warnings from the build
Chris Lattner85d79a02003-01-22 16:14:05 +0000377#
Misha Brukman6aa98682003-07-07 21:27:40 +0000378my @Warn = split "\n", `egrep 'warning:|Entering dir' $Prefix-Build-Log.txt`;
Chris Lattner6a36dc62003-01-20 06:11:03 +0000379my @Warnings;
380my $CurDir = "";
381
382foreach $Warning (@Warn) {
383 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
384 $CurDir = $1; # Keep track of directory warning is in...
Misha Brukman2b6d3382003-08-14 15:26:28 +0000385 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { # Remove buildir prefix if included
Chris Lattner6a36dc62003-01-20 06:11:03 +0000386 $CurDir = $1;
387 }
388 } else {
389 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
390 }
391}
Chris Lattner7f90f612003-01-20 19:18:44 +0000392my $WarningsFile = join "\n", @Warnings;
393my $WarningsList = AddPreTag $WarningsFile;
394$WarningsFile =~ s/:[0-9]+:/::/g;
Chris Lattner6a36dc62003-01-20 06:11:03 +0000395
Chris Lattner3dc06172003-01-20 18:05:27 +0000396# Emit the warnings file, so we can diff...
397WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
398my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
Chris Lattner6a36dc62003-01-20 06:11:03 +0000399
Chris Lattner83ec9452003-10-18 19:31:39 +0000400# Output something to stdout if something has changed
401print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
402print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
403
Chris Lattnereb9d2152003-10-19 16:54:00 +0000404$WarningsAdded = AddPreTag $WarningsAdded;
405$WarningsRemoved = AddPreTag $WarningsRemoved;
Chris Lattner85d79a02003-01-22 16:14:05 +0000406
407#
Chris Lattner6a36dc62003-01-20 06:11:03 +0000408# Get some statistics about CVS commits over the current day...
Chris Lattner85d79a02003-01-22 16:14:05 +0000409#
Chris Lattnera9e9d2c2004-05-28 20:30:23 +0000410if ($VERBOSE) { print "CVS HISTORY ANALYSIS STAGE\n"; }
Chris Lattner6a36dc62003-01-20 06:11:03 +0000411@CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
412#print join "\n", @CVSHistory; print "\n";
413
414# Extract some information from the CVS history... use a hash so no duplicate
415# stuff is stored.
Misha Brukman6aa98682003-07-07 21:27:40 +0000416my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
Chris Lattner6a36dc62003-01-20 06:11:03 +0000417
Chris Lattner34debbf2003-01-22 20:35:59 +0000418my $DateRE = "[-:0-9 ]+\\+[0-9]+";
419
Chris Lattner6a36dc62003-01-20 06:11:03 +0000420# Loop over every record from the CVS history, filling in the hashes.
421foreach $File (@CVSHistory) {
422 my ($Type, $Date, $UID, $Rev, $Filename);
Misha Brukman2b6d3382003-08-14 15:26:28 +0000423 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
Chris Lattner6a36dc62003-01-20 06:11:03 +0000424 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
Chris Lattner4bb9bc32004-01-12 16:55:30 +0000425 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
426 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
Misha Brukman6aa98682003-07-07 21:27:40 +0000427 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
Chris Lattner34debbf2003-01-22 20:35:59 +0000428 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
Chris Lattner6a36dc62003-01-20 06:11:03 +0000429 } else {
Chris Lattner34debbf2003-01-22 20:35:59 +0000430 print "UNMATCHABLE: $File\n";
431 }
432 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
433
434 if ($Filename =~ /^llvm/) {
435 if ($Type eq 'M') { # Modified
436 $ModifiedFiles{$Filename} = 1;
437 $UsersCommitted{$UID} = 1;
438 } elsif ($Type eq 'A') { # Added
439 $AddedFiles{$Filename} = 1;
440 $UsersCommitted{$UID} = 1;
441 } elsif ($Type eq 'R') { # Removed
442 $RemovedFiles{$Filename} = 1;
443 $UsersCommitted{$UID} = 1;
444 } else {
445 $UsersUpdated{$UID} = 1;
446 }
Chris Lattner6a36dc62003-01-20 06:11:03 +0000447 }
448}
449
Chris Lattner7f90f612003-01-20 19:18:44 +0000450my $UserCommitList = join "\n", keys %UsersCommitted;
451my $UserUpdateList = join "\n", keys %UsersUpdated;
Chris Lattnerbade93c2003-08-06 16:02:50 +0000452my $AddedFilesList = AddPreTag join "\n", sort keys %AddedFiles;
453my $ModifiedFilesList = AddPreTag join "\n", sort keys %ModifiedFiles;
454my $RemovedFilesList = AddPreTag join "\n", sort keys %RemovedFiles;
Chris Lattner6a36dc62003-01-20 06:11:03 +0000455
Chris Lattner88126c02003-02-28 20:30:20 +0000456my $TestError = 1;
Chris Lattnerf5ba14b2003-08-18 06:05:21 +0000457my $SingleSourceProgramsTable;
458my $MultiSourceProgramsTable;
Chris Lattnered51e682003-08-21 15:55:26 +0000459my $ExternalProgramsTable;
Chris Lattner85d79a02003-01-22 16:14:05 +0000460
Chris Lattnerf5ba14b2003-08-18 06:05:21 +0000461
462sub TestDirectory {
463 my $SubDir = shift;
464
465 chdir "test/Programs/$SubDir" or
466 die "Could not change into test/Programs/$SubDir testdir!";
Chris Lattner88126c02003-02-28 20:30:20 +0000467
468 # Run the programs tests... creating a report.nightly.html file
469 if (!$NOTEST) {
Chris Lattner8f668f262003-12-19 03:47:31 +0000470 system "gmake -k $MAKEOPTS $ENABLELINEARSCAN report.nightly.html "
471 . "TEST=nightly > $Prefix-$SubDir-ProgramTest.txt 2>&1";
Chris Lattner88126c02003-02-28 20:30:20 +0000472 } else {
Chris Lattnerf5ba14b2003-08-18 06:05:21 +0000473 system "gunzip $Prefix-$SubDir-ProgramTest.txt.gz";
Chris Lattner88126c02003-02-28 20:30:20 +0000474 }
475
Chris Lattnerf5ba14b2003-08-18 06:05:21 +0000476 my $ProgramsTable;
Chris Lattner42fee012003-08-20 15:44:33 +0000477 if (`grep '^gmake[^:]: .*Error' $Prefix-$SubDir-ProgramTest.txt | wc -l` + 0){
Chris Lattner88126c02003-02-28 20:30:20 +0000478 $TestError = 1;
Chris Lattnerc09c0b92003-05-10 21:40:10 +0000479 $ProgramsTable = "<font color=white><h2>Error running tests!</h2></font>";
Chris Lattnereb9d2152003-10-19 16:54:00 +0000480 print "ERROR TESTING\n";
Chris Lattner42fee012003-08-20 15:44:33 +0000481 } elsif (`grep '^gmake[^:]: .*No rule to make target' $Prefix-$SubDir-ProgramTest.txt | wc -l` + 0) {
Chris Lattner0a55e462003-05-11 15:23:10 +0000482 $TestError = 1;
483 $ProgramsTable =
484 "<font color=white><h2>Makefile error running tests!</h2></font>";
Chris Lattnereb9d2152003-10-19 16:54:00 +0000485 print "ERROR TESTING\n";
Chris Lattner0a55e462003-05-11 15:23:10 +0000486 } else {
Chris Lattner88126c02003-02-28 20:30:20 +0000487 $TestError = 0;
488 $ProgramsTable = ReadFile "report.nightly.html";
489
490 #
491 # Create a list of the tests which were run...
492 #
Chris Lattnerf5ba14b2003-08-18 06:05:21 +0000493 system "egrep 'TEST-(PASS|FAIL)' < $Prefix-$SubDir-ProgramTest.txt "
494 . "| sort > $Prefix-$SubDir-Tests.txt";
Chris Lattner88126c02003-02-28 20:30:20 +0000495 }
496
497 # Compress the test output
Chris Lattnerf5ba14b2003-08-18 06:05:21 +0000498 system "gzip -f $Prefix-$SubDir-ProgramTest.txt";
499 chdir "../../.." or die "Cannot return to parent directory!";
500 return $ProgramsTable;
501}
502
Chris Lattnerd1fc00d2003-08-19 15:08:34 +0000503# If we build the tree successfully, run the nightly programs tests...
Chris Lattnerf5ba14b2003-08-18 06:05:21 +0000504if ($BuildError eq "") {
Chris Lattnera9e9d2c2004-05-28 20:30:23 +0000505 if ( $VERBOSE ) {
506 print "SingleSource TEST STAGE\n";
507 }
Chris Lattnerf5ba14b2003-08-18 06:05:21 +0000508 $SingleSourceProgramsTable = TestDirectory("SingleSource");
Chris Lattnera9e9d2c2004-05-28 20:30:23 +0000509 if ( $VERBOSE ) {
510 print "MultiSource TEST STAGE\n";
511 }
Chris Lattnerf5ba14b2003-08-18 06:05:21 +0000512 $MultiSourceProgramsTable = TestDirectory("MultiSource");
Chris Lattnera9e9d2c2004-05-28 20:30:23 +0000513 if ( $VERBOSE ) {
514 print "External TEST STAGE\n";
515 }
Chris Lattnered51e682003-08-21 15:55:26 +0000516 $ExternalProgramsTable = TestDirectory("External");
Chris Lattner71f65432003-08-18 15:11:13 +0000517 system "cat $Prefix-SingleSource-Tests.txt $Prefix-MultiSource-Tests.txt ".
Chris Lattnered51e682003-08-21 15:55:26 +0000518 " $Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
Chris Lattnerd090dbb2003-01-23 19:31:28 +0000519}
Chris Lattner85d79a02003-01-22 16:14:05 +0000520
Chris Lattnera9e9d2c2004-05-28 20:30:23 +0000521if ( $VERBOSE ) {
522 print "TEST INFORMATION COLLECTION STAGE\n";
523}
Chris Lattner34debbf2003-01-22 20:35:59 +0000524my ($TestsAdded, $TestsRemoved, $TestsFixed, $TestsBroken) = ("","","","");
525
Chris Lattner88126c02003-02-28 20:30:20 +0000526if ($TestError) {
527 $TestsAdded = "<b>error testing</b><br>";
528 $TestsRemoved = "<b>error testing</b><br>";
529 $TestsFixed = "<b>error testing</b><br>";
530 $TestsBroken = "<b>error testing</b><br>";
531} else {
532 my ($RTestsAdded, $RTestsRemoved) = DiffFiles "-Tests.txt";
533
534 my @RawTestsAddedArray = split '\n', $RTestsAdded;
535 my @RawTestsRemovedArray = split '\n', $RTestsRemoved;
536
537 my %OldTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
538 @RawTestsRemovedArray;
539 my %NewTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
540 @RawTestsAddedArray;
541
542 foreach $Test (keys %NewTests) {
543 if (!exists $OldTests{$Test}) { # TestAdded if in New but not old
544 $TestsAdded = "$TestsAdded$Test\n";
Chris Lattner34debbf2003-01-22 20:35:59 +0000545 } else {
Chris Lattner88126c02003-02-28 20:30:20 +0000546 if ($OldTests{$Test} =~ /TEST-PASS/) { # Was the old one a pass?
547 $TestsBroken = "$TestsBroken$Test\n"; # New one must be a failure
548 } else {
549 $TestsFixed = "$TestsFixed$Test\n"; # No, new one is a pass.
550 }
Chris Lattner34debbf2003-01-22 20:35:59 +0000551 }
552 }
Chris Lattner88126c02003-02-28 20:30:20 +0000553 foreach $Test (keys %OldTests) { # TestRemoved if in Old but not New
554 $TestsRemoved = "$TestsRemoved$Test\n" if (!exists $NewTests{$Test});
555 }
Chris Lattner34debbf2003-01-22 20:35:59 +0000556
Chris Lattner518f3fd2003-10-21 15:47:31 +0000557 print "\nTESTS ADDED: \n\n$TestsAdded\n\n" if (length $TestsAdded);
558 print "\nTESTS REMOVED:\n\n$TestsRemoved\n\n" if (length $TestsRemoved);
559 print "\nTESTS FIXED: \n\n$TestsFixed\n\n" if (length $TestsFixed);
560 print "\nTESTS BROKEN: \n\n$TestsBroken\n\n" if (length $TestsBroken);
Chris Lattnereb9d2152003-10-19 16:54:00 +0000561
Chris Lattner88126c02003-02-28 20:30:20 +0000562 $TestsAdded = AddPreTag $TestsAdded;
563 $TestsRemoved = AddPreTag $TestsRemoved;
564 $TestsFixed = AddPreTag $TestsFixed;
565 $TestsBroken = AddPreTag $TestsBroken;
566}
Chris Lattner34debbf2003-01-22 20:35:59 +0000567
Chris Lattner83ec9452003-10-18 19:31:39 +0000568
Chris Lattnerd1fc00d2003-08-19 15:08:34 +0000569# If we built the tree successfully, runs of the Olden suite with
570# LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
571if ($BuildError eq "") {
Chris Lattner05c8f642003-08-19 18:35:03 +0000572 my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
Chris Lattnerd1fc00d2003-08-19 15:08:34 +0000573 $MachCodeSize) = ("","","","","","","");
Chris Lattner05c8f642003-08-19 18:35:03 +0000574 if (!$NORUNNINGTESTS) {
Chris Lattner9aa85982003-09-14 06:00:49 +0000575 chdir "test/Programs/MultiSource/Benchmarks/Olden" or die "Olden tests moved?";
Chris Lattnerd1fc00d2003-08-19 15:08:34 +0000576
577 # Clean out previous results...
578 system "gmake $MAKEOPTS clean > /dev/null 2>&1";
579
580 # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE enabled!
Chris Lattnerd09f3392003-10-28 18:37:24 +0000581 system "gmake -k $MAKEOPTS report.nightly.raw.out TEST=nightly " .
Chris Lattnerd1fc00d2003-08-19 15:08:34 +0000582 " LARGE_PROBLEM_SIZE=1 > /dev/null 2>&1";
583 system "cp report.nightly.raw.out $Prefix-Olden-tests.txt";
584 } else {
585 system "gunzip $Prefix-Olden-tests.txt.gz";
586 }
587
588 # Now we know we have $Prefix-Olden-tests.txt as the raw output file. Split
589 # it up into records and read the useful information.
Chris Lattner05c8f642003-08-19 18:35:03 +0000590 my @Records = split />>> ========= /, ReadFile "$Prefix-Olden-tests.txt";
Chris Lattnerd1fc00d2003-08-19 15:08:34 +0000591 shift @Records; # Delete the first (garbage) record
592
593 # Loop over all of the records, summarizing them into rows for the running
594 # totals file.
595 my $WallTimeRE = "[A-Za-z0-9.: ]+\\(([0-9.]+) wall clock";
596 foreach $Rec (@Records) {
Chris Lattner05c8f642003-08-19 18:35:03 +0000597 my $rNATTime = GetRegex 'TEST-RESULT-nat-time: real\s*([.0-9m]+)', $Rec;
598 my $rCBETime = GetRegex 'TEST-RESULT-cbe-time: real\s*([.0-9m]+)', $Rec;
599 my $rLLCTime = GetRegex 'TEST-RESULT-llc-time: real\s*([.0-9m]+)', $Rec;
600 my $rJITTime = GetRegex 'TEST-RESULT-jit-time: real\s*([.0-9m]+)', $Rec;
Chris Lattnerd1fc00d2003-08-19 15:08:34 +0000601 my $rOptTime = GetRegex "TEST-RESULT-compile: $WallTimeRE", $Rec;
602 my $rBytecodeSize = GetRegex 'TEST-RESULT-compile: *([0-9]+)', $Rec;
603 my $rMachCodeSize = GetRegex 'TEST-RESULT-jit-machcode: *([0-9]+).*bytes of machine code', $Rec;
604
605 $NATTime .= " " . FormatTime($rNATTime);
606 $CBETime .= " " . FormatTime($rCBETime);
607 $LLCTime .= " " . FormatTime($rLLCTime);
608 $JITTime .= " " . FormatTime($rJITTime);
609 $OptTime .= " $rOptTime";
Chris Lattner05c8f642003-08-19 18:35:03 +0000610 $BytecodeSize .= " $rBytecodeSize";
611 $MachCodeSize .= " $rMachCodeSize";
Chris Lattnerd1fc00d2003-08-19 15:08:34 +0000612 }
613
614 # Now that we have all of the numbers we want, add them to the running totals
615 # files.
Chris Lattner05c8f642003-08-19 18:35:03 +0000616 AddRecord($NATTime, "running_Olden_nat_time.txt");
Chris Lattnerd1fc00d2003-08-19 15:08:34 +0000617 AddRecord($CBETime, "running_Olden_cbe_time.txt");
618 AddRecord($LLCTime, "running_Olden_llc_time.txt");
619 AddRecord($JITTime, "running_Olden_jit_time.txt");
620 AddRecord($OptTime, "running_Olden_opt_time.txt");
621 AddRecord($BytecodeSize, "running_Olden_bytecode.txt");
622 AddRecord($MachCodeSize, "running_Olden_machcode.txt");
Chris Lattner05c8f642003-08-19 18:35:03 +0000623
624 system "gzip -f $Prefix-Olden-tests.txt";
Chris Lattnerd1fc00d2003-08-19 15:08:34 +0000625}
626
627
628
629
Chris Lattner34debbf2003-01-22 20:35:59 +0000630#
Chris Lattner6a36dc62003-01-20 06:11:03 +0000631# Get a list of the previous days that we can link to...
Chris Lattner85d79a02003-01-22 16:14:05 +0000632#
Chris Lattner3dc06172003-01-20 18:05:27 +0000633my @PrevDays = map {s/.html//; $_} GetDir ".html";
Chris Lattner6a36dc62003-01-20 06:11:03 +0000634
635splice @PrevDays, 20; # Trim down list to something reasonable...
636
637my $PrevDaysList = # Format list for sidebar
638 join "\n ", map { "<a href=\"$_.html\">$_</a><br>" } @PrevDays;
639
Chris Lattner3c81d9a2003-08-18 20:07:54 +0000640#
641# Start outputing files into the web directory
642#
643chdir $WebDir or die "Could not change into web directory!";
644
645# Add information to the files which accumulate information for graphs...
646AddRecord($LOC, "running_loc.txt");
647AddRecord($BuildTime, "running_build_time.txt");
648
Chris Lattnera9e9d2c2004-05-28 20:30:23 +0000649if ( $VERBOSE ) {
650 print "GRAPH GENERATION STAGE\n";
651}
Chris Lattner3c81d9a2003-08-18 20:07:54 +0000652#
653# Rebuild the graphs now...
654#
Brian Gaeke91d16b32003-10-11 05:34:00 +0000655$GNUPLOT = "/usr/dcs/software/supported/bin/gnuplot";
656$GNUPLOT = "gnuplot" if ! -x $GNUPLOT;
657$PlotScriptFilename = "$BuildDir/llvm/utils/NightlyTest.gnuplot";
658system ($GNUPLOT, $PlotScriptFilename);
Chris Lattner85d79a02003-01-22 16:14:05 +0000659
Chris Lattner6a36dc62003-01-20 06:11:03 +0000660#
661# Remove the cvs tree...
662#
663system "rm -rf $BuildDir" if (!$NOCHECKOUT and !$NOREMOVE);
664
Chris Lattner85d79a02003-01-22 16:14:05 +0000665#
Chris Lattner6a36dc62003-01-20 06:11:03 +0000666# Print out information...
Chris Lattner85d79a02003-01-22 16:14:05 +0000667#
Chris Lattnera9e9d2c2004-05-28 20:30:23 +0000668if ($VERBOSE) {
Chris Lattner6a36dc62003-01-20 06:11:03 +0000669 print "DateString: $DateString\n";
670 print "CVS Checkout: $CVSCheckoutTime seconds\n";
671 print "Files/Dirs/LOC in CVS: $NumFilesInCVS/$NumDirsInCVS/$LOC\n";
Chris Lattner6a36dc62003-01-20 06:11:03 +0000672 print "Build Time: $BuildTime seconds\n";
Chris Lattnera9e9d2c2004-05-28 20:30:23 +0000673 print "Feature Test Time: $FeatureTime seconds\n";
674 print "Regression Test Time: $RegressionTime seconds\n";
Chris Lattner6a36dc62003-01-20 06:11:03 +0000675 print "Libraries/Executables/Objects built: $NumLibraries/$NumExecutables/$NumObjects\n";
676
677 print "WARNINGS:\n $WarningsList\n";
678
Chris Lattner6a36dc62003-01-20 06:11:03 +0000679 print "Users committed: $UserCommitList\n";
680 print "Added Files: \n $AddedFilesList\n";
681 print "Modified Files: \n $ModifiedFilesList\n";
682 print "Removed Files: \n $RemovedFilesList\n";
683
684 print "Previous Days =\n $PrevDaysList\n";
685}
686
Chris Lattner85d79a02003-01-22 16:14:05 +0000687
Chris Lattner3dc06172003-01-20 18:05:27 +0000688#
689# Output the files...
690#
691
Chris Lattnera9e9d2c2004-05-28 20:30:23 +0000692if ( $VERBOSE ) {
693 print "OUTPUT STAGE\n";
694}
Chris Lattner3dc06172003-01-20 18:05:27 +0000695# Main HTML file...
Chris Lattner6a36dc62003-01-20 06:11:03 +0000696my $Output;
697eval "\$Output = <<ENDOFFILE;$TemplateContents\nENDOFFILE\n";
Chris Lattner3dc06172003-01-20 18:05:27 +0000698WriteFile "$DATE.html", $Output;
Chris Lattner6a36dc62003-01-20 06:11:03 +0000699
700# Change the index.html symlink...
701system "ln -sf $DATE.html index.html";
702
703sub AddRecord {
704 my ($Val, $Filename) = @_;
705 my @Records;
Chris Lattnerd1fc00d2003-08-19 15:08:34 +0000706 if (open FILE, "$WebDir/$Filename") {
Chris Lattner6a36dc62003-01-20 06:11:03 +0000707 @Records = grep !/$DATE/, split "\n", <FILE>;
708 close FILE;
709 }
710 push @Records, "$DATE: $Val";
Chris Lattner05c8f642003-08-19 18:35:03 +0000711 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
Chris Lattner6a36dc62003-01-20 06:11:03 +0000712 return @Records;
713}