blob: c8fb302865a9af2610e01591622f36d2971ba351 [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.
16# -notest Do not even attempt to run the test programs. Implies
17# -norunningtests.
18# -norunningtests Do not run the Olden benchmark suite with
19# LARGE_PROBLEM_SIZE enabled.
Reid Spencer1d914632004-06-23 07:45:46 +000020# -noexternals Do not run the external tests (for cases where povray
21# or SPEC are not installed)
Tanya Lattner056ec062004-12-04 06:25:50 +000022# -nodejagnu Do not run feature or regression tests
Brian Gaekeb3dab902003-10-11 05:34:00 +000023# -parallel Run two parallel jobs with GNU Make.
Reid Spencerf6d02332004-06-11 07:06:22 +000024# -release Build an LLVM Release version
Reid Spencer39ce11b2005-01-13 18:02:40 +000025# -enable-llcbeta Enable testing of beta features in llc.
Brian Gaeke047e6062004-08-05 19:54:59 +000026# -disable-llc Disable LLC tests in the nightly tester.
27# -disable-jit Disable JIT tests in the nightly tester.
Chris Lattner4d00fde2004-05-28 20:30:23 +000028# -verbose Turn on some debug output
29# -debug Print information useful only to maintainers of this script.
Reid Spencercb6a3aa2004-06-22 15:38:37 +000030# -nice Checkout/Configure/Build with "nice" to reduce impact
31# on busy servers.
Misha Brukman2e9ac692004-11-08 03:28:27 +000032# -f2c Next argument specifies path to F2C utility
Reid Spencercb6a3aa2004-06-22 15:38:37 +000033# -gnuplotscript Next argument specifies gnuplot script to use
34# -templatefile Next argument specifies template file to use
Chris Lattner892cdb32004-07-27 08:29:06 +000035# -gccpath Path to gcc/g++ used to build LLVM
Misha Brukmanf5f37f02005-05-26 16:28:55 +000036# -cvstag Check out a specific CVS tag to build LLVM (useful for
37# testing release branches)
Misha Brukman4391bb52005-06-06 19:17:05 +000038# -target Specify the target triplet
Evan Cheng34688642006-02-08 09:08:06 +000039# -cflags Next argument specifies that C compilation options that
40# override the default.
41# -cxxflags Next argument specifies that C++ compilation options that
42# override the default.
43# -ldflags Next argument specifies that linker options that override
44# the default.
Chris Lattnerbb0aca52003-12-19 03:47:31 +000045#
Chris Lattnerb0ddb492005-11-01 17:59:42 +000046# ---------------- Options to configure llvm-test ----------------------------
47# -spec2000path Path to the benchspec directory in the SPEC 2000 distro
48# -spec95path Path to the benchspec directory in the SPEC 95 distro.
49# -povraypath Path to the povray sources
50# -namdpath Path to the namd sources
51#
Brian Gaekeb3dab902003-10-11 05:34:00 +000052# CVSROOT is the CVS repository from which the tree will be checked out,
53# specified either in the full :method:user@host:/dir syntax, or
54# just /dir if using a local repo.
55# BUILDDIR is the directory where sources for this test run will be checked out
56# AND objects for this test run will be built. This directory MUST NOT
57# exist before the script is run; it will be created by the cvs checkout
58# process and erased (unless -noremove is specified; see above.)
59# WEBDIR is the directory into which the test results web page will be written,
60# AND in which the "index.html" is assumed to be a symlink to the most recent
Brian Gaeke90c82b92004-09-28 16:04:00 +000061# copy of the results. This directory will be created if it does not exist.
Reid Spencer932b69f2004-12-26 05:21:13 +000062# LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
63# to. This is the same as you would have for a normal LLVM build.
Chris Lattner4c7e3032003-01-20 06:11:03 +000064#
65use POSIX qw(strftime);
Tanya Lattner5debe8c2004-11-21 00:02:40 +000066use File::Copy;
Chris Lattner4c7e3032003-01-20 06:11:03 +000067
Brian Gaekeb3dab902003-10-11 05:34:00 +000068my $HOME = $ENV{'HOME'};
69my $CVSRootDir = $ENV{'CVSROOT'};
Chris Lattner9d13efa2003-10-14 01:22:08 +000070 $CVSRootDir = "/home/vadve/shared/PublicCVS"
Chris Lattner4d00fde2004-05-28 20:30:23 +000071 unless $CVSRootDir;
72my $BuildDir = $ENV{'BUILDDIR'};
73 $BuildDir = "$HOME/buildtest"
74 unless $BuildDir;
75my $WebDir = $ENV{'WEBDIR'};
76 $WebDir = "$HOME/cvs/testresults-X86"
77 unless $WebDir;
Chris Lattner2f8cb572003-01-20 18:05:27 +000078
79# Calculate the date prefix...
80@TIME = localtime;
81my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
82my $DateString = strftime "%B %d, %Y", localtime;
Chris Lattner004e19e2005-02-13 16:08:30 +000083my $TestStartTime = gmtime() . "GMT<br>" . localtime() . " (local)";
Reid Spencercb6a3aa2004-06-22 15:38:37 +000084
85# Command line argument settings...
86my $NOCHECKOUT = 0;
Misha Brukman2e9ac692004-11-08 03:28:27 +000087my $NOREMOVE = 0;
Misha Brukman2e9ac692004-11-08 03:28:27 +000088my $NOTEST = 0;
Reid Spencercb6a3aa2004-06-22 15:38:37 +000089my $NORUNNINGTESTS = 0;
Reid Spencer1d914632004-06-23 07:45:46 +000090my $NOEXTERNALS = 0;
Misha Brukman2e9ac692004-11-08 03:28:27 +000091my $MAKEOPTS = "";
Reid Spencercb6a3aa2004-06-22 15:38:37 +000092my $PROGTESTOPTS = "";
Misha Brukman2e9ac692004-11-08 03:28:27 +000093my $VERBOSE = 0;
Reid Spencercb6a3aa2004-06-22 15:38:37 +000094my $DEBUG = 0;
Brian Gaeke047e6062004-08-05 19:54:59 +000095my $CONFIGUREARGS = "";
Misha Brukmanf5f37f02005-05-26 16:28:55 +000096my $CVSCOOPT = "-APR";
Reid Spencercb6a3aa2004-06-22 15:38:37 +000097my $NICE = "";
Tanya Lattner056ec062004-12-04 06:25:50 +000098my $NODEJAGNU = 0;
Chris Lattner2f8cb572003-01-20 18:05:27 +000099
Chris Lattnerb0ddb492005-11-01 17:59:42 +0000100my $LLVMTESTCONFIGARGS = "";
101
Chris Lattnerb3440302003-01-22 16:14:05 +0000102sub ReadFile {
103 if (open (FILE, $_[0])) {
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000104 undef $/;
Chris Lattnerb3440302003-01-22 16:14:05 +0000105 my $Ret = <FILE>;
106 close FILE;
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000107 $/ = '\n';
Chris Lattnerb3440302003-01-22 16:14:05 +0000108 return $Ret;
109 } else {
110 print "Could not open file '$_[0]' for reading!";
111 return "";
112 }
113}
114
Chris Lattner2f8cb572003-01-20 18:05:27 +0000115sub WriteFile { # (filename, contents)
116 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!";
117 print FILE $_[1];
118 close FILE;
119}
120
121sub GetRegex { # (Regex with ()'s, value)
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000122 $_[1] =~ /$_[0]/m;
Chris Lattner08e24762003-08-19 18:35:03 +0000123 if (defined($1)) {
124 return $1;
125 }
Reid Spencera337f0c2004-06-23 06:36:34 +0000126 return "0";
Chris Lattner2f8cb572003-01-20 18:05:27 +0000127}
128
Brian Gaeke90c82b92004-09-28 16:04:00 +0000129sub Touch {
130 my @files = @_;
131 my $now = time;
132 foreach my $file (@files) {
133 if (! -f $file) {
134 open (FILE, ">$file") or warn "Could not create new file $file";
135 close FILE;
136 }
137 utime $now, $now, $file;
138 }
139}
140
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000141sub AddRecord {
142 my ($Val, $Filename) = @_;
143 my @Records;
144 if (open FILE, "$WebDir/$Filename") {
145 @Records = grep !/$DATE/, split "\n", <FILE>;
146 close FILE;
147 }
148 push @Records, "$DATE: $Val";
149 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000150}
151
Chris Lattner2f8cb572003-01-20 18:05:27 +0000152sub AddPreTag { # Add pre tags around nonempty list, or convert to "none"
153 $_ = shift;
Chris Lattner1cbc0a62003-01-20 19:18:44 +0000154 if (length) { return "<ul><pre>$_</pre></ul>"; } else { "<b>none</b><br>"; }
Chris Lattner2f8cb572003-01-20 18:05:27 +0000155}
156
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000157sub ChangeDir { # directory, logical name
158 my ($dir,$name) = @_;
159 chomp($dir);
160 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
161 chdir($dir) || die "Cannot change directory to: $name ($dir) ";
162}
163
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000164sub CopyFile { #filename, newfile
165 my ($file, $newfile) = @_;
166 chomp($file);
167 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
168 copy($file, $newfile);
169}
170
Chris Lattner2f8cb572003-01-20 18:05:27 +0000171sub GetDir {
172 my $Suffix = shift;
173 opendir DH, $WebDir;
174 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
175 closedir DH;
176 return @Result;
177}
178
179# DiffFiles - Diff the current version of the file against the last version of
180# the file, reporting things added and removed. This is used to report, for
181# example, added and removed warnings. This returns a pair (added, removed)
182#
183sub DiffFiles {
184 my $Suffix = shift;
185 my @Others = GetDir $Suffix;
186 if (@Others == 0) { # No other files? We added all entries...
187 return (`cat $WebDir/$DATE$Suffix`, "");
188 }
189 # Diff the files now...
190 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
191 my $Added = join "\n", grep /^</, @Diffs;
192 my $Removed = join "\n", grep /^>/, @Diffs;
Chris Lattner1cbc0a62003-01-20 19:18:44 +0000193 $Added =~ s/^< //gm;
194 $Removed =~ s/^> //gm;
Chris Lattner2f8cb572003-01-20 18:05:27 +0000195 return ($Added, $Removed);
196}
197
Chris Lattner196a14a2003-08-19 15:08:34 +0000198# FormatTime - Convert a time from 1m23.45 into 83.45
199sub FormatTime {
200 my $Time = shift;
201 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
202 $Time = sprintf("%7.4f", $1*60.0+$2);
203 }
204 return $Time;
205}
206
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000207sub GetRegexNum {
208 my ($Regex, $Num, $Regex2, $File) = @_;
209 my @Items = split "\n", `grep '$Regex' $File`;
210 return GetRegex $Regex2, $Items[$Num];
211}
212
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000213sub GetDejagnuTestResults { # (filename, log)
214 my ($filename, $DejagnuLog) = @_;
215 my @lines;
216 my $firstline;
217 $/ = "\n"; #Make sure we're going line at a time.
Chris Lattner453d0622005-03-10 16:26:50 +0000218
Chris Lattner8f457312005-03-17 16:07:45 +0000219 print "DEJAGNU TEST RESULTS:\n";
Chris Lattner453d0622005-03-10 16:26:50 +0000220
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000221 if (open SRCHFILE, $filename) {
222 # Process test results
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000223 my $first_list = 1;
224 my $should_break = 1;
225 my $nocopy = 0;
226 my $readingsum = 0;
227 while ( <SRCHFILE> ) {
228 if ( length($_) > 1 ) {
229 chomp($_);
230 if ( m/^XPASS:/ || m/^FAIL:/ ) {
231 $nocopy = 0;
232 if ( $first_list ) {
Misha Brukmand3a54122005-03-10 16:32:33 +0000233 push(@lines, "<h3>UNEXPECTED TEST RESULTS</h3><ol><li>\n");
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000234 $first_list = 0;
235 $should_break = 1;
Misha Brukmand3a54122005-03-10 16:32:33 +0000236 push(@lines, "<b>$_</b><br/>\n");
Chris Lattner453d0622005-03-10 16:26:50 +0000237 print " $_\n";
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000238 } else {
Misha Brukmand3a54122005-03-10 16:32:33 +0000239 push(@lines, "</li><li><b>$_</b><br/>\n");
Chris Lattner453d0622005-03-10 16:26:50 +0000240 print " $_\n";
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000241 }
242 } elsif ( m/Summary/ ) {
Chris Lattner453d0622005-03-10 16:26:50 +0000243 if ( $first_list ) {
Misha Brukmand3a54122005-03-10 16:32:33 +0000244 push(@lines, "<b>PERFECT!</b>");
245 print " PERFECT!\n";
246 } else {
247 push(@lines, "</li></ol>\n");
248 }
249 push(@lines, "<h3>STATISTICS</h3><pre>\n");
Chris Lattner8f457312005-03-17 16:07:45 +0000250 print "\nDEJAGNU STATISTICS:\n";
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000251 $should_break = 0;
252 $nocopy = 0;
253 $readingsum = 1;
254 } elsif ( $readingsum ) {
255 push(@lines,"$_\n");
Chris Lattner8f457312005-03-17 16:07:45 +0000256 print " $_\n";
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000257 }
258 }
259 }
260 }
261 push(@lines, "</pre>\n");
262 close SRCHFILE;
263
Misha Brukmand3a54122005-03-10 16:32:33 +0000264 my $content = join("", @lines);
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000265 return "$content</li></ol>\n";
266}
267
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000268
269#####################################################################
270## MAIN PROGRAM
271#####################################################################
272
273my $Template = "";
274my $PlotScriptFilename = "";
275
276# Parse arguments...
277while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
278 shift;
279 last if /^--$/; # Stop processing arguments on --
280
281 # List command line options here...
282 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
Misha Brukman2e9ac692004-11-08 03:28:27 +0000283 if (/^-noremove$/) { $NOREMOVE = 1; next; }
Misha Brukman2e9ac692004-11-08 03:28:27 +0000284 if (/^-notest$/) { $NOTEST = 1; $NORUNNINGTESTS = 1; next; }
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000285 if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
Misha Brukman2e9ac692004-11-08 03:28:27 +0000286 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j2 -l3.0"; next; }
287 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1"; next; }
Chris Lattnerc82a6c82005-01-08 21:03:58 +0000288 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
Brian Gaeke047e6062004-08-05 19:54:59 +0000289 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
290 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
291 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
292 $CONFIGUREARGS .= " --disable-jit"; next; }
Misha Brukman2e9ac692004-11-08 03:28:27 +0000293 if (/^-verbose$/) { $VERBOSE = 1; next; }
294 if (/^-debug$/) { $DEBUG = 1; next; }
295 if (/^-nice$/) { $NICE = "nice "; next; }
296 if (/^-f2c$/) {
297 $CONFIGUREARGS .= " --with-f2c=$ARGV[0]"; shift; next;
298 }
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000299 if (/^-gnuplotscript$/) { $PlotScriptFilename = $ARGV[0]; shift; next; }
Reid Spencerc5b67052004-06-23 14:07:12 +0000300 if (/^-templatefile$/) { $Template = $ARGV[0]; shift; next; }
Misha Brukman2e9ac692004-11-08 03:28:27 +0000301 if (/^-gccpath/) {
302 $CONFIGUREARGS .= " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++"; shift; next;
303 }
Misha Brukmanf5f37f02005-05-26 16:28:55 +0000304 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
Misha Brukman4391bb52005-06-06 19:17:05 +0000305 if (/^-target/) {
306 $CONFIGUREARGS .= " --target=$ARGV[0]"; shift; next;
307 }
Evan Cheng34688642006-02-08 09:08:06 +0000308 if (/^-cflags/) {
309 $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'"; shift; next;
310 }
311 if (/^-cxxflags/) {
312 $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'"; shift; next;
313 }
314 if (/^-ldflags/) {
315 $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'"; shift; next;
316 }
Reid Spencer1d914632004-06-23 07:45:46 +0000317 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
Misha Brukman4391bb52005-06-06 19:17:05 +0000318 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
Chris Lattnerb0ddb492005-11-01 17:59:42 +0000319 if (/^-spec2000path$/) {
320 $LLVMTESTCONFIGARGS .= " --enable-spec2000=$ARGV[0]"; shift; next;
321 }
322 if (/^-spec95path$/) {
323 $LLVMTESTCONFIGARGS .= " --enable-spec95=$ARGV[0]"; shift; next;
324 }
325 if (/^-povraypath$/) {
326 $LLVMTESTCONFIGARGS .= " --enable-povray=$ARGV[0]"; shift; next;
327 }
328 if (/^-namdpath$/) {
329 $LLVMTESTCONFIGARGS .= " --enable-namd=$ARGV[0]"; shift; next;
330 }
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000331 print "Unknown option: $_ : ignoring!\n";
332}
333
Reid Spencer932b69f2004-12-26 05:21:13 +0000334if ($ENV{'LLVMGCCDIR'}) {
335 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
336}
Brian Gaeke047e6062004-08-05 19:54:59 +0000337if ($CONFIGUREARGS !~ /--disable-jit/) {
338 $CONFIGUREARGS .= " --enable-jit";
339}
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000340
341die "Must specify 0 or 3 options!" if (@ARGV != 0 and @ARGV != 3);
342
343if (@ARGV == 3) {
344 $CVSRootDir = $ARGV[0];
345 $BuildDir = $ARGV[1];
346 $WebDir = $ARGV[2];
347}
348
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000349my $Prefix = "$WebDir/$DATE";
350
351#define the file names we'll use
352my $BuildLog = "$Prefix-Build-Log.txt";
353my $CVSLog = "$Prefix-CVS-Log.txt";
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000354my $OldenTestsLog = "$Prefix-Olden-tests.txt";
355my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
356my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
357my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000358my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
359my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
360my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000361
362if ($VERBOSE) {
363 print "INITIALIZED\n";
364 print "CVS Root = $CVSRootDir\n";
365 print "BuildDir = $BuildDir\n";
366 print "WebDir = $WebDir\n";
367 print "Prefix = $Prefix\n";
368 print "CVSLog = $CVSLog\n";
369 print "BuildLog = $BuildLog\n";
370}
371
Brian Gaeke90c82b92004-09-28 16:04:00 +0000372if (! -d $WebDir) {
373 mkdir $WebDir, 0777;
374 warn "Warning: $WebDir did not exist; creating it.\n";
375}
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000376
377#
378# Create the CVS repository directory
379#
380if (!$NOCHECKOUT) {
381 if (-d $BuildDir) {
382 if (!$NOREMOVE) {
383 system "rm -rf $BuildDir";
384 } else {
385 die "CVS checkout directory $BuildDir already exists!";
386 }
387 }
388 mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
389}
390
391ChangeDir( $BuildDir, "CVS checkout directory" );
392
393
394#
395# Check out the llvm tree, saving CVS messages to the cvs log...
396#
Misha Brukmanf5f37f02005-05-26 16:28:55 +0000397my $CVSOPT = "";
398# Use compression if going over ssh.
399$CVSOPT = "-z3" if $CVSRootDir =~ /^:ext:/;
400my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co $CVSCOOPT";
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000401if (!$NOCHECKOUT) {
402 if ( $VERBOSE ) { print "CHECKOUT STAGE\n"; }
Misha Brukmanf5f37f02005-05-26 16:28:55 +0000403 system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
404 "$CVSCMD llvm-test ) > $CVSLog 2>&1";
Reid Spencer10ffe012004-09-05 07:58:10 +0000405 ChangeDir( $BuildDir , "CVS Checkout directory") ;
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000406}
407
408ChangeDir( "llvm" , "llvm source directory") ;
409
410if (!$NOCHECKOUT) {
411 if ( $VERBOSE ) { print "UPDATE STAGE\n"; }
Reid Spencer10ffe012004-09-05 07:58:10 +0000412 system "$NICE cvs update -PdRA >> $CVSLog 2>&1" ;
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000413}
414
Reid Spencerc5b67052004-06-23 14:07:12 +0000415if ( $Template eq "" ) {
416 $Template = "$BuildDir/llvm/utils/NightlyTestTemplate.html";
417}
418die "Template file $Template is not readable" if ( ! -r "$Template" );
419
420if ( $PlotScriptFilename eq "" ) {
421 $PlotScriptFilename = "$BuildDir/llvm/utils/NightlyTest.gnuplot";
422}
423die "GNUPlot Script $PlotScriptFilename is not readable" if ( ! -r "$PlotScriptFilename" );
424
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000425# Read in the HTML template file...
426if ( $VERBOSE ) { print "READING TEMPLATE\n"; }
427my $TemplateContents = ReadFile $Template;
428
429#
430# Get some static statistics about the current state of CVS
431#
432my $CVSCheckoutTime = GetRegex "([0-9.]+)", `grep '^real' $CVSLog`;
433my $NumFilesInCVS = `egrep '^U' $CVSLog | wc -l` + 0;
434my $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $CVSLog | wc -l` + 0;
Reid Spencere993f462004-09-06 19:32:55 +0000435$LOC = `utils/countloc.sh`;
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000436
437#
438# Build the entire tree, saving build messages to the build log
439#
440if (!$NOCHECKOUT) {
441 if ( $VERBOSE ) { print "CONFIGURE STAGE\n"; }
Chris Lattnerb0ddb492005-11-01 17:59:42 +0000442 my $EXTRAFLAGS = "--enable-spec --with-objroot=.$LLVMTESTCONFIGARGS";
Chris Lattnere50caac2005-10-28 16:35:18 +0000443 system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) > $BuildLog 2>&1";
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000444
445 if ( $VERBOSE ) { print "BUILD STAGE\n"; }
446 # Build the entire tree, capturing the output into $BuildLog
447 system "(time -p $NICE gmake $MAKEOPTS) >> $BuildLog 2>&1";
448}
449
450
451#
452# Get some statistics about the build...
453#
454my @Linked = split '\n', `grep Linking $BuildLog`;
455my $NumExecutables = scalar(grep(/executable/, @Linked));
456my $NumLibraries = scalar(grep(!/executable/, @Linked));
Chris Lattner0bb48282005-03-11 20:17:04 +0000457my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000458
459my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
460my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
461my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
462my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
463
464my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
465my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
466my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
467my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
468
Misha Brukman9a612752005-01-12 03:31:38 +0000469my $BuildError = 0, $BuildStatus = "OK";
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000470if (`grep '^gmake[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
471 `grep '^gmake: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
Misha Brukman9a612752005-01-12 03:31:38 +0000472 $BuildStatus = "<h3><font color='red'>error: compilation " .
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000473 "<a href=\"$DATE-Build-Log.txt\">aborted</a></font></h3>";
Misha Brukman9a612752005-01-12 03:31:38 +0000474 $BuildError = 1;
Chris Lattner08313102005-12-11 19:55:39 +0000475 print "\n***ERROR BUILDING TREE\n\n";
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000476}
477
Tanya Lattner056ec062004-12-04 06:25:50 +0000478if ($BuildError) { $NODEJAGNU=1; }
Brian Gaeke22800982004-06-25 07:25:28 +0000479
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000480my $DejangnuTestResults; # String containing the results of the dejagnu
Tanya Lattner59a86552004-12-04 06:35:14 +0000481if(!$NODEJAGNU) {
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000482 if($VERBOSE) { print "DEJAGNU FEATURE/REGRESSION TEST STAGE\n"; }
483
484 my $dejagnu_output = "$DejagnuTestsLog";
485
486 #Run the feature and regression tests, results are put into testrun.sum
487 #Full log in testrun.log
Tanya Lattner056ec062004-12-04 06:25:50 +0000488 system "(time -p gmake $MAKEOPTS check) > $dejagnu_output 2>&1";
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000489
490 #Extract time of dejagnu tests
491 my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
492 my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
493 $DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
494 $DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
495
496 #Copy the testrun.log and testrun.sum to our webdir
497 CopyFile("test/testrun.log", $DejagnuLog);
498 CopyFile("test/testrun.sum", $DejagnuSum);
499
500 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
Tanya Lattnera2dfbf92004-12-17 20:58:34 +0000501
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000502} else {
503 $DejagnuTestResults = "Skipped by user choice.";
504 $DejagnuTime = "0.0";
505 $DejagnuWallTime = "0.0";
506}
507
Chris Lattner4d00fde2004-05-28 20:30:23 +0000508if ($DEBUG) {
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000509 print $DejagnuTestResults;
Chris Lattner4d00fde2004-05-28 20:30:23 +0000510}
511
512if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
Chris Lattnerb3440302003-01-22 16:14:05 +0000513#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000514# Get warnings from the build
Chris Lattnerb3440302003-01-22 16:14:05 +0000515#
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000516my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000517my @Warnings;
518my $CurDir = "";
519
520foreach $Warning (@Warn) {
521 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
522 $CurDir = $1; # Keep track of directory warning is in...
Misha Brukman8e9554a2003-08-14 15:26:28 +0000523 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { # Remove buildir prefix if included
Chris Lattner4c7e3032003-01-20 06:11:03 +0000524 $CurDir = $1;
525 }
526 } else {
527 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
528 }
529}
Chris Lattner1cbc0a62003-01-20 19:18:44 +0000530my $WarningsFile = join "\n", @Warnings;
531my $WarningsList = AddPreTag $WarningsFile;
532$WarningsFile =~ s/:[0-9]+:/::/g;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000533
Chris Lattner2f8cb572003-01-20 18:05:27 +0000534# Emit the warnings file, so we can diff...
535WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
536my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000537
Chris Lattner9efd7f42003-10-18 19:31:39 +0000538# Output something to stdout if something has changed
539print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
540print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
541
Chris Lattnerbe197872003-10-19 16:54:00 +0000542$WarningsAdded = AddPreTag $WarningsAdded;
543$WarningsRemoved = AddPreTag $WarningsRemoved;
Chris Lattnerb3440302003-01-22 16:14:05 +0000544
545#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000546# Get some statistics about CVS commits over the current day...
Chris Lattnerb3440302003-01-22 16:14:05 +0000547#
Chris Lattner4d00fde2004-05-28 20:30:23 +0000548if ($VERBOSE) { print "CVS HISTORY ANALYSIS STAGE\n"; }
Chris Lattner4c7e3032003-01-20 06:11:03 +0000549@CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
550#print join "\n", @CVSHistory; print "\n";
551
552# Extract some information from the CVS history... use a hash so no duplicate
553# stuff is stored.
Misha Brukman1b366892003-07-07 21:27:40 +0000554my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
Chris Lattner4c7e3032003-01-20 06:11:03 +0000555
Brian Gaeke43f38672004-06-10 07:44:28 +0000556my $DateRE = '[-/:0-9 ]+\+[0-9]+';
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000557
Chris Lattner4c7e3032003-01-20 06:11:03 +0000558# Loop over every record from the CVS history, filling in the hashes.
559foreach $File (@CVSHistory) {
560 my ($Type, $Date, $UID, $Rev, $Filename);
Misha Brukman8e9554a2003-08-14 15:26:28 +0000561 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
Chris Lattner4c7e3032003-01-20 06:11:03 +0000562 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
Chris Lattnerd56147d2004-01-12 16:55:30 +0000563 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
564 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
Misha Brukman1b366892003-07-07 21:27:40 +0000565 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000566 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
Chris Lattner4c7e3032003-01-20 06:11:03 +0000567 } else {
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000568 print "UNMATCHABLE: $File\n";
Brian Gaeke43f38672004-06-10 07:44:28 +0000569 next;
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000570 }
571 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
572
573 if ($Filename =~ /^llvm/) {
574 if ($Type eq 'M') { # Modified
575 $ModifiedFiles{$Filename} = 1;
576 $UsersCommitted{$UID} = 1;
577 } elsif ($Type eq 'A') { # Added
578 $AddedFiles{$Filename} = 1;
579 $UsersCommitted{$UID} = 1;
580 } elsif ($Type eq 'R') { # Removed
581 $RemovedFiles{$Filename} = 1;
582 $UsersCommitted{$UID} = 1;
583 } else {
584 $UsersUpdated{$UID} = 1;
585 }
Chris Lattner4c7e3032003-01-20 06:11:03 +0000586 }
587}
588
Chris Lattner5e5d2202005-03-16 17:09:53 +0000589my $UserCommitList = join "\n", sort keys %UsersCommitted;
590my $UserUpdateList = join "\n", sort keys %UsersUpdated;
Chris Lattnerc9cdadf2003-08-06 16:02:50 +0000591my $AddedFilesList = AddPreTag join "\n", sort keys %AddedFiles;
592my $ModifiedFilesList = AddPreTag join "\n", sort keys %ModifiedFiles;
593my $RemovedFilesList = AddPreTag join "\n", sort keys %RemovedFiles;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000594
Chris Lattnerec0e3742003-02-28 20:30:20 +0000595my $TestError = 1;
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000596my $SingleSourceProgramsTable = "!";
597my $MultiSourceProgramsTable = "!";
598my $ExternalProgramsTable = "!";
Chris Lattnerb3440302003-01-22 16:14:05 +0000599
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000600
601sub TestDirectory {
602 my $SubDir = shift;
603
Reid Spencer10ffe012004-09-05 07:58:10 +0000604 ChangeDir( "projects/llvm-test/$SubDir", "Programs Test Subdirectory" );
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000605
606 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
Chris Lattnerec0e3742003-02-28 20:30:20 +0000607
608 # Run the programs tests... creating a report.nightly.html file
609 if (!$NOTEST) {
Chris Lattner20d13ea2004-06-03 03:29:39 +0000610 system "gmake -k $MAKEOPTS $PROGTESTOPTS report.nightly.html "
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000611 . "TEST=nightly > $ProgramTestLog 2>&1";
Chris Lattnerec0e3742003-02-28 20:30:20 +0000612 } else {
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000613 system "gunzip ${ProgramTestLog}.gz";
Chris Lattnerec0e3742003-02-28 20:30:20 +0000614 }
615
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000616 my $ProgramsTable;
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000617 if (`grep '^gmake[^:]: .*Error' $ProgramTestLog | wc -l` + 0){
Chris Lattnerec0e3742003-02-28 20:30:20 +0000618 $TestError = 1;
Chris Lattner2e8be142003-05-10 21:40:10 +0000619 $ProgramsTable = "<font color=white><h2>Error running tests!</h2></font>";
Chris Lattnerbe197872003-10-19 16:54:00 +0000620 print "ERROR TESTING\n";
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000621 } elsif (`grep '^gmake[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
Chris Lattner6e51bfa2003-05-11 15:23:10 +0000622 $TestError = 1;
623 $ProgramsTable =
624 "<font color=white><h2>Makefile error running tests!</h2></font>";
Chris Lattnerbe197872003-10-19 16:54:00 +0000625 print "ERROR TESTING\n";
Chris Lattner6e51bfa2003-05-11 15:23:10 +0000626 } else {
Chris Lattnerec0e3742003-02-28 20:30:20 +0000627 $TestError = 0;
628 $ProgramsTable = ReadFile "report.nightly.html";
629
630 #
631 # Create a list of the tests which were run...
632 #
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000633 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog "
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000634 . "| sort > $Prefix-$SubDir-Tests.txt";
Chris Lattnerec0e3742003-02-28 20:30:20 +0000635 }
636
637 # Compress the test output
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000638 system "gzip -f $ProgramTestLog";
639 ChangeDir( "../../..", "Programs Test Parent Directory" );
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000640 return $ProgramsTable;
641}
642
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000643# If we built the tree successfully, run the nightly programs tests...
Misha Brukman9a612752005-01-12 03:31:38 +0000644if (!$BuildError) {
Chris Lattner4d00fde2004-05-28 20:30:23 +0000645 if ( $VERBOSE ) {
646 print "SingleSource TEST STAGE\n";
647 }
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000648 $SingleSourceProgramsTable = TestDirectory("SingleSource");
Chris Lattner4d00fde2004-05-28 20:30:23 +0000649 if ( $VERBOSE ) {
650 print "MultiSource TEST STAGE\n";
651 }
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000652 $MultiSourceProgramsTable = TestDirectory("MultiSource");
Reid Spencer1d914632004-06-23 07:45:46 +0000653 if ( ! $NOEXTERNALS ) {
654 if ( $VERBOSE ) {
655 print "External TEST STAGE\n";
656 }
657 $ExternalProgramsTable = TestDirectory("External");
658 system "cat $Prefix-SingleSource-Tests.txt $Prefix-MultiSource-Tests.txt ".
Chris Lattnereac3cdc2003-08-21 15:55:26 +0000659 " $Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
Reid Spencer1d914632004-06-23 07:45:46 +0000660 } else {
Reid Spencerb8e825b2004-12-04 22:18:28 +0000661 $ExternalProgramsTable = '<tr><td>External TEST STAGE SKIPPED</td></tr>';
Reid Spencer1d914632004-06-23 07:45:46 +0000662 if ( $VERBOSE ) {
663 print "External TEST STAGE SKIPPED\n";
664 }
665 system "cat $Prefix-SingleSource-Tests.txt $Prefix-MultiSource-Tests.txt ".
666 " | sort > $Prefix-Tests.txt";
667 }
Chris Lattner5d6c4382003-01-23 19:31:28 +0000668}
Chris Lattnerb3440302003-01-22 16:14:05 +0000669
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000670if ( $VERBOSE ) { print "TEST INFORMATION COLLECTION STAGE\n"; }
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000671my ($TestsAdded, $TestsRemoved, $TestsFixed, $TestsBroken) = ("","","","");
672
Chris Lattnerec0e3742003-02-28 20:30:20 +0000673if ($TestError) {
674 $TestsAdded = "<b>error testing</b><br>";
675 $TestsRemoved = "<b>error testing</b><br>";
676 $TestsFixed = "<b>error testing</b><br>";
677 $TestsBroken = "<b>error testing</b><br>";
678} else {
679 my ($RTestsAdded, $RTestsRemoved) = DiffFiles "-Tests.txt";
680
681 my @RawTestsAddedArray = split '\n', $RTestsAdded;
682 my @RawTestsRemovedArray = split '\n', $RTestsRemoved;
683
684 my %OldTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
685 @RawTestsRemovedArray;
686 my %NewTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
687 @RawTestsAddedArray;
688
689 foreach $Test (keys %NewTests) {
690 if (!exists $OldTests{$Test}) { # TestAdded if in New but not old
691 $TestsAdded = "$TestsAdded$Test\n";
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000692 } else {
Chris Lattnerec0e3742003-02-28 20:30:20 +0000693 if ($OldTests{$Test} =~ /TEST-PASS/) { # Was the old one a pass?
694 $TestsBroken = "$TestsBroken$Test\n"; # New one must be a failure
695 } else {
696 $TestsFixed = "$TestsFixed$Test\n"; # No, new one is a pass.
697 }
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000698 }
699 }
Chris Lattnerec0e3742003-02-28 20:30:20 +0000700 foreach $Test (keys %OldTests) { # TestRemoved if in Old but not New
701 $TestsRemoved = "$TestsRemoved$Test\n" if (!exists $NewTests{$Test});
702 }
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000703
Chris Lattner91480ff2003-10-21 15:47:31 +0000704 print "\nTESTS ADDED: \n\n$TestsAdded\n\n" if (length $TestsAdded);
705 print "\nTESTS REMOVED:\n\n$TestsRemoved\n\n" if (length $TestsRemoved);
706 print "\nTESTS FIXED: \n\n$TestsFixed\n\n" if (length $TestsFixed);
707 print "\nTESTS BROKEN: \n\n$TestsBroken\n\n" if (length $TestsBroken);
Chris Lattnerbe197872003-10-19 16:54:00 +0000708
Chris Lattnerec0e3742003-02-28 20:30:20 +0000709 $TestsAdded = AddPreTag $TestsAdded;
710 $TestsRemoved = AddPreTag $TestsRemoved;
711 $TestsFixed = AddPreTag $TestsFixed;
712 $TestsBroken = AddPreTag $TestsBroken;
713}
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000714
Chris Lattner9efd7f42003-10-18 19:31:39 +0000715
Chris Lattner196a14a2003-08-19 15:08:34 +0000716# If we built the tree successfully, runs of the Olden suite with
717# LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
Misha Brukman9a612752005-01-12 03:31:38 +0000718if (!$BuildError) {
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000719 if ( $VERBOSE ) { print "OLDEN TEST SUITE STAGE\n"; }
Chris Lattner08e24762003-08-19 18:35:03 +0000720 my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
Chris Lattner196a14a2003-08-19 15:08:34 +0000721 $MachCodeSize) = ("","","","","","","");
Chris Lattner08e24762003-08-19 18:35:03 +0000722 if (!$NORUNNINGTESTS) {
Reid Spencer10ffe012004-09-05 07:58:10 +0000723 ChangeDir( "$BuildDir/llvm/projects/llvm-test/MultiSource/Benchmarks/Olden",
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000724 "Olden Test Directory");
Chris Lattner196a14a2003-08-19 15:08:34 +0000725
726 # Clean out previous results...
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000727 system "$NICE gmake $MAKEOPTS clean > /dev/null 2>&1";
Chris Lattner196a14a2003-08-19 15:08:34 +0000728
Chris Lattner36dc5c72004-11-06 21:35:40 +0000729 # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE and
730 # GET_STABLE_NUMBERS enabled!
Brian Gaeke85668542004-06-04 00:07:12 +0000731 system "gmake -k $MAKEOPTS $PROGTESTOPTS report.nightly.raw.out TEST=nightly " .
Chris Lattner36dc5c72004-11-06 21:35:40 +0000732 " LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 > /dev/null 2>&1";
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000733 system "cp report.nightly.raw.out $OldenTestsLog";
Chris Lattner196a14a2003-08-19 15:08:34 +0000734 } else {
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000735 system "gunzip ${OldenTestsLog}.gz";
Chris Lattner196a14a2003-08-19 15:08:34 +0000736 }
737
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000738 # Now we know we have $OldenTestsLog as the raw output file. Split
Chris Lattner196a14a2003-08-19 15:08:34 +0000739 # it up into records and read the useful information.
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000740 my @Records = split />>> ========= /, ReadFile "$OldenTestsLog";
Chris Lattner196a14a2003-08-19 15:08:34 +0000741 shift @Records; # Delete the first (garbage) record
742
743 # Loop over all of the records, summarizing them into rows for the running
744 # totals file.
Chris Lattnerfed8a142004-12-14 22:42:59 +0000745 my $WallTimeRE = "Time: ([0-9.]+) seconds \\([0-9.]+ wall clock";
Chris Lattner196a14a2003-08-19 15:08:34 +0000746 foreach $Rec (@Records) {
Chris Lattner36dc5c72004-11-06 21:35:40 +0000747 my $rNATTime = GetRegex 'TEST-RESULT-nat-time: program\s*([.0-9m]+)', $Rec;
748 my $rCBETime = GetRegex 'TEST-RESULT-cbe-time: program\s*([.0-9m]+)', $Rec;
749 my $rLLCTime = GetRegex 'TEST-RESULT-llc-time: program\s*([.0-9m]+)', $Rec;
750 my $rJITTime = GetRegex 'TEST-RESULT-jit-time: program\s*([.0-9m]+)', $Rec;
Chris Lattnerfed8a142004-12-14 22:42:59 +0000751 my $rOptTime = GetRegex "TEST-RESULT-compile: .*$WallTimeRE", $Rec;
Chris Lattner196a14a2003-08-19 15:08:34 +0000752 my $rBytecodeSize = GetRegex 'TEST-RESULT-compile: *([0-9]+)', $Rec;
Chris Lattner196a14a2003-08-19 15:08:34 +0000753
754 $NATTime .= " " . FormatTime($rNATTime);
755 $CBETime .= " " . FormatTime($rCBETime);
756 $LLCTime .= " " . FormatTime($rLLCTime);
757 $JITTime .= " " . FormatTime($rJITTime);
758 $OptTime .= " $rOptTime";
Chris Lattner08e24762003-08-19 18:35:03 +0000759 $BytecodeSize .= " $rBytecodeSize";
Chris Lattner196a14a2003-08-19 15:08:34 +0000760 }
761
762 # Now that we have all of the numbers we want, add them to the running totals
763 # files.
Chris Lattner08e24762003-08-19 18:35:03 +0000764 AddRecord($NATTime, "running_Olden_nat_time.txt");
Chris Lattner196a14a2003-08-19 15:08:34 +0000765 AddRecord($CBETime, "running_Olden_cbe_time.txt");
766 AddRecord($LLCTime, "running_Olden_llc_time.txt");
767 AddRecord($JITTime, "running_Olden_jit_time.txt");
768 AddRecord($OptTime, "running_Olden_opt_time.txt");
769 AddRecord($BytecodeSize, "running_Olden_bytecode.txt");
Chris Lattner08e24762003-08-19 18:35:03 +0000770
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000771 system "gzip -f $OldenTestsLog";
Chris Lattner196a14a2003-08-19 15:08:34 +0000772}
773
774
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000775#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000776# Get a list of the previous days that we can link to...
Chris Lattnerb3440302003-01-22 16:14:05 +0000777#
Chris Lattner2f8cb572003-01-20 18:05:27 +0000778my @PrevDays = map {s/.html//; $_} GetDir ".html";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000779
Brian Gaeke253231e2004-06-11 19:55:30 +0000780if ((scalar @PrevDays) > 20) {
781 splice @PrevDays, 20; # Trim down list to something reasonable...
782}
Chris Lattner4c7e3032003-01-20 06:11:03 +0000783
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000784# Format list for sidebar
785my $PrevDaysList = join "\n ", map { "<a href=\"$_.html\">$_</a><br>" } @PrevDays;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000786
Chris Lattnerc75b14e2003-08-18 20:07:54 +0000787#
Brian Gaeke90c82b92004-09-28 16:04:00 +0000788# Start outputting files into the web directory
Chris Lattnerc75b14e2003-08-18 20:07:54 +0000789#
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000790ChangeDir( $WebDir, "Web Directory" );
Chris Lattnerc75b14e2003-08-18 20:07:54 +0000791
Brian Gaeke90c82b92004-09-28 16:04:00 +0000792# Make sure we don't get errors running the nightly tester the first time
793# because of files that don't exist.
794Touch ('running_build_time.txt', 'running_Olden_llc_time.txt',
Chris Lattnere50caac2005-10-28 16:35:18 +0000795 'running_loc.txt',
Brian Gaeke90c82b92004-09-28 16:04:00 +0000796 'running_Olden_bytecode.txt', 'running_Olden_nat_time.txt',
797 'running_Olden_cbe_time.txt', 'running_Olden_opt_time.txt',
798 'running_Olden_jit_time.txt');
799
Chris Lattnerc75b14e2003-08-18 20:07:54 +0000800# Add information to the files which accumulate information for graphs...
801AddRecord($LOC, "running_loc.txt");
802AddRecord($BuildTime, "running_build_time.txt");
803
Chris Lattner4d00fde2004-05-28 20:30:23 +0000804if ( $VERBOSE ) {
805 print "GRAPH GENERATION STAGE\n";
806}
Chris Lattnerc75b14e2003-08-18 20:07:54 +0000807#
808# Rebuild the graphs now...
809#
Chris Lattnerfe2597a2004-07-27 18:41:49 +0000810$GNUPLOT = "/usr/bin/gnuplot";
Brian Gaekeb3dab902003-10-11 05:34:00 +0000811$GNUPLOT = "gnuplot" if ! -x $GNUPLOT;
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000812system ("$GNUPLOT", $PlotScriptFilename);
Chris Lattnerb3440302003-01-22 16:14:05 +0000813
Chris Lattner4c7e3032003-01-20 06:11:03 +0000814#
815# Remove the cvs tree...
816#
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000817system ( "$NICE rm -rf $BuildDir") if (!$NOCHECKOUT and !$NOREMOVE);
Chris Lattner4c7e3032003-01-20 06:11:03 +0000818
Chris Lattner5e5d2202005-03-16 17:09:53 +0000819print "\nUSERS WHO COMMITTED:\n " . (join "\n ", sort keys %UsersCommitted) . "\n"
820 if (scalar %UsersCommitted);
821
822print "\nADDED FILES:\n " . (join "\n ", sort keys %AddedFiles) . "\n"
823 if (scalar %AddedFiles);
824
825print "\nCHANGED FILES:\n " . (join "\n ", sort keys %ModifiedFiles) . "\n"
826 if (scalar %ModifiedFiles);
827
828print "\nREMOVED FILES:\n " . (join "\n ", sort keys %RemovedFiles) . "\n"
829 if (scalar %RemovedFiles);
830
Chris Lattnerb3440302003-01-22 16:14:05 +0000831#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000832# Print out information...
Chris Lattnerb3440302003-01-22 16:14:05 +0000833#
Chris Lattner4d00fde2004-05-28 20:30:23 +0000834if ($VERBOSE) {
Chris Lattner4c7e3032003-01-20 06:11:03 +0000835 print "DateString: $DateString\n";
836 print "CVS Checkout: $CVSCheckoutTime seconds\n";
837 print "Files/Dirs/LOC in CVS: $NumFilesInCVS/$NumDirsInCVS/$LOC\n";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000838 print "Build Time: $BuildTime seconds\n";
839 print "Libraries/Executables/Objects built: $NumLibraries/$NumExecutables/$NumObjects\n";
840
841 print "WARNINGS:\n $WarningsList\n";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000842 print "Previous Days =\n $PrevDaysList\n";
843}
844
Chris Lattnerb3440302003-01-22 16:14:05 +0000845
Chris Lattner2f8cb572003-01-20 18:05:27 +0000846#
847# Output the files...
848#
849
Chris Lattner4d00fde2004-05-28 20:30:23 +0000850if ( $VERBOSE ) {
851 print "OUTPUT STAGE\n";
852}
Chris Lattner2f8cb572003-01-20 18:05:27 +0000853# Main HTML file...
Chris Lattner4c7e3032003-01-20 06:11:03 +0000854my $Output;
Chris Lattner004e19e2005-02-13 16:08:30 +0000855my $TestFinishTime = gmtime() . " GMT<br>" . localtime() . " (local)";
856
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000857my $TestPlatform = `uname -a`;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000858eval "\$Output = <<ENDOFFILE;$TemplateContents\nENDOFFILE\n";
Chris Lattner2f8cb572003-01-20 18:05:27 +0000859WriteFile "$DATE.html", $Output;
Chris Lattnerd9aadd42006-01-31 16:10:53 +0000860
861# Remove the symlink before creating it for systems that don't have "ln -sf".
862system ("rm index.html");
863system ("ln -s $DATE.html index.html");
Chris Lattner4c7e3032003-01-20 06:11:03 +0000864
865# Change the index.html symlink...
Chris Lattner4c7e3032003-01-20 06:11:03 +0000866
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000867# vim: sw=2 ai