blob: b1e907f8c7cbab887eafec0991902938bd91f26d [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.
20# -parallel Run two parallel jobs with GNU Make.
Chris Lattnerbb0aca52003-12-19 03:47:31 +000021# -enable-linscan Enable linearscan tests
22#
Brian Gaekeb3dab902003-10-11 05:34:00 +000023# CVSROOT is the CVS repository from which the tree will be checked out,
24# specified either in the full :method:user@host:/dir syntax, or
25# just /dir if using a local repo.
26# BUILDDIR is the directory where sources for this test run will be checked out
27# AND objects for this test run will be built. This directory MUST NOT
28# exist before the script is run; it will be created by the cvs checkout
29# process and erased (unless -noremove is specified; see above.)
30# WEBDIR is the directory into which the test results web page will be written,
31# AND in which the "index.html" is assumed to be a symlink to the most recent
32# copy of the results. This directory MUST exist before the script is run.
Chris Lattner4c7e3032003-01-20 06:11:03 +000033#
34use POSIX qw(strftime);
35
Brian Gaekeb3dab902003-10-11 05:34:00 +000036my $HOME = $ENV{'HOME'};
37my $CVSRootDir = $ENV{'CVSROOT'};
Chris Lattner9d13efa2003-10-14 01:22:08 +000038 $CVSRootDir = "/home/vadve/shared/PublicCVS"
Brian Gaekeb3dab902003-10-11 05:34:00 +000039 unless $CVSRootDir;
Chris Lattner2f8cb572003-01-20 18:05:27 +000040my $BuildDir = "$HOME/buildtest";
41my $WebDir = "$HOME/cvs/testresults-X86";
42
43# Calculate the date prefix...
44@TIME = localtime;
45my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
46my $DateString = strftime "%B %d, %Y", localtime;
47
Chris Lattnerb3440302003-01-22 16:14:05 +000048sub ReadFile {
Chris Lattner196a14a2003-08-19 15:08:34 +000049 undef $/;
Chris Lattnerb3440302003-01-22 16:14:05 +000050 if (open (FILE, $_[0])) {
51 my $Ret = <FILE>;
52 close FILE;
53 return $Ret;
54 } else {
55 print "Could not open file '$_[0]' for reading!";
56 return "";
57 }
58}
59
Chris Lattner2f8cb572003-01-20 18:05:27 +000060sub WriteFile { # (filename, contents)
61 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!";
62 print FILE $_[1];
63 close FILE;
64}
65
66sub GetRegex { # (Regex with ()'s, value)
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +000067 $_[1] =~ /$_[0]/m;
Chris Lattner08e24762003-08-19 18:35:03 +000068 if (defined($1)) {
69 return $1;
70 }
71 return "?";
Chris Lattner2f8cb572003-01-20 18:05:27 +000072}
73
74sub AddPreTag { # Add pre tags around nonempty list, or convert to "none"
75 $_ = shift;
Chris Lattner1cbc0a62003-01-20 19:18:44 +000076 if (length) { return "<ul><pre>$_</pre></ul>"; } else { "<b>none</b><br>"; }
Chris Lattner2f8cb572003-01-20 18:05:27 +000077}
78
79sub GetDir {
80 my $Suffix = shift;
81 opendir DH, $WebDir;
82 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
83 closedir DH;
84 return @Result;
85}
86
87# DiffFiles - Diff the current version of the file against the last version of
88# the file, reporting things added and removed. This is used to report, for
89# example, added and removed warnings. This returns a pair (added, removed)
90#
91sub DiffFiles {
92 my $Suffix = shift;
93 my @Others = GetDir $Suffix;
94 if (@Others == 0) { # No other files? We added all entries...
95 return (`cat $WebDir/$DATE$Suffix`, "");
96 }
97 # Diff the files now...
98 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
99 my $Added = join "\n", grep /^</, @Diffs;
100 my $Removed = join "\n", grep /^>/, @Diffs;
Chris Lattner1cbc0a62003-01-20 19:18:44 +0000101 $Added =~ s/^< //gm;
102 $Removed =~ s/^> //gm;
Chris Lattner2f8cb572003-01-20 18:05:27 +0000103 return ($Added, $Removed);
104}
105
Chris Lattner196a14a2003-08-19 15:08:34 +0000106# FormatTime - Convert a time from 1m23.45 into 83.45
107sub FormatTime {
108 my $Time = shift;
109 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
110 $Time = sprintf("%7.4f", $1*60.0+$2);
111 }
112 return $Time;
113}
114
Chris Lattner2f8cb572003-01-20 18:05:27 +0000115
Chris Lattner4c7e3032003-01-20 06:11:03 +0000116# Command line argument settings...
117my $NOCHECKOUT = 0;
118my $NOREMOVE = 0;
Chris Lattnerb3440302003-01-22 16:14:05 +0000119my $NOTEST = 0;
Chris Lattner08e24762003-08-19 18:35:03 +0000120my $NORUNNINGTESTS = 0;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000121my $MAKEOPTS = "";
Chris Lattnerbb0aca52003-12-19 03:47:31 +0000122my $ENABLELINEARSCAN = "";
Brian Gaekeb3dab902003-10-11 05:34:00 +0000123
Chris Lattner4c7e3032003-01-20 06:11:03 +0000124# Parse arguments...
125while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
126 shift;
127 last if /^--$/; # Stop processing arguments on --
128
129 # List command line options here...
Chris Lattner08e24762003-08-19 18:35:03 +0000130 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
131 if (/^-noremove$/) { $NOREMOVE = 1; next; }
132 if (/^-notest$/) { $NOTEST = 1; $NORUNNINGTESTS = 1; next; }
133 if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
134 if (/^-parallel$/) { $MAKEOPTS = "-j2 -l3.0"; next; }
Chris Lattner370e8092003-12-19 19:48:43 +0000135 if (/^-enable-linscan$/) { $ENABLELINEARSCAN = "ENABLE_LINEARSCAN=1"; next; }
Chris Lattner4c7e3032003-01-20 06:11:03 +0000136
137 print "Unknown option: $_ : ignoring!\n";
138}
139
Chris Lattner2f8cb572003-01-20 18:05:27 +0000140die "Must specify 0 or 3 options!" if (@ARGV != 0 and @ARGV != 3);
Chris Lattner4c7e3032003-01-20 06:11:03 +0000141
Chris Lattner4c7e3032003-01-20 06:11:03 +0000142if (@ARGV == 3) {
143 $CVSRootDir = $ARGV[0];
144 $BuildDir = $ARGV[1];
145 $WebDir = $ARGV[2];
146}
147
Misha Brukman1b366892003-07-07 21:27:40 +0000148my $Template = "$BuildDir/llvm/utils/NightlyTestTemplate.html";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000149my $Prefix = "$WebDir/$DATE";
150
151if (0) {
152 print "CVS Root = $CVSRootDir\n";
153 print "BuildDir = $BuildDir\n";
154 print "WebDir = $WebDir\n";
155 print "Prefix = $Prefix\n";
156}
157
Chris Lattnerb3440302003-01-22 16:14:05 +0000158
159#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000160# Create the CVS repository directory
Chris Lattnerb3440302003-01-22 16:14:05 +0000161#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000162if (!$NOCHECKOUT) {
Misha Brukman1b366892003-07-07 21:27:40 +0000163 mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000164}
Misha Brukman1b366892003-07-07 21:27:40 +0000165chdir $BuildDir or die "Could not change to CVS checkout directory $BuildDir!";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000166
Chris Lattnerb3440302003-01-22 16:14:05 +0000167
168#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000169# Check out the llvm tree, saving CVS messages to the cvs log...
Chris Lattnerb3440302003-01-22 16:14:05 +0000170#
Brian Gaekeb3dab902003-10-11 05:34:00 +0000171$CVSOPT = "";
172$CVSOPT = "-z3" if $CVSRootDir =~ /^:ext:/; # Use compression if going over ssh.
173system "(time -p cvs $CVSOPT -d $CVSRootDir co llvm) > $Prefix-CVS-Log.txt 2>&1"
Chris Lattner4c7e3032003-01-20 06:11:03 +0000174 if (!$NOCHECKOUT);
175
176chdir "llvm" or die "Could not change into llvm directory!";
177
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000178system "cvs up -P -d > /dev/null 2>&1" if (!$NOCHECKOUT);
179
Chris Lattner4c7e3032003-01-20 06:11:03 +0000180# Read in the HTML template file...
Chris Lattnerb3440302003-01-22 16:14:05 +0000181my $TemplateContents = ReadFile $Template;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000182
Chris Lattnerb3440302003-01-22 16:14:05 +0000183
184#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000185# Get some static statistics about the current state of CVS
Chris Lattnerb3440302003-01-22 16:14:05 +0000186#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000187my $CVSCheckoutTime = GetRegex "([0-9.]+)", `grep '^real' $Prefix-CVS-Log.txt`;
Brian Gaekeac5d96b2003-12-01 05:31:12 +0000188my $NumFilesInCVS = `egrep '^U' $Prefix-CVS-Log.txt | wc -l` + 0;
189my $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $Prefix-CVS-Log.txt | wc -l` + 0;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000190$LOC = GetRegex "([0-9]+) +total", `wc -l \`utils/getsrcs.sh\` | grep total`;
191
Chris Lattnerb3440302003-01-22 16:14:05 +0000192#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000193# Build the entire tree, saving build messages to the build log
Chris Lattnerb3440302003-01-22 16:14:05 +0000194#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000195if (!$NOCHECKOUT) {
Misha Brukman8e9554a2003-08-14 15:26:28 +0000196 system "(time -p ./configure --enable-jit --enable-spec --with-objroot=.) > $Prefix-Build-Log.txt 2>&1";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000197
198 # Build the entire tree, capturing the output into $Prefix-Build-Log.txt
Chris Lattner42815c82003-07-01 16:02:00 +0000199 system "(time -p gmake $MAKEOPTS) >> $Prefix-Build-Log.txt 2>&1";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000200}
201
Chris Lattnerb3440302003-01-22 16:14:05 +0000202
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000203sub GetRegexNum {
204 my ($Regex, $Num, $Regex2, $File) = @_;
205 my @Items = split "\n", `grep '$Regex' $File`;
206 return GetRegex $Regex2, $Items[$Num];
207}
208
Chris Lattnerb3440302003-01-22 16:14:05 +0000209#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000210# Get some statistics about the build...
Chris Lattnerb3440302003-01-22 16:14:05 +0000211#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000212my @Linked = split '\n', `grep Linking $Prefix-Build-Log.txt`;
213my $NumExecutables = scalar(grep(/executable/, @Linked));
214my $NumLibraries = scalar(grep(!/executable/, @Linked));
215my $NumObjects = `grep '^Compiling' $Prefix-Build-Log.txt | wc -l` + 0;
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000216
217my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$Prefix-Build-Log.txt";
218my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$Prefix-Build-Log.txt";
Chris Lattner00d7af62003-08-18 14:07:03 +0000219my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000220my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$Prefix-Build-Log.txt";
221
222my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$Prefix-Build-Log.txt";
223my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$Prefix-Build-Log.txt";
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000224my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000225my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$Prefix-Build-Log.txt";
226
Chris Lattnerb3440302003-01-22 16:14:05 +0000227my $BuildError = "";
Chris Lattner338dd7e2003-09-23 20:33:04 +0000228if (`grep '^gmake[^:]*: .*Error' $Prefix-Build-Log.txt | wc -l` + 0 ||
Chris Lattnerccee2962003-09-23 22:02:01 +0000229 `grep '^gmake: \*\*\*.*Stop.' $Prefix-Build-Log.txt | wc -l`+0) {
Misha Brukman71b0a312003-08-21 20:22:52 +0000230 $BuildError = "<h3><font color='red'>Build error: compilation " .
231 "<a href=\"$DATE-Build-Log.txt\">aborted</a></font></h3>";
Chris Lattnerbe197872003-10-19 16:54:00 +0000232 print "BUILD ERROR\n";
Chris Lattnerb3440302003-01-22 16:14:05 +0000233}
Chris Lattner4c7e3032003-01-20 06:11:03 +0000234
Chris Lattnerb3440302003-01-22 16:14:05 +0000235#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000236# Get warnings from the build
Chris Lattnerb3440302003-01-22 16:14:05 +0000237#
Misha Brukman1b366892003-07-07 21:27:40 +0000238my @Warn = split "\n", `egrep 'warning:|Entering dir' $Prefix-Build-Log.txt`;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000239my @Warnings;
240my $CurDir = "";
241
242foreach $Warning (@Warn) {
243 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
244 $CurDir = $1; # Keep track of directory warning is in...
Misha Brukman8e9554a2003-08-14 15:26:28 +0000245 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { # Remove buildir prefix if included
Chris Lattner4c7e3032003-01-20 06:11:03 +0000246 $CurDir = $1;
247 }
248 } else {
249 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
250 }
251}
Chris Lattner1cbc0a62003-01-20 19:18:44 +0000252my $WarningsFile = join "\n", @Warnings;
253my $WarningsList = AddPreTag $WarningsFile;
254$WarningsFile =~ s/:[0-9]+:/::/g;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000255
Chris Lattner2f8cb572003-01-20 18:05:27 +0000256# Emit the warnings file, so we can diff...
257WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
258my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000259
Chris Lattner9efd7f42003-10-18 19:31:39 +0000260# Output something to stdout if something has changed
261print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
262print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
263
Chris Lattnerbe197872003-10-19 16:54:00 +0000264$WarningsAdded = AddPreTag $WarningsAdded;
265$WarningsRemoved = AddPreTag $WarningsRemoved;
Chris Lattnerb3440302003-01-22 16:14:05 +0000266
267#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000268# Get some statistics about CVS commits over the current day...
Chris Lattnerb3440302003-01-22 16:14:05 +0000269#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000270@CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
271#print join "\n", @CVSHistory; print "\n";
272
273# Extract some information from the CVS history... use a hash so no duplicate
274# stuff is stored.
Misha Brukman1b366892003-07-07 21:27:40 +0000275my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
Chris Lattner4c7e3032003-01-20 06:11:03 +0000276
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000277my $DateRE = "[-:0-9 ]+\\+[0-9]+";
278
Chris Lattner4c7e3032003-01-20 06:11:03 +0000279# Loop over every record from the CVS history, filling in the hashes.
280foreach $File (@CVSHistory) {
281 my ($Type, $Date, $UID, $Rev, $Filename);
Misha Brukman8e9554a2003-08-14 15:26:28 +0000282 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
Chris Lattner4c7e3032003-01-20 06:11:03 +0000283 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
Misha Brukman1b366892003-07-07 21:27:40 +0000284 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+)/) {
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000285 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
Misha Brukman1b366892003-07-07 21:27:40 +0000286 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000287 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
Chris Lattner4c7e3032003-01-20 06:11:03 +0000288 } else {
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000289 print "UNMATCHABLE: $File\n";
290 }
291 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
292
293 if ($Filename =~ /^llvm/) {
294 if ($Type eq 'M') { # Modified
295 $ModifiedFiles{$Filename} = 1;
296 $UsersCommitted{$UID} = 1;
297 } elsif ($Type eq 'A') { # Added
298 $AddedFiles{$Filename} = 1;
299 $UsersCommitted{$UID} = 1;
300 } elsif ($Type eq 'R') { # Removed
301 $RemovedFiles{$Filename} = 1;
302 $UsersCommitted{$UID} = 1;
303 } else {
304 $UsersUpdated{$UID} = 1;
305 }
Chris Lattner4c7e3032003-01-20 06:11:03 +0000306 }
307}
308
Chris Lattner1cbc0a62003-01-20 19:18:44 +0000309my $UserCommitList = join "\n", keys %UsersCommitted;
310my $UserUpdateList = join "\n", keys %UsersUpdated;
Chris Lattnerc9cdadf2003-08-06 16:02:50 +0000311my $AddedFilesList = AddPreTag join "\n", sort keys %AddedFiles;
312my $ModifiedFilesList = AddPreTag join "\n", sort keys %ModifiedFiles;
313my $RemovedFilesList = AddPreTag join "\n", sort keys %RemovedFiles;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000314
Chris Lattnerec0e3742003-02-28 20:30:20 +0000315my $TestError = 1;
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000316my $SingleSourceProgramsTable;
317my $MultiSourceProgramsTable;
Chris Lattnereac3cdc2003-08-21 15:55:26 +0000318my $ExternalProgramsTable;
Chris Lattnerb3440302003-01-22 16:14:05 +0000319
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000320
321sub TestDirectory {
322 my $SubDir = shift;
323
324 chdir "test/Programs/$SubDir" or
325 die "Could not change into test/Programs/$SubDir testdir!";
Chris Lattnerec0e3742003-02-28 20:30:20 +0000326
327 # Run the programs tests... creating a report.nightly.html file
328 if (!$NOTEST) {
Chris Lattnerbb0aca52003-12-19 03:47:31 +0000329 system "gmake -k $MAKEOPTS $ENABLELINEARSCAN report.nightly.html "
330 . "TEST=nightly > $Prefix-$SubDir-ProgramTest.txt 2>&1";
Chris Lattnerec0e3742003-02-28 20:30:20 +0000331 } else {
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000332 system "gunzip $Prefix-$SubDir-ProgramTest.txt.gz";
Chris Lattnerec0e3742003-02-28 20:30:20 +0000333 }
334
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000335 my $ProgramsTable;
Chris Lattnerc7294152003-08-20 15:44:33 +0000336 if (`grep '^gmake[^:]: .*Error' $Prefix-$SubDir-ProgramTest.txt | wc -l` + 0){
Chris Lattnerec0e3742003-02-28 20:30:20 +0000337 $TestError = 1;
Chris Lattner2e8be142003-05-10 21:40:10 +0000338 $ProgramsTable = "<font color=white><h2>Error running tests!</h2></font>";
Chris Lattnerbe197872003-10-19 16:54:00 +0000339 print "ERROR TESTING\n";
Chris Lattnerc7294152003-08-20 15:44:33 +0000340 } elsif (`grep '^gmake[^:]: .*No rule to make target' $Prefix-$SubDir-ProgramTest.txt | wc -l` + 0) {
Chris Lattner6e51bfa2003-05-11 15:23:10 +0000341 $TestError = 1;
342 $ProgramsTable =
343 "<font color=white><h2>Makefile error running tests!</h2></font>";
Chris Lattnerbe197872003-10-19 16:54:00 +0000344 print "ERROR TESTING\n";
Chris Lattner6e51bfa2003-05-11 15:23:10 +0000345 } else {
Chris Lattnerec0e3742003-02-28 20:30:20 +0000346 $TestError = 0;
347 $ProgramsTable = ReadFile "report.nightly.html";
348
349 #
350 # Create a list of the tests which were run...
351 #
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000352 system "egrep 'TEST-(PASS|FAIL)' < $Prefix-$SubDir-ProgramTest.txt "
353 . "| sort > $Prefix-$SubDir-Tests.txt";
Chris Lattnerec0e3742003-02-28 20:30:20 +0000354 }
355
356 # Compress the test output
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000357 system "gzip -f $Prefix-$SubDir-ProgramTest.txt";
358 chdir "../../.." or die "Cannot return to parent directory!";
359 return $ProgramsTable;
360}
361
Chris Lattner196a14a2003-08-19 15:08:34 +0000362# If we build the tree successfully, run the nightly programs tests...
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000363if ($BuildError eq "") {
364 $SingleSourceProgramsTable = TestDirectory("SingleSource");
365 $MultiSourceProgramsTable = TestDirectory("MultiSource");
Chris Lattnereac3cdc2003-08-21 15:55:26 +0000366 $ExternalProgramsTable = TestDirectory("External");
Chris Lattnerf5a6ab92003-08-18 15:11:13 +0000367 system "cat $Prefix-SingleSource-Tests.txt $Prefix-MultiSource-Tests.txt ".
Chris Lattnereac3cdc2003-08-21 15:55:26 +0000368 " $Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
Chris Lattner5d6c4382003-01-23 19:31:28 +0000369}
Chris Lattnerb3440302003-01-22 16:14:05 +0000370
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000371my ($TestsAdded, $TestsRemoved, $TestsFixed, $TestsBroken) = ("","","","");
372
Chris Lattnerec0e3742003-02-28 20:30:20 +0000373if ($TestError) {
374 $TestsAdded = "<b>error testing</b><br>";
375 $TestsRemoved = "<b>error testing</b><br>";
376 $TestsFixed = "<b>error testing</b><br>";
377 $TestsBroken = "<b>error testing</b><br>";
378} else {
379 my ($RTestsAdded, $RTestsRemoved) = DiffFiles "-Tests.txt";
380
381 my @RawTestsAddedArray = split '\n', $RTestsAdded;
382 my @RawTestsRemovedArray = split '\n', $RTestsRemoved;
383
384 my %OldTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
385 @RawTestsRemovedArray;
386 my %NewTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
387 @RawTestsAddedArray;
388
389 foreach $Test (keys %NewTests) {
390 if (!exists $OldTests{$Test}) { # TestAdded if in New but not old
391 $TestsAdded = "$TestsAdded$Test\n";
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000392 } else {
Chris Lattnerec0e3742003-02-28 20:30:20 +0000393 if ($OldTests{$Test} =~ /TEST-PASS/) { # Was the old one a pass?
394 $TestsBroken = "$TestsBroken$Test\n"; # New one must be a failure
395 } else {
396 $TestsFixed = "$TestsFixed$Test\n"; # No, new one is a pass.
397 }
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000398 }
399 }
Chris Lattnerec0e3742003-02-28 20:30:20 +0000400 foreach $Test (keys %OldTests) { # TestRemoved if in Old but not New
401 $TestsRemoved = "$TestsRemoved$Test\n" if (!exists $NewTests{$Test});
402 }
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000403
Chris Lattner91480ff2003-10-21 15:47:31 +0000404 print "\nTESTS ADDED: \n\n$TestsAdded\n\n" if (length $TestsAdded);
405 print "\nTESTS REMOVED:\n\n$TestsRemoved\n\n" if (length $TestsRemoved);
406 print "\nTESTS FIXED: \n\n$TestsFixed\n\n" if (length $TestsFixed);
407 print "\nTESTS BROKEN: \n\n$TestsBroken\n\n" if (length $TestsBroken);
Chris Lattnerbe197872003-10-19 16:54:00 +0000408
Chris Lattnerec0e3742003-02-28 20:30:20 +0000409 $TestsAdded = AddPreTag $TestsAdded;
410 $TestsRemoved = AddPreTag $TestsRemoved;
411 $TestsFixed = AddPreTag $TestsFixed;
412 $TestsBroken = AddPreTag $TestsBroken;
413}
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000414
Chris Lattner9efd7f42003-10-18 19:31:39 +0000415
Chris Lattner196a14a2003-08-19 15:08:34 +0000416# If we built the tree successfully, runs of the Olden suite with
417# LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
418if ($BuildError eq "") {
Chris Lattner08e24762003-08-19 18:35:03 +0000419 my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
Chris Lattner196a14a2003-08-19 15:08:34 +0000420 $MachCodeSize) = ("","","","","","","");
Chris Lattner08e24762003-08-19 18:35:03 +0000421 if (!$NORUNNINGTESTS) {
Chris Lattner8f9c4bd2003-09-14 06:00:49 +0000422 chdir "test/Programs/MultiSource/Benchmarks/Olden" or die "Olden tests moved?";
Chris Lattner196a14a2003-08-19 15:08:34 +0000423
424 # Clean out previous results...
425 system "gmake $MAKEOPTS clean > /dev/null 2>&1";
426
427 # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE enabled!
Chris Lattner3e457f72003-10-28 18:37:24 +0000428 system "gmake -k $MAKEOPTS report.nightly.raw.out TEST=nightly " .
Chris Lattner196a14a2003-08-19 15:08:34 +0000429 " LARGE_PROBLEM_SIZE=1 > /dev/null 2>&1";
430 system "cp report.nightly.raw.out $Prefix-Olden-tests.txt";
431 } else {
432 system "gunzip $Prefix-Olden-tests.txt.gz";
433 }
434
435 # Now we know we have $Prefix-Olden-tests.txt as the raw output file. Split
436 # it up into records and read the useful information.
Chris Lattner08e24762003-08-19 18:35:03 +0000437 my @Records = split />>> ========= /, ReadFile "$Prefix-Olden-tests.txt";
Chris Lattner196a14a2003-08-19 15:08:34 +0000438 shift @Records; # Delete the first (garbage) record
439
440 # Loop over all of the records, summarizing them into rows for the running
441 # totals file.
442 my $WallTimeRE = "[A-Za-z0-9.: ]+\\(([0-9.]+) wall clock";
443 foreach $Rec (@Records) {
Chris Lattner08e24762003-08-19 18:35:03 +0000444 my $rNATTime = GetRegex 'TEST-RESULT-nat-time: real\s*([.0-9m]+)', $Rec;
445 my $rCBETime = GetRegex 'TEST-RESULT-cbe-time: real\s*([.0-9m]+)', $Rec;
446 my $rLLCTime = GetRegex 'TEST-RESULT-llc-time: real\s*([.0-9m]+)', $Rec;
447 my $rJITTime = GetRegex 'TEST-RESULT-jit-time: real\s*([.0-9m]+)', $Rec;
Chris Lattner196a14a2003-08-19 15:08:34 +0000448 my $rOptTime = GetRegex "TEST-RESULT-compile: $WallTimeRE", $Rec;
449 my $rBytecodeSize = GetRegex 'TEST-RESULT-compile: *([0-9]+)', $Rec;
450 my $rMachCodeSize = GetRegex 'TEST-RESULT-jit-machcode: *([0-9]+).*bytes of machine code', $Rec;
451
452 $NATTime .= " " . FormatTime($rNATTime);
453 $CBETime .= " " . FormatTime($rCBETime);
454 $LLCTime .= " " . FormatTime($rLLCTime);
455 $JITTime .= " " . FormatTime($rJITTime);
456 $OptTime .= " $rOptTime";
Chris Lattner08e24762003-08-19 18:35:03 +0000457 $BytecodeSize .= " $rBytecodeSize";
458 $MachCodeSize .= " $rMachCodeSize";
Chris Lattner196a14a2003-08-19 15:08:34 +0000459 }
460
461 # Now that we have all of the numbers we want, add them to the running totals
462 # files.
Chris Lattner08e24762003-08-19 18:35:03 +0000463 AddRecord($NATTime, "running_Olden_nat_time.txt");
Chris Lattner196a14a2003-08-19 15:08:34 +0000464 AddRecord($CBETime, "running_Olden_cbe_time.txt");
465 AddRecord($LLCTime, "running_Olden_llc_time.txt");
466 AddRecord($JITTime, "running_Olden_jit_time.txt");
467 AddRecord($OptTime, "running_Olden_opt_time.txt");
468 AddRecord($BytecodeSize, "running_Olden_bytecode.txt");
469 AddRecord($MachCodeSize, "running_Olden_machcode.txt");
Chris Lattner08e24762003-08-19 18:35:03 +0000470
471 system "gzip -f $Prefix-Olden-tests.txt";
Chris Lattner196a14a2003-08-19 15:08:34 +0000472}
473
474
475
476
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000477#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000478# Get a list of the previous days that we can link to...
Chris Lattnerb3440302003-01-22 16:14:05 +0000479#
Chris Lattner2f8cb572003-01-20 18:05:27 +0000480my @PrevDays = map {s/.html//; $_} GetDir ".html";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000481
482splice @PrevDays, 20; # Trim down list to something reasonable...
483
484my $PrevDaysList = # Format list for sidebar
485 join "\n ", map { "<a href=\"$_.html\">$_</a><br>" } @PrevDays;
486
Chris Lattnerc75b14e2003-08-18 20:07:54 +0000487#
488# Start outputing files into the web directory
489#
490chdir $WebDir or die "Could not change into web directory!";
491
492# Add information to the files which accumulate information for graphs...
493AddRecord($LOC, "running_loc.txt");
494AddRecord($BuildTime, "running_build_time.txt");
495
496#
497# Rebuild the graphs now...
498#
Brian Gaekeb3dab902003-10-11 05:34:00 +0000499$GNUPLOT = "/usr/dcs/software/supported/bin/gnuplot";
500$GNUPLOT = "gnuplot" if ! -x $GNUPLOT;
501$PlotScriptFilename = "$BuildDir/llvm/utils/NightlyTest.gnuplot";
502system ($GNUPLOT, $PlotScriptFilename);
Chris Lattnerb3440302003-01-22 16:14:05 +0000503
Chris Lattner4c7e3032003-01-20 06:11:03 +0000504#
505# Remove the cvs tree...
506#
507system "rm -rf $BuildDir" if (!$NOCHECKOUT and !$NOREMOVE);
508
Chris Lattnerb3440302003-01-22 16:14:05 +0000509#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000510# Print out information...
Chris Lattnerb3440302003-01-22 16:14:05 +0000511#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000512if (0) {
513 print "DateString: $DateString\n";
514 print "CVS Checkout: $CVSCheckoutTime seconds\n";
515 print "Files/Dirs/LOC in CVS: $NumFilesInCVS/$NumDirsInCVS/$LOC\n";
516
517 print "Build Time: $BuildTime seconds\n";
518 print "Libraries/Executables/Objects built: $NumLibraries/$NumExecutables/$NumObjects\n";
519
520 print "WARNINGS:\n $WarningsList\n";
521
Chris Lattner4c7e3032003-01-20 06:11:03 +0000522 print "Users committed: $UserCommitList\n";
523 print "Added Files: \n $AddedFilesList\n";
524 print "Modified Files: \n $ModifiedFilesList\n";
525 print "Removed Files: \n $RemovedFilesList\n";
526
527 print "Previous Days =\n $PrevDaysList\n";
528}
529
Chris Lattnerb3440302003-01-22 16:14:05 +0000530
Chris Lattner2f8cb572003-01-20 18:05:27 +0000531#
532# Output the files...
533#
534
535# Main HTML file...
Chris Lattner4c7e3032003-01-20 06:11:03 +0000536my $Output;
537eval "\$Output = <<ENDOFFILE;$TemplateContents\nENDOFFILE\n";
Chris Lattner2f8cb572003-01-20 18:05:27 +0000538WriteFile "$DATE.html", $Output;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000539
540# Change the index.html symlink...
541system "ln -sf $DATE.html index.html";
542
543sub AddRecord {
544 my ($Val, $Filename) = @_;
545 my @Records;
Chris Lattner196a14a2003-08-19 15:08:34 +0000546 if (open FILE, "$WebDir/$Filename") {
Chris Lattner4c7e3032003-01-20 06:11:03 +0000547 @Records = grep !/$DATE/, split "\n", <FILE>;
548 close FILE;
549 }
550 push @Records, "$DATE: $Val";
Chris Lattner08e24762003-08-19 18:35:03 +0000551 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000552 return @Records;
553}