blob: 26a380efb6b16d09bde3283afa23e55ac96bcbae [file] [log] [blame]
Alkis Evlogimenos2e142f52004-01-07 01:48:26 +00001#!/usr/bin/perl -w
Chris Lattner4c7e3032003-01-20 06:11:03 +00002#
3# Program: NightlyTest.pl
4#
5# Synopsis: Perform a series of tests which are designed to be run nightly.
6# This is used to keep track of the status of the LLVM tree, tracking
7# regressions and performance changes. This generates one web page a
8# day which can be used to access this information.
9#
Brian Gaekeb3dab902003-10-11 05:34:00 +000010# Syntax: NightlyTest.pl [OPTIONS] [CVSROOT BUILDDIR WEBDIR]
11# where
12# OPTIONS may include one or more of the following:
13# -nocheckout Do not create, checkout, update, or configure
14# the source tree.
15# -noremove Do not remove the BUILDDIR after it has been built.
Chris Lattner4d00fde2004-05-28 20:30:23 +000016# -nofeaturetests Do not run the feature tests.
17# -noregressiontests Do not run the regression tests.
Brian Gaekeb3dab902003-10-11 05:34:00 +000018# -notest Do not even attempt to run the test programs. Implies
19# -norunningtests.
20# -norunningtests Do not run the Olden benchmark suite with
21# LARGE_PROBLEM_SIZE enabled.
22# -parallel Run two parallel jobs with GNU Make.
Chris Lattnerbb0aca52003-12-19 03:47:31 +000023# -enable-linscan Enable linearscan tests
Chris Lattner4d00fde2004-05-28 20:30:23 +000024# -verbose Turn on some debug output
25# -debug Print information useful only to maintainers of this script.
Chris Lattnerbb0aca52003-12-19 03:47:31 +000026#
Brian Gaekeb3dab902003-10-11 05:34:00 +000027# CVSROOT is the CVS repository from which the tree will be checked out,
28# specified either in the full :method:user@host:/dir syntax, or
29# just /dir if using a local repo.
30# BUILDDIR is the directory where sources for this test run will be checked out
31# AND objects for this test run will be built. This directory MUST NOT
32# exist before the script is run; it will be created by the cvs checkout
33# process and erased (unless -noremove is specified; see above.)
34# WEBDIR is the directory into which the test results web page will be written,
35# AND in which the "index.html" is assumed to be a symlink to the most recent
36# copy of the results. This directory MUST exist before the script is run.
Chris Lattner4c7e3032003-01-20 06:11:03 +000037#
38use POSIX qw(strftime);
39
Brian Gaekeb3dab902003-10-11 05:34:00 +000040my $HOME = $ENV{'HOME'};
41my $CVSRootDir = $ENV{'CVSROOT'};
Chris Lattner9d13efa2003-10-14 01:22:08 +000042 $CVSRootDir = "/home/vadve/shared/PublicCVS"
Chris Lattner4d00fde2004-05-28 20:30:23 +000043 unless $CVSRootDir;
44my $BuildDir = $ENV{'BUILDDIR'};
45 $BuildDir = "$HOME/buildtest"
46 unless $BuildDir;
47my $WebDir = $ENV{'WEBDIR'};
48 $WebDir = "$HOME/cvs/testresults-X86"
49 unless $WebDir;
Chris Lattner2f8cb572003-01-20 18:05:27 +000050
51# Calculate the date prefix...
52@TIME = localtime;
53my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
54my $DateString = strftime "%B %d, %Y", localtime;
55
Chris Lattnerb3440302003-01-22 16:14:05 +000056sub ReadFile {
Chris Lattner196a14a2003-08-19 15:08:34 +000057 undef $/;
Chris Lattnerb3440302003-01-22 16:14:05 +000058 if (open (FILE, $_[0])) {
59 my $Ret = <FILE>;
60 close FILE;
61 return $Ret;
62 } else {
63 print "Could not open file '$_[0]' for reading!";
64 return "";
65 }
66}
67
Chris Lattner2f8cb572003-01-20 18:05:27 +000068sub WriteFile { # (filename, contents)
69 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!";
70 print FILE $_[1];
71 close FILE;
72}
73
74sub GetRegex { # (Regex with ()'s, value)
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +000075 $_[1] =~ /$_[0]/m;
Chris Lattner08e24762003-08-19 18:35:03 +000076 if (defined($1)) {
77 return $1;
78 }
79 return "?";
Chris Lattner2f8cb572003-01-20 18:05:27 +000080}
81
82sub AddPreTag { # Add pre tags around nonempty list, or convert to "none"
83 $_ = shift;
Chris Lattner1cbc0a62003-01-20 19:18:44 +000084 if (length) { return "<ul><pre>$_</pre></ul>"; } else { "<b>none</b><br>"; }
Chris Lattner2f8cb572003-01-20 18:05:27 +000085}
86
87sub GetDir {
88 my $Suffix = shift;
89 opendir DH, $WebDir;
90 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
91 closedir DH;
92 return @Result;
93}
94
95# DiffFiles - Diff the current version of the file against the last version of
96# the file, reporting things added and removed. This is used to report, for
97# example, added and removed warnings. This returns a pair (added, removed)
98#
99sub DiffFiles {
100 my $Suffix = shift;
101 my @Others = GetDir $Suffix;
102 if (@Others == 0) { # No other files? We added all entries...
103 return (`cat $WebDir/$DATE$Suffix`, "");
104 }
105 # Diff the files now...
106 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
107 my $Added = join "\n", grep /^</, @Diffs;
108 my $Removed = join "\n", grep /^>/, @Diffs;
Chris Lattner1cbc0a62003-01-20 19:18:44 +0000109 $Added =~ s/^< //gm;
110 $Removed =~ s/^> //gm;
Chris Lattner2f8cb572003-01-20 18:05:27 +0000111 return ($Added, $Removed);
112}
113
Chris Lattner196a14a2003-08-19 15:08:34 +0000114# FormatTime - Convert a time from 1m23.45 into 83.45
115sub FormatTime {
116 my $Time = shift;
117 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
118 $Time = sprintf("%7.4f", $1*60.0+$2);
119 }
120 return $Time;
121}
122
Chris Lattner2f8cb572003-01-20 18:05:27 +0000123
Chris Lattner4c7e3032003-01-20 06:11:03 +0000124# Command line argument settings...
125my $NOCHECKOUT = 0;
126my $NOREMOVE = 0;
Chris Lattner4d00fde2004-05-28 20:30:23 +0000127my $NOFEATURES = 0;
128my $NOREGRESSIONS = 0;
Chris Lattnerb3440302003-01-22 16:14:05 +0000129my $NOTEST = 0;
Chris Lattner08e24762003-08-19 18:35:03 +0000130my $NORUNNINGTESTS = 0;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000131my $MAKEOPTS = "";
Chris Lattnerbb0aca52003-12-19 03:47:31 +0000132my $ENABLELINEARSCAN = "";
Chris Lattner4d00fde2004-05-28 20:30:23 +0000133my $VERBOSE = 0;
134my $DEBUG = 0;
Brian Gaekeb3dab902003-10-11 05:34:00 +0000135
Chris Lattner4c7e3032003-01-20 06:11:03 +0000136# Parse arguments...
137while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
138 shift;
139 last if /^--$/; # Stop processing arguments on --
140
141 # List command line options here...
Chris Lattner08e24762003-08-19 18:35:03 +0000142 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
143 if (/^-noremove$/) { $NOREMOVE = 1; next; }
Chris Lattner4d00fde2004-05-28 20:30:23 +0000144 if (/^-nofeaturetests$/) { $NOFEATURES = 1; next; }
145 if (/^-noregressiontests$/){ $NOREGRESSIONS = 1; next; }
Chris Lattner08e24762003-08-19 18:35:03 +0000146 if (/^-notest$/) { $NOTEST = 1; $NORUNNINGTESTS = 1; next; }
147 if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
148 if (/^-parallel$/) { $MAKEOPTS = "-j2 -l3.0"; next; }
Chris Lattner370e8092003-12-19 19:48:43 +0000149 if (/^-enable-linscan$/) { $ENABLELINEARSCAN = "ENABLE_LINEARSCAN=1"; next; }
Chris Lattner4d00fde2004-05-28 20:30:23 +0000150 if (/^-verbose$/) { $VERBOSE = 1; next; }
151 if (/^-debug$/) { $DEBUG = 1; next; }
Chris Lattner4c7e3032003-01-20 06:11:03 +0000152
153 print "Unknown option: $_ : ignoring!\n";
154}
155
Chris Lattner2f8cb572003-01-20 18:05:27 +0000156die "Must specify 0 or 3 options!" if (@ARGV != 0 and @ARGV != 3);
Chris Lattner4c7e3032003-01-20 06:11:03 +0000157
Chris Lattner4c7e3032003-01-20 06:11:03 +0000158if (@ARGV == 3) {
159 $CVSRootDir = $ARGV[0];
160 $BuildDir = $ARGV[1];
161 $WebDir = $ARGV[2];
162}
163
Chris Lattner4d00fde2004-05-28 20:30:23 +0000164
Misha Brukman1b366892003-07-07 21:27:40 +0000165my $Template = "$BuildDir/llvm/utils/NightlyTestTemplate.html";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000166my $Prefix = "$WebDir/$DATE";
167
Chris Lattner4d00fde2004-05-28 20:30:23 +0000168if ($VERBOSE) {
169 print "INITIALIZED\n";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000170 print "CVS Root = $CVSRootDir\n";
171 print "BuildDir = $BuildDir\n";
172 print "WebDir = $WebDir\n";
173 print "Prefix = $Prefix\n";
174}
175
Chris Lattnerb3440302003-01-22 16:14:05 +0000176
177#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000178# Create the CVS repository directory
Chris Lattnerb3440302003-01-22 16:14:05 +0000179#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000180if (!$NOCHECKOUT) {
Chris Lattner4d00fde2004-05-28 20:30:23 +0000181 if (-d $BuildDir) {
182 if (!$NOREMOVE) {
183 rmdir $BuildDir or die "Could not remove CVS checkout directory $BuildDir!";
184 } else {
185 die "CVS checkout directory $BuildDir already exists!";
186 }
187 }
Misha Brukman1b366892003-07-07 21:27:40 +0000188 mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000189}
Misha Brukman1b366892003-07-07 21:27:40 +0000190chdir $BuildDir or die "Could not change to CVS checkout directory $BuildDir!";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000191
Chris Lattnerb3440302003-01-22 16:14:05 +0000192
193#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000194# Check out the llvm tree, saving CVS messages to the cvs log...
Chris Lattnerb3440302003-01-22 16:14:05 +0000195#
Brian Gaekeb3dab902003-10-11 05:34:00 +0000196$CVSOPT = "";
197$CVSOPT = "-z3" if $CVSRootDir =~ /^:ext:/; # Use compression if going over ssh.
Chris Lattner4d00fde2004-05-28 20:30:23 +0000198if (!$NOCHECKOUT) {
199 if ( $VERBOSE ) { print "CHECKOUT STAGE\n"; }
200 system "(time -p cvs $CVSOPT -d $CVSRootDir co llvm) > $Prefix-CVS-Log.txt 2>&1";
201}
Chris Lattner4c7e3032003-01-20 06:11:03 +0000202
203chdir "llvm" or die "Could not change into llvm directory!";
204
Chris Lattner4d00fde2004-05-28 20:30:23 +0000205if (!$NOCHECKOUT) {
206 if ( $VERBOSE ) { print "UPDATE STAGE\n"; }
207 system "cvs update -P -d > /dev/null 2>&1" ;
208}
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000209
Chris Lattner4c7e3032003-01-20 06:11:03 +0000210# Read in the HTML template file...
Chris Lattnerb3440302003-01-22 16:14:05 +0000211my $TemplateContents = ReadFile $Template;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000212
Chris Lattnerb3440302003-01-22 16:14:05 +0000213
214#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000215# Get some static statistics about the current state of CVS
Chris Lattnerb3440302003-01-22 16:14:05 +0000216#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000217my $CVSCheckoutTime = GetRegex "([0-9.]+)", `grep '^real' $Prefix-CVS-Log.txt`;
Brian Gaekeac5d96b2003-12-01 05:31:12 +0000218my $NumFilesInCVS = `egrep '^U' $Prefix-CVS-Log.txt | wc -l` + 0;
219my $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $Prefix-CVS-Log.txt | wc -l` + 0;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000220$LOC = GetRegex "([0-9]+) +total", `wc -l \`utils/getsrcs.sh\` | grep total`;
221
Chris Lattnerb3440302003-01-22 16:14:05 +0000222#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000223# Build the entire tree, saving build messages to the build log
Chris Lattnerb3440302003-01-22 16:14:05 +0000224#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000225if (!$NOCHECKOUT) {
Chris Lattner4d00fde2004-05-28 20:30:23 +0000226 if ( $VERBOSE ) { print "CONFIGURE STAGE\n"; }
Misha Brukman8e9554a2003-08-14 15:26:28 +0000227 system "(time -p ./configure --enable-jit --enable-spec --with-objroot=.) > $Prefix-Build-Log.txt 2>&1";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000228
Chris Lattner4d00fde2004-05-28 20:30:23 +0000229 if ( $VERBOSE ) { print "BUILD STAGE\n"; }
Chris Lattner4c7e3032003-01-20 06:11:03 +0000230 # Build the entire tree, capturing the output into $Prefix-Build-Log.txt
Chris Lattner42815c82003-07-01 16:02:00 +0000231 system "(time -p gmake $MAKEOPTS) >> $Prefix-Build-Log.txt 2>&1";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000232}
233
Chris Lattnerb3440302003-01-22 16:14:05 +0000234
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000235sub GetRegexNum {
236 my ($Regex, $Num, $Regex2, $File) = @_;
237 my @Items = split "\n", `grep '$Regex' $File`;
238 return GetRegex $Regex2, $Items[$Num];
239}
240
Chris Lattnerb3440302003-01-22 16:14:05 +0000241#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000242# Get some statistics about the build...
Chris Lattnerb3440302003-01-22 16:14:05 +0000243#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000244my @Linked = split '\n', `grep Linking $Prefix-Build-Log.txt`;
245my $NumExecutables = scalar(grep(/executable/, @Linked));
246my $NumLibraries = scalar(grep(!/executable/, @Linked));
247my $NumObjects = `grep '^Compiling' $Prefix-Build-Log.txt | wc -l` + 0;
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000248
249my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$Prefix-Build-Log.txt";
250my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$Prefix-Build-Log.txt";
Chris Lattner00d7af62003-08-18 14:07:03 +0000251my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000252my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$Prefix-Build-Log.txt";
253
254my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$Prefix-Build-Log.txt";
255my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$Prefix-Build-Log.txt";
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000256my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000257my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$Prefix-Build-Log.txt";
258
Chris Lattnerb3440302003-01-22 16:14:05 +0000259my $BuildError = "";
Chris Lattner338dd7e2003-09-23 20:33:04 +0000260if (`grep '^gmake[^:]*: .*Error' $Prefix-Build-Log.txt | wc -l` + 0 ||
Chris Lattnerccee2962003-09-23 22:02:01 +0000261 `grep '^gmake: \*\*\*.*Stop.' $Prefix-Build-Log.txt | wc -l`+0) {
Misha Brukman71b0a312003-08-21 20:22:52 +0000262 $BuildError = "<h3><font color='red'>Build error: compilation " .
263 "<a href=\"$DATE-Build-Log.txt\">aborted</a></font></h3>";
Chris Lattnerbe197872003-10-19 16:54:00 +0000264 print "BUILD ERROR\n";
Chris Lattnerb3440302003-01-22 16:14:05 +0000265}
Chris Lattner4c7e3032003-01-20 06:11:03 +0000266
Chris Lattner4d00fde2004-05-28 20:30:23 +0000267sub GetQMTestResults { # (filename)
268 my ($filename) = @_;
269 my @lines;
270 my $firstline;
271 $/ = "\n"; #Make sure we're going line at a time.
272 if (open SRCHFILE, $filename) {
273 while ( <SRCHFILE> ) {
274 if ( m/^--- TEST RESULTS/ ) {
275 push(@lines, $_); last;
276 }
277 }
278 while ( <SRCHFILE> ) {
279 if ( length($_) > 1 ) {
280 if ( ! m/^gmake:/ && ! m/^ qmtest.target:/ && !/^ local/ ) {
281 push(@lines,$_);
282 }
283 }
284 }
285 close SRCHFILE;
286 }
287 my $content = join("",@lines);
288 return "<pre>\n@lines</pre>\n";
289}
290
291
292# Get results of feature tests.
293my $FeatureTestResults; # String containing the results of the feature tests
294my $FeatureTime; # System+CPU Time for feature tests
295my $FeatureWallTime; # Wall Clock Time for feature tests
296if (!$NOFEATURES) {
297 if ( $VERBOSE ) { print "FEATURE TEST STAGE\n"; }
298 my $feature_output = "$Prefix-FeatureTests-Log.txt";
299
300 # Run the feature tests so we can summarize the results
301 system "(time -p gmake -C test Feature.t) > $feature_output 2>&1";
302
303 # Extract test results
304 $FeatureTestResults = GetQMTestResults("$feature_output");
305
306 # Extract time of feature tests
307 my $FeatureTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$feature_output";
308 my $FeatureTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$feature_output";
309 $FeatureTime = $FeatureTimeU+$FeatureTimeS; # FeatureTime = User+System
310 $FeatureWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$feature_output";
311 # Run the regression tests so we can summarize the results
312} else {
313 $FeatureTestResults = "Skipped by user choice.";
314 $FeatureTime = "0.0";
315 $FeatureWallTime = "0.0";
316}
317
318if (!$NOREGRESSIONS) {
319 if ( $VERBOSE ) { print "REGRESSION TEST STAGE\n"; }
320 my $regression_output = "$Prefix-RegressionTests-Log.txt";
321
322 # Run the regression tests so we can summarize the results
323 system "(time -p gmake -C test Regression.t) > $regression_output 2>&1";
324
325 # Extract test results
326 $RegressionTestResults = GetQMTestResults("$regression_output");
327
328 # Extract time of regressions tests
329 my $RegressionTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$regression_output";
330 my $RegressionTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$regression_output";
331 $RegressionTime = $RegressionTimeU+$RegressionTimeS; # RegressionTime = User+System
332 $RegressionWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$regression_output";
333} else {
334 $RegressionTestResults = "Skipped by user choice.";
335 $RegressionTime = "0.0";
336 $RegressionWallTime = "0.0";
337}
338
339if ($DEBUG) {
340 print $FeatureTestResults;
341 print $RegressionTestResults;
342}
343
344if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
Chris Lattnerb3440302003-01-22 16:14:05 +0000345#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000346# Get warnings from the build
Chris Lattnerb3440302003-01-22 16:14:05 +0000347#
Misha Brukman1b366892003-07-07 21:27:40 +0000348my @Warn = split "\n", `egrep 'warning:|Entering dir' $Prefix-Build-Log.txt`;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000349my @Warnings;
350my $CurDir = "";
351
352foreach $Warning (@Warn) {
353 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
354 $CurDir = $1; # Keep track of directory warning is in...
Misha Brukman8e9554a2003-08-14 15:26:28 +0000355 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { # Remove buildir prefix if included
Chris Lattner4c7e3032003-01-20 06:11:03 +0000356 $CurDir = $1;
357 }
358 } else {
359 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
360 }
361}
Chris Lattner1cbc0a62003-01-20 19:18:44 +0000362my $WarningsFile = join "\n", @Warnings;
363my $WarningsList = AddPreTag $WarningsFile;
364$WarningsFile =~ s/:[0-9]+:/::/g;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000365
Chris Lattner2f8cb572003-01-20 18:05:27 +0000366# Emit the warnings file, so we can diff...
367WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
368my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000369
Chris Lattner9efd7f42003-10-18 19:31:39 +0000370# Output something to stdout if something has changed
371print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
372print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
373
Chris Lattnerbe197872003-10-19 16:54:00 +0000374$WarningsAdded = AddPreTag $WarningsAdded;
375$WarningsRemoved = AddPreTag $WarningsRemoved;
Chris Lattnerb3440302003-01-22 16:14:05 +0000376
377#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000378# Get some statistics about CVS commits over the current day...
Chris Lattnerb3440302003-01-22 16:14:05 +0000379#
Chris Lattner4d00fde2004-05-28 20:30:23 +0000380if ($VERBOSE) { print "CVS HISTORY ANALYSIS STAGE\n"; }
Chris Lattner4c7e3032003-01-20 06:11:03 +0000381@CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
382#print join "\n", @CVSHistory; print "\n";
383
384# Extract some information from the CVS history... use a hash so no duplicate
385# stuff is stored.
Misha Brukman1b366892003-07-07 21:27:40 +0000386my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
Chris Lattner4c7e3032003-01-20 06:11:03 +0000387
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000388my $DateRE = "[-:0-9 ]+\\+[0-9]+";
389
Chris Lattner4c7e3032003-01-20 06:11:03 +0000390# Loop over every record from the CVS history, filling in the hashes.
391foreach $File (@CVSHistory) {
392 my ($Type, $Date, $UID, $Rev, $Filename);
Misha Brukman8e9554a2003-08-14 15:26:28 +0000393 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
Chris Lattner4c7e3032003-01-20 06:11:03 +0000394 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
Chris Lattnerd56147d2004-01-12 16:55:30 +0000395 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
396 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
Misha Brukman1b366892003-07-07 21:27:40 +0000397 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000398 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
Chris Lattner4c7e3032003-01-20 06:11:03 +0000399 } else {
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000400 print "UNMATCHABLE: $File\n";
401 }
402 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
403
404 if ($Filename =~ /^llvm/) {
405 if ($Type eq 'M') { # Modified
406 $ModifiedFiles{$Filename} = 1;
407 $UsersCommitted{$UID} = 1;
408 } elsif ($Type eq 'A') { # Added
409 $AddedFiles{$Filename} = 1;
410 $UsersCommitted{$UID} = 1;
411 } elsif ($Type eq 'R') { # Removed
412 $RemovedFiles{$Filename} = 1;
413 $UsersCommitted{$UID} = 1;
414 } else {
415 $UsersUpdated{$UID} = 1;
416 }
Chris Lattner4c7e3032003-01-20 06:11:03 +0000417 }
418}
419
Chris Lattner1cbc0a62003-01-20 19:18:44 +0000420my $UserCommitList = join "\n", keys %UsersCommitted;
421my $UserUpdateList = join "\n", keys %UsersUpdated;
Chris Lattnerc9cdadf2003-08-06 16:02:50 +0000422my $AddedFilesList = AddPreTag join "\n", sort keys %AddedFiles;
423my $ModifiedFilesList = AddPreTag join "\n", sort keys %ModifiedFiles;
424my $RemovedFilesList = AddPreTag join "\n", sort keys %RemovedFiles;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000425
Chris Lattnerec0e3742003-02-28 20:30:20 +0000426my $TestError = 1;
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000427my $SingleSourceProgramsTable;
428my $MultiSourceProgramsTable;
Chris Lattnereac3cdc2003-08-21 15:55:26 +0000429my $ExternalProgramsTable;
Chris Lattnerb3440302003-01-22 16:14:05 +0000430
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000431
432sub TestDirectory {
433 my $SubDir = shift;
434
435 chdir "test/Programs/$SubDir" or
436 die "Could not change into test/Programs/$SubDir testdir!";
Chris Lattnerec0e3742003-02-28 20:30:20 +0000437
438 # Run the programs tests... creating a report.nightly.html file
439 if (!$NOTEST) {
Chris Lattnerbb0aca52003-12-19 03:47:31 +0000440 system "gmake -k $MAKEOPTS $ENABLELINEARSCAN report.nightly.html "
441 . "TEST=nightly > $Prefix-$SubDir-ProgramTest.txt 2>&1";
Chris Lattnerec0e3742003-02-28 20:30:20 +0000442 } else {
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000443 system "gunzip $Prefix-$SubDir-ProgramTest.txt.gz";
Chris Lattnerec0e3742003-02-28 20:30:20 +0000444 }
445
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000446 my $ProgramsTable;
Chris Lattnerc7294152003-08-20 15:44:33 +0000447 if (`grep '^gmake[^:]: .*Error' $Prefix-$SubDir-ProgramTest.txt | wc -l` + 0){
Chris Lattnerec0e3742003-02-28 20:30:20 +0000448 $TestError = 1;
Chris Lattner2e8be142003-05-10 21:40:10 +0000449 $ProgramsTable = "<font color=white><h2>Error running tests!</h2></font>";
Chris Lattnerbe197872003-10-19 16:54:00 +0000450 print "ERROR TESTING\n";
Chris Lattnerc7294152003-08-20 15:44:33 +0000451 } elsif (`grep '^gmake[^:]: .*No rule to make target' $Prefix-$SubDir-ProgramTest.txt | wc -l` + 0) {
Chris Lattner6e51bfa2003-05-11 15:23:10 +0000452 $TestError = 1;
453 $ProgramsTable =
454 "<font color=white><h2>Makefile error running tests!</h2></font>";
Chris Lattnerbe197872003-10-19 16:54:00 +0000455 print "ERROR TESTING\n";
Chris Lattner6e51bfa2003-05-11 15:23:10 +0000456 } else {
Chris Lattnerec0e3742003-02-28 20:30:20 +0000457 $TestError = 0;
458 $ProgramsTable = ReadFile "report.nightly.html";
459
460 #
461 # Create a list of the tests which were run...
462 #
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000463 system "egrep 'TEST-(PASS|FAIL)' < $Prefix-$SubDir-ProgramTest.txt "
464 . "| sort > $Prefix-$SubDir-Tests.txt";
Chris Lattnerec0e3742003-02-28 20:30:20 +0000465 }
466
467 # Compress the test output
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000468 system "gzip -f $Prefix-$SubDir-ProgramTest.txt";
469 chdir "../../.." or die "Cannot return to parent directory!";
470 return $ProgramsTable;
471}
472
Chris Lattner196a14a2003-08-19 15:08:34 +0000473# If we build the tree successfully, run the nightly programs tests...
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000474if ($BuildError eq "") {
Chris Lattner4d00fde2004-05-28 20:30:23 +0000475 if ( $VERBOSE ) {
476 print "SingleSource TEST STAGE\n";
477 }
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000478 $SingleSourceProgramsTable = TestDirectory("SingleSource");
Chris Lattner4d00fde2004-05-28 20:30:23 +0000479 if ( $VERBOSE ) {
480 print "MultiSource TEST STAGE\n";
481 }
Chris Lattnerbf6a4dc2003-08-18 06:05:21 +0000482 $MultiSourceProgramsTable = TestDirectory("MultiSource");
Chris Lattner4d00fde2004-05-28 20:30:23 +0000483 if ( $VERBOSE ) {
484 print "External TEST STAGE\n";
485 }
Chris Lattnereac3cdc2003-08-21 15:55:26 +0000486 $ExternalProgramsTable = TestDirectory("External");
Chris Lattnerf5a6ab92003-08-18 15:11:13 +0000487 system "cat $Prefix-SingleSource-Tests.txt $Prefix-MultiSource-Tests.txt ".
Chris Lattnereac3cdc2003-08-21 15:55:26 +0000488 " $Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
Chris Lattner5d6c4382003-01-23 19:31:28 +0000489}
Chris Lattnerb3440302003-01-22 16:14:05 +0000490
Chris Lattner4d00fde2004-05-28 20:30:23 +0000491if ( $VERBOSE ) {
492 print "TEST INFORMATION COLLECTION STAGE\n";
493}
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000494my ($TestsAdded, $TestsRemoved, $TestsFixed, $TestsBroken) = ("","","","");
495
Chris Lattnerec0e3742003-02-28 20:30:20 +0000496if ($TestError) {
497 $TestsAdded = "<b>error testing</b><br>";
498 $TestsRemoved = "<b>error testing</b><br>";
499 $TestsFixed = "<b>error testing</b><br>";
500 $TestsBroken = "<b>error testing</b><br>";
501} else {
502 my ($RTestsAdded, $RTestsRemoved) = DiffFiles "-Tests.txt";
503
504 my @RawTestsAddedArray = split '\n', $RTestsAdded;
505 my @RawTestsRemovedArray = split '\n', $RTestsRemoved;
506
507 my %OldTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
508 @RawTestsRemovedArray;
509 my %NewTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
510 @RawTestsAddedArray;
511
512 foreach $Test (keys %NewTests) {
513 if (!exists $OldTests{$Test}) { # TestAdded if in New but not old
514 $TestsAdded = "$TestsAdded$Test\n";
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000515 } else {
Chris Lattnerec0e3742003-02-28 20:30:20 +0000516 if ($OldTests{$Test} =~ /TEST-PASS/) { # Was the old one a pass?
517 $TestsBroken = "$TestsBroken$Test\n"; # New one must be a failure
518 } else {
519 $TestsFixed = "$TestsFixed$Test\n"; # No, new one is a pass.
520 }
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000521 }
522 }
Chris Lattnerec0e3742003-02-28 20:30:20 +0000523 foreach $Test (keys %OldTests) { # TestRemoved if in Old but not New
524 $TestsRemoved = "$TestsRemoved$Test\n" if (!exists $NewTests{$Test});
525 }
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000526
Chris Lattner91480ff2003-10-21 15:47:31 +0000527 print "\nTESTS ADDED: \n\n$TestsAdded\n\n" if (length $TestsAdded);
528 print "\nTESTS REMOVED:\n\n$TestsRemoved\n\n" if (length $TestsRemoved);
529 print "\nTESTS FIXED: \n\n$TestsFixed\n\n" if (length $TestsFixed);
530 print "\nTESTS BROKEN: \n\n$TestsBroken\n\n" if (length $TestsBroken);
Chris Lattnerbe197872003-10-19 16:54:00 +0000531
Chris Lattnerec0e3742003-02-28 20:30:20 +0000532 $TestsAdded = AddPreTag $TestsAdded;
533 $TestsRemoved = AddPreTag $TestsRemoved;
534 $TestsFixed = AddPreTag $TestsFixed;
535 $TestsBroken = AddPreTag $TestsBroken;
536}
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000537
Chris Lattner9efd7f42003-10-18 19:31:39 +0000538
Chris Lattner196a14a2003-08-19 15:08:34 +0000539# If we built the tree successfully, runs of the Olden suite with
540# LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
541if ($BuildError eq "") {
Chris Lattner08e24762003-08-19 18:35:03 +0000542 my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
Chris Lattner196a14a2003-08-19 15:08:34 +0000543 $MachCodeSize) = ("","","","","","","");
Chris Lattner08e24762003-08-19 18:35:03 +0000544 if (!$NORUNNINGTESTS) {
Chris Lattner8f9c4bd2003-09-14 06:00:49 +0000545 chdir "test/Programs/MultiSource/Benchmarks/Olden" or die "Olden tests moved?";
Chris Lattner196a14a2003-08-19 15:08:34 +0000546
547 # Clean out previous results...
548 system "gmake $MAKEOPTS clean > /dev/null 2>&1";
549
550 # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE enabled!
Chris Lattner3e457f72003-10-28 18:37:24 +0000551 system "gmake -k $MAKEOPTS report.nightly.raw.out TEST=nightly " .
Chris Lattner196a14a2003-08-19 15:08:34 +0000552 " LARGE_PROBLEM_SIZE=1 > /dev/null 2>&1";
553 system "cp report.nightly.raw.out $Prefix-Olden-tests.txt";
554 } else {
555 system "gunzip $Prefix-Olden-tests.txt.gz";
556 }
557
558 # Now we know we have $Prefix-Olden-tests.txt as the raw output file. Split
559 # it up into records and read the useful information.
Chris Lattner08e24762003-08-19 18:35:03 +0000560 my @Records = split />>> ========= /, ReadFile "$Prefix-Olden-tests.txt";
Chris Lattner196a14a2003-08-19 15:08:34 +0000561 shift @Records; # Delete the first (garbage) record
562
563 # Loop over all of the records, summarizing them into rows for the running
564 # totals file.
565 my $WallTimeRE = "[A-Za-z0-9.: ]+\\(([0-9.]+) wall clock";
566 foreach $Rec (@Records) {
Chris Lattner08e24762003-08-19 18:35:03 +0000567 my $rNATTime = GetRegex 'TEST-RESULT-nat-time: real\s*([.0-9m]+)', $Rec;
568 my $rCBETime = GetRegex 'TEST-RESULT-cbe-time: real\s*([.0-9m]+)', $Rec;
569 my $rLLCTime = GetRegex 'TEST-RESULT-llc-time: real\s*([.0-9m]+)', $Rec;
570 my $rJITTime = GetRegex 'TEST-RESULT-jit-time: real\s*([.0-9m]+)', $Rec;
Chris Lattner196a14a2003-08-19 15:08:34 +0000571 my $rOptTime = GetRegex "TEST-RESULT-compile: $WallTimeRE", $Rec;
572 my $rBytecodeSize = GetRegex 'TEST-RESULT-compile: *([0-9]+)', $Rec;
573 my $rMachCodeSize = GetRegex 'TEST-RESULT-jit-machcode: *([0-9]+).*bytes of machine code', $Rec;
574
575 $NATTime .= " " . FormatTime($rNATTime);
576 $CBETime .= " " . FormatTime($rCBETime);
577 $LLCTime .= " " . FormatTime($rLLCTime);
578 $JITTime .= " " . FormatTime($rJITTime);
579 $OptTime .= " $rOptTime";
Chris Lattner08e24762003-08-19 18:35:03 +0000580 $BytecodeSize .= " $rBytecodeSize";
581 $MachCodeSize .= " $rMachCodeSize";
Chris Lattner196a14a2003-08-19 15:08:34 +0000582 }
583
584 # Now that we have all of the numbers we want, add them to the running totals
585 # files.
Chris Lattner08e24762003-08-19 18:35:03 +0000586 AddRecord($NATTime, "running_Olden_nat_time.txt");
Chris Lattner196a14a2003-08-19 15:08:34 +0000587 AddRecord($CBETime, "running_Olden_cbe_time.txt");
588 AddRecord($LLCTime, "running_Olden_llc_time.txt");
589 AddRecord($JITTime, "running_Olden_jit_time.txt");
590 AddRecord($OptTime, "running_Olden_opt_time.txt");
591 AddRecord($BytecodeSize, "running_Olden_bytecode.txt");
592 AddRecord($MachCodeSize, "running_Olden_machcode.txt");
Chris Lattner08e24762003-08-19 18:35:03 +0000593
594 system "gzip -f $Prefix-Olden-tests.txt";
Chris Lattner196a14a2003-08-19 15:08:34 +0000595}
596
597
598
599
Chris Lattnerd9bdbaa2003-01-22 20:35:59 +0000600#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000601# Get a list of the previous days that we can link to...
Chris Lattnerb3440302003-01-22 16:14:05 +0000602#
Chris Lattner2f8cb572003-01-20 18:05:27 +0000603my @PrevDays = map {s/.html//; $_} GetDir ".html";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000604
605splice @PrevDays, 20; # Trim down list to something reasonable...
606
607my $PrevDaysList = # Format list for sidebar
608 join "\n ", map { "<a href=\"$_.html\">$_</a><br>" } @PrevDays;
609
Chris Lattnerc75b14e2003-08-18 20:07:54 +0000610#
611# Start outputing files into the web directory
612#
613chdir $WebDir or die "Could not change into web directory!";
614
615# Add information to the files which accumulate information for graphs...
616AddRecord($LOC, "running_loc.txt");
617AddRecord($BuildTime, "running_build_time.txt");
618
Chris Lattner4d00fde2004-05-28 20:30:23 +0000619if ( $VERBOSE ) {
620 print "GRAPH GENERATION STAGE\n";
621}
Chris Lattnerc75b14e2003-08-18 20:07:54 +0000622#
623# Rebuild the graphs now...
624#
Brian Gaekeb3dab902003-10-11 05:34:00 +0000625$GNUPLOT = "/usr/dcs/software/supported/bin/gnuplot";
626$GNUPLOT = "gnuplot" if ! -x $GNUPLOT;
627$PlotScriptFilename = "$BuildDir/llvm/utils/NightlyTest.gnuplot";
628system ($GNUPLOT, $PlotScriptFilename);
Chris Lattnerb3440302003-01-22 16:14:05 +0000629
Chris Lattner4c7e3032003-01-20 06:11:03 +0000630#
631# Remove the cvs tree...
632#
633system "rm -rf $BuildDir" if (!$NOCHECKOUT and !$NOREMOVE);
634
Chris Lattnerb3440302003-01-22 16:14:05 +0000635#
Chris Lattner4c7e3032003-01-20 06:11:03 +0000636# Print out information...
Chris Lattnerb3440302003-01-22 16:14:05 +0000637#
Chris Lattner4d00fde2004-05-28 20:30:23 +0000638if ($VERBOSE) {
Chris Lattner4c7e3032003-01-20 06:11:03 +0000639 print "DateString: $DateString\n";
640 print "CVS Checkout: $CVSCheckoutTime seconds\n";
641 print "Files/Dirs/LOC in CVS: $NumFilesInCVS/$NumDirsInCVS/$LOC\n";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000642 print "Build Time: $BuildTime seconds\n";
Chris Lattner4d00fde2004-05-28 20:30:23 +0000643 print "Feature Test Time: $FeatureTime seconds\n";
644 print "Regression Test Time: $RegressionTime seconds\n";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000645 print "Libraries/Executables/Objects built: $NumLibraries/$NumExecutables/$NumObjects\n";
646
647 print "WARNINGS:\n $WarningsList\n";
648
Chris Lattner4c7e3032003-01-20 06:11:03 +0000649 print "Users committed: $UserCommitList\n";
650 print "Added Files: \n $AddedFilesList\n";
651 print "Modified Files: \n $ModifiedFilesList\n";
652 print "Removed Files: \n $RemovedFilesList\n";
653
654 print "Previous Days =\n $PrevDaysList\n";
655}
656
Chris Lattnerb3440302003-01-22 16:14:05 +0000657
Chris Lattner2f8cb572003-01-20 18:05:27 +0000658#
659# Output the files...
660#
661
Chris Lattner4d00fde2004-05-28 20:30:23 +0000662if ( $VERBOSE ) {
663 print "OUTPUT STAGE\n";
664}
Chris Lattner2f8cb572003-01-20 18:05:27 +0000665# Main HTML file...
Chris Lattner4c7e3032003-01-20 06:11:03 +0000666my $Output;
667eval "\$Output = <<ENDOFFILE;$TemplateContents\nENDOFFILE\n";
Chris Lattner2f8cb572003-01-20 18:05:27 +0000668WriteFile "$DATE.html", $Output;
Chris Lattner4c7e3032003-01-20 06:11:03 +0000669
670# Change the index.html symlink...
671system "ln -sf $DATE.html index.html";
672
673sub AddRecord {
674 my ($Val, $Filename) = @_;
675 my @Records;
Chris Lattner196a14a2003-08-19 15:08:34 +0000676 if (open FILE, "$WebDir/$Filename") {
Chris Lattner4c7e3032003-01-20 06:11:03 +0000677 @Records = grep !/$DATE/, split "\n", <FILE>;
678 close FILE;
679 }
680 push @Records, "$DATE: $Val";
Chris Lattner08e24762003-08-19 18:35:03 +0000681 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
Chris Lattner4c7e3032003-01-20 06:11:03 +0000682 return @Records;
683}