blob: 6101b0ab79e91519609afa9de540e66e0fbe9c09 [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.
34# -disable-llc Disable LLC tests in the nightly tester.
35# -disable-jit Disable JIT tests in the nightly tester.
36# -disable-cbe Disable C backend tests in the nightly tester.
37# -verbose Turn on some debug output
38# -debug Print information useful only to maintainers of this script.
39# -nice Checkout/Configure/Build with "nice" to reduce impact
40# on busy servers.
41# -f2c Next argument specifies path to F2C utility
42# -nickname The next argument specifieds the nickname this script
43# will submit to the nightlytest results repository.
44# -gccpath Path to gcc/g++ used to build LLVM
45# -cvstag Check out a specific CVS tag to build LLVM (useful for
46# testing release branches)
47# -target Specify the target triplet
48# -cflags Next argument specifies that C compilation options that
49# override the default.
50# -cxxflags Next argument specifies that C++ compilation options that
51# override the default.
52# -ldflags Next argument specifies that linker options that override
53# the default.
Patrick Jenkins215b48f2006-07-07 18:50:51 +000054# -compileflags Next argument specifies extra options passed to make when
55# building LLVM.
Patrick Jenkins0e9402f2006-08-11 23:02:09 +000056# -use-gmake Use gmake instead of the default make command to build
Patrick Jenkins1cd46912006-07-27 01:17:17 +000057# llvm and run tests.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000058#
59# ---------------- Options to configure llvm-test ----------------------------
Patrick Jenkins215b48f2006-07-07 18:50:51 +000060# -extraflags Next argument specifies extra options that are passed to
61# compile the tests.
62# -noexternals Do not run the external tests (for cases where povray
63# or SPEC are not installed)
64# -with-externals Specify a directory where the external tests are located.
Patrick Jenkins0e9402f2006-08-11 23:02:09 +000065# -submit-server Specifies a server to submit the test results too. If this
66# option is not specified it defaults to
67# llvm.org. This is basically just the address of the
68# webserver
69# -submit-script Specifies which script to call on the submit server. If
70# this option is not specified it defaults to
Jim Laskey6d8a1b72006-09-15 17:03:36 +000071# /nightlytest/NightlyTestAccept.php. This is basically
Patrick Jenkins0e9402f2006-08-11 23:02:09 +000072# everything after the www.yourserver.org.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000073#
74# CVSROOT is the CVS repository from which the tree will be checked out,
75# specified either in the full :method:user@host:/dir syntax, or
76# just /dir if using a local repo.
77# BUILDDIR is the directory where sources for this test run will be checked out
78# AND objects for this test run will be built. This directory MUST NOT
79# exist before the script is run; it will be created by the cvs checkout
80# process and erased (unless -noremove is specified; see above.)
81# WEBDIR is the directory into which the test results web page will be written,
82# AND in which the "index.html" is assumed to be a symlink to the most recent
83# copy of the results. This directory will be created if it does not exist.
84# LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
85# to. This is the same as you would have for a normal LLVM build.
86#
87##############################################################
88#
89# Getting environment variables
90#
91##############################################################
Reid Spencerfa34d7b2006-08-13 09:53:02 +000092my $HOME = $ENV{'HOME'};
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000093my $CVSRootDir = $ENV{'CVSROOT'};
Reid Spencerfa34d7b2006-08-13 09:53:02 +000094$CVSRootDir = "/home/vadve/shared/PublicCVS" unless $CVSRootDir;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000095my $BuildDir = $ENV{'BUILDDIR'};
Reid Spencerfa34d7b2006-08-13 09:53:02 +000096$BuildDir = "$HOME/buildtest" unless $BuildDir;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000097my $WebDir = $ENV{'WEBDIR'};
Reid Spencerfa34d7b2006-08-13 09:53:02 +000098$WebDir = "$HOME/cvs/testresults-X86" unless $WebDir;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000099
100##############################################################
101#
102# Calculate the date prefix...
103#
104##############################################################
105@TIME = localtime;
106my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
107my $DateString = strftime "%B %d, %Y", localtime;
108my $TestStartTime = gmtime() . "GMT<br>" . localtime() . " (local)";
109
110##############################################################
111#
112# Parse arguments...
113#
114##############################################################
115$CONFIGUREARGS="";
Patrick Jenkins49717a42006-07-21 01:39:42 +0000116$nickname="";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000117$NOTEST=0;
118$NORUNNINGTESTS=0;
Patrick Jenkins1cd46912006-07-27 01:17:17 +0000119$MAKECMD="make";
Patrick Jenkins0e9402f2006-08-11 23:02:09 +0000120$SUBMITSERVER = "llvm.org";
Jim Laskey6d8a1b72006-09-15 17:03:36 +0000121$SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000122
123while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000124 shift;
125 last if /^--$/; # Stop processing arguments on --
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000126
127 # List command line options here...
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000128 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
129 if (/^-nocvsstats$/) { $NOCVSSTATS = 1; next; }
130 if (/^-noremove$/) { $NOREMOVE = 1; next; }
131 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
132 if (/^-notest$/) { $NOTEST = 1; $NORUNNINGTESTS = 1; next; }
133 if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
134 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j2 -l3.0"; next; }
135 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
136 "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
Jim Laskey27b8ba02006-09-28 17:49:20 +0000137 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
138 "DISABLE-ASSERTIONS=1 ".
139 "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release-asserts"; next;}
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000140 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
141 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
142 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
143 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
144 $CONFIGUREARGS .= " --disable-jit"; next; }
145 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
146 if (/^-verbose$/) { $VERBOSE = 1; next; }
147 if (/^-debug$/) { $DEBUG = 1; next; }
148 if (/^-nice$/) { $NICE = "nice "; next; }
149 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
150 shift; next; }
151 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
152 shift; next; }
153 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
154 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
155 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
156 if (/^-gccpath/) { $CONFIGUREARGS .=
157 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
158 $GCCPATH=$ARGV[0]; shift; next; }
159 else { $GCCPATH=""; }
160 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
161 else { $CVSCOOPT="";}
162 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
163 shift; next; }
164 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
165 shift; next; }
166 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
167 shift; next; }
168 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
169 shift; next; }
170 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
171 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
172 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
173 if (/^-extraflags/) { $CONFIGUREARGS .=
174 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
175 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
176 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
177 if (/^-nobuild$/) { $NOBUILD = 1; next; }
178 print "Unknown option: $_ : ignoring!\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000179}
180
181if ($ENV{'LLVMGCCDIR'}) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000182 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000183}
184if ($CONFIGUREARGS !~ /--disable-jit/) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000185 $CONFIGUREARGS .= " --enable-jit";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000186}
187
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000188if (@ARGV != 0 and @ARGV != 3 and $VERBOSE) {
189 foreach $x (@ARGV) {
190 print "$x\n";
191 }
192 print "Must specify 0 or 3 options!";
Patrick Jenkinsf58473f2006-07-27 01:03:46 +0000193}
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000194
195if (@ARGV == 3) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000196 $CVSRootDir = $ARGV[0];
197 $BuildDir = $ARGV[1];
198 $WebDir = $ARGV[2];
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000199}
200
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000201if ($CVSRootDir eq "" or
202 $BuildDir eq "" or
203 $WebDir eq "") {
204 die("please specify a cvs root directory, a build directory, and a ".
Patrick Jenkinsf58473f2006-07-27 01:03:46 +0000205 "web directory");
206 }
207
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000208if ($nickname eq "") {
209 die ("Please invoke NewNightlyTest.pl with command line option " .
210 "\"-nickname <nickname>\"");
Patrick Jenkins514e2582006-07-20 22:28:43 +0000211}
Patrick Jenkins1cd46912006-07-27 01:17:17 +0000212
Jim Laskey27b8ba02006-09-28 17:49:20 +0000213if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000214 $BUILDTYPE = "debug";
Patrick Jenkins26ba6092006-07-23 22:57:28 +0000215}
Patrick Jenkins514e2582006-07-20 22:28:43 +0000216
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000217##############################################################
218#
219#define the file names we'll use
220#
221##############################################################
222my $Prefix = "$WebDir/$DATE";
223my $BuildLog = "$Prefix-Build-Log.txt";
224my $CVSLog = "$Prefix-CVS-Log.txt";
225my $OldenTestsLog = "$Prefix-Olden-tests.txt";
226my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
227my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
Patrick Jenkins26ba6092006-07-23 22:57:28 +0000228my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000229my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
230my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
231my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
232if (! -d $WebDir) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000233 mkdir $WebDir, 0777;
Patrick Jenkins03137752006-08-21 20:45:57 +0000234 if($VERBOSE){
235 warn "$WebDir did not exist; creating it.\n";
236 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000237}
238
239if ($VERBOSE) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000240 print "INITIALIZED\n";
241 print "CVS Root = $CVSRootDir\n";
242 print "BuildDir = $BuildDir\n";
243 print "WebDir = $WebDir\n";
244 print "Prefix = $Prefix\n";
245 print "CVSLog = $CVSLog\n";
246 print "BuildLog = $BuildLog\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000247}
248
249##############################################################
250#
251# Helper functions
252#
253##############################################################
254sub GetDir {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000255 my $Suffix = shift;
256 opendir DH, $WebDir;
257 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
258 closedir DH;
259 return @Result;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000260}
261
262#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
263#
264# DiffFiles - Diff the current version of the file against the last version of
265# the file, reporting things added and removed. This is used to report, for
266# example, added and removed warnings. This returns a pair (added, removed)
267#
268#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
269sub DiffFiles {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000270 my $Suffix = shift;
271 my @Others = GetDir $Suffix;
272 if (@Others == 0) { # No other files? We added all entries...
273 return (`cat $WebDir/$DATE$Suffix`, "");
274 }
275# Diff the files now...
276 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
277 my $Added = join "\n", grep /^</, @Diffs;
278 my $Removed = join "\n", grep /^>/, @Diffs;
279 $Added =~ s/^< //gm;
280 $Removed =~ s/^> //gm;
281 return ($Added, $Removed);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000282}
283
284#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
285#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
286sub GetRegex { # (Regex with ()'s, value)
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000287 $_[1] =~ /$_[0]/m;
288 return $1
289 if (defined($1));
290 return "0";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000291}
292
293#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
294#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
295sub GetRegexNum {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000296 my ($Regex, $Num, $Regex2, $File) = @_;
297 my @Items = split "\n", `grep '$Regex' $File`;
298 return GetRegex $Regex2, $Items[$Num];
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000299}
300
301#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
302#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
303sub ChangeDir { # directory, logical name
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000304 my ($dir,$name) = @_;
305 chomp($dir);
306 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
307 $result = chdir($dir);
308 if (!$result) {
309 print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
310 return false;
311 }
312 return true;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000313}
314
315#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
316#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
317sub ReadFile {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000318 if (open (FILE, $_[0])) {
319 undef $/;
320 my $Ret = <FILE>;
321 close FILE;
322 $/ = '\n';
323 return $Ret;
324 } else {
325 print "Could not open file '$_[0]' for reading!\n";
326 return "";
327 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000328}
329
330#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
331#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
332sub WriteFile { # (filename, contents)
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000333 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
334 print FILE $_[1];
335 close FILE;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000336}
337
338#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
339#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
340sub CopyFile { #filename, newfile
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000341 my ($file, $newfile) = @_;
342 chomp($file);
343 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
344 copy($file, $newfile);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000345}
346
347#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
348#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
349sub AddRecord {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000350 my ($Val, $Filename,$WebDir) = @_;
351 my @Records;
352 if (open FILE, "$WebDir/$Filename") {
353 @Records = grep !/$DATE/, split "\n", <FILE>;
354 close FILE;
355 }
356 push @Records, "$DATE: $Val";
357 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000358}
359
360#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
361#
362# FormatTime - Convert a time from 1m23.45 into 83.45
363#
364#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
365sub FormatTime {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000366 my $Time = shift;
367 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
368 $Time = sprintf("%7.4f", $1*60.0+$2);
369 }
370 return $Time;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000371}
372
373#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000374#
375# This function is meant to read in the dejagnu sum file and
376# return a string with only the results (i.e. PASS/FAIL/XPASS/
377# XFAIL).
378#
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000379#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
380sub GetDejagnuTestResults { # (filename, log)
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000381 my ($filename, $DejagnuLog) = @_;
382 my @lines;
383 $/ = "\n"; #Make sure we're going line at a time.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000384
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000385 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000386
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000387 if (open SRCHFILE, $filename) {
388 # Process test results
389 while ( <SRCHFILE> ) {
390 if ( length($_) > 1 ) {
391 chomp($_);
Jim Laskey01d7bcf2006-09-20 09:20:22 +0000392 if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\/test\/(.*)$/ ) {
393 push(@lines, "$1: test/$2");
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000394 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000395 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000396 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000397 }
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000398 close SRCHFILE;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000399
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000400 my $content = join("\n", @lines);
401 return $content;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000402}
403
404
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000405
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000406#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
407#
408# This function acts as a mini web browswer submitting data
409# to our central server via the post method
410#
411#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
412sub SendData{
413 $host = $_[0];
414 $file = $_[1];
415 $variables=$_[2];
416
417 $port=80;
418 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
Patrick Jenkinsadea55e2006-07-17 16:41:19 +0000419 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000420 die "Bad socket\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000421 connect SOCK, $socketaddr or die "Bad connection\n";
422 select((select(SOCK), $| = 1)[0]);
423
424 #creating content here
425 my $content;
426 foreach $key (keys (%$variables)){
427 $value = $variables->{$key};
428 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
429 $content .= "$key=$value&";
430 }
431
432 $length = length($content);
433
434 my $send= "POST $file HTTP/1.0\n";
435 $send.= "Content-Type: application/x-www-form-urlencoded\n";
436 $send.= "Content-length: $length\n\n";
437 $send.= "$content";
438
Patrick Jenkinse8501eb2006-08-07 01:54:37 +0000439 print SOCK $send;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000440 my $result;
441 while(<SOCK>){
442 $result .= $_;
443 }
444 close(SOCK);
445
446 my $sentdata="";
Patrick Jenkins4c4e3562006-07-07 21:40:34 +0000447 foreach $x (keys (%$variables)){
Patrick Jenkins7267bd62006-07-10 18:35:41 +0000448 $value = $variables->{$x};
449 $sentdata.= "$x => $value\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000450 }
451 WriteFile "$Prefix-sentdata.txt", $sentdata;
Patrick Jenkins4c4e3562006-07-07 21:40:34 +0000452
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000453
454 return $result;
455}
456
Patrick Jenkins215b48f2006-07-07 18:50:51 +0000457##############################################################
458#
459# Getting Start timestamp
460#
461##############################################################
Patrick Jenkinsb67e1182006-07-21 21:43:09 +0000462$starttime = `date "+20%y-%m-%d %H:%M:%S"`;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000463
464##############################################################
465#
466# Create the CVS repository directory
467#
468##############################################################
469if (!$NOCHECKOUT) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000470 if (-d $BuildDir) {
471 if (!$NOREMOVE) {
472 if ( $VERBOSE ) {
473 print "Build directory exists! Removing it\n";
474 }
475 system "rm -rf $BuildDir";
Jim Laskey6d8a1b72006-09-15 17:03:36 +0000476 mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000477 } else {
Jim Laskey6d8a1b72006-09-15 17:03:36 +0000478 if ( $VERBOSE ) {
479 print "Build directory exists!\n";
480 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000481 }
Jim Laskey6d8a1b72006-09-15 17:03:36 +0000482 } else {
483 mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000484 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000485}
486ChangeDir( $BuildDir, "CVS checkout directory" );
487
488
489##############################################################
490#
491# Check out the llvm tree, saving CVS messages to the cvs log...
492#
493##############################################################
494my $CVSOPT = "";
495# Use compression if going over ssh.
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000496$CVSOPT = "-z3"
497 if $CVSRootDir =~ /^:ext:/;
Evan Cheng71899662006-08-29 18:01:18 +0000498my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co -P $CVSCOOPT";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000499if (!$NOCHECKOUT) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000500 if ( $VERBOSE ) {
501 print "CHECKOUT STAGE:\n";
502 print "( time -p $CVSCMD llvm; cd llvm/projects ; $CVSCMD llvm-test ) " .
503 "> $CVSLog 2>&1\n";
504 }
505 system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
506 "$CVSCMD llvm-test ) > $CVSLog 2>&1";
507 ChangeDir( $BuildDir , "CVS Checkout directory") ;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000508}
509ChangeDir( "llvm" , "llvm source directory") ;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000510
511##############################################################
512#
513# Get some static statistics about the current state of CVS
514#
515# This can probably be put on the server side
516#
517##############################################################
518my $CVSCheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $CVSLog`;
519my $CVSCheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $CVSLog`;
520my $CVSCheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $CVSLog`;
521my $CVSCheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
522
523my $NumFilesInCVS = `egrep '^U' $CVSLog | wc -l` + 0;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000524my $NumDirsInCVS =
525 `egrep '^cvs (checkout|server|update):' $CVSLog | wc -l` + 0;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000526
527##############################################################
528#
529# Extract some information from the CVS history... use a hash so no duplicate
530# stuff is stored. This gets the history from the previous days worth
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000531# of cvs activity and parses it.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000532#
533##############################################################
534
535my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
536
537if(!$NOCVSSTATS){
538
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000539 if ($VERBOSE) { print "CVS HISTORY ANALYSIS STAGE\n"; }
540 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000541#print join "\n", @CVSHistory; print "\n";
542
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000543 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000544
545# Loop over every record from the CVS history, filling in the hashes.
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000546 foreach $File (@CVSHistory) {
547 my ($Type, $Date, $UID, $Rev, $Filename);
548 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
549 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
550 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
551 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
552 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
553 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
554 } else {
555 print "UNMATCHABLE: $File\n";
556 next;
557 }
558 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
559
560 if ($Filename =~ /^llvm/) {
561 if ($Type eq 'M') { # Modified
562 $ModifiedFiles{$Filename} = 1;
563 $UsersCommitted{$UID} = 1;
564 } elsif ($Type eq 'A') { # Added
565 $AddedFiles{$Filename} = 1;
566 $UsersCommitted{$UID} = 1;
567 } elsif ($Type eq 'R') { # Removed
568 $RemovedFiles{$Filename} = 1;
569 $UsersCommitted{$UID} = 1;
570 } else {
571 $UsersUpdated{$UID} = 1;
572 }
573 }
574 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000575
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000576 my $TestError = 1;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000577
578}#!NOCVSSTATS
579
580my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
581my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
582my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
583my $UserCommitList = join "\n", sort keys %UsersCommitted;
584my $UserUpdateList = join "\n", sort keys %UsersUpdated;
585
586##############################################################
587#
588# Build the entire tree, saving build messages to the build log
589#
590##############################################################
591if (!$NOCHECKOUT && !$NOBUILD) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000592 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
593 if ( $VERBOSE ) {
594 print "CONFIGURE STAGE:\n";
595 print "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
596 "> $BuildLog 2>&1\n";
597 }
598 system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
599 "> $BuildLog 2>&1";
600 if ( $VERBOSE ) {
601 print "BUILD STAGE:\n";
602 print "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1\n";
603 }
604 # Build the entire tree, capturing the output into $BuildLog
605 system "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000606}
607
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000608##############################################################
609#
610# Get some statistics about the build...
611#
612##############################################################
613#this can de done on server
614#my @Linked = split '\n', `grep Linking $BuildLog`;
615#my $NumExecutables = scalar(grep(/executable/, @Linked));
616#my $NumLibraries = scalar(grep(!/executable/, @Linked));
617#my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
618
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000619# Get the number of lines of source code. Must be here after the build is done
620# because countloc.sh uses the llvm-config script which must be built.
Patrick Jenkinsb993b0a2006-08-16 22:18:41 +0000621my $LOC = `utils/countloc.sh -topdir $BuildDir/llvm`;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000622
623# Get the time taken by the configure script
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000624my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
625my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
626my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
627my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
628
629$ConfigTime=-1 unless $ConfigTime;
630$ConfigWallTime=-1 unless $ConfigWallTime;
631
632my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
633my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
634my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
635my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
636
637$BuildTime=-1 unless $BuildTime;
638$BuildWallTime=-1 unless $BuildWallTime;
639
640my $BuildError = 0, $BuildStatus = "OK";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000641if ($NOBUILD) {
642 $BuildStatus = "Skipped by user";
643 $BuildError = 1;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000644}
Patrick Jenkinsf58473f2006-07-27 01:03:46 +0000645elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000646 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
647 $BuildStatus = "Error: compilation aborted";
648 $BuildError = 1;
649 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000650}
651if ($BuildError) { $NODEJAGNU=1; }
652
Patrick Jenkins169357e2006-07-23 21:38:07 +0000653my $a_file_sizes="";
654my $o_file_sizes="";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000655if (!$BuildError) {
656 print "Organizing size of .o and .a files\n"
657 if ( $VERBOSE );
658 ChangeDir( "$BuildDir/llvm", "Build Directory" );
659 $afiles.= `find utils/ -iname '*.a' -ls`;
660 $afiles.= `find lib/ -iname '*.a' -ls`;
661 $afiles.= `find tools/ -iname '*.a' -ls`;
662 if($BUILDTYPE eq "release"){
Jim Laskey7a8efce2006-09-29 17:31:45 +0000663 $afiles.= `find Release/ -iname '*.a' -ls`;
Jim Laskey27b8ba02006-09-28 17:49:20 +0000664 } elsif($BUILDTYPE eq "release-asserts") {
665 $afiles.= `find Release-Asserts/ -iname '*.a' -ls`;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000666 } else {
667 $afiles.= `find Debug/ -iname '*.a' -ls`;
668 }
669
670 $ofiles.= `find utils/ -iname '*.o' -ls`;
671 $ofiles.= `find lib/ -iname '*.o' -ls`;
672 $ofiles.= `find tools/ -iname '*.o' -ls`;
673 if($BUILDTYPE eq "release"){
Jim Laskey7a8efce2006-09-29 17:31:45 +0000674 $ofiles.= `find Release/ -iname '*.o' -ls`;
Jim Laskey27b8ba02006-09-28 17:49:20 +0000675 } elsif($BUILDTYPE eq "release-asserts") {
676 $ofiles.= `find Release-Asserts/ -iname '*.o' -ls`;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000677 } else {
678 $ofiles.= `find Debug/ -iname '*.o' -ls`;
679 }
680
681 @AFILES = split "\n", $afiles;
682 $a_file_sizes="";
683 foreach $x (@AFILES){
684 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
685 $a_file_sizes.="$1 $2 $BUILDTYPE\n";
686 }
687 @OFILES = split "\n", $ofiles;
688 $o_file_sizes="";
689 foreach $x (@OFILES){
690 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
691 $o_file_sizes.="$1 $2 $BUILDTYPE\n";
692 }
693} else {
694 $a_file_sizes="No data due to a bad build.";
695 $o_file_sizes="No data due to a bad build.";
Patrick Jenkins169357e2006-07-23 21:38:07 +0000696}
Patrick Jenkins169357e2006-07-23 21:38:07 +0000697
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000698##############################################################
699#
700# Running dejagnu tests
701#
702##############################################################
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000703my $DejangnuTestResults=""; # String containing the results of the dejagnu
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000704my $dejagnu_output = "$DejagnuTestsLog";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000705if (!$NODEJAGNU) {
706 if($VERBOSE) {
707 print "DEJAGNU FEATURE/REGRESSION TEST STAGE:\n";
708 print "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1\n";
709 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000710
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000711 #Run the feature and regression tests, results are put into testrun.sum
712 #Full log in testrun.log
713 system "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1";
714
715 #Copy the testrun.log and testrun.sum to our webdir
716 CopyFile("test/testrun.log", $DejagnuLog);
717 CopyFile("test/testrun.sum", $DejagnuSum);
718 #can be done on server
719 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
720 $unexpfail_tests = $DejagnuTestResults;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000721}
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000722
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000723#Extract time of dejagnu tests
724my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
725my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
726$DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
727$DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000728$DejagnuTestResults =
729 "Dejagnu skipped by user choice." unless $DejagnuTestResults;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000730$DejagnuTime = "0.0" unless $DejagnuTime;
731$DejagnuWallTime = "0.0" unless $DejagnuWallTime;
732
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000733##############################################################
734#
735# Get warnings from the build
736#
737##############################################################
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000738if (!$NODEJAGNU) {
739 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
740 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
741 my @Warnings;
742 my $CurDir = "";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000743
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000744 foreach $Warning (@Warn) {
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000745 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000746 $CurDir = $1; # Keep track of directory warning is in...
747 # Remove buildir prefix if included
748 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { $CurDir = $1; }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000749 } else {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000750 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000751 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000752 }
753 my $WarningsFile = join "\n", @Warnings;
754 $WarningsFile =~ s/:[0-9]+:/::/g;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000755
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000756 # Emit the warnings file, so we can diff...
757 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
758 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000759
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000760 # Output something to stdout if something has changed
761 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
762 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000763
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000764 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
765 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000766
767} #endif !NODEGAGNU
768
769##############################################################
770#
771# If we built the tree successfully, run the nightly programs tests...
772#
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000773# A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
774# "External")
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000775#
776##############################################################
777sub TestDirectory {
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000778 my $SubDir = shift;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000779 ChangeDir( "$BuildDir/llvm/projects/llvm-test/$SubDir",
780 "Programs Test Subdirectory" ) || return ("", "");
781
782 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
783
784 # Run the programs tests... creating a report.nightly.csv file
785 if (!$NOTEST) {
786 if( $VERBOSE) {
787 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
788 "TEST=nightly > $ProgramTestLog 2>&1\n";
789 }
790 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000791 "TEST=nightly > $ProgramTestLog 2>&1";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000792 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
793 }
794
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000795 my $ProgramsTable;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000796 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000797 $TestError = 1;
798 $ProgramsTable="Error running test $SubDir\n";
799 print "ERROR TESTING\n";
800 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
801 $TestError = 1;
802 $ProgramsTable="Makefile error running tests $SubDir!\n";
803 print "ERROR TESTING\n";
804 } else {
805 $TestError = 0;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000806 #
807 # Create a list of the tests which were run...
808 #
809 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000810 "| sort > $Prefix-$SubDir-Tests.txt";
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000811 }
812 $ProgramsTable = ReadFile "report.nightly.csv";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000813
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000814 ChangeDir( "../../..", "Programs Test Parent Directory" );
815 return ($ProgramsTable, $llcbeta_options);
Patrick Jenkins9e384ab2006-08-14 16:07:14 +0000816} #end sub TestDirectory
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000817
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000818##############################################################
819#
820# Calling sub TestDirectory
821#
822##############################################################
Patrick Jenkinsc281b0d2006-07-27 19:00:01 +0000823if (!$BuildError) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000824 if ( $VERBOSE ) {
Patrick Jenkinse631c4a2006-08-04 17:55:01 +0000825 print "SingleSource TEST STAGE\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000826 }
827 ($SingleSourceProgramsTable, $llcbeta_options) =
828 TestDirectory("SingleSource");
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000829 WriteFile "$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
Patrick Jenkins4257ccb2006-08-08 02:03:53 +0000830 if ( $VERBOSE ) {
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000831 print "MultiSource TEST STAGE\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000832 }
833 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000834 WriteFile "$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000835 if ( ! $NOEXTERNALS ) {
836 if ( $VERBOSE ) {
837 print "External TEST STAGE\n";
838 }
839 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000840 WriteFile "$Prefix-External-Performance.txt", $ExternalProgramsTable;
841 system "cat $Prefix-SingleSource-Tests.txt " .
842 "$Prefix-MultiSource-Tests.txt ".
843 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
844 system "cat $Prefix-SingleSource-Performance.txt " .
845 "$Prefix-MultiSource-Performance.txt ".
846 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000847 } else {
848 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
849 if ( $VERBOSE ) {
850 print "External TEST STAGE SKIPPED\n";
851 }
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000852 system "cat $Prefix-SingleSource-Tests.txt " .
853 "$Prefix-MultiSource-Tests.txt ".
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000854 " | sort > $Prefix-Tests.txt";
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000855 system "cat $Prefix-SingleSource-Performance.txt " .
856 "$Prefix-MultiSource-Performance.txt ".
857 " | sort > $Prefix-Performance.txt";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000858 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000859
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000860 ##############################################################
861 #
862 #
863 # gathering tests added removed broken information here
864 #
865 #
866 ##############################################################
867 my $dejagnu_test_list = ReadFile "$Prefix-Tests.txt";
868 my @DEJAGNU = split "\n", $dejagnu_test_list;
869 my ($passes, $fails, $xfails) = "";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000870
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000871 if(!$NODEJAGNU) {
872 for ($x=0; $x<@DEJAGNU; $x++) {
873 if ($DEJAGNU[$x] =~ m/^PASS:/) {
874 $passes.="$DEJAGNU[$x]\n";
875 }
876 elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
877 $fails.="$DEJAGNU[$x]\n";
878 }
879 elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
880 $xfails.="$DEJAGNU[$x]\n";
881 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000882 }
883 }
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000884
885} #end if !$BuildError
886
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000887
888##############################################################
889#
890# If we built the tree successfully, runs of the Olden suite with
891# LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
892#
893##############################################################
894if (!$BuildError) {
Patrick Jenkinsd7210f92006-08-02 18:37:40 +0000895 if ( $VERBOSE ) { print "OLDEN TEST SUITE STAGE\n"; }
896 my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
897 $MachCodeSize) = ("","","","","","","");
898 if (!$NORUNNINGTESTS) {
899 ChangeDir( "$BuildDir/llvm/projects/llvm-test/MultiSource/Benchmarks/Olden",
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000900 "Olden Test Directory");
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000901
Patrick Jenkinsd7210f92006-08-02 18:37:40 +0000902 # Clean out previous results...
903 system "$NICE $MAKECMD $MAKEOPTS clean > /dev/null 2>&1";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000904
Patrick Jenkinsd7210f92006-08-02 18:37:40 +0000905 # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE and
906 # GET_STABLE_NUMBERS enabled!
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000907 if( $VERBOSE ) {
908 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
909 "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
910 "> /dev/null 2>&1\n";
911 }
912 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
913 "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
914 "> /dev/null 2>&1";
915 system "cp report.nightly.csv $OldenTestsLog";
Patrick Jenkinsd7210f92006-08-02 18:37:40 +0000916 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000917}
918
Patrick Jenkins215b48f2006-07-07 18:50:51 +0000919##############################################################
920#
921# Getting end timestamp
922#
923##############################################################
Patrick Jenkinsb67e1182006-07-21 21:43:09 +0000924$endtime = `date "+20%y-%m-%d %H:%M:%S"`;
Patrick Jenkins215b48f2006-07-07 18:50:51 +0000925
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000926
927##############################################################
928#
929# Place all the logs neatly into one humungous file
930#
931##############################################################
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000932if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
933
934$machine_data = "uname: ".`uname -a`.
935 "hardware: ".`uname -m`.
936 "os: ".`uname -sr`.
937 "name: ".`uname -n`.
938 "date: ".`date \"+20%y-%m-%d\"`.
939 "time: ".`date +\"%H:%M:%S\"`;
940
941my @CVS_DATA;
942my $cvs_data;
943@CVS_DATA = ReadFile "$CVSLog";
944$cvs_data = join("\n", @CVS_DATA);
945
946my @BUILD_DATA;
947my $build_data;
948@BUILD_DATA = ReadFile "$BuildLog";
949$build_data = join("\n", @BUILD_DATA);
950
Patrick Jenkins03137752006-08-21 20:45:57 +0000951my (@DEJAGNU_LOG, @DEJAGNU_SUM, @DEJAGNULOG_FULL, @GCC_VERSION);
952my ($dejagnutests_log ,$dejagnutests_sum, $dejagnulog_full) = "";
953my ($gcc_version, $gcc_version_long) = "";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000954
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000955$gcc_version_long="";
956if ($GCCPATH ne "") {
957 $gcc_version_long = `$GCCPATH/gcc --version`;
958} else {
959 $gcc_version_long = `gcc --version`;
960}
961@GCC_VERSION = split '\n', $gcc_version_long;
962$gcc_version = $GCC_VERSION[0];
963
Patrick Jenkins03137752006-08-21 20:45:57 +0000964if(!$BuildError){
965 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
966 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
967 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
968 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000969
Patrick Jenkins03137752006-08-21 20:45:57 +0000970 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
971 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
Patrick Jenkins79fbf7f2006-07-14 20:44:09 +0000972}
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000973
974##############################################################
975#
976# Send data via a post request
977#
978##############################################################
979
980if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
981
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000982my %hash_of_data = (
983 'machine_data' => $machine_data,
984 'build_data' => $build_data,
985 'gcc_version' => $gcc_version,
986 'nickname' => $nickname,
987 'dejagnutime_wall' => $DejagnuWallTime,
988 'dejagnutime_cpu' => $DejagnuTime,
989 'cvscheckouttime_wall' => $CVSCheckoutTime_Wall,
990 'cvscheckouttime_cpu' => $CVSCheckoutTime_CPU,
991 'configtime_wall' => $ConfigWallTime,
992 'configtime_cpu'=> $ConfigTime,
993 'buildtime_wall' => $BuildWallTime,
994 'buildtime_cpu' => $BuildTime,
995 'warnings' => $WarningsFile,
996 'cvsusercommitlist' => $UserCommitList,
997 'cvsuserupdatelist' => $UserUpdateList,
998 'cvsaddedfiles' => $CVSAddedFiles,
999 'cvsmodifiedfiles' => $CVSModifiedFiles,
1000 'cvsremovedfiles' => $CVSRemovedFiles,
1001 'lines_of_code' => $LOC,
1002 'cvs_file_count' => $NumFilesInCVS,
1003 'cvs_dir_count' => $NumDirsInCVS,
1004 'buildstatus' => $BuildStatus,
1005 'singlesource_programstable' => $SingleSourceProgramsTable,
1006 'multisource_programstable' => $MultiSourceProgramsTable,
1007 'externalsource_programstable' => $ExternalProgramsTable,
1008 'llcbeta_options' => $multisource_llcbeta_options,
1009 'warnings_removed' => $WarningsRemoved,
1010 'warnings_added' => $WarningsAdded,
1011 'passing_tests' => $passes,
1012 'expfail_tests' => $xfails,
1013 'unexpfail_tests' => $fails,
1014 'all_tests' => $dejagnu_test_list,
1015 'new_tests' => "",
1016 'removed_tests' => "",
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +00001017 'dejagnutests_results' => $DejagnuTestResults,
1018 'dejagnutests_log' => $dejagnulog_full,
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001019 'starttime' => $starttime,
1020 'endtime' => $endtime,
1021 'o_file_sizes' => $o_file_sizes,
1022 'a_file_sizes' => $a_file_sizes
1023);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001024
1025$TESTING = 0;
1026
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001027if ($TESTING) {
1028 print "============================\n";
1029 foreach $x(keys %hash_of_data){
1030 print "$x => $hash_of_data{$x}\n";
1031 }
1032} else {
1033 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
1034 if( $VERBOSE) { print "============================\n$response"; }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001035}
1036
1037##############################################################
1038#
1039# Remove the cvs tree...
1040#
1041##############################################################
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001042system ( "$NICE rm -rf $BuildDir")
1043 if (!$NOCHECKOUT and !$NOREMOVE);
1044system ( "$NICE rm -rf $WebDir")
1045 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);