blob: 45ebad93037640ca25fd3cafa7ea29d1d073fa53 [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)
Reid Spencer43fdfdc2006-04-14 13:53:56 +000022# -with-externals Specify a directory where the external tests are located.
Tanya Lattner056ec062004-12-04 06:25:50 +000023# -nodejagnu Do not run feature or regression tests
Brian Gaekeb3dab902003-10-11 05:34:00 +000024# -parallel Run two parallel jobs with GNU Make.
Reid Spencerf6d02332004-06-11 07:06:22 +000025# -release Build an LLVM Release version
Reid Spencer39ce11b2005-01-13 18:02:40 +000026# -enable-llcbeta Enable testing of beta features in llc.
Brian Gaeke047e6062004-08-05 19:54:59 +000027# -disable-llc Disable LLC tests in the nightly tester.
28# -disable-jit Disable JIT tests in the nightly tester.
Chris Lattner4d00fde2004-05-28 20:30:23 +000029# -verbose Turn on some debug output
30# -debug Print information useful only to maintainers of this script.
Reid Spencercb6a3aa2004-06-22 15:38:37 +000031# -nice Checkout/Configure/Build with "nice" to reduce impact
32# on busy servers.
Misha Brukman2e9ac692004-11-08 03:28:27 +000033# -f2c Next argument specifies path to F2C utility
Reid Spencercb6a3aa2004-06-22 15:38:37 +000034# -gnuplotscript Next argument specifies gnuplot script to use
35# -templatefile Next argument specifies template file to use
Chris Lattner892cdb32004-07-27 08:29:06 +000036# -gccpath Path to gcc/g++ used to build LLVM
Misha Brukmanf5f37f02005-05-26 16:28:55 +000037# -cvstag Check out a specific CVS tag to build LLVM (useful for
38# testing release branches)
Misha Brukman4391bb52005-06-06 19:17:05 +000039# -target Specify the target triplet
Evan Cheng34688642006-02-08 09:08:06 +000040# -cflags Next argument specifies that C compilation options that
41# override the default.
42# -cxxflags Next argument specifies that C++ compilation options that
43# override the default.
44# -ldflags Next argument specifies that linker options that override
45# the default.
Chris Lattnerbb0aca52003-12-19 03:47:31 +000046#
Chris Lattnerb0ddb492005-11-01 17:59:42 +000047# ---------------- Options to configure llvm-test ----------------------------
48# -spec2000path Path to the benchspec directory in the SPEC 2000 distro
49# -spec95path Path to the benchspec directory in the SPEC 95 distro.
50# -povraypath Path to the povray sources
51# -namdpath Path to the namd sources
52#
Brian Gaekeb3dab902003-10-11 05:34:00 +000053# CVSROOT is the CVS repository from which the tree will be checked out,
54# specified either in the full :method:user@host:/dir syntax, or
55# just /dir if using a local repo.
56# BUILDDIR is the directory where sources for this test run will be checked out
57# AND objects for this test run will be built. This directory MUST NOT
58# exist before the script is run; it will be created by the cvs checkout
59# process and erased (unless -noremove is specified; see above.)
60# WEBDIR is the directory into which the test results web page will be written,
61# AND in which the "index.html" is assumed to be a symlink to the most recent
Brian Gaeke90c82b92004-09-28 16:04:00 +000062# copy of the results. This directory will be created if it does not exist.
Reid Spencer932b69f2004-12-26 05:21:13 +000063# LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
64# to. This is the same as you would have for a normal LLVM build.
Chris Lattner4c7e3032003-01-20 06:11:03 +000065#
66use POSIX qw(strftime);
Tanya Lattner5debe8c2004-11-21 00:02:40 +000067use File::Copy;
Chris Lattner4c7e3032003-01-20 06:11:03 +000068
Brian Gaekeb3dab902003-10-11 05:34:00 +000069my $HOME = $ENV{'HOME'};
70my $CVSRootDir = $ENV{'CVSROOT'};
Chris Lattner9d13efa2003-10-14 01:22:08 +000071 $CVSRootDir = "/home/vadve/shared/PublicCVS"
Chris Lattner4d00fde2004-05-28 20:30:23 +000072 unless $CVSRootDir;
73my $BuildDir = $ENV{'BUILDDIR'};
74 $BuildDir = "$HOME/buildtest"
75 unless $BuildDir;
76my $WebDir = $ENV{'WEBDIR'};
77 $WebDir = "$HOME/cvs/testresults-X86"
78 unless $WebDir;
Chris Lattner2f8cb572003-01-20 18:05:27 +000079
80# Calculate the date prefix...
81@TIME = localtime;
82my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
83my $DateString = strftime "%B %d, %Y", localtime;
Chris Lattner004e19e2005-02-13 16:08:30 +000084my $TestStartTime = gmtime() . "GMT<br>" . localtime() . " (local)";
Reid Spencercb6a3aa2004-06-22 15:38:37 +000085
86# Command line argument settings...
87my $NOCHECKOUT = 0;
Misha Brukman2e9ac692004-11-08 03:28:27 +000088my $NOREMOVE = 0;
Misha Brukman2e9ac692004-11-08 03:28:27 +000089my $NOTEST = 0;
Reid Spencercb6a3aa2004-06-22 15:38:37 +000090my $NORUNNINGTESTS = 0;
Reid Spencer1d914632004-06-23 07:45:46 +000091my $NOEXTERNALS = 0;
Misha Brukman2e9ac692004-11-08 03:28:27 +000092my $MAKEOPTS = "";
Reid Spencercb6a3aa2004-06-22 15:38:37 +000093my $PROGTESTOPTS = "";
Misha Brukman2e9ac692004-11-08 03:28:27 +000094my $VERBOSE = 0;
Reid Spencercb6a3aa2004-06-22 15:38:37 +000095my $DEBUG = 0;
Brian Gaeke047e6062004-08-05 19:54:59 +000096my $CONFIGUREARGS = "";
Misha Brukmanf5f37f02005-05-26 16:28:55 +000097my $CVSCOOPT = "-APR";
Reid Spencercb6a3aa2004-06-22 15:38:37 +000098my $NICE = "";
Tanya Lattner056ec062004-12-04 06:25:50 +000099my $NODEJAGNU = 0;
Chris Lattner2f8cb572003-01-20 18:05:27 +0000100
Chris Lattnerb0ddb492005-11-01 17:59:42 +0000101my $LLVMTESTCONFIGARGS = "";
102
Chris Lattnerb3440302003-01-22 16:14:05 +0000103sub ReadFile {
104 if (open (FILE, $_[0])) {
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000105 undef $/;
Chris Lattnerb3440302003-01-22 16:14:05 +0000106 my $Ret = <FILE>;
107 close FILE;
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000108 $/ = '\n';
Chris Lattnerb3440302003-01-22 16:14:05 +0000109 return $Ret;
110 } else {
111 print "Could not open file '$_[0]' for reading!";
112 return "";
113 }
114}
115
Chris Lattner2f8cb572003-01-20 18:05:27 +0000116sub WriteFile { # (filename, contents)
117 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!";
118 print FILE $_[1];
119 close FILE;
120}
121
122sub GetRegex { # (Regex with ()'s, value)
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000123 $_[1] =~ /$_[0]/m;
Chris Lattner08e24762003-08-19 18:35:03 +0000124 if (defined($1)) {
125 return $1;
126 }
Reid Spencera337f0c2004-06-23 06:36:34 +0000127 return "0";
Chris Lattner2f8cb572003-01-20 18:05:27 +0000128}
129
Brian Gaeke90c82b92004-09-28 16:04:00 +0000130sub Touch {
131 my @files = @_;
132 my $now = time;
133 foreach my $file (@files) {
134 if (! -f $file) {
135 open (FILE, ">$file") or warn "Could not create new file $file";
136 close FILE;
137 }
138 utime $now, $now, $file;
139 }
140}
141
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000142sub AddRecord {
143 my ($Val, $Filename) = @_;
144 my @Records;
145 if (open FILE, "$WebDir/$Filename") {
146 @Records = grep !/$DATE/, split "\n", <FILE>;
147 close FILE;
148 }
149 push @Records, "$DATE: $Val";
150 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000151}
152
Chris Lattner2f8cb572003-01-20 18:05:27 +0000153sub AddPreTag { # Add pre tags around nonempty list, or convert to "none"
154 $_ = shift;
Reid Spencer7d6a5152006-03-21 01:21:39 +0000155 if (length) { return "<pre>$_</pre>"; } else { "<b>none</b><br>"; }
156}
157
158sub ArrayToList { # Add <li> tags around nonempty list or convert to "none"
159 my $result = "";
160 if (scalar @_) {
161 $result = "<ul>";
162 foreach $item (@_) {
163 $result .= "<li><tt>$item</tt></li>";
164 }
165 $result .= "</ul>";
166 } else {
167 $result = "<p><b>none</b></p>";
168 }
169 return $result;
Chris Lattner2f8cb572003-01-20 18:05:27 +0000170}
171
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000172sub ChangeDir { # directory, logical name
173 my ($dir,$name) = @_;
174 chomp($dir);
175 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
176 chdir($dir) || die "Cannot change directory to: $name ($dir) ";
177}
178
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000179sub CopyFile { #filename, newfile
180 my ($file, $newfile) = @_;
181 chomp($file);
182 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
183 copy($file, $newfile);
184}
185
Chris Lattner2f8cb572003-01-20 18:05:27 +0000186sub GetDir {
187 my $Suffix = shift;
188 opendir DH, $WebDir;
189 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
190 closedir DH;
191 return @Result;
192}
193
194# DiffFiles - Diff the current version of the file against the last version of
195# the file, reporting things added and removed. This is used to report, for
196# example, added and removed warnings. This returns a pair (added, removed)
197#
198sub DiffFiles {
199 my $Suffix = shift;
200 my @Others = GetDir $Suffix;
201 if (@Others == 0) { # No other files? We added all entries...
202 return (`cat $WebDir/$DATE$Suffix`, "");
203 }
204 # Diff the files now...
205 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
206 my $Added = join "\n", grep /^</, @Diffs;
207 my $Removed = join "\n", grep /^>/, @Diffs;
Chris Lattner1cbc0a62003-01-20 19:18:44 +0000208 $Added =~ s/^< //gm;
209 $Removed =~ s/^> //gm;
Chris Lattner2f8cb572003-01-20 18:05:27 +0000210 return ($Added, $Removed);
211}
212
Chris Lattner196a14a2003-08-19 15:08:34 +0000213# FormatTime - Convert a time from 1m23.45 into 83.45
214sub FormatTime {
215 my $Time = shift;
216 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
217 $Time = sprintf("%7.4f", $1*60.0+$2);
218 }
219 return $Time;
220}
221
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000222sub GetRegexNum {
223 my ($Regex, $Num, $Regex2, $File) = @_;
224 my @Items = split "\n", `grep '$Regex' $File`;
225 return GetRegex $Regex2, $Items[$Num];
226}
227
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000228sub GetDejagnuTestResults { # (filename, log)
229 my ($filename, $DejagnuLog) = @_;
230 my @lines;
231 my $firstline;
232 $/ = "\n"; #Make sure we're going line at a time.
Chris Lattner453d0622005-03-10 16:26:50 +0000233
Chris Lattner8f457312005-03-17 16:07:45 +0000234 print "DEJAGNU TEST RESULTS:\n";
Chris Lattner453d0622005-03-10 16:26:50 +0000235
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000236 if (open SRCHFILE, $filename) {
237 # Process test results
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000238 my $first_list = 1;
239 my $should_break = 1;
240 my $nocopy = 0;
241 my $readingsum = 0;
242 while ( <SRCHFILE> ) {
243 if ( length($_) > 1 ) {
244 chomp($_);
245 if ( m/^XPASS:/ || m/^FAIL:/ ) {
246 $nocopy = 0;
247 if ( $first_list ) {
Misha Brukmand3a54122005-03-10 16:32:33 +0000248 push(@lines, "<h3>UNEXPECTED TEST RESULTS</h3><ol><li>\n");
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000249 $first_list = 0;
250 $should_break = 1;
Misha Brukmand3a54122005-03-10 16:32:33 +0000251 push(@lines, "<b>$_</b><br/>\n");
Chris Lattner453d0622005-03-10 16:26:50 +0000252 print " $_\n";
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000253 } else {
Misha Brukmand3a54122005-03-10 16:32:33 +0000254 push(@lines, "</li><li><b>$_</b><br/>\n");
Chris Lattner453d0622005-03-10 16:26:50 +0000255 print " $_\n";
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000256 }
257 } elsif ( m/Summary/ ) {
Chris Lattner453d0622005-03-10 16:26:50 +0000258 if ( $first_list ) {
Misha Brukmand3a54122005-03-10 16:32:33 +0000259 push(@lines, "<b>PERFECT!</b>");
260 print " PERFECT!\n";
261 } else {
262 push(@lines, "</li></ol>\n");
263 }
264 push(@lines, "<h3>STATISTICS</h3><pre>\n");
Chris Lattner8f457312005-03-17 16:07:45 +0000265 print "\nDEJAGNU STATISTICS:\n";
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000266 $should_break = 0;
267 $nocopy = 0;
268 $readingsum = 1;
269 } elsif ( $readingsum ) {
270 push(@lines,"$_\n");
Chris Lattner8f457312005-03-17 16:07:45 +0000271 print " $_\n";
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000272 }
273 }
274 }
275 }
276 push(@lines, "</pre>\n");
277 close SRCHFILE;
278
Misha Brukmand3a54122005-03-10 16:32:33 +0000279 my $content = join("", @lines);
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000280 return "$content</li></ol>\n";
281}
282
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000283
284#####################################################################
285## MAIN PROGRAM
286#####################################################################
287
288my $Template = "";
289my $PlotScriptFilename = "";
290
291# Parse arguments...
292while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
293 shift;
294 last if /^--$/; # Stop processing arguments on --
295
296 # List command line options here...
297 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
Misha Brukman2e9ac692004-11-08 03:28:27 +0000298 if (/^-noremove$/) { $NOREMOVE = 1; next; }
Misha Brukman2e9ac692004-11-08 03:28:27 +0000299 if (/^-notest$/) { $NOTEST = 1; $NORUNNINGTESTS = 1; next; }
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000300 if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
Misha Brukman2e9ac692004-11-08 03:28:27 +0000301 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j2 -l3.0"; next; }
302 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1"; next; }
Chris Lattnerc82a6c82005-01-08 21:03:58 +0000303 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
Brian Gaeke047e6062004-08-05 19:54:59 +0000304 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
305 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
306 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
307 $CONFIGUREARGS .= " --disable-jit"; next; }
Misha Brukman2e9ac692004-11-08 03:28:27 +0000308 if (/^-verbose$/) { $VERBOSE = 1; next; }
309 if (/^-debug$/) { $DEBUG = 1; next; }
310 if (/^-nice$/) { $NICE = "nice "; next; }
311 if (/^-f2c$/) {
312 $CONFIGUREARGS .= " --with-f2c=$ARGV[0]"; shift; next;
313 }
Reid Spencer43fdfdc2006-04-14 13:53:56 +0000314 if (/^-with-externals/) {
315 $CONFIGUREARGS .= "--with-externals=$ARGV[0]"; shift; next
316 }
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000317 if (/^-gnuplotscript$/) { $PlotScriptFilename = $ARGV[0]; shift; next; }
Reid Spencerc5b67052004-06-23 14:07:12 +0000318 if (/^-templatefile$/) { $Template = $ARGV[0]; shift; next; }
Misha Brukman2e9ac692004-11-08 03:28:27 +0000319 if (/^-gccpath/) {
320 $CONFIGUREARGS .= " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++"; shift; next;
321 }
Misha Brukmanf5f37f02005-05-26 16:28:55 +0000322 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
Misha Brukman4391bb52005-06-06 19:17:05 +0000323 if (/^-target/) {
324 $CONFIGUREARGS .= " --target=$ARGV[0]"; shift; next;
325 }
Evan Cheng34688642006-02-08 09:08:06 +0000326 if (/^-cflags/) {
327 $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'"; shift; next;
328 }
329 if (/^-cxxflags/) {
330 $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'"; shift; next;
331 }
332 if (/^-ldflags/) {
333 $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'"; shift; next;
334 }
Reid Spencer1d914632004-06-23 07:45:46 +0000335 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
Misha Brukman4391bb52005-06-06 19:17:05 +0000336 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
Chris Lattnerb0ddb492005-11-01 17:59:42 +0000337 if (/^-spec2000path$/) {
338 $LLVMTESTCONFIGARGS .= " --enable-spec2000=$ARGV[0]"; shift; next;
339 }
340 if (/^-spec95path$/) {
341 $LLVMTESTCONFIGARGS .= " --enable-spec95=$ARGV[0]"; shift; next;
342 }
343 if (/^-povraypath$/) {
344 $LLVMTESTCONFIGARGS .= " --enable-povray=$ARGV[0]"; shift; next;
345 }
346 if (/^-namdpath$/) {
347 $LLVMTESTCONFIGARGS .= " --enable-namd=$ARGV[0]"; shift; next;
348 }
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000349 print "Unknown option: $_ : ignoring!\n";
350}
351
Reid Spencer932b69f2004-12-26 05:21:13 +0000352if ($ENV{'LLVMGCCDIR'}) {
353 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
354}
Brian Gaeke047e6062004-08-05 19:54:59 +0000355if ($CONFIGUREARGS !~ /--disable-jit/) {
356 $CONFIGUREARGS .= " --enable-jit";
357}
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000358
359die "Must specify 0 or 3 options!" if (@ARGV != 0 and @ARGV != 3);
360
361if (@ARGV == 3) {
362 $CVSRootDir = $ARGV[0];
363 $BuildDir = $ARGV[1];
364 $WebDir = $ARGV[2];
365}
366
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000367my $Prefix = "$WebDir/$DATE";
368
369#define the file names we'll use
370my $BuildLog = "$Prefix-Build-Log.txt";
371my $CVSLog = "$Prefix-CVS-Log.txt";
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000372my $OldenTestsLog = "$Prefix-Olden-tests.txt";
373my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
374my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
375my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000376my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
377my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
378my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000379
380if ($VERBOSE) {
381 print "INITIALIZED\n";
382 print "CVS Root = $CVSRootDir\n";
383 print "BuildDir = $BuildDir\n";
384 print "WebDir = $WebDir\n";
385 print "Prefix = $Prefix\n";
386 print "CVSLog = $CVSLog\n";
387 print "BuildLog = $BuildLog\n";
388}
389
Brian Gaeke90c82b92004-09-28 16:04:00 +0000390if (! -d $WebDir) {
391 mkdir $WebDir, 0777;
392 warn "Warning: $WebDir did not exist; creating it.\n";
393}
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000394
395#
396# Create the CVS repository directory
397#
398if (!$NOCHECKOUT) {
399 if (-d $BuildDir) {
400 if (!$NOREMOVE) {
401 system "rm -rf $BuildDir";
402 } else {
403 die "CVS checkout directory $BuildDir already exists!";
404 }
405 }
406 mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
407}
408
409ChangeDir( $BuildDir, "CVS checkout directory" );
410
411
412#
413# Check out the llvm tree, saving CVS messages to the cvs log...
414#
Misha Brukmanf5f37f02005-05-26 16:28:55 +0000415my $CVSOPT = "";
416# Use compression if going over ssh.
417$CVSOPT = "-z3" if $CVSRootDir =~ /^:ext:/;
418my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co $CVSCOOPT";
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000419if (!$NOCHECKOUT) {
420 if ( $VERBOSE ) { print "CHECKOUT STAGE\n"; }
Misha Brukmanf5f37f02005-05-26 16:28:55 +0000421 system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
422 "$CVSCMD llvm-test ) > $CVSLog 2>&1";
Reid Spencer10ffe012004-09-05 07:58:10 +0000423 ChangeDir( $BuildDir , "CVS Checkout directory") ;
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000424}
425
426ChangeDir( "llvm" , "llvm source directory") ;
427
428if (!$NOCHECKOUT) {
429 if ( $VERBOSE ) { print "UPDATE STAGE\n"; }
Reid Spencer10ffe012004-09-05 07:58:10 +0000430 system "$NICE cvs update -PdRA >> $CVSLog 2>&1" ;
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000431}
432
Reid Spencerc5b67052004-06-23 14:07:12 +0000433if ( $Template eq "" ) {
434 $Template = "$BuildDir/llvm/utils/NightlyTestTemplate.html";
435}
436die "Template file $Template is not readable" if ( ! -r "$Template" );
437
438if ( $PlotScriptFilename eq "" ) {
439 $PlotScriptFilename = "$BuildDir/llvm/utils/NightlyTest.gnuplot";
440}
441die "GNUPlot Script $PlotScriptFilename is not readable" if ( ! -r "$PlotScriptFilename" );
442
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000443# Read in the HTML template file...
444if ( $VERBOSE ) { print "READING TEMPLATE\n"; }
445my $TemplateContents = ReadFile $Template;
446
447#
448# Get some static statistics about the current state of CVS
449#
450my $CVSCheckoutTime = GetRegex "([0-9.]+)", `grep '^real' $CVSLog`;
451my $NumFilesInCVS = `egrep '^U' $CVSLog | wc -l` + 0;
452my $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $CVSLog | wc -l` + 0;
Reid Spencere993f462004-09-06 19:32:55 +0000453$LOC = `utils/countloc.sh`;
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000454
455#
456# Build the entire tree, saving build messages to the build log
457#
458if (!$NOCHECKOUT) {
459 if ( $VERBOSE ) { print "CONFIGURE STAGE\n"; }
Chris Lattnerb0ddb492005-11-01 17:59:42 +0000460 my $EXTRAFLAGS = "--enable-spec --with-objroot=.$LLVMTESTCONFIGARGS";
Chris Lattnere50caac2005-10-28 16:35:18 +0000461 system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) > $BuildLog 2>&1";
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000462
463 if ( $VERBOSE ) { print "BUILD STAGE\n"; }
464 # Build the entire tree, capturing the output into $BuildLog
465 system "(time -p $NICE gmake $MAKEOPTS) >> $BuildLog 2>&1";
466}
467
468
469#
470# Get some statistics about the build...
471#
472my @Linked = split '\n', `grep Linking $BuildLog`;
473my $NumExecutables = scalar(grep(/executable/, @Linked));
474my $NumLibraries = scalar(grep(!/executable/, @Linked));
Chris Lattner0bb48282005-03-11 20:17:04 +0000475my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000476
477my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
478my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
479my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
480my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
481
482my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
483my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
484my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
485my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
486
Misha Brukman9a612752005-01-12 03:31:38 +0000487my $BuildError = 0, $BuildStatus = "OK";
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000488if (`grep '^gmake[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
489 `grep '^gmake: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
Misha Brukman9a612752005-01-12 03:31:38 +0000490 $BuildStatus = "<h3><font color='red'>error: compilation " .
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000491 "<a href=\"$DATE-Build-Log.txt\">aborted</a></font></h3>";
Misha Brukman9a612752005-01-12 03:31:38 +0000492 $BuildError = 1;
Chris Lattner08313102005-12-11 19:55:39 +0000493 print "\n***ERROR BUILDING TREE\n\n";
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000494}
495
Tanya Lattner056ec062004-12-04 06:25:50 +0000496if ($BuildError) { $NODEJAGNU=1; }
Brian Gaeke22800982004-06-25 07:25:28 +0000497
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000498my $DejangnuTestResults; # String containing the results of the dejagnu
Tanya Lattner59a86552004-12-04 06:35:14 +0000499if(!$NODEJAGNU) {
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000500 if($VERBOSE) { print "DEJAGNU FEATURE/REGRESSION TEST STAGE\n"; }
501
502 my $dejagnu_output = "$DejagnuTestsLog";
503
504 #Run the feature and regression tests, results are put into testrun.sum
505 #Full log in testrun.log
Tanya Lattner056ec062004-12-04 06:25:50 +0000506 system "(time -p gmake $MAKEOPTS check) > $dejagnu_output 2>&1";
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000507
508 #Extract time of dejagnu tests
509 my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
510 my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
511 $DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
512 $DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
513
514 #Copy the testrun.log and testrun.sum to our webdir
515 CopyFile("test/testrun.log", $DejagnuLog);
516 CopyFile("test/testrun.sum", $DejagnuSum);
517
518 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
Tanya Lattnera2dfbf92004-12-17 20:58:34 +0000519
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000520} else {
521 $DejagnuTestResults = "Skipped by user choice.";
522 $DejagnuTime = "0.0";
523 $DejagnuWallTime = "0.0";
524}
525
Chris Lattner4d00fde2004-05-28 20:30:23 +0000526if ($DEBUG) {
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000527 print $DejagnuTestResults;
Chris Lattner4d00fde2004-05-28 20:30:23 +0000528}
529
530if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
Chris Lattnerb3440302003-01-22 16:14:05 +0000531#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000532# Get warnings from the build
Chris Lattnerb3440302003-01-22 16:14:05 +0000533#
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000534my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000535my @Warnings;
536my $CurDir = "";
537
538foreach $Warning (@Warn) {
539 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
540 $CurDir = $1; # Keep track of directory warning is in...
Misha Brukman8e9554a2003-08-14 15:26:28 +0000541 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { # Remove buildir prefix if included
Chris Lattner4c7e3032003-01-20 06:11:03 +0000542 $CurDir = $1;
543 }
544 } else {
545 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
546 }
547}
Chris Lattner1cbc0a62003-01-20 19:18:44 +0000548my $WarningsFile = join "\n", @Warnings;
Reid Spencer7d6a5152006-03-21 01:21:39 +0000549my $WarningsList = ArrayToList @Warnings;
Chris Lattner1cbc0a62003-01-20 19:18:44 +0000550$WarningsFile =~ s/:[0-9]+:/::/g;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000551
Chris Lattner2f8cb572003-01-20 18:05:27 +0000552# Emit the warnings file, so we can diff...
553WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
554my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000555
Chris Lattner9efd7f42003-10-18 19:31:39 +0000556# Output something to stdout if something has changed
557print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
558print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
559
Reid Spencer7d6a5152006-03-21 01:21:39 +0000560my @TmpWarningsAdded = split "\n", $WarningsAdded;
561my @TmpWarningsRemoved = split "\n", $WarningsRemoved;
562$WarningsAdded = ArrayToList @TmpWarningsAdded;
563$WarningsRemoved = ArrayToList @TmpWarningsRemoved;
Chris Lattnerb3440302003-01-22 16:14:05 +0000564
565#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000566# Get some statistics about CVS commits over the current day...
Chris Lattnerb3440302003-01-22 16:14:05 +0000567#
Chris Lattner4d00fde2004-05-28 20:30:23 +0000568if ($VERBOSE) { print "CVS HISTORY ANALYSIS STAGE\n"; }
Chris Lattner4c7e3032003-01-20 06:11:03 +0000569@CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
570#print join "\n", @CVSHistory; print "\n";
571
572# Extract some information from the CVS history... use a hash so no duplicate
573# stuff is stored.
Misha Brukman1b366892003-07-07 21:27:40 +0000574my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
Chris Lattner4c7e3032003-01-20 06:11:03 +0000575
Brian Gaeke43f38672004-06-10 07:44:28 +0000576my $DateRE = '[-/:0-9 ]+\+[0-9]+';
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000577
Chris Lattner4c7e3032003-01-20 06:11:03 +0000578# Loop over every record from the CVS history, filling in the hashes.
579foreach $File (@CVSHistory) {
580 my ($Type, $Date, $UID, $Rev, $Filename);
Misha Brukman8e9554a2003-08-14 15:26:28 +0000581 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
Chris Lattner4c7e3032003-01-20 06:11:03 +0000582 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
Chris Lattnerd56147d2004-01-12 16:55:30 +0000583 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
584 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
Misha Brukman1b366892003-07-07 21:27:40 +0000585 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000586 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
Chris Lattner4c7e3032003-01-20 06:11:03 +0000587 } else {
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000588 print "UNMATCHABLE: $File\n";
Brian Gaeke43f38672004-06-10 07:44:28 +0000589 next;
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000590 }
591 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
592
593 if ($Filename =~ /^llvm/) {
594 if ($Type eq 'M') { # Modified
595 $ModifiedFiles{$Filename} = 1;
596 $UsersCommitted{$UID} = 1;
597 } elsif ($Type eq 'A') { # Added
598 $AddedFiles{$Filename} = 1;
599 $UsersCommitted{$UID} = 1;
600 } elsif ($Type eq 'R') { # Removed
601 $RemovedFiles{$Filename} = 1;
602 $UsersCommitted{$UID} = 1;
603 } else {
604 $UsersUpdated{$UID} = 1;
605 }
Chris Lattner4c7e3032003-01-20 06:11:03 +0000606 }
607}
608
Chris Lattner5e5d2202005-03-16 17:09:53 +0000609my $UserCommitList = join "\n", sort keys %UsersCommitted;
610my $UserUpdateList = join "\n", sort keys %UsersUpdated;
Chris Lattnerc9cdadf2003-08-06 16:02:50 +0000611my $AddedFilesList = AddPreTag join "\n", sort keys %AddedFiles;
612my $ModifiedFilesList = AddPreTag join "\n", sort keys %ModifiedFiles;
613my $RemovedFilesList = AddPreTag join "\n", sort keys %RemovedFiles;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000614
Chris Lattnerec0e3742003-02-28 20:30:20 +0000615my $TestError = 1;
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000616my $SingleSourceProgramsTable = "!";
617my $MultiSourceProgramsTable = "!";
618my $ExternalProgramsTable = "!";
Chris Lattnerb3440302003-01-22 16:14:05 +0000619
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000620
621sub TestDirectory {
622 my $SubDir = shift;
623
Reid Spencer10ffe012004-09-05 07:58:10 +0000624 ChangeDir( "projects/llvm-test/$SubDir", "Programs Test Subdirectory" );
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000625
626 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
Chris Lattnerec0e3742003-02-28 20:30:20 +0000627
628 # Run the programs tests... creating a report.nightly.html file
629 if (!$NOTEST) {
Chris Lattner20d13ea2004-06-03 03:29:39 +0000630 system "gmake -k $MAKEOPTS $PROGTESTOPTS report.nightly.html "
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000631 . "TEST=nightly > $ProgramTestLog 2>&1";
Chris Lattnerec0e3742003-02-28 20:30:20 +0000632 } else {
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000633 system "gunzip ${ProgramTestLog}.gz";
Chris Lattnerec0e3742003-02-28 20:30:20 +0000634 }
635
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000636 my $ProgramsTable;
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000637 if (`grep '^gmake[^:]: .*Error' $ProgramTestLog | wc -l` + 0){
Chris Lattnerec0e3742003-02-28 20:30:20 +0000638 $TestError = 1;
Chris Lattner2e8be142003-05-10 21:40:10 +0000639 $ProgramsTable = "<font color=white><h2>Error running tests!</h2></font>";
Chris Lattnerbe197872003-10-19 16:54:00 +0000640 print "ERROR TESTING\n";
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000641 } elsif (`grep '^gmake[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
Chris Lattner6e51bfa2003-05-11 15:23:10 +0000642 $TestError = 1;
643 $ProgramsTable =
644 "<font color=white><h2>Makefile error running tests!</h2></font>";
Chris Lattnerbe197872003-10-19 16:54:00 +0000645 print "ERROR TESTING\n";
Chris Lattner6e51bfa2003-05-11 15:23:10 +0000646 } else {
Chris Lattnerec0e3742003-02-28 20:30:20 +0000647 $TestError = 0;
648 $ProgramsTable = ReadFile "report.nightly.html";
649
650 #
651 # Create a list of the tests which were run...
652 #
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000653 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog "
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000654 . "| sort > $Prefix-$SubDir-Tests.txt";
Chris Lattnerec0e3742003-02-28 20:30:20 +0000655 }
656
657 # Compress the test output
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000658 system "gzip -f $ProgramTestLog";
659 ChangeDir( "../../..", "Programs Test Parent Directory" );
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000660 return $ProgramsTable;
661}
662
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000663# If we built the tree successfully, run the nightly programs tests...
Misha Brukman9a612752005-01-12 03:31:38 +0000664if (!$BuildError) {
Chris Lattner4d00fde2004-05-28 20:30:23 +0000665 if ( $VERBOSE ) {
666 print "SingleSource TEST STAGE\n";
667 }
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000668 $SingleSourceProgramsTable = TestDirectory("SingleSource");
Chris Lattner4d00fde2004-05-28 20:30:23 +0000669 if ( $VERBOSE ) {
670 print "MultiSource TEST STAGE\n";
671 }
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000672 $MultiSourceProgramsTable = TestDirectory("MultiSource");
Reid Spencer1d914632004-06-23 07:45:46 +0000673 if ( ! $NOEXTERNALS ) {
674 if ( $VERBOSE ) {
675 print "External TEST STAGE\n";
676 }
677 $ExternalProgramsTable = TestDirectory("External");
678 system "cat $Prefix-SingleSource-Tests.txt $Prefix-MultiSource-Tests.txt ".
Chris Lattnereac3cdc2003-08-21 15:55:26 +0000679 " $Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
Reid Spencer1d914632004-06-23 07:45:46 +0000680 } else {
Reid Spencerb8e825b2004-12-04 22:18:28 +0000681 $ExternalProgramsTable = '<tr><td>External TEST STAGE SKIPPED</td></tr>';
Reid Spencer1d914632004-06-23 07:45:46 +0000682 if ( $VERBOSE ) {
683 print "External TEST STAGE SKIPPED\n";
684 }
685 system "cat $Prefix-SingleSource-Tests.txt $Prefix-MultiSource-Tests.txt ".
686 " | sort > $Prefix-Tests.txt";
687 }
Chris Lattner5d6c4382003-01-23 19:31:28 +0000688}
Chris Lattnerb3440302003-01-22 16:14:05 +0000689
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000690if ( $VERBOSE ) { print "TEST INFORMATION COLLECTION STAGE\n"; }
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000691my ($TestsAdded, $TestsRemoved, $TestsFixed, $TestsBroken) = ("","","","");
692
Chris Lattnerec0e3742003-02-28 20:30:20 +0000693if ($TestError) {
694 $TestsAdded = "<b>error testing</b><br>";
695 $TestsRemoved = "<b>error testing</b><br>";
696 $TestsFixed = "<b>error testing</b><br>";
697 $TestsBroken = "<b>error testing</b><br>";
698} else {
699 my ($RTestsAdded, $RTestsRemoved) = DiffFiles "-Tests.txt";
700
701 my @RawTestsAddedArray = split '\n', $RTestsAdded;
702 my @RawTestsRemovedArray = split '\n', $RTestsRemoved;
703
704 my %OldTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
705 @RawTestsRemovedArray;
706 my %NewTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
707 @RawTestsAddedArray;
708
709 foreach $Test (keys %NewTests) {
710 if (!exists $OldTests{$Test}) { # TestAdded if in New but not old
711 $TestsAdded = "$TestsAdded$Test\n";
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000712 } else {
Chris Lattnerec0e3742003-02-28 20:30:20 +0000713 if ($OldTests{$Test} =~ /TEST-PASS/) { # Was the old one a pass?
714 $TestsBroken = "$TestsBroken$Test\n"; # New one must be a failure
715 } else {
716 $TestsFixed = "$TestsFixed$Test\n"; # No, new one is a pass.
717 }
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000718 }
719 }
Chris Lattnerec0e3742003-02-28 20:30:20 +0000720 foreach $Test (keys %OldTests) { # TestRemoved if in Old but not New
721 $TestsRemoved = "$TestsRemoved$Test\n" if (!exists $NewTests{$Test});
722 }
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000723
Chris Lattner91480ff2003-10-21 15:47:31 +0000724 print "\nTESTS ADDED: \n\n$TestsAdded\n\n" if (length $TestsAdded);
725 print "\nTESTS REMOVED:\n\n$TestsRemoved\n\n" if (length $TestsRemoved);
726 print "\nTESTS FIXED: \n\n$TestsFixed\n\n" if (length $TestsFixed);
727 print "\nTESTS BROKEN: \n\n$TestsBroken\n\n" if (length $TestsBroken);
Chris Lattnerbe197872003-10-19 16:54:00 +0000728
Chris Lattnerec0e3742003-02-28 20:30:20 +0000729 $TestsAdded = AddPreTag $TestsAdded;
730 $TestsRemoved = AddPreTag $TestsRemoved;
731 $TestsFixed = AddPreTag $TestsFixed;
732 $TestsBroken = AddPreTag $TestsBroken;
733}
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000734
Chris Lattner9efd7f42003-10-18 19:31:39 +0000735
Chris Lattner196a14a2003-08-19 15:08:34 +0000736# If we built the tree successfully, runs of the Olden suite with
737# LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
Misha Brukman9a612752005-01-12 03:31:38 +0000738if (!$BuildError) {
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000739 if ( $VERBOSE ) { print "OLDEN TEST SUITE STAGE\n"; }
Chris Lattner08e24762003-08-19 18:35:03 +0000740 my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
Chris Lattner196a14a2003-08-19 15:08:34 +0000741 $MachCodeSize) = ("","","","","","","");
Chris Lattner08e24762003-08-19 18:35:03 +0000742 if (!$NORUNNINGTESTS) {
Reid Spencer10ffe012004-09-05 07:58:10 +0000743 ChangeDir( "$BuildDir/llvm/projects/llvm-test/MultiSource/Benchmarks/Olden",
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000744 "Olden Test Directory");
Chris Lattner196a14a2003-08-19 15:08:34 +0000745
746 # Clean out previous results...
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000747 system "$NICE gmake $MAKEOPTS clean > /dev/null 2>&1";
Chris Lattner196a14a2003-08-19 15:08:34 +0000748
Chris Lattner36dc5c72004-11-06 21:35:40 +0000749 # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE and
750 # GET_STABLE_NUMBERS enabled!
Brian Gaeke85668542004-06-04 00:07:12 +0000751 system "gmake -k $MAKEOPTS $PROGTESTOPTS report.nightly.raw.out TEST=nightly " .
Chris Lattner36dc5c72004-11-06 21:35:40 +0000752 " LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 > /dev/null 2>&1";
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000753 system "cp report.nightly.raw.out $OldenTestsLog";
Chris Lattner196a14a2003-08-19 15:08:34 +0000754 } else {
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000755 system "gunzip ${OldenTestsLog}.gz";
Chris Lattner196a14a2003-08-19 15:08:34 +0000756 }
757
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000758 # Now we know we have $OldenTestsLog as the raw output file. Split
Chris Lattner196a14a2003-08-19 15:08:34 +0000759 # it up into records and read the useful information.
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000760 my @Records = split />>> ========= /, ReadFile "$OldenTestsLog";
Chris Lattner196a14a2003-08-19 15:08:34 +0000761 shift @Records; # Delete the first (garbage) record
762
763 # Loop over all of the records, summarizing them into rows for the running
764 # totals file.
Chris Lattnerfed8a142004-12-14 22:42:59 +0000765 my $WallTimeRE = "Time: ([0-9.]+) seconds \\([0-9.]+ wall clock";
Chris Lattner196a14a2003-08-19 15:08:34 +0000766 foreach $Rec (@Records) {
Chris Lattner36dc5c72004-11-06 21:35:40 +0000767 my $rNATTime = GetRegex 'TEST-RESULT-nat-time: program\s*([.0-9m]+)', $Rec;
768 my $rCBETime = GetRegex 'TEST-RESULT-cbe-time: program\s*([.0-9m]+)', $Rec;
769 my $rLLCTime = GetRegex 'TEST-RESULT-llc-time: program\s*([.0-9m]+)', $Rec;
770 my $rJITTime = GetRegex 'TEST-RESULT-jit-time: program\s*([.0-9m]+)', $Rec;
Chris Lattnerfed8a142004-12-14 22:42:59 +0000771 my $rOptTime = GetRegex "TEST-RESULT-compile: .*$WallTimeRE", $Rec;
Chris Lattner196a14a2003-08-19 15:08:34 +0000772 my $rBytecodeSize = GetRegex 'TEST-RESULT-compile: *([0-9]+)', $Rec;
Chris Lattner196a14a2003-08-19 15:08:34 +0000773
774 $NATTime .= " " . FormatTime($rNATTime);
775 $CBETime .= " " . FormatTime($rCBETime);
776 $LLCTime .= " " . FormatTime($rLLCTime);
777 $JITTime .= " " . FormatTime($rJITTime);
778 $OptTime .= " $rOptTime";
Chris Lattner08e24762003-08-19 18:35:03 +0000779 $BytecodeSize .= " $rBytecodeSize";
Chris Lattner196a14a2003-08-19 15:08:34 +0000780 }
781
782 # Now that we have all of the numbers we want, add them to the running totals
783 # files.
Chris Lattner08e24762003-08-19 18:35:03 +0000784 AddRecord($NATTime, "running_Olden_nat_time.txt");
Chris Lattner196a14a2003-08-19 15:08:34 +0000785 AddRecord($CBETime, "running_Olden_cbe_time.txt");
786 AddRecord($LLCTime, "running_Olden_llc_time.txt");
787 AddRecord($JITTime, "running_Olden_jit_time.txt");
788 AddRecord($OptTime, "running_Olden_opt_time.txt");
789 AddRecord($BytecodeSize, "running_Olden_bytecode.txt");
Chris Lattner08e24762003-08-19 18:35:03 +0000790
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000791 system "gzip -f $OldenTestsLog";
Chris Lattner196a14a2003-08-19 15:08:34 +0000792}
793
794
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000795#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000796# Get a list of the previous days that we can link to...
Chris Lattnerb3440302003-01-22 16:14:05 +0000797#
Chris Lattner2f8cb572003-01-20 18:05:27 +0000798my @PrevDays = map {s/.html//; $_} GetDir ".html";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000799
Brian Gaeke253231e2004-06-11 19:55:30 +0000800if ((scalar @PrevDays) > 20) {
801 splice @PrevDays, 20; # Trim down list to something reasonable...
802}
Chris Lattner4c7e3032003-01-20 06:11:03 +0000803
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000804# Format list for sidebar
805my $PrevDaysList = join "\n ", map { "<a href=\"$_.html\">$_</a><br>" } @PrevDays;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000806
Chris Lattnerc75b14e2003-08-18 20:07:54 +0000807#
Brian Gaeke90c82b92004-09-28 16:04:00 +0000808# Start outputting files into the web directory
Chris Lattnerc75b14e2003-08-18 20:07:54 +0000809#
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000810ChangeDir( $WebDir, "Web Directory" );
Chris Lattnerc75b14e2003-08-18 20:07:54 +0000811
Brian Gaeke90c82b92004-09-28 16:04:00 +0000812# Make sure we don't get errors running the nightly tester the first time
813# because of files that don't exist.
814Touch ('running_build_time.txt', 'running_Olden_llc_time.txt',
Chris Lattnere50caac2005-10-28 16:35:18 +0000815 'running_loc.txt',
Brian Gaeke90c82b92004-09-28 16:04:00 +0000816 'running_Olden_bytecode.txt', 'running_Olden_nat_time.txt',
817 'running_Olden_cbe_time.txt', 'running_Olden_opt_time.txt',
818 'running_Olden_jit_time.txt');
819
Chris Lattnerc75b14e2003-08-18 20:07:54 +0000820# Add information to the files which accumulate information for graphs...
821AddRecord($LOC, "running_loc.txt");
822AddRecord($BuildTime, "running_build_time.txt");
823
Chris Lattner4d00fde2004-05-28 20:30:23 +0000824if ( $VERBOSE ) {
825 print "GRAPH GENERATION STAGE\n";
826}
Chris Lattnerc75b14e2003-08-18 20:07:54 +0000827#
828# Rebuild the graphs now...
829#
Chris Lattnerfe2597a2004-07-27 18:41:49 +0000830$GNUPLOT = "/usr/bin/gnuplot";
Brian Gaekeb3dab902003-10-11 05:34:00 +0000831$GNUPLOT = "gnuplot" if ! -x $GNUPLOT;
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000832system ("$GNUPLOT", $PlotScriptFilename);
Chris Lattnerb3440302003-01-22 16:14:05 +0000833
Chris Lattner4c7e3032003-01-20 06:11:03 +0000834#
835# Remove the cvs tree...
836#
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000837system ( "$NICE rm -rf $BuildDir") if (!$NOCHECKOUT and !$NOREMOVE);
Chris Lattner4c7e3032003-01-20 06:11:03 +0000838
Chris Lattner5e5d2202005-03-16 17:09:53 +0000839print "\nUSERS WHO COMMITTED:\n " . (join "\n ", sort keys %UsersCommitted) . "\n"
840 if (scalar %UsersCommitted);
841
842print "\nADDED FILES:\n " . (join "\n ", sort keys %AddedFiles) . "\n"
843 if (scalar %AddedFiles);
844
845print "\nCHANGED FILES:\n " . (join "\n ", sort keys %ModifiedFiles) . "\n"
846 if (scalar %ModifiedFiles);
847
848print "\nREMOVED FILES:\n " . (join "\n ", sort keys %RemovedFiles) . "\n"
849 if (scalar %RemovedFiles);
850
Chris Lattnerb3440302003-01-22 16:14:05 +0000851#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000852# Print out information...
Chris Lattnerb3440302003-01-22 16:14:05 +0000853#
Chris Lattner4d00fde2004-05-28 20:30:23 +0000854if ($VERBOSE) {
Chris Lattner4c7e3032003-01-20 06:11:03 +0000855 print "DateString: $DateString\n";
856 print "CVS Checkout: $CVSCheckoutTime seconds\n";
857 print "Files/Dirs/LOC in CVS: $NumFilesInCVS/$NumDirsInCVS/$LOC\n";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000858 print "Build Time: $BuildTime seconds\n";
859 print "Libraries/Executables/Objects built: $NumLibraries/$NumExecutables/$NumObjects\n";
860
861 print "WARNINGS:\n $WarningsList\n";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000862 print "Previous Days =\n $PrevDaysList\n";
863}
864
Chris Lattnerb3440302003-01-22 16:14:05 +0000865
Chris Lattner2f8cb572003-01-20 18:05:27 +0000866#
867# Output the files...
868#
869
Chris Lattner4d00fde2004-05-28 20:30:23 +0000870if ( $VERBOSE ) {
871 print "OUTPUT STAGE\n";
872}
Chris Lattner2f8cb572003-01-20 18:05:27 +0000873# Main HTML file...
Chris Lattner4c7e3032003-01-20 06:11:03 +0000874my $Output;
Chris Lattner004e19e2005-02-13 16:08:30 +0000875my $TestFinishTime = gmtime() . " GMT<br>" . localtime() . " (local)";
876
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000877my $TestPlatform = `uname -a`;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000878eval "\$Output = <<ENDOFFILE;$TemplateContents\nENDOFFILE\n";
Chris Lattner2f8cb572003-01-20 18:05:27 +0000879WriteFile "$DATE.html", $Output;
Chris Lattnerd9aadd42006-01-31 16:10:53 +0000880
881# Remove the symlink before creating it for systems that don't have "ln -sf".
882system ("rm index.html");
883system ("ln -s $DATE.html index.html");
Chris Lattner4c7e3032003-01-20 06:11:03 +0000884
885# Change the index.html symlink...
Chris Lattner4c7e3032003-01-20 06:11:03 +0000886
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000887# vim: sw=2 ai