blob: 846071934608c019a219e39327bd0338ddada603 [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.
Evan Cheng19fd7ef2006-06-07 05:28:07 +000046# -extraflags Next argument specifies extra options that are passed to
47# compile the tests.
Chris Lattnerbb0aca52003-12-19 03:47:31 +000048#
Chris Lattnerb0ddb492005-11-01 17:59:42 +000049# ---------------- Options to configure llvm-test ----------------------------
50# -spec2000path Path to the benchspec directory in the SPEC 2000 distro
51# -spec95path Path to the benchspec directory in the SPEC 95 distro.
52# -povraypath Path to the povray sources
53# -namdpath Path to the namd sources
54#
Brian Gaekeb3dab902003-10-11 05:34:00 +000055# CVSROOT is the CVS repository from which the tree will be checked out,
56# specified either in the full :method:user@host:/dir syntax, or
57# just /dir if using a local repo.
58# BUILDDIR is the directory where sources for this test run will be checked out
59# AND objects for this test run will be built. This directory MUST NOT
60# exist before the script is run; it will be created by the cvs checkout
61# process and erased (unless -noremove is specified; see above.)
62# WEBDIR is the directory into which the test results web page will be written,
63# AND in which the "index.html" is assumed to be a symlink to the most recent
Brian Gaeke90c82b92004-09-28 16:04:00 +000064# copy of the results. This directory will be created if it does not exist.
Reid Spencer932b69f2004-12-26 05:21:13 +000065# LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
66# to. This is the same as you would have for a normal LLVM build.
Chris Lattner4c7e3032003-01-20 06:11:03 +000067#
68use POSIX qw(strftime);
Tanya Lattner5debe8c2004-11-21 00:02:40 +000069use File::Copy;
Chris Lattner4c7e3032003-01-20 06:11:03 +000070
Brian Gaekeb3dab902003-10-11 05:34:00 +000071my $HOME = $ENV{'HOME'};
72my $CVSRootDir = $ENV{'CVSROOT'};
Chris Lattner9d13efa2003-10-14 01:22:08 +000073 $CVSRootDir = "/home/vadve/shared/PublicCVS"
Chris Lattner4d00fde2004-05-28 20:30:23 +000074 unless $CVSRootDir;
75my $BuildDir = $ENV{'BUILDDIR'};
76 $BuildDir = "$HOME/buildtest"
77 unless $BuildDir;
78my $WebDir = $ENV{'WEBDIR'};
79 $WebDir = "$HOME/cvs/testresults-X86"
80 unless $WebDir;
Chris Lattner2f8cb572003-01-20 18:05:27 +000081
82# Calculate the date prefix...
83@TIME = localtime;
84my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
85my $DateString = strftime "%B %d, %Y", localtime;
Chris Lattner004e19e2005-02-13 16:08:30 +000086my $TestStartTime = gmtime() . "GMT<br>" . localtime() . " (local)";
Reid Spencercb6a3aa2004-06-22 15:38:37 +000087
88# Command line argument settings...
89my $NOCHECKOUT = 0;
Misha Brukman2e9ac692004-11-08 03:28:27 +000090my $NOREMOVE = 0;
Misha Brukman2e9ac692004-11-08 03:28:27 +000091my $NOTEST = 0;
Reid Spencercb6a3aa2004-06-22 15:38:37 +000092my $NORUNNINGTESTS = 0;
Reid Spencer1d914632004-06-23 07:45:46 +000093my $NOEXTERNALS = 0;
Misha Brukman2e9ac692004-11-08 03:28:27 +000094my $MAKEOPTS = "";
Reid Spencercb6a3aa2004-06-22 15:38:37 +000095my $PROGTESTOPTS = "";
Misha Brukman2e9ac692004-11-08 03:28:27 +000096my $VERBOSE = 0;
Reid Spencercb6a3aa2004-06-22 15:38:37 +000097my $DEBUG = 0;
Brian Gaeke047e6062004-08-05 19:54:59 +000098my $CONFIGUREARGS = "";
Misha Brukmanf5f37f02005-05-26 16:28:55 +000099my $CVSCOOPT = "-APR";
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000100my $NICE = "";
Tanya Lattner056ec062004-12-04 06:25:50 +0000101my $NODEJAGNU = 0;
Chris Lattner2f8cb572003-01-20 18:05:27 +0000102
Chris Lattnerb0ddb492005-11-01 17:59:42 +0000103my $LLVMTESTCONFIGARGS = "";
104
Chris Lattnerb3440302003-01-22 16:14:05 +0000105sub ReadFile {
106 if (open (FILE, $_[0])) {
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000107 undef $/;
Chris Lattnerb3440302003-01-22 16:14:05 +0000108 my $Ret = <FILE>;
109 close FILE;
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000110 $/ = '\n';
Chris Lattnerb3440302003-01-22 16:14:05 +0000111 return $Ret;
112 } else {
113 print "Could not open file '$_[0]' for reading!";
114 return "";
115 }
116}
117
Chris Lattner2f8cb572003-01-20 18:05:27 +0000118sub WriteFile { # (filename, contents)
119 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!";
120 print FILE $_[1];
121 close FILE;
122}
123
124sub GetRegex { # (Regex with ()'s, value)
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000125 $_[1] =~ /$_[0]/m;
Chris Lattner08e24762003-08-19 18:35:03 +0000126 if (defined($1)) {
127 return $1;
128 }
Reid Spencera337f0c2004-06-23 06:36:34 +0000129 return "0";
Chris Lattner2f8cb572003-01-20 18:05:27 +0000130}
131
Brian Gaeke90c82b92004-09-28 16:04:00 +0000132sub Touch {
133 my @files = @_;
134 my $now = time;
135 foreach my $file (@files) {
136 if (! -f $file) {
137 open (FILE, ">$file") or warn "Could not create new file $file";
138 close FILE;
139 }
140 utime $now, $now, $file;
141 }
142}
143
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000144sub AddRecord {
145 my ($Val, $Filename) = @_;
146 my @Records;
147 if (open FILE, "$WebDir/$Filename") {
148 @Records = grep !/$DATE/, split "\n", <FILE>;
149 close FILE;
150 }
151 push @Records, "$DATE: $Val";
152 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000153}
154
Chris Lattner2f8cb572003-01-20 18:05:27 +0000155sub AddPreTag { # Add pre tags around nonempty list, or convert to "none"
156 $_ = shift;
Reid Spencer7d6a5152006-03-21 01:21:39 +0000157 if (length) { return "<pre>$_</pre>"; } else { "<b>none</b><br>"; }
158}
159
160sub ArrayToList { # Add <li> tags around nonempty list or convert to "none"
161 my $result = "";
162 if (scalar @_) {
163 $result = "<ul>";
164 foreach $item (@_) {
165 $result .= "<li><tt>$item</tt></li>";
166 }
167 $result .= "</ul>";
168 } else {
169 $result = "<p><b>none</b></p>";
170 }
171 return $result;
Chris Lattner2f8cb572003-01-20 18:05:27 +0000172}
173
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000174sub ChangeDir { # directory, logical name
175 my ($dir,$name) = @_;
176 chomp($dir);
177 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
178 chdir($dir) || die "Cannot change directory to: $name ($dir) ";
179}
180
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000181sub CopyFile { #filename, newfile
182 my ($file, $newfile) = @_;
183 chomp($file);
184 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
185 copy($file, $newfile);
186}
187
Chris Lattner2f8cb572003-01-20 18:05:27 +0000188sub GetDir {
189 my $Suffix = shift;
190 opendir DH, $WebDir;
191 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
192 closedir DH;
193 return @Result;
194}
195
196# DiffFiles - Diff the current version of the file against the last version of
197# the file, reporting things added and removed. This is used to report, for
198# example, added and removed warnings. This returns a pair (added, removed)
199#
200sub DiffFiles {
201 my $Suffix = shift;
202 my @Others = GetDir $Suffix;
203 if (@Others == 0) { # No other files? We added all entries...
204 return (`cat $WebDir/$DATE$Suffix`, "");
205 }
206 # Diff the files now...
207 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
208 my $Added = join "\n", grep /^</, @Diffs;
209 my $Removed = join "\n", grep /^>/, @Diffs;
Chris Lattner1cbc0a62003-01-20 19:18:44 +0000210 $Added =~ s/^< //gm;
211 $Removed =~ s/^> //gm;
Chris Lattner2f8cb572003-01-20 18:05:27 +0000212 return ($Added, $Removed);
213}
214
Chris Lattner196a14a2003-08-19 15:08:34 +0000215# FormatTime - Convert a time from 1m23.45 into 83.45
216sub FormatTime {
217 my $Time = shift;
218 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
219 $Time = sprintf("%7.4f", $1*60.0+$2);
220 }
221 return $Time;
222}
223
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000224sub GetRegexNum {
225 my ($Regex, $Num, $Regex2, $File) = @_;
226 my @Items = split "\n", `grep '$Regex' $File`;
227 return GetRegex $Regex2, $Items[$Num];
228}
229
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000230sub GetDejagnuTestResults { # (filename, log)
231 my ($filename, $DejagnuLog) = @_;
232 my @lines;
233 my $firstline;
234 $/ = "\n"; #Make sure we're going line at a time.
Chris Lattner453d0622005-03-10 16:26:50 +0000235
Chris Lattner8f457312005-03-17 16:07:45 +0000236 print "DEJAGNU TEST RESULTS:\n";
Chris Lattner453d0622005-03-10 16:26:50 +0000237
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000238 if (open SRCHFILE, $filename) {
239 # Process test results
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000240 my $first_list = 1;
241 my $should_break = 1;
242 my $nocopy = 0;
243 my $readingsum = 0;
244 while ( <SRCHFILE> ) {
245 if ( length($_) > 1 ) {
246 chomp($_);
247 if ( m/^XPASS:/ || m/^FAIL:/ ) {
248 $nocopy = 0;
249 if ( $first_list ) {
Misha Brukmand3a54122005-03-10 16:32:33 +0000250 push(@lines, "<h3>UNEXPECTED TEST RESULTS</h3><ol><li>\n");
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000251 $first_list = 0;
252 $should_break = 1;
Misha Brukmand3a54122005-03-10 16:32:33 +0000253 push(@lines, "<b>$_</b><br/>\n");
Chris Lattner453d0622005-03-10 16:26:50 +0000254 print " $_\n";
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000255 } else {
Misha Brukmand3a54122005-03-10 16:32:33 +0000256 push(@lines, "</li><li><b>$_</b><br/>\n");
Chris Lattner453d0622005-03-10 16:26:50 +0000257 print " $_\n";
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000258 }
259 } elsif ( m/Summary/ ) {
Chris Lattner453d0622005-03-10 16:26:50 +0000260 if ( $first_list ) {
Misha Brukmand3a54122005-03-10 16:32:33 +0000261 push(@lines, "<b>PERFECT!</b>");
262 print " PERFECT!\n";
263 } else {
264 push(@lines, "</li></ol>\n");
265 }
266 push(@lines, "<h3>STATISTICS</h3><pre>\n");
Chris Lattner8f457312005-03-17 16:07:45 +0000267 print "\nDEJAGNU STATISTICS:\n";
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000268 $should_break = 0;
269 $nocopy = 0;
270 $readingsum = 1;
271 } elsif ( $readingsum ) {
272 push(@lines,"$_\n");
Chris Lattner8f457312005-03-17 16:07:45 +0000273 print " $_\n";
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000274 }
275 }
276 }
277 }
278 push(@lines, "</pre>\n");
279 close SRCHFILE;
280
Misha Brukmand3a54122005-03-10 16:32:33 +0000281 my $content = join("", @lines);
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000282 return "$content</li></ol>\n";
283}
284
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000285
286#####################################################################
287## MAIN PROGRAM
288#####################################################################
289
290my $Template = "";
291my $PlotScriptFilename = "";
292
293# Parse arguments...
294while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
295 shift;
296 last if /^--$/; # Stop processing arguments on --
297
298 # List command line options here...
299 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
Misha Brukman2e9ac692004-11-08 03:28:27 +0000300 if (/^-noremove$/) { $NOREMOVE = 1; next; }
Misha Brukman2e9ac692004-11-08 03:28:27 +0000301 if (/^-notest$/) { $NOTEST = 1; $NORUNNINGTESTS = 1; next; }
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000302 if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
Misha Brukman2e9ac692004-11-08 03:28:27 +0000303 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j2 -l3.0"; next; }
304 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1"; next; }
Chris Lattnerc82a6c82005-01-08 21:03:58 +0000305 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
Brian Gaeke047e6062004-08-05 19:54:59 +0000306 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
307 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
308 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
309 $CONFIGUREARGS .= " --disable-jit"; next; }
Misha Brukman2e9ac692004-11-08 03:28:27 +0000310 if (/^-verbose$/) { $VERBOSE = 1; next; }
311 if (/^-debug$/) { $DEBUG = 1; next; }
312 if (/^-nice$/) { $NICE = "nice "; next; }
313 if (/^-f2c$/) {
314 $CONFIGUREARGS .= " --with-f2c=$ARGV[0]"; shift; next;
315 }
Reid Spencer43fdfdc2006-04-14 13:53:56 +0000316 if (/^-with-externals/) {
Evan Cheng19fd7ef2006-06-07 05:28:07 +0000317 $CONFIGUREARGS .= " --with-externals=$ARGV[0]"; shift; next
Reid Spencer43fdfdc2006-04-14 13:53:56 +0000318 }
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000319 if (/^-gnuplotscript$/) { $PlotScriptFilename = $ARGV[0]; shift; next; }
Reid Spencerc5b67052004-06-23 14:07:12 +0000320 if (/^-templatefile$/) { $Template = $ARGV[0]; shift; next; }
Misha Brukman2e9ac692004-11-08 03:28:27 +0000321 if (/^-gccpath/) {
322 $CONFIGUREARGS .= " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++"; shift; next;
323 }
Misha Brukmanf5f37f02005-05-26 16:28:55 +0000324 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
Misha Brukman4391bb52005-06-06 19:17:05 +0000325 if (/^-target/) {
326 $CONFIGUREARGS .= " --target=$ARGV[0]"; shift; next;
327 }
Evan Cheng34688642006-02-08 09:08:06 +0000328 if (/^-cflags/) {
329 $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'"; shift; next;
330 }
331 if (/^-cxxflags/) {
332 $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'"; shift; next;
333 }
334 if (/^-ldflags/) {
335 $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'"; shift; next;
336 }
Evan Cheng19fd7ef2006-06-07 05:28:07 +0000337 if (/^-extraflags/) {
338 $PROGTESTOPTS .= " EXTRA_FLAGS=\'$ARGV[0]\'"; shift; next;
339 }
Reid Spencer1d914632004-06-23 07:45:46 +0000340 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
Misha Brukman4391bb52005-06-06 19:17:05 +0000341 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
Chris Lattnerb0ddb492005-11-01 17:59:42 +0000342 if (/^-spec2000path$/) {
343 $LLVMTESTCONFIGARGS .= " --enable-spec2000=$ARGV[0]"; shift; next;
344 }
345 if (/^-spec95path$/) {
346 $LLVMTESTCONFIGARGS .= " --enable-spec95=$ARGV[0]"; shift; next;
347 }
348 if (/^-povraypath$/) {
349 $LLVMTESTCONFIGARGS .= " --enable-povray=$ARGV[0]"; shift; next;
350 }
351 if (/^-namdpath$/) {
352 $LLVMTESTCONFIGARGS .= " --enable-namd=$ARGV[0]"; shift; next;
353 }
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000354 print "Unknown option: $_ : ignoring!\n";
355}
356
Reid Spencer932b69f2004-12-26 05:21:13 +0000357if ($ENV{'LLVMGCCDIR'}) {
358 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
359}
Brian Gaeke047e6062004-08-05 19:54:59 +0000360if ($CONFIGUREARGS !~ /--disable-jit/) {
361 $CONFIGUREARGS .= " --enable-jit";
362}
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000363
364die "Must specify 0 or 3 options!" if (@ARGV != 0 and @ARGV != 3);
365
366if (@ARGV == 3) {
367 $CVSRootDir = $ARGV[0];
368 $BuildDir = $ARGV[1];
369 $WebDir = $ARGV[2];
370}
371
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000372my $Prefix = "$WebDir/$DATE";
373
374#define the file names we'll use
375my $BuildLog = "$Prefix-Build-Log.txt";
376my $CVSLog = "$Prefix-CVS-Log.txt";
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000377my $OldenTestsLog = "$Prefix-Olden-tests.txt";
378my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
379my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
380my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000381my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
382my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
383my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000384
385if ($VERBOSE) {
386 print "INITIALIZED\n";
387 print "CVS Root = $CVSRootDir\n";
388 print "BuildDir = $BuildDir\n";
389 print "WebDir = $WebDir\n";
390 print "Prefix = $Prefix\n";
391 print "CVSLog = $CVSLog\n";
392 print "BuildLog = $BuildLog\n";
393}
394
Brian Gaeke90c82b92004-09-28 16:04:00 +0000395if (! -d $WebDir) {
396 mkdir $WebDir, 0777;
397 warn "Warning: $WebDir did not exist; creating it.\n";
398}
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000399
400#
401# Create the CVS repository directory
402#
403if (!$NOCHECKOUT) {
404 if (-d $BuildDir) {
405 if (!$NOREMOVE) {
406 system "rm -rf $BuildDir";
407 } else {
408 die "CVS checkout directory $BuildDir already exists!";
409 }
410 }
411 mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
412}
413
414ChangeDir( $BuildDir, "CVS checkout directory" );
415
416
417#
418# Check out the llvm tree, saving CVS messages to the cvs log...
419#
Misha Brukmanf5f37f02005-05-26 16:28:55 +0000420my $CVSOPT = "";
421# Use compression if going over ssh.
422$CVSOPT = "-z3" if $CVSRootDir =~ /^:ext:/;
423my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co $CVSCOOPT";
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000424if (!$NOCHECKOUT) {
425 if ( $VERBOSE ) { print "CHECKOUT STAGE\n"; }
Misha Brukmanf5f37f02005-05-26 16:28:55 +0000426 system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
427 "$CVSCMD llvm-test ) > $CVSLog 2>&1";
Reid Spencer10ffe012004-09-05 07:58:10 +0000428 ChangeDir( $BuildDir , "CVS Checkout directory") ;
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000429}
430
431ChangeDir( "llvm" , "llvm source directory") ;
432
433if (!$NOCHECKOUT) {
434 if ( $VERBOSE ) { print "UPDATE STAGE\n"; }
Reid Spencer10ffe012004-09-05 07:58:10 +0000435 system "$NICE cvs update -PdRA >> $CVSLog 2>&1" ;
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000436}
437
Reid Spencerc5b67052004-06-23 14:07:12 +0000438if ( $Template eq "" ) {
439 $Template = "$BuildDir/llvm/utils/NightlyTestTemplate.html";
440}
441die "Template file $Template is not readable" if ( ! -r "$Template" );
442
443if ( $PlotScriptFilename eq "" ) {
444 $PlotScriptFilename = "$BuildDir/llvm/utils/NightlyTest.gnuplot";
445}
446die "GNUPlot Script $PlotScriptFilename is not readable" if ( ! -r "$PlotScriptFilename" );
447
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000448# Read in the HTML template file...
449if ( $VERBOSE ) { print "READING TEMPLATE\n"; }
450my $TemplateContents = ReadFile $Template;
451
452#
453# Get some static statistics about the current state of CVS
454#
455my $CVSCheckoutTime = GetRegex "([0-9.]+)", `grep '^real' $CVSLog`;
456my $NumFilesInCVS = `egrep '^U' $CVSLog | wc -l` + 0;
457my $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $CVSLog | wc -l` + 0;
Reid Spencere993f462004-09-06 19:32:55 +0000458$LOC = `utils/countloc.sh`;
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000459
460#
461# Build the entire tree, saving build messages to the build log
462#
463if (!$NOCHECKOUT) {
464 if ( $VERBOSE ) { print "CONFIGURE STAGE\n"; }
Chris Lattnerb0ddb492005-11-01 17:59:42 +0000465 my $EXTRAFLAGS = "--enable-spec --with-objroot=.$LLVMTESTCONFIGARGS";
Chris Lattnere50caac2005-10-28 16:35:18 +0000466 system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) > $BuildLog 2>&1";
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000467
468 if ( $VERBOSE ) { print "BUILD STAGE\n"; }
469 # Build the entire tree, capturing the output into $BuildLog
470 system "(time -p $NICE gmake $MAKEOPTS) >> $BuildLog 2>&1";
471}
472
473
474#
475# Get some statistics about the build...
476#
477my @Linked = split '\n', `grep Linking $BuildLog`;
478my $NumExecutables = scalar(grep(/executable/, @Linked));
479my $NumLibraries = scalar(grep(!/executable/, @Linked));
Chris Lattner0bb48282005-03-11 20:17:04 +0000480my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000481
482my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
483my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
484my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
485my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
486
487my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
488my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
489my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
490my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
491
Misha Brukman9a612752005-01-12 03:31:38 +0000492my $BuildError = 0, $BuildStatus = "OK";
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000493if (`grep '^gmake[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
494 `grep '^gmake: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
Misha Brukman9a612752005-01-12 03:31:38 +0000495 $BuildStatus = "<h3><font color='red'>error: compilation " .
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000496 "<a href=\"$DATE-Build-Log.txt\">aborted</a></font></h3>";
Misha Brukman9a612752005-01-12 03:31:38 +0000497 $BuildError = 1;
Chris Lattner08313102005-12-11 19:55:39 +0000498 print "\n***ERROR BUILDING TREE\n\n";
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000499}
500
Tanya Lattner056ec062004-12-04 06:25:50 +0000501if ($BuildError) { $NODEJAGNU=1; }
Brian Gaeke22800982004-06-25 07:25:28 +0000502
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000503my $DejangnuTestResults; # String containing the results of the dejagnu
Tanya Lattner59a86552004-12-04 06:35:14 +0000504if(!$NODEJAGNU) {
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000505 if($VERBOSE) { print "DEJAGNU FEATURE/REGRESSION TEST STAGE\n"; }
506
507 my $dejagnu_output = "$DejagnuTestsLog";
508
509 #Run the feature and regression tests, results are put into testrun.sum
510 #Full log in testrun.log
Tanya Lattner056ec062004-12-04 06:25:50 +0000511 system "(time -p gmake $MAKEOPTS check) > $dejagnu_output 2>&1";
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000512
513 #Extract time of dejagnu tests
514 my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
515 my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
516 $DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
517 $DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
518
519 #Copy the testrun.log and testrun.sum to our webdir
520 CopyFile("test/testrun.log", $DejagnuLog);
521 CopyFile("test/testrun.sum", $DejagnuSum);
522
523 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
Tanya Lattnera2dfbf92004-12-17 20:58:34 +0000524
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000525} else {
526 $DejagnuTestResults = "Skipped by user choice.";
527 $DejagnuTime = "0.0";
528 $DejagnuWallTime = "0.0";
529}
530
Chris Lattner4d00fde2004-05-28 20:30:23 +0000531if ($DEBUG) {
Tanya Lattner5debe8c2004-11-21 00:02:40 +0000532 print $DejagnuTestResults;
Chris Lattner4d00fde2004-05-28 20:30:23 +0000533}
534
535if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
Chris Lattnerb3440302003-01-22 16:14:05 +0000536#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000537# Get warnings from the build
Chris Lattnerb3440302003-01-22 16:14:05 +0000538#
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000539my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000540my @Warnings;
541my $CurDir = "";
542
543foreach $Warning (@Warn) {
544 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
545 $CurDir = $1; # Keep track of directory warning is in...
Misha Brukman8e9554a2003-08-14 15:26:28 +0000546 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { # Remove buildir prefix if included
Chris Lattner4c7e3032003-01-20 06:11:03 +0000547 $CurDir = $1;
548 }
549 } else {
550 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
551 }
552}
Chris Lattner1cbc0a62003-01-20 19:18:44 +0000553my $WarningsFile = join "\n", @Warnings;
Reid Spencer7d6a5152006-03-21 01:21:39 +0000554my $WarningsList = ArrayToList @Warnings;
Chris Lattner1cbc0a62003-01-20 19:18:44 +0000555$WarningsFile =~ s/:[0-9]+:/::/g;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000556
Chris Lattner2f8cb572003-01-20 18:05:27 +0000557# Emit the warnings file, so we can diff...
558WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
559my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000560
Chris Lattner9efd7f42003-10-18 19:31:39 +0000561# Output something to stdout if something has changed
562print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
563print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
564
Reid Spencer7d6a5152006-03-21 01:21:39 +0000565my @TmpWarningsAdded = split "\n", $WarningsAdded;
566my @TmpWarningsRemoved = split "\n", $WarningsRemoved;
567$WarningsAdded = ArrayToList @TmpWarningsAdded;
568$WarningsRemoved = ArrayToList @TmpWarningsRemoved;
Chris Lattnerb3440302003-01-22 16:14:05 +0000569
570#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000571# Get some statistics about CVS commits over the current day...
Chris Lattnerb3440302003-01-22 16:14:05 +0000572#
Chris Lattner4d00fde2004-05-28 20:30:23 +0000573if ($VERBOSE) { print "CVS HISTORY ANALYSIS STAGE\n"; }
Chris Lattner4c7e3032003-01-20 06:11:03 +0000574@CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
575#print join "\n", @CVSHistory; print "\n";
576
577# Extract some information from the CVS history... use a hash so no duplicate
578# stuff is stored.
Misha Brukman1b366892003-07-07 21:27:40 +0000579my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
Chris Lattner4c7e3032003-01-20 06:11:03 +0000580
Brian Gaeke43f38672004-06-10 07:44:28 +0000581my $DateRE = '[-/:0-9 ]+\+[0-9]+';
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000582
Chris Lattner4c7e3032003-01-20 06:11:03 +0000583# Loop over every record from the CVS history, filling in the hashes.
584foreach $File (@CVSHistory) {
585 my ($Type, $Date, $UID, $Rev, $Filename);
Misha Brukman8e9554a2003-08-14 15:26:28 +0000586 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
Chris Lattner4c7e3032003-01-20 06:11:03 +0000587 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
Chris Lattnerd56147d2004-01-12 16:55:30 +0000588 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
589 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
Misha Brukman1b366892003-07-07 21:27:40 +0000590 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000591 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
Chris Lattner4c7e3032003-01-20 06:11:03 +0000592 } else {
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000593 print "UNMATCHABLE: $File\n";
Brian Gaeke43f38672004-06-10 07:44:28 +0000594 next;
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000595 }
596 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
597
598 if ($Filename =~ /^llvm/) {
599 if ($Type eq 'M') { # Modified
600 $ModifiedFiles{$Filename} = 1;
601 $UsersCommitted{$UID} = 1;
602 } elsif ($Type eq 'A') { # Added
603 $AddedFiles{$Filename} = 1;
604 $UsersCommitted{$UID} = 1;
605 } elsif ($Type eq 'R') { # Removed
606 $RemovedFiles{$Filename} = 1;
607 $UsersCommitted{$UID} = 1;
608 } else {
609 $UsersUpdated{$UID} = 1;
610 }
Chris Lattner4c7e3032003-01-20 06:11:03 +0000611 }
612}
613
Chris Lattner5e5d2202005-03-16 17:09:53 +0000614my $UserCommitList = join "\n", sort keys %UsersCommitted;
615my $UserUpdateList = join "\n", sort keys %UsersUpdated;
Chris Lattnerc9cdadf2003-08-06 16:02:50 +0000616my $AddedFilesList = AddPreTag join "\n", sort keys %AddedFiles;
617my $ModifiedFilesList = AddPreTag join "\n", sort keys %ModifiedFiles;
618my $RemovedFilesList = AddPreTag join "\n", sort keys %RemovedFiles;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000619
Chris Lattnerec0e3742003-02-28 20:30:20 +0000620my $TestError = 1;
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000621my $SingleSourceProgramsTable = "!";
622my $MultiSourceProgramsTable = "!";
623my $ExternalProgramsTable = "!";
Chris Lattnerb3440302003-01-22 16:14:05 +0000624
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000625
626sub TestDirectory {
627 my $SubDir = shift;
628
Reid Spencer10ffe012004-09-05 07:58:10 +0000629 ChangeDir( "projects/llvm-test/$SubDir", "Programs Test Subdirectory" );
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000630
631 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
Chris Lattnerec0e3742003-02-28 20:30:20 +0000632
633 # Run the programs tests... creating a report.nightly.html file
634 if (!$NOTEST) {
Chris Lattner20d13ea2004-06-03 03:29:39 +0000635 system "gmake -k $MAKEOPTS $PROGTESTOPTS report.nightly.html "
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000636 . "TEST=nightly > $ProgramTestLog 2>&1";
Chris Lattnerec0e3742003-02-28 20:30:20 +0000637 } else {
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000638 system "gunzip ${ProgramTestLog}.gz";
Chris Lattnerec0e3742003-02-28 20:30:20 +0000639 }
640
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000641 my $ProgramsTable;
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000642 if (`grep '^gmake[^:]: .*Error' $ProgramTestLog | wc -l` + 0){
Chris Lattnerec0e3742003-02-28 20:30:20 +0000643 $TestError = 1;
Chris Lattner2e8be142003-05-10 21:40:10 +0000644 $ProgramsTable = "<font color=white><h2>Error running tests!</h2></font>";
Chris Lattnerbe197872003-10-19 16:54:00 +0000645 print "ERROR TESTING\n";
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000646 } elsif (`grep '^gmake[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
Chris Lattner6e51bfa2003-05-11 15:23:10 +0000647 $TestError = 1;
648 $ProgramsTable =
649 "<font color=white><h2>Makefile error running tests!</h2></font>";
Chris Lattnerbe197872003-10-19 16:54:00 +0000650 print "ERROR TESTING\n";
Chris Lattner6e51bfa2003-05-11 15:23:10 +0000651 } else {
Chris Lattnerec0e3742003-02-28 20:30:20 +0000652 $TestError = 0;
653 $ProgramsTable = ReadFile "report.nightly.html";
654
655 #
656 # Create a list of the tests which were run...
657 #
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000658 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog "
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000659 . "| sort > $Prefix-$SubDir-Tests.txt";
Chris Lattnerec0e3742003-02-28 20:30:20 +0000660 }
661
662 # Compress the test output
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000663 system "gzip -f $ProgramTestLog";
664 ChangeDir( "../../..", "Programs Test Parent Directory" );
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000665 return $ProgramsTable;
666}
667
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000668# If we built the tree successfully, run the nightly programs tests...
Misha Brukman9a612752005-01-12 03:31:38 +0000669if (!$BuildError) {
Chris Lattner4d00fde2004-05-28 20:30:23 +0000670 if ( $VERBOSE ) {
671 print "SingleSource TEST STAGE\n";
672 }
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000673 $SingleSourceProgramsTable = TestDirectory("SingleSource");
Chris Lattner4d00fde2004-05-28 20:30:23 +0000674 if ( $VERBOSE ) {
675 print "MultiSource TEST STAGE\n";
676 }
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000677 $MultiSourceProgramsTable = TestDirectory("MultiSource");
Reid Spencer1d914632004-06-23 07:45:46 +0000678 if ( ! $NOEXTERNALS ) {
679 if ( $VERBOSE ) {
680 print "External TEST STAGE\n";
681 }
682 $ExternalProgramsTable = TestDirectory("External");
683 system "cat $Prefix-SingleSource-Tests.txt $Prefix-MultiSource-Tests.txt ".
Chris Lattnereac3cdc2003-08-21 15:55:26 +0000684 " $Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
Reid Spencer1d914632004-06-23 07:45:46 +0000685 } else {
Reid Spencerb8e825b2004-12-04 22:18:28 +0000686 $ExternalProgramsTable = '<tr><td>External TEST STAGE SKIPPED</td></tr>';
Reid Spencer1d914632004-06-23 07:45:46 +0000687 if ( $VERBOSE ) {
688 print "External TEST STAGE SKIPPED\n";
689 }
690 system "cat $Prefix-SingleSource-Tests.txt $Prefix-MultiSource-Tests.txt ".
691 " | sort > $Prefix-Tests.txt";
692 }
Chris Lattner5d6c4382003-01-23 19:31:28 +0000693}
Chris Lattnerb3440302003-01-22 16:14:05 +0000694
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000695if ( $VERBOSE ) { print "TEST INFORMATION COLLECTION STAGE\n"; }
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000696my ($TestsAdded, $TestsRemoved, $TestsFixed, $TestsBroken) = ("","","","");
697
Chris Lattnerec0e3742003-02-28 20:30:20 +0000698if ($TestError) {
699 $TestsAdded = "<b>error testing</b><br>";
700 $TestsRemoved = "<b>error testing</b><br>";
701 $TestsFixed = "<b>error testing</b><br>";
702 $TestsBroken = "<b>error testing</b><br>";
703} else {
704 my ($RTestsAdded, $RTestsRemoved) = DiffFiles "-Tests.txt";
705
706 my @RawTestsAddedArray = split '\n', $RTestsAdded;
707 my @RawTestsRemovedArray = split '\n', $RTestsRemoved;
708
709 my %OldTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
710 @RawTestsRemovedArray;
711 my %NewTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
712 @RawTestsAddedArray;
713
714 foreach $Test (keys %NewTests) {
715 if (!exists $OldTests{$Test}) { # TestAdded if in New but not old
716 $TestsAdded = "$TestsAdded$Test\n";
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000717 } else {
Chris Lattnerec0e3742003-02-28 20:30:20 +0000718 if ($OldTests{$Test} =~ /TEST-PASS/) { # Was the old one a pass?
719 $TestsBroken = "$TestsBroken$Test\n"; # New one must be a failure
720 } else {
721 $TestsFixed = "$TestsFixed$Test\n"; # No, new one is a pass.
722 }
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000723 }
724 }
Chris Lattnerec0e3742003-02-28 20:30:20 +0000725 foreach $Test (keys %OldTests) { # TestRemoved if in Old but not New
726 $TestsRemoved = "$TestsRemoved$Test\n" if (!exists $NewTests{$Test});
727 }
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000728
Chris Lattner91480ff2003-10-21 15:47:31 +0000729 print "\nTESTS ADDED: \n\n$TestsAdded\n\n" if (length $TestsAdded);
730 print "\nTESTS REMOVED:\n\n$TestsRemoved\n\n" if (length $TestsRemoved);
731 print "\nTESTS FIXED: \n\n$TestsFixed\n\n" if (length $TestsFixed);
732 print "\nTESTS BROKEN: \n\n$TestsBroken\n\n" if (length $TestsBroken);
Chris Lattnerbe197872003-10-19 16:54:00 +0000733
Chris Lattnerec0e3742003-02-28 20:30:20 +0000734 $TestsAdded = AddPreTag $TestsAdded;
735 $TestsRemoved = AddPreTag $TestsRemoved;
736 $TestsFixed = AddPreTag $TestsFixed;
737 $TestsBroken = AddPreTag $TestsBroken;
738}
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000739
Chris Lattner9efd7f42003-10-18 19:31:39 +0000740
Chris Lattner196a14a2003-08-19 15:08:34 +0000741# If we built the tree successfully, runs of the Olden suite with
742# LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
Misha Brukman9a612752005-01-12 03:31:38 +0000743if (!$BuildError) {
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000744 if ( $VERBOSE ) { print "OLDEN TEST SUITE STAGE\n"; }
Chris Lattner08e24762003-08-19 18:35:03 +0000745 my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
Chris Lattner196a14a2003-08-19 15:08:34 +0000746 $MachCodeSize) = ("","","","","","","");
Chris Lattner08e24762003-08-19 18:35:03 +0000747 if (!$NORUNNINGTESTS) {
Reid Spencer10ffe012004-09-05 07:58:10 +0000748 ChangeDir( "$BuildDir/llvm/projects/llvm-test/MultiSource/Benchmarks/Olden",
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000749 "Olden Test Directory");
Chris Lattner196a14a2003-08-19 15:08:34 +0000750
751 # Clean out previous results...
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000752 system "$NICE gmake $MAKEOPTS clean > /dev/null 2>&1";
Chris Lattner196a14a2003-08-19 15:08:34 +0000753
Chris Lattner36dc5c72004-11-06 21:35:40 +0000754 # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE and
755 # GET_STABLE_NUMBERS enabled!
Brian Gaeke85668542004-06-04 00:07:12 +0000756 system "gmake -k $MAKEOPTS $PROGTESTOPTS report.nightly.raw.out TEST=nightly " .
Chris Lattner36dc5c72004-11-06 21:35:40 +0000757 " LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 > /dev/null 2>&1";
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000758 system "cp report.nightly.raw.out $OldenTestsLog";
Chris Lattner196a14a2003-08-19 15:08:34 +0000759 } else {
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000760 system "gunzip ${OldenTestsLog}.gz";
Chris Lattner196a14a2003-08-19 15:08:34 +0000761 }
762
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000763 # Now we know we have $OldenTestsLog as the raw output file. Split
Chris Lattner196a14a2003-08-19 15:08:34 +0000764 # it up into records and read the useful information.
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000765 my @Records = split />>> ========= /, ReadFile "$OldenTestsLog";
Chris Lattner196a14a2003-08-19 15:08:34 +0000766 shift @Records; # Delete the first (garbage) record
767
768 # Loop over all of the records, summarizing them into rows for the running
769 # totals file.
Chris Lattnerfed8a142004-12-14 22:42:59 +0000770 my $WallTimeRE = "Time: ([0-9.]+) seconds \\([0-9.]+ wall clock";
Chris Lattner196a14a2003-08-19 15:08:34 +0000771 foreach $Rec (@Records) {
Chris Lattner36dc5c72004-11-06 21:35:40 +0000772 my $rNATTime = GetRegex 'TEST-RESULT-nat-time: program\s*([.0-9m]+)', $Rec;
773 my $rCBETime = GetRegex 'TEST-RESULT-cbe-time: program\s*([.0-9m]+)', $Rec;
774 my $rLLCTime = GetRegex 'TEST-RESULT-llc-time: program\s*([.0-9m]+)', $Rec;
775 my $rJITTime = GetRegex 'TEST-RESULT-jit-time: program\s*([.0-9m]+)', $Rec;
Chris Lattnerfed8a142004-12-14 22:42:59 +0000776 my $rOptTime = GetRegex "TEST-RESULT-compile: .*$WallTimeRE", $Rec;
Chris Lattner196a14a2003-08-19 15:08:34 +0000777 my $rBytecodeSize = GetRegex 'TEST-RESULT-compile: *([0-9]+)', $Rec;
Chris Lattner196a14a2003-08-19 15:08:34 +0000778
779 $NATTime .= " " . FormatTime($rNATTime);
780 $CBETime .= " " . FormatTime($rCBETime);
781 $LLCTime .= " " . FormatTime($rLLCTime);
782 $JITTime .= " " . FormatTime($rJITTime);
783 $OptTime .= " $rOptTime";
Chris Lattner08e24762003-08-19 18:35:03 +0000784 $BytecodeSize .= " $rBytecodeSize";
Chris Lattner196a14a2003-08-19 15:08:34 +0000785 }
786
787 # Now that we have all of the numbers we want, add them to the running totals
788 # files.
Chris Lattner08e24762003-08-19 18:35:03 +0000789 AddRecord($NATTime, "running_Olden_nat_time.txt");
Chris Lattner196a14a2003-08-19 15:08:34 +0000790 AddRecord($CBETime, "running_Olden_cbe_time.txt");
791 AddRecord($LLCTime, "running_Olden_llc_time.txt");
792 AddRecord($JITTime, "running_Olden_jit_time.txt");
793 AddRecord($OptTime, "running_Olden_opt_time.txt");
794 AddRecord($BytecodeSize, "running_Olden_bytecode.txt");
Chris Lattner08e24762003-08-19 18:35:03 +0000795
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000796 system "gzip -f $OldenTestsLog";
Chris Lattner196a14a2003-08-19 15:08:34 +0000797}
798
799
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000800#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000801# Get a list of the previous days that we can link to...
Chris Lattnerb3440302003-01-22 16:14:05 +0000802#
Chris Lattner2f8cb572003-01-20 18:05:27 +0000803my @PrevDays = map {s/.html//; $_} GetDir ".html";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000804
Brian Gaeke253231e2004-06-11 19:55:30 +0000805if ((scalar @PrevDays) > 20) {
806 splice @PrevDays, 20; # Trim down list to something reasonable...
807}
Chris Lattner4c7e3032003-01-20 06:11:03 +0000808
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000809# Format list for sidebar
810my $PrevDaysList = join "\n ", map { "<a href=\"$_.html\">$_</a><br>" } @PrevDays;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000811
Chris Lattnerc75b14e2003-08-18 20:07:54 +0000812#
Brian Gaeke90c82b92004-09-28 16:04:00 +0000813# Start outputting files into the web directory
Chris Lattnerc75b14e2003-08-18 20:07:54 +0000814#
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000815ChangeDir( $WebDir, "Web Directory" );
Chris Lattnerc75b14e2003-08-18 20:07:54 +0000816
Brian Gaeke90c82b92004-09-28 16:04:00 +0000817# Make sure we don't get errors running the nightly tester the first time
818# because of files that don't exist.
819Touch ('running_build_time.txt', 'running_Olden_llc_time.txt',
Chris Lattnere50caac2005-10-28 16:35:18 +0000820 'running_loc.txt',
Brian Gaeke90c82b92004-09-28 16:04:00 +0000821 'running_Olden_bytecode.txt', 'running_Olden_nat_time.txt',
822 'running_Olden_cbe_time.txt', 'running_Olden_opt_time.txt',
823 'running_Olden_jit_time.txt');
824
Chris Lattnerc75b14e2003-08-18 20:07:54 +0000825# Add information to the files which accumulate information for graphs...
826AddRecord($LOC, "running_loc.txt");
827AddRecord($BuildTime, "running_build_time.txt");
828
Chris Lattner4d00fde2004-05-28 20:30:23 +0000829if ( $VERBOSE ) {
830 print "GRAPH GENERATION STAGE\n";
831}
Chris Lattnerc75b14e2003-08-18 20:07:54 +0000832#
833# Rebuild the graphs now...
834#
Chris Lattnerfe2597a2004-07-27 18:41:49 +0000835$GNUPLOT = "/usr/bin/gnuplot";
Brian Gaekeb3dab902003-10-11 05:34:00 +0000836$GNUPLOT = "gnuplot" if ! -x $GNUPLOT;
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000837system ("$GNUPLOT", $PlotScriptFilename);
Chris Lattnerb3440302003-01-22 16:14:05 +0000838
Chris Lattner4c7e3032003-01-20 06:11:03 +0000839#
840# Remove the cvs tree...
841#
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000842system ( "$NICE rm -rf $BuildDir") if (!$NOCHECKOUT and !$NOREMOVE);
Chris Lattner4c7e3032003-01-20 06:11:03 +0000843
Chris Lattner5e5d2202005-03-16 17:09:53 +0000844print "\nUSERS WHO COMMITTED:\n " . (join "\n ", sort keys %UsersCommitted) . "\n"
845 if (scalar %UsersCommitted);
846
847print "\nADDED FILES:\n " . (join "\n ", sort keys %AddedFiles) . "\n"
848 if (scalar %AddedFiles);
849
850print "\nCHANGED FILES:\n " . (join "\n ", sort keys %ModifiedFiles) . "\n"
851 if (scalar %ModifiedFiles);
852
853print "\nREMOVED FILES:\n " . (join "\n ", sort keys %RemovedFiles) . "\n"
854 if (scalar %RemovedFiles);
855
Chris Lattnerb3440302003-01-22 16:14:05 +0000856#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000857# Print out information...
Chris Lattnerb3440302003-01-22 16:14:05 +0000858#
Chris Lattner4d00fde2004-05-28 20:30:23 +0000859if ($VERBOSE) {
Chris Lattner4c7e3032003-01-20 06:11:03 +0000860 print "DateString: $DateString\n";
861 print "CVS Checkout: $CVSCheckoutTime seconds\n";
862 print "Files/Dirs/LOC in CVS: $NumFilesInCVS/$NumDirsInCVS/$LOC\n";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000863 print "Build Time: $BuildTime seconds\n";
864 print "Libraries/Executables/Objects built: $NumLibraries/$NumExecutables/$NumObjects\n";
865
866 print "WARNINGS:\n $WarningsList\n";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000867 print "Previous Days =\n $PrevDaysList\n";
868}
869
Chris Lattnerb3440302003-01-22 16:14:05 +0000870
Chris Lattner2f8cb572003-01-20 18:05:27 +0000871#
872# Output the files...
873#
874
Chris Lattner4d00fde2004-05-28 20:30:23 +0000875if ( $VERBOSE ) {
876 print "OUTPUT STAGE\n";
877}
Chris Lattner2f8cb572003-01-20 18:05:27 +0000878# Main HTML file...
Chris Lattner4c7e3032003-01-20 06:11:03 +0000879my $Output;
Chris Lattner004e19e2005-02-13 16:08:30 +0000880my $TestFinishTime = gmtime() . " GMT<br>" . localtime() . " (local)";
881
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000882my $TestPlatform = `uname -a`;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000883eval "\$Output = <<ENDOFFILE;$TemplateContents\nENDOFFILE\n";
Chris Lattner2f8cb572003-01-20 18:05:27 +0000884WriteFile "$DATE.html", $Output;
Chris Lattnerd9aadd42006-01-31 16:10:53 +0000885
886# Remove the symlink before creating it for systems that don't have "ln -sf".
887system ("rm index.html");
888system ("ln -s $DATE.html index.html");
Chris Lattner4c7e3032003-01-20 06:11:03 +0000889
890# Change the index.html symlink...
Chris Lattner4c7e3032003-01-20 06:11:03 +0000891
Reid Spencercb6a3aa2004-06-22 15:38:37 +0000892# vim: sw=2 ai