blob: 0ab685e648ced2befd37c1c55598ab83b2b9c172 [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 Lattner20d13ea2004-06-03 03:29:39 +000024# -disable-codegen Disable LLC and JIT tests in the nightly tester.
Chris Lattner4d00fde2004-05-28 20:30:23 +000025# -verbose Turn on some debug output
26# -debug Print information useful only to maintainers of this script.
Chris Lattnerbb0aca52003-12-19 03:47:31 +000027#
Brian Gaekeb3dab902003-10-11 05:34:00 +000028# CVSROOT is the CVS repository from which the tree will be checked out,
29# specified either in the full :method:user@host:/dir syntax, or
30# just /dir if using a local repo.
31# BUILDDIR is the directory where sources for this test run will be checked out
32# AND objects for this test run will be built. This directory MUST NOT
33# exist before the script is run; it will be created by the cvs checkout
34# process and erased (unless -noremove is specified; see above.)
35# WEBDIR is the directory into which the test results web page will be written,
36# AND in which the "index.html" is assumed to be a symlink to the most recent
37# copy of the results. This directory MUST exist before the script is run.
Chris Lattner4c7e3032003-01-20 06:11:03 +000038#
39use POSIX qw(strftime);
40
Brian Gaekeb3dab902003-10-11 05:34:00 +000041my $HOME = $ENV{'HOME'};
42my $CVSRootDir = $ENV{'CVSROOT'};
Chris Lattner9d13efa2003-10-14 01:22:08 +000043 $CVSRootDir = "/home/vadve/shared/PublicCVS"
Chris Lattner4d00fde2004-05-28 20:30:23 +000044 unless $CVSRootDir;
45my $BuildDir = $ENV{'BUILDDIR'};
46 $BuildDir = "$HOME/buildtest"
47 unless $BuildDir;
48my $WebDir = $ENV{'WEBDIR'};
49 $WebDir = "$HOME/cvs/testresults-X86"
50 unless $WebDir;
Chris Lattner2f8cb572003-01-20 18:05:27 +000051
52# Calculate the date prefix...
53@TIME = localtime;
54my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
55my $DateString = strftime "%B %d, %Y", localtime;
56
Chris Lattnerb3440302003-01-22 16:14:05 +000057sub ReadFile {
Chris Lattner196a14a2003-08-19 15:08:34 +000058 undef $/;
Chris Lattnerb3440302003-01-22 16:14:05 +000059 if (open (FILE, $_[0])) {
60 my $Ret = <FILE>;
61 close FILE;
62 return $Ret;
63 } else {
64 print "Could not open file '$_[0]' for reading!";
65 return "";
66 }
67}
68
Chris Lattner2f8cb572003-01-20 18:05:27 +000069sub WriteFile { # (filename, contents)
70 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!";
71 print FILE $_[1];
72 close FILE;
73}
74
75sub GetRegex { # (Regex with ()'s, value)
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +000076 $_[1] =~ /$_[0]/m;
Chris Lattner08e24762003-08-19 18:35:03 +000077 if (defined($1)) {
78 return $1;
79 }
80 return "?";
Chris Lattner2f8cb572003-01-20 18:05:27 +000081}
82
83sub AddPreTag { # Add pre tags around nonempty list, or convert to "none"
84 $_ = shift;
Chris Lattner1cbc0a62003-01-20 19:18:44 +000085 if (length) { return "<ul><pre>$_</pre></ul>"; } else { "<b>none</b><br>"; }
Chris Lattner2f8cb572003-01-20 18:05:27 +000086}
87
88sub GetDir {
89 my $Suffix = shift;
90 opendir DH, $WebDir;
91 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
92 closedir DH;
93 return @Result;
94}
95
96# DiffFiles - Diff the current version of the file against the last version of
97# the file, reporting things added and removed. This is used to report, for
98# example, added and removed warnings. This returns a pair (added, removed)
99#
100sub DiffFiles {
101 my $Suffix = shift;
102 my @Others = GetDir $Suffix;
103 if (@Others == 0) { # No other files? We added all entries...
104 return (`cat $WebDir/$DATE$Suffix`, "");
105 }
106 # Diff the files now...
107 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
108 my $Added = join "\n", grep /^</, @Diffs;
109 my $Removed = join "\n", grep /^>/, @Diffs;
Chris Lattner1cbc0a62003-01-20 19:18:44 +0000110 $Added =~ s/^< //gm;
111 $Removed =~ s/^> //gm;
Chris Lattner2f8cb572003-01-20 18:05:27 +0000112 return ($Added, $Removed);
113}
114
Chris Lattner196a14a2003-08-19 15:08:34 +0000115# FormatTime - Convert a time from 1m23.45 into 83.45
116sub FormatTime {
117 my $Time = shift;
118 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
119 $Time = sprintf("%7.4f", $1*60.0+$2);
120 }
121 return $Time;
122}
123
Chris Lattner2f8cb572003-01-20 18:05:27 +0000124
Chris Lattner4c7e3032003-01-20 06:11:03 +0000125# Command line argument settings...
126my $NOCHECKOUT = 0;
127my $NOREMOVE = 0;
Chris Lattner4d00fde2004-05-28 20:30:23 +0000128my $NOFEATURES = 0;
129my $NOREGRESSIONS = 0;
Chris Lattnerb3440302003-01-22 16:14:05 +0000130my $NOTEST = 0;
Chris Lattner08e24762003-08-19 18:35:03 +0000131my $NORUNNINGTESTS = 0;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000132my $MAKEOPTS = "";
Chris Lattner20d13ea2004-06-03 03:29:39 +0000133my $PROGTESTOPTS = "";
Chris Lattner4d00fde2004-05-28 20:30:23 +0000134my $VERBOSE = 0;
135my $DEBUG = 0;
Brian Gaekeb3dab902003-10-11 05:34:00 +0000136
Chris Lattner4c7e3032003-01-20 06:11:03 +0000137# Parse arguments...
138while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
139 shift;
140 last if /^--$/; # Stop processing arguments on --
141
142 # List command line options here...
Chris Lattner08e24762003-08-19 18:35:03 +0000143 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
144 if (/^-noremove$/) { $NOREMOVE = 1; next; }
Chris Lattner20d13ea2004-06-03 03:29:39 +0000145 if (/^-nofeaturetests$/) { $NOFEATURES = 1; next; }
146 if (/^-noregressiontests$/){ $NOREGRESSIONS = 1; next; }
Chris Lattner08e24762003-08-19 18:35:03 +0000147 if (/^-notest$/) { $NOTEST = 1; $NORUNNINGTESTS = 1; next; }
148 if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
149 if (/^-parallel$/) { $MAKEOPTS = "-j2 -l3.0"; next; }
Chris Lattner20d13ea2004-06-03 03:29:39 +0000150 if (/^-enable-linscan$/) { $PROGTESTOPTS .= " ENABLE_LINEARSCAN=1"; next; }
151 if (/^-disable-codegen$/){ $PROGTESTOPTS .= " DISABLE_JIT=1 DISABLE_LLC=1"; next; }
Chris Lattner4d00fde2004-05-28 20:30:23 +0000152 if (/^-verbose$/) { $VERBOSE = 1; next; }
153 if (/^-debug$/) { $DEBUG = 1; next; }
Chris Lattner4c7e3032003-01-20 06:11:03 +0000154
155 print "Unknown option: $_ : ignoring!\n";
156}
157
Chris Lattner2f8cb572003-01-20 18:05:27 +0000158die "Must specify 0 or 3 options!" if (@ARGV != 0 and @ARGV != 3);
Chris Lattner4c7e3032003-01-20 06:11:03 +0000159
Chris Lattner4c7e3032003-01-20 06:11:03 +0000160if (@ARGV == 3) {
161 $CVSRootDir = $ARGV[0];
162 $BuildDir = $ARGV[1];
163 $WebDir = $ARGV[2];
164}
165
Chris Lattner4d00fde2004-05-28 20:30:23 +0000166
Misha Brukman1b366892003-07-07 21:27:40 +0000167my $Template = "$BuildDir/llvm/utils/NightlyTestTemplate.html";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000168my $Prefix = "$WebDir/$DATE";
169
Chris Lattner4d00fde2004-05-28 20:30:23 +0000170if ($VERBOSE) {
171 print "INITIALIZED\n";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000172 print "CVS Root = $CVSRootDir\n";
173 print "BuildDir = $BuildDir\n";
174 print "WebDir = $WebDir\n";
175 print "Prefix = $Prefix\n";
176}
177
Chris Lattnerb3440302003-01-22 16:14:05 +0000178
179#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000180# Create the CVS repository directory
Chris Lattnerb3440302003-01-22 16:14:05 +0000181#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000182if (!$NOCHECKOUT) {
Chris Lattner4d00fde2004-05-28 20:30:23 +0000183 if (-d $BuildDir) {
184 if (!$NOREMOVE) {
Reid Spencer542e8592004-05-30 00:17:47 +0000185 system "rm -rf $BuildDir";
Chris Lattner4d00fde2004-05-28 20:30:23 +0000186 } else {
187 die "CVS checkout directory $BuildDir already exists!";
188 }
189 }
Misha Brukman1b366892003-07-07 21:27:40 +0000190 mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000191}
Misha Brukman1b366892003-07-07 21:27:40 +0000192chdir $BuildDir or die "Could not change to CVS checkout directory $BuildDir!";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000193
Chris Lattnerb3440302003-01-22 16:14:05 +0000194
195#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000196# Check out the llvm tree, saving CVS messages to the cvs log...
Chris Lattnerb3440302003-01-22 16:14:05 +0000197#
Brian Gaekeb3dab902003-10-11 05:34:00 +0000198$CVSOPT = "";
199$CVSOPT = "-z3" if $CVSRootDir =~ /^:ext:/; # Use compression if going over ssh.
Chris Lattner4d00fde2004-05-28 20:30:23 +0000200if (!$NOCHECKOUT) {
201 if ( $VERBOSE ) { print "CHECKOUT STAGE\n"; }
202 system "(time -p cvs $CVSOPT -d $CVSRootDir co llvm) > $Prefix-CVS-Log.txt 2>&1";
203}
Chris Lattner4c7e3032003-01-20 06:11:03 +0000204
205chdir "llvm" or die "Could not change into llvm directory!";
206
Chris Lattner4d00fde2004-05-28 20:30:23 +0000207if (!$NOCHECKOUT) {
208 if ( $VERBOSE ) { print "UPDATE STAGE\n"; }
209 system "cvs update -P -d > /dev/null 2>&1" ;
210}
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000211
Chris Lattner4c7e3032003-01-20 06:11:03 +0000212# Read in the HTML template file...
Chris Lattnerb3440302003-01-22 16:14:05 +0000213my $TemplateContents = ReadFile $Template;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000214
Chris Lattnerb3440302003-01-22 16:14:05 +0000215
216#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000217# Get some static statistics about the current state of CVS
Chris Lattnerb3440302003-01-22 16:14:05 +0000218#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000219my $CVSCheckoutTime = GetRegex "([0-9.]+)", `grep '^real' $Prefix-CVS-Log.txt`;
Brian Gaekeac5d96b2003-12-01 05:31:12 +0000220my $NumFilesInCVS = `egrep '^U' $Prefix-CVS-Log.txt | wc -l` + 0;
221my $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $Prefix-CVS-Log.txt | wc -l` + 0;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000222$LOC = GetRegex "([0-9]+) +total", `wc -l \`utils/getsrcs.sh\` | grep total`;
223
Chris Lattnerb3440302003-01-22 16:14:05 +0000224#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000225# Build the entire tree, saving build messages to the build log
Chris Lattnerb3440302003-01-22 16:14:05 +0000226#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000227if (!$NOCHECKOUT) {
Chris Lattner4d00fde2004-05-28 20:30:23 +0000228 if ( $VERBOSE ) { print "CONFIGURE STAGE\n"; }
Misha Brukman8e9554a2003-08-14 15:26:28 +0000229 system "(time -p ./configure --enable-jit --enable-spec --with-objroot=.) > $Prefix-Build-Log.txt 2>&1";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000230
Chris Lattner4d00fde2004-05-28 20:30:23 +0000231 if ( $VERBOSE ) { print "BUILD STAGE\n"; }
Chris Lattner4c7e3032003-01-20 06:11:03 +0000232 # Build the entire tree, capturing the output into $Prefix-Build-Log.txt
Chris Lattner42815c82003-07-01 16:02:00 +0000233 system "(time -p gmake $MAKEOPTS) >> $Prefix-Build-Log.txt 2>&1";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000234}
235
Chris Lattnerb3440302003-01-22 16:14:05 +0000236
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000237sub GetRegexNum {
238 my ($Regex, $Num, $Regex2, $File) = @_;
239 my @Items = split "\n", `grep '$Regex' $File`;
240 return GetRegex $Regex2, $Items[$Num];
241}
242
Chris Lattnerb3440302003-01-22 16:14:05 +0000243#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000244# Get some statistics about the build...
Chris Lattnerb3440302003-01-22 16:14:05 +0000245#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000246my @Linked = split '\n', `grep Linking $Prefix-Build-Log.txt`;
247my $NumExecutables = scalar(grep(/executable/, @Linked));
248my $NumLibraries = scalar(grep(!/executable/, @Linked));
249my $NumObjects = `grep '^Compiling' $Prefix-Build-Log.txt | wc -l` + 0;
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000250
251my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$Prefix-Build-Log.txt";
252my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$Prefix-Build-Log.txt";
Chris Lattner00d7af62003-08-18 14:07:03 +0000253my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000254my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$Prefix-Build-Log.txt";
255
256my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$Prefix-Build-Log.txt";
257my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$Prefix-Build-Log.txt";
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000258my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000259my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$Prefix-Build-Log.txt";
260
Chris Lattnerb3440302003-01-22 16:14:05 +0000261my $BuildError = "";
Chris Lattner338dd7e2003-09-23 20:33:04 +0000262if (`grep '^gmake[^:]*: .*Error' $Prefix-Build-Log.txt | wc -l` + 0 ||
Chris Lattnerccee2962003-09-23 22:02:01 +0000263 `grep '^gmake: \*\*\*.*Stop.' $Prefix-Build-Log.txt | wc -l`+0) {
Misha Brukman71b0a312003-08-21 20:22:52 +0000264 $BuildError = "<h3><font color='red'>Build error: compilation " .
265 "<a href=\"$DATE-Build-Log.txt\">aborted</a></font></h3>";
Chris Lattnerbe197872003-10-19 16:54:00 +0000266 print "BUILD ERROR\n";
Chris Lattnerb3440302003-01-22 16:14:05 +0000267}
Chris Lattner4c7e3032003-01-20 06:11:03 +0000268
Chris Lattner4d00fde2004-05-28 20:30:23 +0000269sub GetQMTestResults { # (filename)
270 my ($filename) = @_;
271 my @lines;
272 my $firstline;
273 $/ = "\n"; #Make sure we're going line at a time.
274 if (open SRCHFILE, $filename) {
Reid Spencer542e8592004-05-30 00:17:47 +0000275 # Skip stuff before ---TEST RESULTS
Chris Lattner4d00fde2004-05-28 20:30:23 +0000276 while ( <SRCHFILE> ) {
Reid Spenceraa0bfbe2004-05-31 20:59:55 +0000277 if ( m/^--- TEST RESULTS/ ) { last; }
Chris Lattner4d00fde2004-05-28 20:30:23 +0000278 }
Reid Spencer542e8592004-05-30 00:17:47 +0000279 # Process test results
Reid Spenceraa0bfbe2004-05-31 20:59:55 +0000280 push(@lines,"<h3>TEST RESULTS</h3><ol><li>\n");
281 my $first_list = 1;
282 my $should_break = 1;
Chris Lattner4d00fde2004-05-28 20:30:23 +0000283 while ( <SRCHFILE> ) {
284 if ( length($_) > 1 ) {
Reid Spenceraa0bfbe2004-05-31 20:59:55 +0000285 chomp($_);
286 if ( ! m/: PASS[ ]*$/ &&
287 ! m/^ qmtest.target:/ &&
288 ! m/^ local/ &&
289 ! m/^gmake:/ ) {
290 if ( m/: XFAIL/ || m/: XPASS/ || m/: FAIL/ ) {
291 if ( $first_list ) {
292 $first_list = 0;
293 $should_break = 1;
294 push(@lines,"<b>$_</b><br/>\n");
295 } else {
296 push(@lines,"</li><li><b>$_</b><br/>\n");
297 }
298 } elsif ( m/^--- STATISTICS/ ) {
299 if ( $first_list ) { push(@lines,"<b>PERFECT!</b>"); }
300 push(@lines,"</li></ol><h3>STATISTICS</h3><pre>\n");
301 $should_break = 0;
302 } elsif ( m/^--- TESTS WITH/ ) {
303 $should_break = 1;
304 $first_list = 1;
305 push(@lines,"</pre><h3>TESTS WITH UNEXPECTED RESULTS</h3><ol><li>\n");
306 } elsif ( m/^real / ) {
307 last;
308 } else {
309 if ( $should_break ) {
310 push(@lines,"$_<br/>\n");
311 } else {
312 push(@lines,"$_\n");
313 }
314 }
Chris Lattner4d00fde2004-05-28 20:30:23 +0000315 }
316 }
317 }
318 close SRCHFILE;
319 }
320 my $content = join("",@lines);
Reid Spenceraa0bfbe2004-05-31 20:59:55 +0000321 return "$content</pre>\n";
Chris Lattner4d00fde2004-05-28 20:30:23 +0000322}
323
Chris Lattner4d00fde2004-05-28 20:30:23 +0000324# Get results of feature tests.
325my $FeatureTestResults; # String containing the results of the feature tests
326my $FeatureTime; # System+CPU Time for feature tests
327my $FeatureWallTime; # Wall Clock Time for feature tests
328if (!$NOFEATURES) {
329 if ( $VERBOSE ) { print "FEATURE TEST STAGE\n"; }
330 my $feature_output = "$Prefix-FeatureTests-Log.txt";
331
332 # Run the feature tests so we can summarize the results
333 system "(time -p gmake -C test Feature.t) > $feature_output 2>&1";
334
335 # Extract test results
336 $FeatureTestResults = GetQMTestResults("$feature_output");
337
338 # Extract time of feature tests
339 my $FeatureTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$feature_output";
340 my $FeatureTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$feature_output";
341 $FeatureTime = $FeatureTimeU+$FeatureTimeS; # FeatureTime = User+System
342 $FeatureWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$feature_output";
343 # Run the regression tests so we can summarize the results
344} else {
345 $FeatureTestResults = "Skipped by user choice.";
346 $FeatureTime = "0.0";
347 $FeatureWallTime = "0.0";
348}
349
350if (!$NOREGRESSIONS) {
351 if ( $VERBOSE ) { print "REGRESSION TEST STAGE\n"; }
352 my $regression_output = "$Prefix-RegressionTests-Log.txt";
353
354 # Run the regression tests so we can summarize the results
355 system "(time -p gmake -C test Regression.t) > $regression_output 2>&1";
356
357 # Extract test results
358 $RegressionTestResults = GetQMTestResults("$regression_output");
359
360 # Extract time of regressions tests
361 my $RegressionTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$regression_output";
362 my $RegressionTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$regression_output";
363 $RegressionTime = $RegressionTimeU+$RegressionTimeS; # RegressionTime = User+System
364 $RegressionWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$regression_output";
365} else {
366 $RegressionTestResults = "Skipped by user choice.";
367 $RegressionTime = "0.0";
368 $RegressionWallTime = "0.0";
369}
370
371if ($DEBUG) {
372 print $FeatureTestResults;
373 print $RegressionTestResults;
374}
375
376if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
Chris Lattnerb3440302003-01-22 16:14:05 +0000377#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000378# Get warnings from the build
Chris Lattnerb3440302003-01-22 16:14:05 +0000379#
Misha Brukman1b366892003-07-07 21:27:40 +0000380my @Warn = split "\n", `egrep 'warning:|Entering dir' $Prefix-Build-Log.txt`;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000381my @Warnings;
382my $CurDir = "";
383
384foreach $Warning (@Warn) {
385 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
386 $CurDir = $1; # Keep track of directory warning is in...
Misha Brukman8e9554a2003-08-14 15:26:28 +0000387 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { # Remove buildir prefix if included
Chris Lattner4c7e3032003-01-20 06:11:03 +0000388 $CurDir = $1;
389 }
390 } else {
391 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
392 }
393}
Chris Lattner1cbc0a62003-01-20 19:18:44 +0000394my $WarningsFile = join "\n", @Warnings;
395my $WarningsList = AddPreTag $WarningsFile;
396$WarningsFile =~ s/:[0-9]+:/::/g;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000397
Chris Lattner2f8cb572003-01-20 18:05:27 +0000398# Emit the warnings file, so we can diff...
399WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
400my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000401
Chris Lattner9efd7f42003-10-18 19:31:39 +0000402# Output something to stdout if something has changed
403print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
404print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
405
Chris Lattnerbe197872003-10-19 16:54:00 +0000406$WarningsAdded = AddPreTag $WarningsAdded;
407$WarningsRemoved = AddPreTag $WarningsRemoved;
Chris Lattnerb3440302003-01-22 16:14:05 +0000408
409#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000410# Get some statistics about CVS commits over the current day...
Chris Lattnerb3440302003-01-22 16:14:05 +0000411#
Chris Lattner4d00fde2004-05-28 20:30:23 +0000412if ($VERBOSE) { print "CVS HISTORY ANALYSIS STAGE\n"; }
Chris Lattner4c7e3032003-01-20 06:11:03 +0000413@CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
414#print join "\n", @CVSHistory; print "\n";
415
416# Extract some information from the CVS history... use a hash so no duplicate
417# stuff is stored.
Misha Brukman1b366892003-07-07 21:27:40 +0000418my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
Chris Lattner4c7e3032003-01-20 06:11:03 +0000419
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000420my $DateRE = "[-:0-9 ]+\\+[0-9]+";
421
Chris Lattner4c7e3032003-01-20 06:11:03 +0000422# Loop over every record from the CVS history, filling in the hashes.
423foreach $File (@CVSHistory) {
424 my ($Type, $Date, $UID, $Rev, $Filename);
Misha Brukman8e9554a2003-08-14 15:26:28 +0000425 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
Chris Lattner4c7e3032003-01-20 06:11:03 +0000426 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
Chris Lattnerd56147d2004-01-12 16:55:30 +0000427 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
428 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
Misha Brukman1b366892003-07-07 21:27:40 +0000429 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000430 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
Chris Lattner4c7e3032003-01-20 06:11:03 +0000431 } else {
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000432 print "UNMATCHABLE: $File\n";
433 }
434 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
435
436 if ($Filename =~ /^llvm/) {
437 if ($Type eq 'M') { # Modified
438 $ModifiedFiles{$Filename} = 1;
439 $UsersCommitted{$UID} = 1;
440 } elsif ($Type eq 'A') { # Added
441 $AddedFiles{$Filename} = 1;
442 $UsersCommitted{$UID} = 1;
443 } elsif ($Type eq 'R') { # Removed
444 $RemovedFiles{$Filename} = 1;
445 $UsersCommitted{$UID} = 1;
446 } else {
447 $UsersUpdated{$UID} = 1;
448 }
Chris Lattner4c7e3032003-01-20 06:11:03 +0000449 }
450}
451
Chris Lattner1cbc0a62003-01-20 19:18:44 +0000452my $UserCommitList = join "\n", keys %UsersCommitted;
453my $UserUpdateList = join "\n", keys %UsersUpdated;
Chris Lattnerc9cdadf2003-08-06 16:02:50 +0000454my $AddedFilesList = AddPreTag join "\n", sort keys %AddedFiles;
455my $ModifiedFilesList = AddPreTag join "\n", sort keys %ModifiedFiles;
456my $RemovedFilesList = AddPreTag join "\n", sort keys %RemovedFiles;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000457
Chris Lattnerec0e3742003-02-28 20:30:20 +0000458my $TestError = 1;
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000459my $SingleSourceProgramsTable;
460my $MultiSourceProgramsTable;
Chris Lattnereac3cdc2003-08-21 15:55:26 +0000461my $ExternalProgramsTable;
Chris Lattnerb3440302003-01-22 16:14:05 +0000462
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000463
464sub TestDirectory {
465 my $SubDir = shift;
466
467 chdir "test/Programs/$SubDir" or
468 die "Could not change into test/Programs/$SubDir testdir!";
Chris Lattnerec0e3742003-02-28 20:30:20 +0000469
470 # Run the programs tests... creating a report.nightly.html file
471 if (!$NOTEST) {
Chris Lattner20d13ea2004-06-03 03:29:39 +0000472 system "gmake -k $MAKEOPTS $PROGTESTOPTS report.nightly.html "
Chris Lattnerbb0aca52003-12-19 03:47:31 +0000473 . "TEST=nightly > $Prefix-$SubDir-ProgramTest.txt 2>&1";
Chris Lattnerec0e3742003-02-28 20:30:20 +0000474 } else {
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000475 system "gunzip $Prefix-$SubDir-ProgramTest.txt.gz";
Chris Lattnerec0e3742003-02-28 20:30:20 +0000476 }
477
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000478 my $ProgramsTable;
Chris Lattnerc7294152003-08-20 15:44:33 +0000479 if (`grep '^gmake[^:]: .*Error' $Prefix-$SubDir-ProgramTest.txt | wc -l` + 0){
Chris Lattnerec0e3742003-02-28 20:30:20 +0000480 $TestError = 1;
Chris Lattner2e8be142003-05-10 21:40:10 +0000481 $ProgramsTable = "<font color=white><h2>Error running tests!</h2></font>";
Chris Lattnerbe197872003-10-19 16:54:00 +0000482 print "ERROR TESTING\n";
Chris Lattnerc7294152003-08-20 15:44:33 +0000483 } elsif (`grep '^gmake[^:]: .*No rule to make target' $Prefix-$SubDir-ProgramTest.txt | wc -l` + 0) {
Chris Lattner6e51bfa2003-05-11 15:23:10 +0000484 $TestError = 1;
485 $ProgramsTable =
486 "<font color=white><h2>Makefile error running tests!</h2></font>";
Chris Lattnerbe197872003-10-19 16:54:00 +0000487 print "ERROR TESTING\n";
Chris Lattner6e51bfa2003-05-11 15:23:10 +0000488 } else {
Chris Lattnerec0e3742003-02-28 20:30:20 +0000489 $TestError = 0;
490 $ProgramsTable = ReadFile "report.nightly.html";
491
492 #
493 # Create a list of the tests which were run...
494 #
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000495 system "egrep 'TEST-(PASS|FAIL)' < $Prefix-$SubDir-ProgramTest.txt "
496 . "| sort > $Prefix-$SubDir-Tests.txt";
Chris Lattnerec0e3742003-02-28 20:30:20 +0000497 }
498
499 # Compress the test output
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000500 system "gzip -f $Prefix-$SubDir-ProgramTest.txt";
501 chdir "../../.." or die "Cannot return to parent directory!";
502 return $ProgramsTable;
503}
504
Chris Lattner196a14a2003-08-19 15:08:34 +0000505# If we build the tree successfully, run the nightly programs tests...
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000506if ($BuildError eq "") {
Chris Lattner4d00fde2004-05-28 20:30:23 +0000507 if ( $VERBOSE ) {
508 print "SingleSource TEST STAGE\n";
509 }
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000510 $SingleSourceProgramsTable = TestDirectory("SingleSource");
Chris Lattner4d00fde2004-05-28 20:30:23 +0000511 if ( $VERBOSE ) {
512 print "MultiSource TEST STAGE\n";
513 }
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000514 $MultiSourceProgramsTable = TestDirectory("MultiSource");
Chris Lattner4d00fde2004-05-28 20:30:23 +0000515 if ( $VERBOSE ) {
516 print "External TEST STAGE\n";
517 }
Chris Lattnereac3cdc2003-08-21 15:55:26 +0000518 $ExternalProgramsTable = TestDirectory("External");
Chris Lattnerf5a6ab92003-08-18 15:11:13 +0000519 system "cat $Prefix-SingleSource-Tests.txt $Prefix-MultiSource-Tests.txt ".
Chris Lattnereac3cdc2003-08-21 15:55:26 +0000520 " $Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
Chris Lattner5d6c4382003-01-23 19:31:28 +0000521}
Chris Lattnerb3440302003-01-22 16:14:05 +0000522
Chris Lattner4d00fde2004-05-28 20:30:23 +0000523if ( $VERBOSE ) {
524 print "TEST INFORMATION COLLECTION STAGE\n";
525}
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000526my ($TestsAdded, $TestsRemoved, $TestsFixed, $TestsBroken) = ("","","","");
527
Chris Lattnerec0e3742003-02-28 20:30:20 +0000528if ($TestError) {
529 $TestsAdded = "<b>error testing</b><br>";
530 $TestsRemoved = "<b>error testing</b><br>";
531 $TestsFixed = "<b>error testing</b><br>";
532 $TestsBroken = "<b>error testing</b><br>";
533} else {
534 my ($RTestsAdded, $RTestsRemoved) = DiffFiles "-Tests.txt";
535
536 my @RawTestsAddedArray = split '\n', $RTestsAdded;
537 my @RawTestsRemovedArray = split '\n', $RTestsRemoved;
538
539 my %OldTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
540 @RawTestsRemovedArray;
541 my %NewTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
542 @RawTestsAddedArray;
543
544 foreach $Test (keys %NewTests) {
545 if (!exists $OldTests{$Test}) { # TestAdded if in New but not old
546 $TestsAdded = "$TestsAdded$Test\n";
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000547 } else {
Chris Lattnerec0e3742003-02-28 20:30:20 +0000548 if ($OldTests{$Test} =~ /TEST-PASS/) { # Was the old one a pass?
549 $TestsBroken = "$TestsBroken$Test\n"; # New one must be a failure
550 } else {
551 $TestsFixed = "$TestsFixed$Test\n"; # No, new one is a pass.
552 }
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000553 }
554 }
Chris Lattnerec0e3742003-02-28 20:30:20 +0000555 foreach $Test (keys %OldTests) { # TestRemoved if in Old but not New
556 $TestsRemoved = "$TestsRemoved$Test\n" if (!exists $NewTests{$Test});
557 }
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000558
Chris Lattner91480ff2003-10-21 15:47:31 +0000559 print "\nTESTS ADDED: \n\n$TestsAdded\n\n" if (length $TestsAdded);
560 print "\nTESTS REMOVED:\n\n$TestsRemoved\n\n" if (length $TestsRemoved);
561 print "\nTESTS FIXED: \n\n$TestsFixed\n\n" if (length $TestsFixed);
562 print "\nTESTS BROKEN: \n\n$TestsBroken\n\n" if (length $TestsBroken);
Chris Lattnerbe197872003-10-19 16:54:00 +0000563
Chris Lattnerec0e3742003-02-28 20:30:20 +0000564 $TestsAdded = AddPreTag $TestsAdded;
565 $TestsRemoved = AddPreTag $TestsRemoved;
566 $TestsFixed = AddPreTag $TestsFixed;
567 $TestsBroken = AddPreTag $TestsBroken;
568}
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000569
Chris Lattner9efd7f42003-10-18 19:31:39 +0000570
Chris Lattner196a14a2003-08-19 15:08:34 +0000571# If we built the tree successfully, runs of the Olden suite with
572# LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
573if ($BuildError eq "") {
Chris Lattner08e24762003-08-19 18:35:03 +0000574 my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
Chris Lattner196a14a2003-08-19 15:08:34 +0000575 $MachCodeSize) = ("","","","","","","");
Chris Lattner08e24762003-08-19 18:35:03 +0000576 if (!$NORUNNINGTESTS) {
Chris Lattner8f9c4bd2003-09-14 06:00:49 +0000577 chdir "test/Programs/MultiSource/Benchmarks/Olden" or die "Olden tests moved?";
Chris Lattner196a14a2003-08-19 15:08:34 +0000578
579 # Clean out previous results...
580 system "gmake $MAKEOPTS clean > /dev/null 2>&1";
581
582 # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE enabled!
Chris Lattner3e457f72003-10-28 18:37:24 +0000583 system "gmake -k $MAKEOPTS report.nightly.raw.out TEST=nightly " .
Chris Lattner196a14a2003-08-19 15:08:34 +0000584 " LARGE_PROBLEM_SIZE=1 > /dev/null 2>&1";
585 system "cp report.nightly.raw.out $Prefix-Olden-tests.txt";
586 } else {
587 system "gunzip $Prefix-Olden-tests.txt.gz";
588 }
589
590 # Now we know we have $Prefix-Olden-tests.txt as the raw output file. Split
591 # it up into records and read the useful information.
Chris Lattner08e24762003-08-19 18:35:03 +0000592 my @Records = split />>> ========= /, ReadFile "$Prefix-Olden-tests.txt";
Chris Lattner196a14a2003-08-19 15:08:34 +0000593 shift @Records; # Delete the first (garbage) record
594
595 # Loop over all of the records, summarizing them into rows for the running
596 # totals file.
597 my $WallTimeRE = "[A-Za-z0-9.: ]+\\(([0-9.]+) wall clock";
598 foreach $Rec (@Records) {
Chris Lattner08e24762003-08-19 18:35:03 +0000599 my $rNATTime = GetRegex 'TEST-RESULT-nat-time: real\s*([.0-9m]+)', $Rec;
600 my $rCBETime = GetRegex 'TEST-RESULT-cbe-time: real\s*([.0-9m]+)', $Rec;
601 my $rLLCTime = GetRegex 'TEST-RESULT-llc-time: real\s*([.0-9m]+)', $Rec;
602 my $rJITTime = GetRegex 'TEST-RESULT-jit-time: real\s*([.0-9m]+)', $Rec;
Chris Lattner196a14a2003-08-19 15:08:34 +0000603 my $rOptTime = GetRegex "TEST-RESULT-compile: $WallTimeRE", $Rec;
604 my $rBytecodeSize = GetRegex 'TEST-RESULT-compile: *([0-9]+)', $Rec;
605 my $rMachCodeSize = GetRegex 'TEST-RESULT-jit-machcode: *([0-9]+).*bytes of machine code', $Rec;
606
607 $NATTime .= " " . FormatTime($rNATTime);
608 $CBETime .= " " . FormatTime($rCBETime);
609 $LLCTime .= " " . FormatTime($rLLCTime);
610 $JITTime .= " " . FormatTime($rJITTime);
611 $OptTime .= " $rOptTime";
Chris Lattner08e24762003-08-19 18:35:03 +0000612 $BytecodeSize .= " $rBytecodeSize";
613 $MachCodeSize .= " $rMachCodeSize";
Chris Lattner196a14a2003-08-19 15:08:34 +0000614 }
615
616 # Now that we have all of the numbers we want, add them to the running totals
617 # files.
Chris Lattner08e24762003-08-19 18:35:03 +0000618 AddRecord($NATTime, "running_Olden_nat_time.txt");
Chris Lattner196a14a2003-08-19 15:08:34 +0000619 AddRecord($CBETime, "running_Olden_cbe_time.txt");
620 AddRecord($LLCTime, "running_Olden_llc_time.txt");
621 AddRecord($JITTime, "running_Olden_jit_time.txt");
622 AddRecord($OptTime, "running_Olden_opt_time.txt");
623 AddRecord($BytecodeSize, "running_Olden_bytecode.txt");
624 AddRecord($MachCodeSize, "running_Olden_machcode.txt");
Chris Lattner08e24762003-08-19 18:35:03 +0000625
626 system "gzip -f $Prefix-Olden-tests.txt";
Chris Lattner196a14a2003-08-19 15:08:34 +0000627}
628
629
630
631
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000632#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000633# Get a list of the previous days that we can link to...
Chris Lattnerb3440302003-01-22 16:14:05 +0000634#
Chris Lattner2f8cb572003-01-20 18:05:27 +0000635my @PrevDays = map {s/.html//; $_} GetDir ".html";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000636
637splice @PrevDays, 20; # Trim down list to something reasonable...
638
639my $PrevDaysList = # Format list for sidebar
640 join "\n ", map { "<a href=\"$_.html\">$_</a><br>" } @PrevDays;
641
Chris Lattnerc75b14e2003-08-18 20:07:54 +0000642#
643# Start outputing files into the web directory
644#
645chdir $WebDir or die "Could not change into web directory!";
646
647# Add information to the files which accumulate information for graphs...
648AddRecord($LOC, "running_loc.txt");
649AddRecord($BuildTime, "running_build_time.txt");
650
Chris Lattner4d00fde2004-05-28 20:30:23 +0000651if ( $VERBOSE ) {
652 print "GRAPH GENERATION STAGE\n";
653}
Chris Lattnerc75b14e2003-08-18 20:07:54 +0000654#
655# Rebuild the graphs now...
656#
Brian Gaekeb3dab902003-10-11 05:34:00 +0000657$GNUPLOT = "/usr/dcs/software/supported/bin/gnuplot";
658$GNUPLOT = "gnuplot" if ! -x $GNUPLOT;
659$PlotScriptFilename = "$BuildDir/llvm/utils/NightlyTest.gnuplot";
660system ($GNUPLOT, $PlotScriptFilename);
Chris Lattnerb3440302003-01-22 16:14:05 +0000661
Chris Lattner4c7e3032003-01-20 06:11:03 +0000662#
663# Remove the cvs tree...
664#
665system "rm -rf $BuildDir" if (!$NOCHECKOUT and !$NOREMOVE);
666
Chris Lattnerb3440302003-01-22 16:14:05 +0000667#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000668# Print out information...
Chris Lattnerb3440302003-01-22 16:14:05 +0000669#
Chris Lattner4d00fde2004-05-28 20:30:23 +0000670if ($VERBOSE) {
Chris Lattner4c7e3032003-01-20 06:11:03 +0000671 print "DateString: $DateString\n";
672 print "CVS Checkout: $CVSCheckoutTime seconds\n";
673 print "Files/Dirs/LOC in CVS: $NumFilesInCVS/$NumDirsInCVS/$LOC\n";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000674 print "Build Time: $BuildTime seconds\n";
Chris Lattner4d00fde2004-05-28 20:30:23 +0000675 print "Feature Test Time: $FeatureTime seconds\n";
676 print "Regression Test Time: $RegressionTime seconds\n";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000677 print "Libraries/Executables/Objects built: $NumLibraries/$NumExecutables/$NumObjects\n";
678
679 print "WARNINGS:\n $WarningsList\n";
680
Chris Lattner4c7e3032003-01-20 06:11:03 +0000681 print "Users committed: $UserCommitList\n";
682 print "Added Files: \n $AddedFilesList\n";
683 print "Modified Files: \n $ModifiedFilesList\n";
684 print "Removed Files: \n $RemovedFilesList\n";
685
686 print "Previous Days =\n $PrevDaysList\n";
687}
688
Chris Lattnerb3440302003-01-22 16:14:05 +0000689
Chris Lattner2f8cb572003-01-20 18:05:27 +0000690#
691# Output the files...
692#
693
Chris Lattner4d00fde2004-05-28 20:30:23 +0000694if ( $VERBOSE ) {
695 print "OUTPUT STAGE\n";
696}
Chris Lattner2f8cb572003-01-20 18:05:27 +0000697# Main HTML file...
Chris Lattner4c7e3032003-01-20 06:11:03 +0000698my $Output;
699eval "\$Output = <<ENDOFFILE;$TemplateContents\nENDOFFILE\n";
Chris Lattner2f8cb572003-01-20 18:05:27 +0000700WriteFile "$DATE.html", $Output;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000701
702# Change the index.html symlink...
703system "ln -sf $DATE.html index.html";
704
705sub AddRecord {
706 my ($Val, $Filename) = @_;
707 my @Records;
Chris Lattner196a14a2003-08-19 15:08:34 +0000708 if (open FILE, "$WebDir/$Filename") {
Chris Lattner4c7e3032003-01-20 06:11:03 +0000709 @Records = grep !/$DATE/, split "\n", <FILE>;
710 close FILE;
711 }
712 push @Records, "$DATE: $Val";
Chris Lattner08e24762003-08-19 18:35:03 +0000713 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000714 return @Records;
715}