blob: 956a952626e4fa4eaaf1a7e4d2aca00ccd39b1fd [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;
4use Socket;
5
6#
7# Program: NewNightlyTest.pl
8#
9# Synopsis: Perform a series of tests which are designed to be run nightly.
10# This is used to keep track of the status of the LLVM tree, tracking
11# regressions and performance changes. Submits this information
Reid Spencerfa34d7b2006-08-13 09:53:02 +000012# to llvm.org where it is placed into the nightlytestresults database.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000013#
14# Modified heavily by Patrick Jenkins, July 2006
15#
16# Syntax: NightlyTest.pl [OPTIONS] [CVSROOT BUILDDIR WEBDIR]
17# where
18# OPTIONS may include one or more of the following:
19# -nocheckout Do not create, checkout, update, or configure
20# the source tree.
21# -noremove Do not remove the BUILDDIR after it has been built.
Patrick Jenkinsa5c04d62006-07-07 17:31:38 +000022# -noremoveresults Do not remove the WEBDIR after it has been built.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000023# -nobuild Do not build llvm. If tests are enabled perform them
24# on the llvm build specified in the build directory
25# -notest Do not even attempt to run the test programs. Implies
26# -norunningtests.
27# -norunningtests Do not run the Olden benchmark suite with
28# LARGE_PROBLEM_SIZE enabled.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000029# -nodejagnu Do not run feature or regression tests
30# -parallel Run two parallel jobs with GNU Make.
31# -release Build an LLVM Release version
Jim Laskey27b8ba02006-09-28 17:49:20 +000032# -release-asserts Build an LLVM ReleaseAsserts version
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000033# -enable-llcbeta Enable testing of beta features in llc.
Reid Spencer2bae1f52006-11-24 20:34:16 +000034# -enable-lli Enable testing of lli (interpreter) features, default is off
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000035# -disable-llc Disable LLC tests in the nightly tester.
36# -disable-jit Disable JIT tests in the nightly tester.
37# -disable-cbe Disable C backend tests in the nightly tester.
38# -verbose Turn on some debug output
39# -debug Print information useful only to maintainers of this script.
40# -nice Checkout/Configure/Build with "nice" to reduce impact
41# on busy servers.
42# -f2c Next argument specifies path to F2C utility
43# -nickname The next argument specifieds the nickname this script
44# will submit to the nightlytest results repository.
45# -gccpath Path to gcc/g++ used to build LLVM
46# -cvstag Check out a specific CVS tag to build LLVM (useful for
47# testing release branches)
48# -target Specify the target triplet
49# -cflags Next argument specifies that C compilation options that
50# override the default.
51# -cxxflags Next argument specifies that C++ compilation options that
52# override the default.
53# -ldflags Next argument specifies that linker options that override
54# the default.
Patrick Jenkins215b48f2006-07-07 18:50:51 +000055# -compileflags Next argument specifies extra options passed to make when
56# building LLVM.
Patrick Jenkins0e9402f2006-08-11 23:02:09 +000057# -use-gmake Use gmake instead of the default make command to build
Patrick Jenkins1cd46912006-07-27 01:17:17 +000058# llvm and run tests.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000059#
60# ---------------- Options to configure llvm-test ----------------------------
Patrick Jenkins215b48f2006-07-07 18:50:51 +000061# -extraflags Next argument specifies extra options that are passed to
62# compile the tests.
63# -noexternals Do not run the external tests (for cases where povray
64# or SPEC are not installed)
65# -with-externals Specify a directory where the external tests are located.
Patrick Jenkins0e9402f2006-08-11 23:02:09 +000066# -submit-server Specifies a server to submit the test results too. If this
67# option is not specified it defaults to
68# llvm.org. This is basically just the address of the
69# webserver
70# -submit-script Specifies which script to call on the submit server. If
71# this option is not specified it defaults to
Jim Laskey6d8a1b72006-09-15 17:03:36 +000072# /nightlytest/NightlyTestAccept.php. This is basically
Patrick Jenkins0e9402f2006-08-11 23:02:09 +000073# everything after the www.yourserver.org.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000074#
75# CVSROOT is the CVS repository from which the tree will be checked out,
76# specified either in the full :method:user@host:/dir syntax, or
77# just /dir if using a local repo.
78# BUILDDIR is the directory where sources for this test run will be checked out
79# AND objects for this test run will be built. This directory MUST NOT
80# exist before the script is run; it will be created by the cvs checkout
81# process and erased (unless -noremove is specified; see above.)
82# WEBDIR is the directory into which the test results web page will be written,
83# AND in which the "index.html" is assumed to be a symlink to the most recent
84# copy of the results. This directory will be created if it does not exist.
85# LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
86# to. This is the same as you would have for a normal LLVM build.
87#
88##############################################################
89#
90# Getting environment variables
91#
92##############################################################
Reid Spencerfa34d7b2006-08-13 09:53:02 +000093my $HOME = $ENV{'HOME'};
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000094my $CVSRootDir = $ENV{'CVSROOT'};
Reid Spencerfa34d7b2006-08-13 09:53:02 +000095$CVSRootDir = "/home/vadve/shared/PublicCVS" unless $CVSRootDir;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000096my $BuildDir = $ENV{'BUILDDIR'};
Reid Spencerfa34d7b2006-08-13 09:53:02 +000097$BuildDir = "$HOME/buildtest" unless $BuildDir;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000098my $WebDir = $ENV{'WEBDIR'};
Reid Spencerfa34d7b2006-08-13 09:53:02 +000099$WebDir = "$HOME/cvs/testresults-X86" unless $WebDir;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000100
101##############################################################
102#
103# Calculate the date prefix...
104#
105##############################################################
106@TIME = localtime;
107my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
108my $DateString = strftime "%B %d, %Y", localtime;
109my $TestStartTime = gmtime() . "GMT<br>" . localtime() . " (local)";
110
111##############################################################
112#
113# Parse arguments...
114#
115##############################################################
116$CONFIGUREARGS="";
Patrick Jenkins49717a42006-07-21 01:39:42 +0000117$nickname="";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000118$NOTEST=0;
119$NORUNNINGTESTS=0;
Patrick Jenkins1cd46912006-07-27 01:17:17 +0000120$MAKECMD="make";
Patrick Jenkins0e9402f2006-08-11 23:02:09 +0000121$SUBMITSERVER = "llvm.org";
Jim Laskey6d8a1b72006-09-15 17:03:36 +0000122$SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000123
124while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000125 shift;
126 last if /^--$/; # Stop processing arguments on --
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000127
128 # List command line options here...
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000129 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
130 if (/^-nocvsstats$/) { $NOCVSSTATS = 1; next; }
131 if (/^-noremove$/) { $NOREMOVE = 1; next; }
132 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
133 if (/^-notest$/) { $NOTEST = 1; $NORUNNINGTESTS = 1; next; }
134 if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
135 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j2 -l3.0"; next; }
136 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
137 "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
Jim Laskey27b8ba02006-09-28 17:49:20 +0000138 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
139 "DISABLE-ASSERTIONS=1 ".
Reid Spencer93c456c2006-10-19 15:24:04 +0000140 "OPTIMIZE_OPTION=-O2";
141 $BUILDTYPE="release-asserts"; next;}
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000142 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
Reid Spencer2bae1f52006-11-24 20:34:16 +0000143 if (/^-enable-lli$/) { $PROGTESTOPTS .= " ENABLE_LLI=1";
144 $CONFIGUREARGS .= " --enable-lli"; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000145 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
146 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
147 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
148 $CONFIGUREARGS .= " --disable-jit"; next; }
149 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
150 if (/^-verbose$/) { $VERBOSE = 1; next; }
151 if (/^-debug$/) { $DEBUG = 1; next; }
152 if (/^-nice$/) { $NICE = "nice "; next; }
153 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
154 shift; next; }
155 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
156 shift; next; }
157 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
158 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
159 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
160 if (/^-gccpath/) { $CONFIGUREARGS .=
161 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
162 $GCCPATH=$ARGV[0]; shift; next; }
163 else { $GCCPATH=""; }
164 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
165 else { $CVSCOOPT="";}
166 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
167 shift; next; }
168 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
169 shift; next; }
170 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
171 shift; next; }
172 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
173 shift; next; }
174 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
175 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
176 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
177 if (/^-extraflags/) { $CONFIGUREARGS .=
178 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
179 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
180 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
181 if (/^-nobuild$/) { $NOBUILD = 1; next; }
182 print "Unknown option: $_ : ignoring!\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000183}
184
185if ($ENV{'LLVMGCCDIR'}) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000186 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000187}
188if ($CONFIGUREARGS !~ /--disable-jit/) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000189 $CONFIGUREARGS .= " --enable-jit";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000190}
191
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000192if (@ARGV != 0 and @ARGV != 3 and $VERBOSE) {
193 foreach $x (@ARGV) {
194 print "$x\n";
195 }
196 print "Must specify 0 or 3 options!";
Patrick Jenkinsf58473f2006-07-27 01:03:46 +0000197}
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000198
199if (@ARGV == 3) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000200 $CVSRootDir = $ARGV[0];
201 $BuildDir = $ARGV[1];
202 $WebDir = $ARGV[2];
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000203}
204
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000205if ($CVSRootDir eq "" or
206 $BuildDir eq "" or
207 $WebDir eq "") {
208 die("please specify a cvs root directory, a build directory, and a ".
Patrick Jenkinsf58473f2006-07-27 01:03:46 +0000209 "web directory");
210 }
211
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000212if ($nickname eq "") {
213 die ("Please invoke NewNightlyTest.pl with command line option " .
214 "\"-nickname <nickname>\"");
Patrick Jenkins514e2582006-07-20 22:28:43 +0000215}
Patrick Jenkins1cd46912006-07-27 01:17:17 +0000216
Jim Laskey27b8ba02006-09-28 17:49:20 +0000217if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000218 $BUILDTYPE = "debug";
Patrick Jenkins26ba6092006-07-23 22:57:28 +0000219}
Patrick Jenkins514e2582006-07-20 22:28:43 +0000220
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000221##############################################################
222#
223#define the file names we'll use
224#
225##############################################################
226my $Prefix = "$WebDir/$DATE";
227my $BuildLog = "$Prefix-Build-Log.txt";
Reid Spencer776964a2007-04-04 06:59:36 +0000228my $CVSLog = "$Prefix-CVS-Log.txt";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000229my $OldenTestsLog = "$Prefix-Olden-tests.txt";
230my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
231my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
Patrick Jenkins26ba6092006-07-23 22:57:28 +0000232my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000233my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
234my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
235my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
236if (! -d $WebDir) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000237 mkdir $WebDir, 0777;
Patrick Jenkins03137752006-08-21 20:45:57 +0000238 if($VERBOSE){
239 warn "$WebDir did not exist; creating it.\n";
240 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000241}
242
243if ($VERBOSE) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000244 print "INITIALIZED\n";
Reid Spencer776964a2007-04-04 06:59:36 +0000245 print "CVS Root = $CVSRootDir\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000246 print "BuildDir = $BuildDir\n";
247 print "WebDir = $WebDir\n";
248 print "Prefix = $Prefix\n";
Reid Spencer776964a2007-04-04 06:59:36 +0000249 print "CVSLog = $CVSLog\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000250 print "BuildLog = $BuildLog\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000251}
252
253##############################################################
254#
255# Helper functions
256#
257##############################################################
258sub GetDir {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000259 my $Suffix = shift;
260 opendir DH, $WebDir;
261 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
262 closedir DH;
263 return @Result;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000264}
265
266#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
267#
268# DiffFiles - Diff the current version of the file against the last version of
269# the file, reporting things added and removed. This is used to report, for
270# example, added and removed warnings. This returns a pair (added, removed)
271#
272#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
273sub DiffFiles {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000274 my $Suffix = shift;
275 my @Others = GetDir $Suffix;
276 if (@Others == 0) { # No other files? We added all entries...
277 return (`cat $WebDir/$DATE$Suffix`, "");
278 }
279# Diff the files now...
280 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
281 my $Added = join "\n", grep /^</, @Diffs;
282 my $Removed = join "\n", grep /^>/, @Diffs;
283 $Added =~ s/^< //gm;
284 $Removed =~ s/^> //gm;
285 return ($Added, $Removed);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000286}
287
288#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
289#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
290sub GetRegex { # (Regex with ()'s, value)
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000291 $_[1] =~ /$_[0]/m;
292 return $1
293 if (defined($1));
294 return "0";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000295}
296
297#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
298#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
299sub GetRegexNum {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000300 my ($Regex, $Num, $Regex2, $File) = @_;
301 my @Items = split "\n", `grep '$Regex' $File`;
302 return GetRegex $Regex2, $Items[$Num];
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000303}
304
305#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
306#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
307sub ChangeDir { # directory, logical name
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000308 my ($dir,$name) = @_;
309 chomp($dir);
310 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
311 $result = chdir($dir);
312 if (!$result) {
313 print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
314 return false;
315 }
316 return true;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000317}
318
319#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
320#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
321sub ReadFile {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000322 if (open (FILE, $_[0])) {
323 undef $/;
324 my $Ret = <FILE>;
325 close FILE;
326 $/ = '\n';
327 return $Ret;
328 } else {
329 print "Could not open file '$_[0]' for reading!\n";
330 return "";
331 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000332}
333
334#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
335#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
336sub WriteFile { # (filename, contents)
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000337 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
338 print FILE $_[1];
339 close FILE;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000340}
341
342#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
343#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
344sub CopyFile { #filename, newfile
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000345 my ($file, $newfile) = @_;
346 chomp($file);
347 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
348 copy($file, $newfile);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000349}
350
351#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
352#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
353sub AddRecord {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000354 my ($Val, $Filename,$WebDir) = @_;
355 my @Records;
356 if (open FILE, "$WebDir/$Filename") {
357 @Records = grep !/$DATE/, split "\n", <FILE>;
358 close FILE;
359 }
360 push @Records, "$DATE: $Val";
361 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000362}
363
364#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
365#
366# FormatTime - Convert a time from 1m23.45 into 83.45
367#
368#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
369sub FormatTime {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000370 my $Time = shift;
371 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
372 $Time = sprintf("%7.4f", $1*60.0+$2);
373 }
374 return $Time;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000375}
376
377#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000378#
379# This function is meant to read in the dejagnu sum file and
380# return a string with only the results (i.e. PASS/FAIL/XPASS/
381# XFAIL).
382#
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000383#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
384sub GetDejagnuTestResults { # (filename, log)
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000385 my ($filename, $DejagnuLog) = @_;
386 my @lines;
387 $/ = "\n"; #Make sure we're going line at a time.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000388
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000389 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000390
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000391 if (open SRCHFILE, $filename) {
392 # Process test results
393 while ( <SRCHFILE> ) {
394 if ( length($_) > 1 ) {
395 chomp($_);
Jim Laskey01d7bcf2006-09-20 09:20:22 +0000396 if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\/test\/(.*)$/ ) {
397 push(@lines, "$1: test/$2");
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000398 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000399 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000400 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000401 }
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000402 close SRCHFILE;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000403
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000404 my $content = join("\n", @lines);
405 return $content;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000406}
407
408
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000409
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000410#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
411#
412# This function acts as a mini web browswer submitting data
413# to our central server via the post method
414#
415#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
416sub SendData{
417 $host = $_[0];
418 $file = $_[1];
419 $variables=$_[2];
420
421 $port=80;
422 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
Patrick Jenkinsadea55e2006-07-17 16:41:19 +0000423 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000424 die "Bad socket\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000425 connect SOCK, $socketaddr or die "Bad connection\n";
426 select((select(SOCK), $| = 1)[0]);
427
428 #creating content here
429 my $content;
430 foreach $key (keys (%$variables)){
431 $value = $variables->{$key};
432 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
433 $content .= "$key=$value&";
434 }
435
436 $length = length($content);
437
438 my $send= "POST $file HTTP/1.0\n";
439 $send.= "Content-Type: application/x-www-form-urlencoded\n";
440 $send.= "Content-length: $length\n\n";
441 $send.= "$content";
442
Patrick Jenkinse8501eb2006-08-07 01:54:37 +0000443 print SOCK $send;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000444 my $result;
445 while(<SOCK>){
446 $result .= $_;
447 }
448 close(SOCK);
449
450 my $sentdata="";
Patrick Jenkins4c4e3562006-07-07 21:40:34 +0000451 foreach $x (keys (%$variables)){
Patrick Jenkins7267bd62006-07-10 18:35:41 +0000452 $value = $variables->{$x};
453 $sentdata.= "$x => $value\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000454 }
455 WriteFile "$Prefix-sentdata.txt", $sentdata;
Patrick Jenkins4c4e3562006-07-07 21:40:34 +0000456
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000457
458 return $result;
459}
460
Patrick Jenkins215b48f2006-07-07 18:50:51 +0000461##############################################################
462#
463# Getting Start timestamp
464#
465##############################################################
Patrick Jenkinsb67e1182006-07-21 21:43:09 +0000466$starttime = `date "+20%y-%m-%d %H:%M:%S"`;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000467
468##############################################################
469#
470# Create the CVS repository directory
471#
472##############################################################
473if (!$NOCHECKOUT) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000474 if (-d $BuildDir) {
475 if (!$NOREMOVE) {
476 if ( $VERBOSE ) {
477 print "Build directory exists! Removing it\n";
478 }
479 system "rm -rf $BuildDir";
Reid Spencer776964a2007-04-04 06:59:36 +0000480 mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000481 } else {
Jim Laskey6d8a1b72006-09-15 17:03:36 +0000482 if ( $VERBOSE ) {
483 print "Build directory exists!\n";
484 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000485 }
Jim Laskey6d8a1b72006-09-15 17:03:36 +0000486 } else {
Reid Spencer776964a2007-04-04 06:59:36 +0000487 mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000488 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000489}
Reid Spencer776964a2007-04-04 06:59:36 +0000490ChangeDir( $BuildDir, "CVS checkout directory" );
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000491
492
493##############################################################
494#
Reid Spencer776964a2007-04-04 06:59:36 +0000495# Check out the llvm tree, saving CVS messages to the cvs log...
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000496#
497##############################################################
Reid Spencer776964a2007-04-04 06:59:36 +0000498my $CVSOPT = "";
499# Use compression if going over ssh.
500$CVSOPT = "-z3"
501 if $CVSRootDir =~ /^:ext:/;
502my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co -P $CVSCOOPT";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000503if (!$NOCHECKOUT) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000504 if ( $VERBOSE ) {
505 print "CHECKOUT STAGE:\n";
Reid Spencer776964a2007-04-04 06:59:36 +0000506 print "( time -p $CVSCMD llvm; cd llvm/projects ; $CVSCMD llvm-test ) " .
507 "> $CVSLog 2>&1\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000508 }
Reid Spencer776964a2007-04-04 06:59:36 +0000509 system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
510 "$CVSCMD llvm-test ) > $CVSLog 2>&1";
511 ChangeDir( $BuildDir , "CVS Checkout directory") ;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000512}
513ChangeDir( "llvm" , "llvm source directory") ;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000514
515##############################################################
516#
517# Get some static statistics about the current state of CVS
518#
519# This can probably be put on the server side
520#
521##############################################################
Reid Spencer776964a2007-04-04 06:59:36 +0000522my $CVSCheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $CVSLog`;
523my $CVSCheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $CVSLog`;
524my $CVSCheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $CVSLog`;
525my $CVSCheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000526
Reid Spencer776964a2007-04-04 06:59:36 +0000527my $NumFilesInCVS = `egrep '^U' $CVSLog | wc -l` + 0;
528my $NumDirsInCVS =
529 `egrep '^cvs (checkout|server|update):' $CVSLog | wc -l` + 0;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000530
531##############################################################
532#
533# Extract some information from the CVS history... use a hash so no duplicate
534# stuff is stored. This gets the history from the previous days worth
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000535# of cvs activity and parses it.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000536#
537##############################################################
538
539my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
540
Reid Spencer776964a2007-04-04 06:59:36 +0000541if(!$NOCVSSTATS){
542
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000543 if ($VERBOSE) { print "CVS HISTORY ANALYSIS STAGE\n"; }
Reid Spencer776964a2007-04-04 06:59:36 +0000544 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000545#print join "\n", @CVSHistory; print "\n";
546
Reid Spencer776964a2007-04-04 06:59:36 +0000547 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000548
549# Loop over every record from the CVS history, filling in the hashes.
Reid Spencer776964a2007-04-04 06:59:36 +0000550 foreach $File (@CVSHistory) {
551 my ($Type, $Date, $UID, $Rev, $Filename);
552 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
553 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
554 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
555 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
556 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
557 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
558 } else {
559 print "UNMATCHABLE: $File\n";
560 next;
561 }
562 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
563
564 if ($Filename =~ /^llvm/) {
565 if ($Type eq 'M') { # Modified
566 $ModifiedFiles{$Filename} = 1;
567 $UsersCommitted{$UID} = 1;
568 } elsif ($Type eq 'A') { # Added
569 $AddedFiles{$Filename} = 1;
570 $UsersCommitted{$UID} = 1;
571 } elsif ($Type eq 'R') { # Removed
572 $RemovedFiles{$Filename} = 1;
573 $UsersCommitted{$UID} = 1;
574 } else {
575 $UsersUpdated{$UID} = 1;
576 }
577 }
578 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000579
Reid Spencer776964a2007-04-04 06:59:36 +0000580 my $TestError = 1;
581
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000582}#!NOCVSSTATS
583
584my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
585my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
586my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
587my $UserCommitList = join "\n", sort keys %UsersCommitted;
588my $UserUpdateList = join "\n", sort keys %UsersUpdated;
589
590##############################################################
591#
592# Build the entire tree, saving build messages to the build log
593#
594##############################################################
595if (!$NOCHECKOUT && !$NOBUILD) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000596 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
597 if ( $VERBOSE ) {
598 print "CONFIGURE STAGE:\n";
599 print "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
600 "> $BuildLog 2>&1\n";
601 }
602 system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
603 "> $BuildLog 2>&1";
604 if ( $VERBOSE ) {
605 print "BUILD STAGE:\n";
606 print "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1\n";
607 }
608 # Build the entire tree, capturing the output into $BuildLog
609 system "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000610}
611
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000612##############################################################
613#
614# Get some statistics about the build...
615#
616##############################################################
617#this can de done on server
618#my @Linked = split '\n', `grep Linking $BuildLog`;
619#my $NumExecutables = scalar(grep(/executable/, @Linked));
620#my $NumLibraries = scalar(grep(!/executable/, @Linked));
621#my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
622
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000623# Get the number of lines of source code. Must be here after the build is done
624# because countloc.sh uses the llvm-config script which must be built.
Patrick Jenkinsb993b0a2006-08-16 22:18:41 +0000625my $LOC = `utils/countloc.sh -topdir $BuildDir/llvm`;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000626
627# Get the time taken by the configure script
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000628my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
629my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
630my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
631my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
632
633$ConfigTime=-1 unless $ConfigTime;
634$ConfigWallTime=-1 unless $ConfigWallTime;
635
636my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
637my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
638my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
639my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
640
641$BuildTime=-1 unless $BuildTime;
642$BuildWallTime=-1 unless $BuildWallTime;
643
644my $BuildError = 0, $BuildStatus = "OK";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000645if ($NOBUILD) {
646 $BuildStatus = "Skipped by user";
647 $BuildError = 1;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000648}
Patrick Jenkinsf58473f2006-07-27 01:03:46 +0000649elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000650 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
651 $BuildStatus = "Error: compilation aborted";
652 $BuildError = 1;
653 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000654}
655if ($BuildError) { $NODEJAGNU=1; }
656
Patrick Jenkins169357e2006-07-23 21:38:07 +0000657my $a_file_sizes="";
658my $o_file_sizes="";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000659if (!$BuildError) {
660 print "Organizing size of .o and .a files\n"
661 if ( $VERBOSE );
662 ChangeDir( "$BuildDir/llvm", "Build Directory" );
663 $afiles.= `find utils/ -iname '*.a' -ls`;
664 $afiles.= `find lib/ -iname '*.a' -ls`;
665 $afiles.= `find tools/ -iname '*.a' -ls`;
666 if($BUILDTYPE eq "release"){
Jim Laskey7a8efce2006-09-29 17:31:45 +0000667 $afiles.= `find Release/ -iname '*.a' -ls`;
Jim Laskey27b8ba02006-09-28 17:49:20 +0000668 } elsif($BUILDTYPE eq "release-asserts") {
669 $afiles.= `find Release-Asserts/ -iname '*.a' -ls`;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000670 } else {
671 $afiles.= `find Debug/ -iname '*.a' -ls`;
672 }
673
674 $ofiles.= `find utils/ -iname '*.o' -ls`;
675 $ofiles.= `find lib/ -iname '*.o' -ls`;
676 $ofiles.= `find tools/ -iname '*.o' -ls`;
677 if($BUILDTYPE eq "release"){
Jim Laskey7a8efce2006-09-29 17:31:45 +0000678 $ofiles.= `find Release/ -iname '*.o' -ls`;
Jim Laskey27b8ba02006-09-28 17:49:20 +0000679 } elsif($BUILDTYPE eq "release-asserts") {
680 $ofiles.= `find Release-Asserts/ -iname '*.o' -ls`;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000681 } else {
682 $ofiles.= `find Debug/ -iname '*.o' -ls`;
683 }
684
685 @AFILES = split "\n", $afiles;
686 $a_file_sizes="";
687 foreach $x (@AFILES){
688 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
689 $a_file_sizes.="$1 $2 $BUILDTYPE\n";
690 }
691 @OFILES = split "\n", $ofiles;
692 $o_file_sizes="";
693 foreach $x (@OFILES){
694 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
695 $o_file_sizes.="$1 $2 $BUILDTYPE\n";
696 }
697} else {
698 $a_file_sizes="No data due to a bad build.";
699 $o_file_sizes="No data due to a bad build.";
Patrick Jenkins169357e2006-07-23 21:38:07 +0000700}
Patrick Jenkins169357e2006-07-23 21:38:07 +0000701
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000702##############################################################
703#
704# Running dejagnu tests
705#
706##############################################################
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000707my $DejangnuTestResults=""; # String containing the results of the dejagnu
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000708my $dejagnu_output = "$DejagnuTestsLog";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000709if (!$NODEJAGNU) {
710 if($VERBOSE) {
711 print "DEJAGNU FEATURE/REGRESSION TEST STAGE:\n";
712 print "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1\n";
713 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000714
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000715 #Run the feature and regression tests, results are put into testrun.sum
716 #Full log in testrun.log
717 system "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1";
718
719 #Copy the testrun.log and testrun.sum to our webdir
720 CopyFile("test/testrun.log", $DejagnuLog);
721 CopyFile("test/testrun.sum", $DejagnuSum);
722 #can be done on server
723 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
724 $unexpfail_tests = $DejagnuTestResults;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000725}
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000726
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000727#Extract time of dejagnu tests
728my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
729my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
730$DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
731$DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000732$DejagnuTestResults =
733 "Dejagnu skipped by user choice." unless $DejagnuTestResults;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000734$DejagnuTime = "0.0" unless $DejagnuTime;
735$DejagnuWallTime = "0.0" unless $DejagnuWallTime;
736
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000737##############################################################
738#
739# Get warnings from the build
740#
741##############################################################
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000742if (!$NODEJAGNU) {
743 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
744 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
745 my @Warnings;
746 my $CurDir = "";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000747
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000748 foreach $Warning (@Warn) {
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000749 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000750 $CurDir = $1; # Keep track of directory warning is in...
751 # Remove buildir prefix if included
752 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { $CurDir = $1; }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000753 } else {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000754 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000755 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000756 }
757 my $WarningsFile = join "\n", @Warnings;
758 $WarningsFile =~ s/:[0-9]+:/::/g;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000759
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000760 # Emit the warnings file, so we can diff...
761 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
762 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000763
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000764 # Output something to stdout if something has changed
765 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
766 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000767
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000768 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
769 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000770
771} #endif !NODEGAGNU
772
773##############################################################
774#
775# If we built the tree successfully, run the nightly programs tests...
776#
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000777# A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
778# "External")
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000779#
780##############################################################
781sub TestDirectory {
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000782 my $SubDir = shift;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000783 ChangeDir( "$BuildDir/llvm/projects/llvm-test/$SubDir",
784 "Programs Test Subdirectory" ) || return ("", "");
785
786 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
787
788 # Run the programs tests... creating a report.nightly.csv file
789 if (!$NOTEST) {
790 if( $VERBOSE) {
791 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
792 "TEST=nightly > $ProgramTestLog 2>&1\n";
793 }
794 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000795 "TEST=nightly > $ProgramTestLog 2>&1";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000796 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
797 }
798
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000799 my $ProgramsTable;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000800 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000801 $TestError = 1;
802 $ProgramsTable="Error running test $SubDir\n";
803 print "ERROR TESTING\n";
804 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
805 $TestError = 1;
806 $ProgramsTable="Makefile error running tests $SubDir!\n";
807 print "ERROR TESTING\n";
808 } else {
809 $TestError = 0;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000810 #
811 # Create a list of the tests which were run...
812 #
813 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000814 "| sort > $Prefix-$SubDir-Tests.txt";
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000815 }
816 $ProgramsTable = ReadFile "report.nightly.csv";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000817
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000818 ChangeDir( "../../..", "Programs Test Parent Directory" );
819 return ($ProgramsTable, $llcbeta_options);
Patrick Jenkins9e384ab2006-08-14 16:07:14 +0000820} #end sub TestDirectory
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000821
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000822##############################################################
823#
824# Calling sub TestDirectory
825#
826##############################################################
Patrick Jenkinsc281b0d2006-07-27 19:00:01 +0000827if (!$BuildError) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000828 if ( $VERBOSE ) {
Patrick Jenkinse631c4a2006-08-04 17:55:01 +0000829 print "SingleSource TEST STAGE\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000830 }
831 ($SingleSourceProgramsTable, $llcbeta_options) =
832 TestDirectory("SingleSource");
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000833 WriteFile "$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
Patrick Jenkins4257ccb2006-08-08 02:03:53 +0000834 if ( $VERBOSE ) {
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000835 print "MultiSource TEST STAGE\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000836 }
837 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000838 WriteFile "$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000839 if ( ! $NOEXTERNALS ) {
840 if ( $VERBOSE ) {
841 print "External TEST STAGE\n";
842 }
843 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000844 WriteFile "$Prefix-External-Performance.txt", $ExternalProgramsTable;
845 system "cat $Prefix-SingleSource-Tests.txt " .
846 "$Prefix-MultiSource-Tests.txt ".
847 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
848 system "cat $Prefix-SingleSource-Performance.txt " .
849 "$Prefix-MultiSource-Performance.txt ".
850 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000851 } else {
852 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
853 if ( $VERBOSE ) {
854 print "External TEST STAGE SKIPPED\n";
855 }
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000856 system "cat $Prefix-SingleSource-Tests.txt " .
857 "$Prefix-MultiSource-Tests.txt ".
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000858 " | sort > $Prefix-Tests.txt";
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000859 system "cat $Prefix-SingleSource-Performance.txt " .
860 "$Prefix-MultiSource-Performance.txt ".
861 " | sort > $Prefix-Performance.txt";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000862 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000863
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000864 ##############################################################
865 #
866 #
867 # gathering tests added removed broken information here
868 #
869 #
870 ##############################################################
871 my $dejagnu_test_list = ReadFile "$Prefix-Tests.txt";
872 my @DEJAGNU = split "\n", $dejagnu_test_list;
873 my ($passes, $fails, $xfails) = "";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000874
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000875 if(!$NODEJAGNU) {
876 for ($x=0; $x<@DEJAGNU; $x++) {
877 if ($DEJAGNU[$x] =~ m/^PASS:/) {
878 $passes.="$DEJAGNU[$x]\n";
879 }
880 elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
881 $fails.="$DEJAGNU[$x]\n";
882 }
883 elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
884 $xfails.="$DEJAGNU[$x]\n";
885 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000886 }
887 }
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000888
889} #end if !$BuildError
890
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000891
892##############################################################
893#
894# If we built the tree successfully, runs of the Olden suite with
895# LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
896#
897##############################################################
898if (!$BuildError) {
Patrick Jenkinsd7210f92006-08-02 18:37:40 +0000899 if ( $VERBOSE ) { print "OLDEN TEST SUITE STAGE\n"; }
900 my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
901 $MachCodeSize) = ("","","","","","","");
902 if (!$NORUNNINGTESTS) {
903 ChangeDir( "$BuildDir/llvm/projects/llvm-test/MultiSource/Benchmarks/Olden",
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000904 "Olden Test Directory");
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000905
Patrick Jenkinsd7210f92006-08-02 18:37:40 +0000906 # Clean out previous results...
907 system "$NICE $MAKECMD $MAKEOPTS clean > /dev/null 2>&1";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000908
Patrick Jenkinsd7210f92006-08-02 18:37:40 +0000909 # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE and
910 # GET_STABLE_NUMBERS enabled!
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000911 if( $VERBOSE ) {
912 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
913 "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
914 "> /dev/null 2>&1\n";
915 }
916 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
917 "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
918 "> /dev/null 2>&1";
919 system "cp report.nightly.csv $OldenTestsLog";
Patrick Jenkinsd7210f92006-08-02 18:37:40 +0000920 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000921}
922
Patrick Jenkins215b48f2006-07-07 18:50:51 +0000923##############################################################
924#
925# Getting end timestamp
926#
927##############################################################
Patrick Jenkinsb67e1182006-07-21 21:43:09 +0000928$endtime = `date "+20%y-%m-%d %H:%M:%S"`;
Patrick Jenkins215b48f2006-07-07 18:50:51 +0000929
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000930
931##############################################################
932#
933# Place all the logs neatly into one humungous file
934#
935##############################################################
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000936if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
937
938$machine_data = "uname: ".`uname -a`.
939 "hardware: ".`uname -m`.
940 "os: ".`uname -sr`.
941 "name: ".`uname -n`.
942 "date: ".`date \"+20%y-%m-%d\"`.
943 "time: ".`date +\"%H:%M:%S\"`;
944
945my @CVS_DATA;
946my $cvs_data;
Reid Spencer776964a2007-04-04 06:59:36 +0000947@CVS_DATA = ReadFile "$CVSLog";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000948$cvs_data = join("\n", @CVS_DATA);
949
950my @BUILD_DATA;
951my $build_data;
952@BUILD_DATA = ReadFile "$BuildLog";
953$build_data = join("\n", @BUILD_DATA);
954
Patrick Jenkins03137752006-08-21 20:45:57 +0000955my (@DEJAGNU_LOG, @DEJAGNU_SUM, @DEJAGNULOG_FULL, @GCC_VERSION);
956my ($dejagnutests_log ,$dejagnutests_sum, $dejagnulog_full) = "";
957my ($gcc_version, $gcc_version_long) = "";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000958
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000959$gcc_version_long="";
960if ($GCCPATH ne "") {
961 $gcc_version_long = `$GCCPATH/gcc --version`;
962} else {
963 $gcc_version_long = `gcc --version`;
964}
965@GCC_VERSION = split '\n', $gcc_version_long;
966$gcc_version = $GCC_VERSION[0];
967
Patrick Jenkins03137752006-08-21 20:45:57 +0000968if(!$BuildError){
969 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
970 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
971 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
972 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000973
Patrick Jenkins03137752006-08-21 20:45:57 +0000974 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
975 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
Patrick Jenkins79fbf7f2006-07-14 20:44:09 +0000976}
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000977
978##############################################################
979#
980# Send data via a post request
981#
982##############################################################
983
984if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
985
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000986my %hash_of_data = (
987 'machine_data' => $machine_data,
988 'build_data' => $build_data,
989 'gcc_version' => $gcc_version,
990 'nickname' => $nickname,
991 'dejagnutime_wall' => $DejagnuWallTime,
992 'dejagnutime_cpu' => $DejagnuTime,
Reid Spencer776964a2007-04-04 06:59:36 +0000993 'cvscheckouttime_wall' => $CVSCheckoutTime_Wall,
994 'cvscheckouttime_cpu' => $CVSCheckoutTime_CPU,
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000995 'configtime_wall' => $ConfigWallTime,
996 'configtime_cpu'=> $ConfigTime,
997 'buildtime_wall' => $BuildWallTime,
998 'buildtime_cpu' => $BuildTime,
999 'warnings' => $WarningsFile,
1000 'cvsusercommitlist' => $UserCommitList,
1001 'cvsuserupdatelist' => $UserUpdateList,
1002 'cvsaddedfiles' => $CVSAddedFiles,
1003 'cvsmodifiedfiles' => $CVSModifiedFiles,
1004 'cvsremovedfiles' => $CVSRemovedFiles,
1005 'lines_of_code' => $LOC,
1006 'cvs_file_count' => $NumFilesInCVS,
1007 'cvs_dir_count' => $NumDirsInCVS,
1008 'buildstatus' => $BuildStatus,
1009 'singlesource_programstable' => $SingleSourceProgramsTable,
1010 'multisource_programstable' => $MultiSourceProgramsTable,
1011 'externalsource_programstable' => $ExternalProgramsTable,
1012 'llcbeta_options' => $multisource_llcbeta_options,
1013 'warnings_removed' => $WarningsRemoved,
1014 'warnings_added' => $WarningsAdded,
1015 'passing_tests' => $passes,
1016 'expfail_tests' => $xfails,
1017 'unexpfail_tests' => $fails,
1018 'all_tests' => $dejagnu_test_list,
1019 'new_tests' => "",
1020 'removed_tests' => "",
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +00001021 'dejagnutests_results' => $DejagnuTestResults,
1022 'dejagnutests_log' => $dejagnulog_full,
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001023 'starttime' => $starttime,
1024 'endtime' => $endtime,
1025 'o_file_sizes' => $o_file_sizes,
1026 'a_file_sizes' => $a_file_sizes
1027);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001028
1029$TESTING = 0;
1030
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001031if ($TESTING) {
1032 print "============================\n";
1033 foreach $x(keys %hash_of_data){
1034 print "$x => $hash_of_data{$x}\n";
1035 }
1036} else {
1037 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
1038 if( $VERBOSE) { print "============================\n$response"; }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001039}
1040
1041##############################################################
1042#
1043# Remove the cvs tree...
1044#
1045##############################################################
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001046system ( "$NICE rm -rf $BuildDir")
1047 if (!$NOCHECKOUT and !$NOREMOVE);
1048system ( "$NICE rm -rf $WebDir")
1049 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);