blob: 05749dec6066c4ba0cb15ce7718c0ee850113b01 [file] [log] [blame]
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001#!/usr/bin/perl
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00002use POSIX qw(strftime);
3use File::Copy;
Reid Spencerd0b08792007-04-03 08:28:44 +00004use Date::Parse;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00005use Socket;
6
7#
8# Program: NewNightlyTest.pl
9#
10# Synopsis: Perform a series of tests which are designed to be run nightly.
11# This is used to keep track of the status of the LLVM tree, tracking
12# regressions and performance changes. Submits this information
Reid Spencerfa34d7b2006-08-13 09:53:02 +000013# to llvm.org where it is placed into the nightlytestresults database.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000014#
15# Modified heavily by Patrick Jenkins, July 2006
16#
17# Syntax: NightlyTest.pl [OPTIONS] [CVSROOT BUILDDIR WEBDIR]
18# where
19# OPTIONS may include one or more of the following:
20# -nocheckout Do not create, checkout, update, or configure
21# the source tree.
22# -noremove Do not remove the BUILDDIR after it has been built.
Patrick Jenkinsa5c04d62006-07-07 17:31:38 +000023# -noremoveresults Do not remove the WEBDIR after it has been built.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000024# -nobuild Do not build llvm. If tests are enabled perform them
25# on the llvm build specified in the build directory
26# -notest Do not even attempt to run the test programs. Implies
27# -norunningtests.
28# -norunningtests Do not run the Olden benchmark suite with
29# LARGE_PROBLEM_SIZE enabled.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000030# -nodejagnu Do not run feature or regression tests
31# -parallel Run two parallel jobs with GNU Make.
32# -release Build an LLVM Release version
Jim Laskey27b8ba02006-09-28 17:49:20 +000033# -release-asserts Build an LLVM ReleaseAsserts version
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000034# -enable-llcbeta Enable testing of beta features in llc.
Reid Spencer2bae1f52006-11-24 20:34:16 +000035# -enable-lli Enable testing of lli (interpreter) features, default is off
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000036# -disable-llc Disable LLC tests in the nightly tester.
37# -disable-jit Disable JIT tests in the nightly tester.
38# -disable-cbe Disable C backend tests in the nightly tester.
39# -verbose Turn on some debug output
40# -debug Print information useful only to maintainers of this script.
41# -nice Checkout/Configure/Build with "nice" to reduce impact
42# on busy servers.
43# -f2c Next argument specifies path to F2C utility
44# -nickname The next argument specifieds the nickname this script
45# will submit to the nightlytest results repository.
46# -gccpath Path to gcc/g++ used to build LLVM
47# -cvstag Check out a specific CVS tag to build LLVM (useful for
48# testing release branches)
Reid Spencerd0b08792007-04-03 08:28:44 +000049# -usesvn Check code out from a subversion repository. With no
50# argument, use the standard repository. An argument specifies
51# the repository URL to use.
52# -svnurl Specify the SVN URL where LLVM can be found
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000053# -target Specify the target triplet
54# -cflags Next argument specifies that C compilation options that
55# override the default.
56# -cxxflags Next argument specifies that C++ compilation options that
57# override the default.
58# -ldflags Next argument specifies that linker options that override
59# the default.
Patrick Jenkins215b48f2006-07-07 18:50:51 +000060# -compileflags Next argument specifies extra options passed to make when
61# building LLVM.
Patrick Jenkins0e9402f2006-08-11 23:02:09 +000062# -use-gmake Use gmake instead of the default make command to build
Patrick Jenkins1cd46912006-07-27 01:17:17 +000063# llvm and run tests.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000064#
65# ---------------- Options to configure llvm-test ----------------------------
Patrick Jenkins215b48f2006-07-07 18:50:51 +000066# -extraflags Next argument specifies extra options that are passed to
67# compile the tests.
68# -noexternals Do not run the external tests (for cases where povray
69# or SPEC are not installed)
70# -with-externals Specify a directory where the external tests are located.
Patrick Jenkins0e9402f2006-08-11 23:02:09 +000071# -submit-server Specifies a server to submit the test results too. If this
72# option is not specified it defaults to
73# llvm.org. This is basically just the address of the
74# webserver
75# -submit-script Specifies which script to call on the submit server. If
76# this option is not specified it defaults to
Jim Laskey6d8a1b72006-09-15 17:03:36 +000077# /nightlytest/NightlyTestAccept.php. This is basically
Patrick Jenkins0e9402f2006-08-11 23:02:09 +000078# everything after the www.yourserver.org.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000079#
80# CVSROOT is the CVS repository from which the tree will be checked out,
81# specified either in the full :method:user@host:/dir syntax, or
82# just /dir if using a local repo.
83# BUILDDIR is the directory where sources for this test run will be checked out
84# AND objects for this test run will be built. This directory MUST NOT
85# exist before the script is run; it will be created by the cvs checkout
86# process and erased (unless -noremove is specified; see above.)
87# WEBDIR is the directory into which the test results web page will be written,
88# AND in which the "index.html" is assumed to be a symlink to the most recent
89# copy of the results. This directory will be created if it does not exist.
90# LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
91# to. This is the same as you would have for a normal LLVM build.
92#
93##############################################################
94#
95# Getting environment variables
96#
97##############################################################
Reid Spencerfa34d7b2006-08-13 09:53:02 +000098my $HOME = $ENV{'HOME'};
Reid Spencerd0b08792007-04-03 08:28:44 +000099my $SVNURL = $ENV{"SVNURL"};
100$SVNURL = 'svn://anon@hlvm.org:3691/llvm.svn' unless $SVNURL;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000101my $CVSRootDir = $ENV{'CVSROOT'};
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000102$CVSRootDir = "/home/vadve/shared/PublicCVS" unless $CVSRootDir;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000103my $BuildDir = $ENV{'BUILDDIR'};
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000104$BuildDir = "$HOME/buildtest" unless $BuildDir;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000105my $WebDir = $ENV{'WEBDIR'};
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000106$WebDir = "$HOME/cvs/testresults-X86" unless $WebDir;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000107
108##############################################################
109#
110# Calculate the date prefix...
111#
112##############################################################
113@TIME = localtime;
114my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
115my $DateString = strftime "%B %d, %Y", localtime;
116my $TestStartTime = gmtime() . "GMT<br>" . localtime() . " (local)";
117
118##############################################################
119#
120# Parse arguments...
121#
122##############################################################
123$CONFIGUREARGS="";
Patrick Jenkins49717a42006-07-21 01:39:42 +0000124$nickname="";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000125$NOTEST=0;
Reid Spencerd0b08792007-04-03 08:28:44 +0000126$USESVN=0;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000127$NORUNNINGTESTS=0;
Patrick Jenkins1cd46912006-07-27 01:17:17 +0000128$MAKECMD="make";
Patrick Jenkins0e9402f2006-08-11 23:02:09 +0000129$SUBMITSERVER = "llvm.org";
Jim Laskey6d8a1b72006-09-15 17:03:36 +0000130$SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000131
132while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000133 shift;
134 last if /^--$/; # Stop processing arguments on --
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000135
136 # List command line options here...
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000137 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
138 if (/^-nocvsstats$/) { $NOCVSSTATS = 1; next; }
139 if (/^-noremove$/) { $NOREMOVE = 1; next; }
140 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
141 if (/^-notest$/) { $NOTEST = 1; $NORUNNINGTESTS = 1; next; }
142 if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
143 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j2 -l3.0"; next; }
144 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
145 "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
Jim Laskey27b8ba02006-09-28 17:49:20 +0000146 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
147 "DISABLE-ASSERTIONS=1 ".
Reid Spencer93c456c2006-10-19 15:24:04 +0000148 "OPTIMIZE_OPTION=-O2";
149 $BUILDTYPE="release-asserts"; next;}
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000150 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
Reid Spencer2bae1f52006-11-24 20:34:16 +0000151 if (/^-enable-lli$/) { $PROGTESTOPTS .= " ENABLE_LLI=1";
152 $CONFIGUREARGS .= " --enable-lli"; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000153 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
154 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
155 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
156 $CONFIGUREARGS .= " --disable-jit"; next; }
157 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
158 if (/^-verbose$/) { $VERBOSE = 1; next; }
159 if (/^-debug$/) { $DEBUG = 1; next; }
160 if (/^-nice$/) { $NICE = "nice "; next; }
161 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
162 shift; next; }
163 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
164 shift; next; }
165 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
166 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
167 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
168 if (/^-gccpath/) { $CONFIGUREARGS .=
169 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
170 $GCCPATH=$ARGV[0]; shift; next; }
171 else { $GCCPATH=""; }
172 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
173 else { $CVSCOOPT="";}
Reid Spencerd0b08792007-04-03 08:28:44 +0000174 if (/^-usesvn/) { $USESVN = 1; }
175 if (/^-svnurl/) { $SVNURL = $ARGV[0]; shift; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000176 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
177 shift; next; }
178 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
179 shift; next; }
180 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
181 shift; next; }
182 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
183 shift; next; }
184 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
185 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
186 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
187 if (/^-extraflags/) { $CONFIGUREARGS .=
188 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
189 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
190 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
191 if (/^-nobuild$/) { $NOBUILD = 1; next; }
192 print "Unknown option: $_ : ignoring!\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000193}
194
195if ($ENV{'LLVMGCCDIR'}) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000196 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000197}
198if ($CONFIGUREARGS !~ /--disable-jit/) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000199 $CONFIGUREARGS .= " --enable-jit";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000200}
201
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000202if (@ARGV != 0 and @ARGV != 3 and $VERBOSE) {
203 foreach $x (@ARGV) {
204 print "$x\n";
205 }
206 print "Must specify 0 or 3 options!";
Patrick Jenkinsf58473f2006-07-27 01:03:46 +0000207}
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000208
209if (@ARGV == 3) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000210 $CVSRootDir = $ARGV[0];
211 $BuildDir = $ARGV[1];
212 $WebDir = $ARGV[2];
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000213}
214
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000215if ($CVSRootDir eq "" or
216 $BuildDir eq "" or
217 $WebDir eq "") {
218 die("please specify a cvs root directory, a build directory, and a ".
Patrick Jenkinsf58473f2006-07-27 01:03:46 +0000219 "web directory");
220 }
221
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000222if ($nickname eq "") {
223 die ("Please invoke NewNightlyTest.pl with command line option " .
224 "\"-nickname <nickname>\"");
Patrick Jenkins514e2582006-07-20 22:28:43 +0000225}
Patrick Jenkins1cd46912006-07-27 01:17:17 +0000226
Jim Laskey27b8ba02006-09-28 17:49:20 +0000227if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000228 $BUILDTYPE = "debug";
Patrick Jenkins26ba6092006-07-23 22:57:28 +0000229}
Patrick Jenkins514e2582006-07-20 22:28:43 +0000230
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000231##############################################################
232#
233#define the file names we'll use
234#
235##############################################################
236my $Prefix = "$WebDir/$DATE";
237my $BuildLog = "$Prefix-Build-Log.txt";
Reid Spencerd0b08792007-04-03 08:28:44 +0000238my $COLog = "$Prefix-CVS-Log.txt";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000239my $OldenTestsLog = "$Prefix-Olden-tests.txt";
240my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
241my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
Patrick Jenkins26ba6092006-07-23 22:57:28 +0000242my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000243my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
244my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
245my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
246if (! -d $WebDir) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000247 mkdir $WebDir, 0777;
Patrick Jenkins03137752006-08-21 20:45:57 +0000248 if($VERBOSE){
249 warn "$WebDir did not exist; creating it.\n";
250 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000251}
252
253if ($VERBOSE) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000254 print "INITIALIZED\n";
Reid Spencerd0b08792007-04-03 08:28:44 +0000255 if ($USESVN) {
256 print "SVN URL = $SVNURL\n";
257 } else {
258 print "CVS Root = $CVSRootDir\n";
259 }
260 print "COLog = $COLog\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000261 print "BuildDir = $BuildDir\n";
262 print "WebDir = $WebDir\n";
263 print "Prefix = $Prefix\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000264 print "BuildLog = $BuildLog\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000265}
266
267##############################################################
268#
269# Helper functions
270#
271##############################################################
272sub GetDir {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000273 my $Suffix = shift;
274 opendir DH, $WebDir;
275 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
276 closedir DH;
277 return @Result;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000278}
279
280#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
281#
282# DiffFiles - Diff the current version of the file against the last version of
283# the file, reporting things added and removed. This is used to report, for
284# example, added and removed warnings. This returns a pair (added, removed)
285#
286#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
287sub DiffFiles {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000288 my $Suffix = shift;
289 my @Others = GetDir $Suffix;
290 if (@Others == 0) { # No other files? We added all entries...
291 return (`cat $WebDir/$DATE$Suffix`, "");
292 }
293# Diff the files now...
294 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
295 my $Added = join "\n", grep /^</, @Diffs;
296 my $Removed = join "\n", grep /^>/, @Diffs;
297 $Added =~ s/^< //gm;
298 $Removed =~ s/^> //gm;
299 return ($Added, $Removed);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000300}
301
302#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
303#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
304sub GetRegex { # (Regex with ()'s, value)
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000305 $_[1] =~ /$_[0]/m;
306 return $1
307 if (defined($1));
308 return "0";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000309}
310
311#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
312#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
313sub GetRegexNum {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000314 my ($Regex, $Num, $Regex2, $File) = @_;
315 my @Items = split "\n", `grep '$Regex' $File`;
316 return GetRegex $Regex2, $Items[$Num];
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000317}
318
319#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
320#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
321sub ChangeDir { # directory, logical name
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000322 my ($dir,$name) = @_;
323 chomp($dir);
324 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
325 $result = chdir($dir);
326 if (!$result) {
327 print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
328 return false;
329 }
330 return true;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000331}
332
333#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
334#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
335sub ReadFile {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000336 if (open (FILE, $_[0])) {
337 undef $/;
338 my $Ret = <FILE>;
339 close FILE;
340 $/ = '\n';
341 return $Ret;
342 } else {
343 print "Could not open file '$_[0]' for reading!\n";
344 return "";
345 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000346}
347
348#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
349#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
350sub WriteFile { # (filename, contents)
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000351 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
352 print FILE $_[1];
353 close FILE;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000354}
355
356#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
357#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
358sub CopyFile { #filename, newfile
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000359 my ($file, $newfile) = @_;
360 chomp($file);
361 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
362 copy($file, $newfile);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000363}
364
365#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
366#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
367sub AddRecord {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000368 my ($Val, $Filename,$WebDir) = @_;
369 my @Records;
370 if (open FILE, "$WebDir/$Filename") {
371 @Records = grep !/$DATE/, split "\n", <FILE>;
372 close FILE;
373 }
374 push @Records, "$DATE: $Val";
375 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000376}
377
378#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
379#
380# FormatTime - Convert a time from 1m23.45 into 83.45
381#
382#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
383sub FormatTime {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000384 my $Time = shift;
385 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
386 $Time = sprintf("%7.4f", $1*60.0+$2);
387 }
388 return $Time;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000389}
390
391#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000392#
393# This function is meant to read in the dejagnu sum file and
394# return a string with only the results (i.e. PASS/FAIL/XPASS/
395# XFAIL).
396#
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000397#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
398sub GetDejagnuTestResults { # (filename, log)
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000399 my ($filename, $DejagnuLog) = @_;
400 my @lines;
401 $/ = "\n"; #Make sure we're going line at a time.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000402
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000403 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000404
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000405 if (open SRCHFILE, $filename) {
406 # Process test results
407 while ( <SRCHFILE> ) {
408 if ( length($_) > 1 ) {
409 chomp($_);
Jim Laskey01d7bcf2006-09-20 09:20:22 +0000410 if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\/test\/(.*)$/ ) {
411 push(@lines, "$1: test/$2");
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000412 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000413 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000414 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000415 }
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000416 close SRCHFILE;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000417
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000418 my $content = join("\n", @lines);
419 return $content;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000420}
421
422
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000423
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000424#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
425#
426# This function acts as a mini web browswer submitting data
427# to our central server via the post method
428#
429#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
430sub SendData{
431 $host = $_[0];
432 $file = $_[1];
433 $variables=$_[2];
434
435 $port=80;
436 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
Patrick Jenkinsadea55e2006-07-17 16:41:19 +0000437 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000438 die "Bad socket\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000439 connect SOCK, $socketaddr or die "Bad connection\n";
440 select((select(SOCK), $| = 1)[0]);
441
442 #creating content here
443 my $content;
444 foreach $key (keys (%$variables)){
445 $value = $variables->{$key};
446 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
447 $content .= "$key=$value&";
448 }
449
450 $length = length($content);
451
452 my $send= "POST $file HTTP/1.0\n";
453 $send.= "Content-Type: application/x-www-form-urlencoded\n";
454 $send.= "Content-length: $length\n\n";
455 $send.= "$content";
456
Patrick Jenkinse8501eb2006-08-07 01:54:37 +0000457 print SOCK $send;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000458 my $result;
459 while(<SOCK>){
460 $result .= $_;
461 }
462 close(SOCK);
463
464 my $sentdata="";
Patrick Jenkins4c4e3562006-07-07 21:40:34 +0000465 foreach $x (keys (%$variables)){
Patrick Jenkins7267bd62006-07-10 18:35:41 +0000466 $value = $variables->{$x};
467 $sentdata.= "$x => $value\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000468 }
469 WriteFile "$Prefix-sentdata.txt", $sentdata;
Patrick Jenkins4c4e3562006-07-07 21:40:34 +0000470
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000471
472 return $result;
473}
474
Patrick Jenkins215b48f2006-07-07 18:50:51 +0000475##############################################################
476#
477# Getting Start timestamp
478#
479##############################################################
Patrick Jenkinsb67e1182006-07-21 21:43:09 +0000480$starttime = `date "+20%y-%m-%d %H:%M:%S"`;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000481
482##############################################################
483#
484# Create the CVS repository directory
485#
486##############################################################
487if (!$NOCHECKOUT) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000488 if (-d $BuildDir) {
489 if (!$NOREMOVE) {
490 if ( $VERBOSE ) {
491 print "Build directory exists! Removing it\n";
492 }
493 system "rm -rf $BuildDir";
Reid Spencerd0b08792007-04-03 08:28:44 +0000494 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000495 } else {
Jim Laskey6d8a1b72006-09-15 17:03:36 +0000496 if ( $VERBOSE ) {
497 print "Build directory exists!\n";
498 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000499 }
Jim Laskey6d8a1b72006-09-15 17:03:36 +0000500 } else {
Reid Spencerd0b08792007-04-03 08:28:44 +0000501 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000502 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000503}
Reid Spencerd0b08792007-04-03 08:28:44 +0000504ChangeDir( $BuildDir, "checkout directory" );
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000505
506
507##############################################################
508#
Reid Spencerd0b08792007-04-03 08:28:44 +0000509# Check out the llvm tree, using either SVN or CVS
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000510#
511##############################################################
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000512if (!$NOCHECKOUT) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000513 if ( $VERBOSE ) {
514 print "CHECKOUT STAGE:\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000515 }
Reid Spencerd0b08792007-04-03 08:28:44 +0000516 if ($USESVN) {
517 my $SVNCMD = "$NICE svn co $SVNURL";
518 if ($VERBOSE) {
519 print "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
520 "$SVNCMD/llvm-test/trunk llvm-test ) > $COLog 2>&1\n";
521 system "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
522 "$SVNCMD/llvm-test/trunk llvm-test ) > $COLog 2>&1\n";
523 }
524 } else {
525 my $CVSOPT = "";
526 $CVSOPT = "-z3" # Use compression if going over ssh.
527 if $CVSRootDir =~ /^:ext:/;
528 my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co -P $CVSCOOPT";
529 print "( time -p $CVSCMD llvm; cd llvm/projects ; " .
530 "$CVSCMD llvm-test ) > $COLog 2>&1";
531 system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
532 "$CVSCMD llvm-test ) > $COLog 2>&1";
533 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000534}
Reid Spencerd0b08792007-04-03 08:28:44 +0000535ChangeDir( $BuildDir , "Checkout directory") ;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000536ChangeDir( "llvm" , "llvm source directory") ;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000537
538##############################################################
539#
540# Get some static statistics about the current state of CVS
541#
542# This can probably be put on the server side
543#
544##############################################################
Reid Spencerd0b08792007-04-03 08:28:44 +0000545my $CheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $COLog`;
546my $CheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $COLog`;
547my $CheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $COLog`;
548my $CheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000549
Reid Spencerd0b08792007-04-03 08:28:44 +0000550my $NumFilesInCVS = 0;
551my $NumDirsInCVS = 0;
552if ($USESVN) {
553 $NumFilesInCVS = `egrep '^A' $COLog | wc -l` + 0;
554 $NumDirsInCVS = `sed -e 's#/[^/]*$##' $COLog | sort | uniq | wc -l` + 0;
555} else {
556 $NumFilesInCVS = `egrep '^U' $COLog | wc -l` + 0;
557 $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $COLog | wc -l` + 0;
558}
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000559
560##############################################################
561#
562# Extract some information from the CVS history... use a hash so no duplicate
563# stuff is stored. This gets the history from the previous days worth
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000564# of cvs activity and parses it.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000565#
566##############################################################
567
568my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
569
Reid Spencerd0b08792007-04-03 08:28:44 +0000570if (!$NOCVSSTATS) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000571 if ($VERBOSE) { print "CVS HISTORY ANALYSIS STAGE\n"; }
Reid Spencerd0b08792007-04-03 08:28:44 +0000572
573 if ($USESVN) {
574 my $delimiter = "----------------------------------------------------" .
575 "--------------------\n";
576 @SVNHistory = split $delimiter, `svn log --verbose -r{$DATE}:HEAD`;
577
578# Skip very first entry.
579 shift @SVNHistory;
580 foreach $Record (@SVNHistory) {
581 my (@Lines, @Fields);
582 my ($Rev, $Author, $StrTime, $LogLines, $Time);
583 @Lines = split "\n", $Record;
584# print join"\n", @Lines;
585
586 ($Rev, $Author, $StrTime, $LogLines) = split ' \| ', $Lines[0];
587 $Time = str2time($StrTime);
588 if (time() - $Time > 24*3600) {
589 next;
590 }
591
592 $UsersCommitted{$Author} = 1;
593
594 #print $Rev, $Author, $Time, $LogLines, "\n";
595
596 my $i = 2;
597 while ($Lines[$i] ne '') {
598 my ($Type, $Filename, $FromFile, $FromRev);
599 #print $Lines[$i], "\n";
600
601 if ($Lines[$i] =~ / ([MAD]) ([^ ]+) \(from ([^ ]+):([^ ]+)\)/) {
602 ($Type, $Filename, $FromFile, $FromRev) = ($1, $2, $3, $4);
603 } elsif ($Lines[$i] =~ / ([MAD]) ([^ ]+)/) {
604 ($Type, $Filename, $FromFile, $FromRev) = ($1, $2, "", "");
605 } else {
606 print "UNMATCHABLE: $Lines[$i]\n";
607 }
608
609 if ($Type eq 'M') { # Modified
610 $ModifiedFiles{$Filename} = 1;
611 } elsif ($Type eq 'A') { # Added
612 if ($FromFile eq "") { # File was added
613 $AddedFiles{$Filename} = 1;
614 } else { #File was added from another file - moved or copied.
615 $MovedFiles{$Filename} = 1;
616 }
617 } elsif ($Type eq 'D') { # Removed
618 $RemovedFiles{$Filename} = 1;
619 } else {
620 print "INVALID TYPE: $Type";
621 }
622
623 #print $Filename, "\n";
624 #print $Type, $File, $FromFile, $FromRev, "\n";
625 ++$i;
626 }
627 }
628 } else {
629 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000630#print join "\n", @CVSHistory; print "\n";
631
Reid Spencerd0b08792007-04-03 08:28:44 +0000632 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000633
634# Loop over every record from the CVS history, filling in the hashes.
Reid Spencerd0b08792007-04-03 08:28:44 +0000635 foreach $File (@CVSHistory) {
636 my ($Type, $Date, $UID, $Rev, $Filename);
637 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
638 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
639 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
640 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
641 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
642 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
643 } else {
644 print "UNMATCHABLE: $File\n";
645 next;
646 }
647 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
648
649 if ($Filename =~ /^llvm/) {
650 if ($Type eq 'M') { # Modified
651 $ModifiedFiles{$Filename} = 1;
652 $UsersCommitted{$UID} = 1;
653 } elsif ($Type eq 'A') { # Added
654 $AddedFiles{$Filename} = 1;
655 $UsersCommitted{$UID} = 1;
656 } elsif ($Type eq 'R') { # Removed
657 $RemovedFiles{$Filename} = 1;
658 $UsersCommitted{$UID} = 1;
659 } else {
660 $UsersUpdated{$UID} = 1;
661 }
662 }
663 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000664
Reid Spencerd0b08792007-04-03 08:28:44 +0000665 my $TestError = 1;
666 } #$USESVN
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000667}#!NOCVSSTATS
668
669my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
670my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
671my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
672my $UserCommitList = join "\n", sort keys %UsersCommitted;
673my $UserUpdateList = join "\n", sort keys %UsersUpdated;
674
675##############################################################
676#
677# Build the entire tree, saving build messages to the build log
678#
679##############################################################
680if (!$NOCHECKOUT && !$NOBUILD) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000681 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
682 if ( $VERBOSE ) {
683 print "CONFIGURE STAGE:\n";
684 print "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
685 "> $BuildLog 2>&1\n";
686 }
687 system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
688 "> $BuildLog 2>&1";
689 if ( $VERBOSE ) {
690 print "BUILD STAGE:\n";
691 print "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1\n";
692 }
693 # Build the entire tree, capturing the output into $BuildLog
694 system "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000695}
696
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000697##############################################################
698#
699# Get some statistics about the build...
700#
701##############################################################
702#this can de done on server
703#my @Linked = split '\n', `grep Linking $BuildLog`;
704#my $NumExecutables = scalar(grep(/executable/, @Linked));
705#my $NumLibraries = scalar(grep(!/executable/, @Linked));
706#my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
707
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000708# Get the number of lines of source code. Must be here after the build is done
709# because countloc.sh uses the llvm-config script which must be built.
Patrick Jenkinsb993b0a2006-08-16 22:18:41 +0000710my $LOC = `utils/countloc.sh -topdir $BuildDir/llvm`;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000711
712# Get the time taken by the configure script
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000713my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
714my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
715my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
716my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
717
718$ConfigTime=-1 unless $ConfigTime;
719$ConfigWallTime=-1 unless $ConfigWallTime;
720
721my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
722my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
723my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
724my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
725
726$BuildTime=-1 unless $BuildTime;
727$BuildWallTime=-1 unless $BuildWallTime;
728
729my $BuildError = 0, $BuildStatus = "OK";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000730if ($NOBUILD) {
731 $BuildStatus = "Skipped by user";
732 $BuildError = 1;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000733}
Patrick Jenkinsf58473f2006-07-27 01:03:46 +0000734elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000735 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
736 $BuildStatus = "Error: compilation aborted";
737 $BuildError = 1;
738 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000739}
740if ($BuildError) { $NODEJAGNU=1; }
741
Patrick Jenkins169357e2006-07-23 21:38:07 +0000742my $a_file_sizes="";
743my $o_file_sizes="";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000744if (!$BuildError) {
745 print "Organizing size of .o and .a files\n"
746 if ( $VERBOSE );
747 ChangeDir( "$BuildDir/llvm", "Build Directory" );
748 $afiles.= `find utils/ -iname '*.a' -ls`;
749 $afiles.= `find lib/ -iname '*.a' -ls`;
750 $afiles.= `find tools/ -iname '*.a' -ls`;
751 if($BUILDTYPE eq "release"){
Jim Laskey7a8efce2006-09-29 17:31:45 +0000752 $afiles.= `find Release/ -iname '*.a' -ls`;
Jim Laskey27b8ba02006-09-28 17:49:20 +0000753 } elsif($BUILDTYPE eq "release-asserts") {
754 $afiles.= `find Release-Asserts/ -iname '*.a' -ls`;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000755 } else {
756 $afiles.= `find Debug/ -iname '*.a' -ls`;
757 }
758
759 $ofiles.= `find utils/ -iname '*.o' -ls`;
760 $ofiles.= `find lib/ -iname '*.o' -ls`;
761 $ofiles.= `find tools/ -iname '*.o' -ls`;
762 if($BUILDTYPE eq "release"){
Jim Laskey7a8efce2006-09-29 17:31:45 +0000763 $ofiles.= `find Release/ -iname '*.o' -ls`;
Jim Laskey27b8ba02006-09-28 17:49:20 +0000764 } elsif($BUILDTYPE eq "release-asserts") {
765 $ofiles.= `find Release-Asserts/ -iname '*.o' -ls`;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000766 } else {
767 $ofiles.= `find Debug/ -iname '*.o' -ls`;
768 }
769
770 @AFILES = split "\n", $afiles;
771 $a_file_sizes="";
772 foreach $x (@AFILES){
773 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
774 $a_file_sizes.="$1 $2 $BUILDTYPE\n";
775 }
776 @OFILES = split "\n", $ofiles;
777 $o_file_sizes="";
778 foreach $x (@OFILES){
779 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
780 $o_file_sizes.="$1 $2 $BUILDTYPE\n";
781 }
782} else {
783 $a_file_sizes="No data due to a bad build.";
784 $o_file_sizes="No data due to a bad build.";
Patrick Jenkins169357e2006-07-23 21:38:07 +0000785}
Patrick Jenkins169357e2006-07-23 21:38:07 +0000786
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000787##############################################################
788#
789# Running dejagnu tests
790#
791##############################################################
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000792my $DejangnuTestResults=""; # String containing the results of the dejagnu
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000793my $dejagnu_output = "$DejagnuTestsLog";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000794if (!$NODEJAGNU) {
795 if($VERBOSE) {
796 print "DEJAGNU FEATURE/REGRESSION TEST STAGE:\n";
797 print "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1\n";
798 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000799
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000800 #Run the feature and regression tests, results are put into testrun.sum
801 #Full log in testrun.log
802 system "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1";
803
804 #Copy the testrun.log and testrun.sum to our webdir
805 CopyFile("test/testrun.log", $DejagnuLog);
806 CopyFile("test/testrun.sum", $DejagnuSum);
807 #can be done on server
808 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
809 $unexpfail_tests = $DejagnuTestResults;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000810}
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000811
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000812#Extract time of dejagnu tests
813my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
814my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
815$DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
816$DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000817$DejagnuTestResults =
818 "Dejagnu skipped by user choice." unless $DejagnuTestResults;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000819$DejagnuTime = "0.0" unless $DejagnuTime;
820$DejagnuWallTime = "0.0" unless $DejagnuWallTime;
821
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000822##############################################################
823#
824# Get warnings from the build
825#
826##############################################################
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000827if (!$NODEJAGNU) {
828 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
829 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
830 my @Warnings;
831 my $CurDir = "";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000832
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000833 foreach $Warning (@Warn) {
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000834 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000835 $CurDir = $1; # Keep track of directory warning is in...
836 # Remove buildir prefix if included
837 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { $CurDir = $1; }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000838 } else {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000839 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000840 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000841 }
842 my $WarningsFile = join "\n", @Warnings;
843 $WarningsFile =~ s/:[0-9]+:/::/g;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000844
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000845 # Emit the warnings file, so we can diff...
846 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
847 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000848
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000849 # Output something to stdout if something has changed
850 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
851 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000852
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000853 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
854 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000855
856} #endif !NODEGAGNU
857
858##############################################################
859#
860# If we built the tree successfully, run the nightly programs tests...
861#
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000862# A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
863# "External")
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000864#
865##############################################################
866sub TestDirectory {
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000867 my $SubDir = shift;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000868 ChangeDir( "$BuildDir/llvm/projects/llvm-test/$SubDir",
869 "Programs Test Subdirectory" ) || return ("", "");
870
871 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
872
873 # Run the programs tests... creating a report.nightly.csv file
874 if (!$NOTEST) {
875 if( $VERBOSE) {
876 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
877 "TEST=nightly > $ProgramTestLog 2>&1\n";
878 }
879 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000880 "TEST=nightly > $ProgramTestLog 2>&1";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000881 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
882 }
883
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000884 my $ProgramsTable;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000885 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000886 $TestError = 1;
887 $ProgramsTable="Error running test $SubDir\n";
888 print "ERROR TESTING\n";
889 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
890 $TestError = 1;
891 $ProgramsTable="Makefile error running tests $SubDir!\n";
892 print "ERROR TESTING\n";
893 } else {
894 $TestError = 0;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000895 #
896 # Create a list of the tests which were run...
897 #
898 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000899 "| sort > $Prefix-$SubDir-Tests.txt";
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000900 }
901 $ProgramsTable = ReadFile "report.nightly.csv";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000902
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000903 ChangeDir( "../../..", "Programs Test Parent Directory" );
904 return ($ProgramsTable, $llcbeta_options);
Patrick Jenkins9e384ab2006-08-14 16:07:14 +0000905} #end sub TestDirectory
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000906
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000907##############################################################
908#
909# Calling sub TestDirectory
910#
911##############################################################
Patrick Jenkinsc281b0d2006-07-27 19:00:01 +0000912if (!$BuildError) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000913 if ( $VERBOSE ) {
Patrick Jenkinse631c4a2006-08-04 17:55:01 +0000914 print "SingleSource TEST STAGE\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000915 }
916 ($SingleSourceProgramsTable, $llcbeta_options) =
917 TestDirectory("SingleSource");
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000918 WriteFile "$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
Patrick Jenkins4257ccb2006-08-08 02:03:53 +0000919 if ( $VERBOSE ) {
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000920 print "MultiSource TEST STAGE\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000921 }
922 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000923 WriteFile "$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000924 if ( ! $NOEXTERNALS ) {
925 if ( $VERBOSE ) {
926 print "External TEST STAGE\n";
927 }
928 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000929 WriteFile "$Prefix-External-Performance.txt", $ExternalProgramsTable;
930 system "cat $Prefix-SingleSource-Tests.txt " .
931 "$Prefix-MultiSource-Tests.txt ".
932 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
933 system "cat $Prefix-SingleSource-Performance.txt " .
934 "$Prefix-MultiSource-Performance.txt ".
935 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000936 } else {
937 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
938 if ( $VERBOSE ) {
939 print "External TEST STAGE SKIPPED\n";
940 }
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000941 system "cat $Prefix-SingleSource-Tests.txt " .
942 "$Prefix-MultiSource-Tests.txt ".
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000943 " | sort > $Prefix-Tests.txt";
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000944 system "cat $Prefix-SingleSource-Performance.txt " .
945 "$Prefix-MultiSource-Performance.txt ".
946 " | sort > $Prefix-Performance.txt";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000947 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000948
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000949 ##############################################################
950 #
951 #
952 # gathering tests added removed broken information here
953 #
954 #
955 ##############################################################
956 my $dejagnu_test_list = ReadFile "$Prefix-Tests.txt";
957 my @DEJAGNU = split "\n", $dejagnu_test_list;
958 my ($passes, $fails, $xfails) = "";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000959
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000960 if(!$NODEJAGNU) {
961 for ($x=0; $x<@DEJAGNU; $x++) {
962 if ($DEJAGNU[$x] =~ m/^PASS:/) {
963 $passes.="$DEJAGNU[$x]\n";
964 }
965 elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
966 $fails.="$DEJAGNU[$x]\n";
967 }
968 elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
969 $xfails.="$DEJAGNU[$x]\n";
970 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000971 }
972 }
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000973
974} #end if !$BuildError
975
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000976
977##############################################################
978#
979# If we built the tree successfully, runs of the Olden suite with
980# LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
981#
982##############################################################
983if (!$BuildError) {
Patrick Jenkinsd7210f92006-08-02 18:37:40 +0000984 if ( $VERBOSE ) { print "OLDEN TEST SUITE STAGE\n"; }
985 my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
986 $MachCodeSize) = ("","","","","","","");
987 if (!$NORUNNINGTESTS) {
988 ChangeDir( "$BuildDir/llvm/projects/llvm-test/MultiSource/Benchmarks/Olden",
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000989 "Olden Test Directory");
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000990
Patrick Jenkinsd7210f92006-08-02 18:37:40 +0000991 # Clean out previous results...
992 system "$NICE $MAKECMD $MAKEOPTS clean > /dev/null 2>&1";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000993
Patrick Jenkinsd7210f92006-08-02 18:37:40 +0000994 # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE and
995 # GET_STABLE_NUMBERS enabled!
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000996 if( $VERBOSE ) {
997 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
998 "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
999 "> /dev/null 2>&1\n";
1000 }
1001 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
1002 "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
1003 "> /dev/null 2>&1";
1004 system "cp report.nightly.csv $OldenTestsLog";
Patrick Jenkinsd7210f92006-08-02 18:37:40 +00001005 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001006}
1007
Patrick Jenkins215b48f2006-07-07 18:50:51 +00001008##############################################################
1009#
1010# Getting end timestamp
1011#
1012##############################################################
Patrick Jenkinsb67e1182006-07-21 21:43:09 +00001013$endtime = `date "+20%y-%m-%d %H:%M:%S"`;
Patrick Jenkins215b48f2006-07-07 18:50:51 +00001014
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001015
1016##############################################################
1017#
1018# Place all the logs neatly into one humungous file
1019#
1020##############################################################
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001021if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
1022
1023$machine_data = "uname: ".`uname -a`.
1024 "hardware: ".`uname -m`.
1025 "os: ".`uname -sr`.
1026 "name: ".`uname -n`.
1027 "date: ".`date \"+20%y-%m-%d\"`.
1028 "time: ".`date +\"%H:%M:%S\"`;
1029
1030my @CVS_DATA;
1031my $cvs_data;
Reid Spencerd0b08792007-04-03 08:28:44 +00001032@CVS_DATA = ReadFile "$COLog";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001033$cvs_data = join("\n", @CVS_DATA);
1034
1035my @BUILD_DATA;
1036my $build_data;
1037@BUILD_DATA = ReadFile "$BuildLog";
1038$build_data = join("\n", @BUILD_DATA);
1039
Patrick Jenkins03137752006-08-21 20:45:57 +00001040my (@DEJAGNU_LOG, @DEJAGNU_SUM, @DEJAGNULOG_FULL, @GCC_VERSION);
1041my ($dejagnutests_log ,$dejagnutests_sum, $dejagnulog_full) = "";
1042my ($gcc_version, $gcc_version_long) = "";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001043
Patrick Jenkinsad6f7582006-08-22 18:11:19 +00001044$gcc_version_long="";
1045if ($GCCPATH ne "") {
1046 $gcc_version_long = `$GCCPATH/gcc --version`;
1047} else {
1048 $gcc_version_long = `gcc --version`;
1049}
1050@GCC_VERSION = split '\n', $gcc_version_long;
1051$gcc_version = $GCC_VERSION[0];
1052
Patrick Jenkins03137752006-08-21 20:45:57 +00001053if(!$BuildError){
1054 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
1055 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
1056 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
1057 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001058
Patrick Jenkins03137752006-08-21 20:45:57 +00001059 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
1060 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
Patrick Jenkins79fbf7f2006-07-14 20:44:09 +00001061}
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001062
1063##############################################################
1064#
1065# Send data via a post request
1066#
1067##############################################################
1068
1069if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
1070
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001071my %hash_of_data = (
1072 'machine_data' => $machine_data,
1073 'build_data' => $build_data,
1074 'gcc_version' => $gcc_version,
1075 'nickname' => $nickname,
1076 'dejagnutime_wall' => $DejagnuWallTime,
1077 'dejagnutime_cpu' => $DejagnuTime,
Reid Spencerd0b08792007-04-03 08:28:44 +00001078 'cvscheckouttime_wall' => $CheckoutTime_Wall,
1079 'cvscheckouttime_cpu' => $CheckoutTime_CPU,
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001080 'configtime_wall' => $ConfigWallTime,
1081 'configtime_cpu'=> $ConfigTime,
1082 'buildtime_wall' => $BuildWallTime,
1083 'buildtime_cpu' => $BuildTime,
1084 'warnings' => $WarningsFile,
1085 'cvsusercommitlist' => $UserCommitList,
1086 'cvsuserupdatelist' => $UserUpdateList,
1087 'cvsaddedfiles' => $CVSAddedFiles,
1088 'cvsmodifiedfiles' => $CVSModifiedFiles,
1089 'cvsremovedfiles' => $CVSRemovedFiles,
1090 'lines_of_code' => $LOC,
1091 'cvs_file_count' => $NumFilesInCVS,
1092 'cvs_dir_count' => $NumDirsInCVS,
1093 'buildstatus' => $BuildStatus,
1094 'singlesource_programstable' => $SingleSourceProgramsTable,
1095 'multisource_programstable' => $MultiSourceProgramsTable,
1096 'externalsource_programstable' => $ExternalProgramsTable,
1097 'llcbeta_options' => $multisource_llcbeta_options,
1098 'warnings_removed' => $WarningsRemoved,
1099 'warnings_added' => $WarningsAdded,
1100 'passing_tests' => $passes,
1101 'expfail_tests' => $xfails,
1102 'unexpfail_tests' => $fails,
1103 'all_tests' => $dejagnu_test_list,
1104 'new_tests' => "",
1105 'removed_tests' => "",
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +00001106 'dejagnutests_results' => $DejagnuTestResults,
1107 'dejagnutests_log' => $dejagnulog_full,
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001108 'starttime' => $starttime,
1109 'endtime' => $endtime,
1110 'o_file_sizes' => $o_file_sizes,
1111 'a_file_sizes' => $a_file_sizes
1112);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001113
1114$TESTING = 0;
1115
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001116if ($TESTING) {
1117 print "============================\n";
1118 foreach $x(keys %hash_of_data){
1119 print "$x => $hash_of_data{$x}\n";
1120 }
1121} else {
1122 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
1123 if( $VERBOSE) { print "============================\n$response"; }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001124}
1125
1126##############################################################
1127#
1128# Remove the cvs tree...
1129#
1130##############################################################
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001131system ( "$NICE rm -rf $BuildDir")
1132 if (!$NOCHECKOUT and !$NOREMOVE);
1133system ( "$NICE rm -rf $WebDir")
1134 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);