blob: d08607a4a246b32460fd765eb7297b07804ca92a [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 ".
Reid Spencer93c456c2006-10-19 15:24:04 +0000139 "OPTIMIZE_OPTION=-O2";
140 $BUILDTYPE="release-asserts"; next;}
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000141 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
142 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
143 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
144 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
145 $CONFIGUREARGS .= " --disable-jit"; next; }
146 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
147 if (/^-verbose$/) { $VERBOSE = 1; next; }
148 if (/^-debug$/) { $DEBUG = 1; next; }
149 if (/^-nice$/) { $NICE = "nice "; next; }
150 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
151 shift; next; }
152 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
153 shift; next; }
154 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
155 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
156 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
157 if (/^-gccpath/) { $CONFIGUREARGS .=
158 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
159 $GCCPATH=$ARGV[0]; shift; next; }
160 else { $GCCPATH=""; }
161 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
162 else { $CVSCOOPT="";}
163 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
164 shift; next; }
165 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
166 shift; next; }
167 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
168 shift; next; }
169 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
170 shift; next; }
171 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
172 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
173 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
174 if (/^-extraflags/) { $CONFIGUREARGS .=
175 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
176 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
177 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
178 if (/^-nobuild$/) { $NOBUILD = 1; next; }
179 print "Unknown option: $_ : ignoring!\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000180}
181
182if ($ENV{'LLVMGCCDIR'}) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000183 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000184}
185if ($CONFIGUREARGS !~ /--disable-jit/) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000186 $CONFIGUREARGS .= " --enable-jit";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000187}
188
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000189if (@ARGV != 0 and @ARGV != 3 and $VERBOSE) {
190 foreach $x (@ARGV) {
191 print "$x\n";
192 }
193 print "Must specify 0 or 3 options!";
Patrick Jenkinsf58473f2006-07-27 01:03:46 +0000194}
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000195
196if (@ARGV == 3) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000197 $CVSRootDir = $ARGV[0];
198 $BuildDir = $ARGV[1];
199 $WebDir = $ARGV[2];
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000200}
201
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000202if ($CVSRootDir eq "" or
203 $BuildDir eq "" or
204 $WebDir eq "") {
205 die("please specify a cvs root directory, a build directory, and a ".
Patrick Jenkinsf58473f2006-07-27 01:03:46 +0000206 "web directory");
207 }
208
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000209if ($nickname eq "") {
210 die ("Please invoke NewNightlyTest.pl with command line option " .
211 "\"-nickname <nickname>\"");
Patrick Jenkins514e2582006-07-20 22:28:43 +0000212}
Patrick Jenkins1cd46912006-07-27 01:17:17 +0000213
Jim Laskey27b8ba02006-09-28 17:49:20 +0000214if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000215 $BUILDTYPE = "debug";
Patrick Jenkins26ba6092006-07-23 22:57:28 +0000216}
Patrick Jenkins514e2582006-07-20 22:28:43 +0000217
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000218##############################################################
219#
220#define the file names we'll use
221#
222##############################################################
223my $Prefix = "$WebDir/$DATE";
224my $BuildLog = "$Prefix-Build-Log.txt";
225my $CVSLog = "$Prefix-CVS-Log.txt";
226my $OldenTestsLog = "$Prefix-Olden-tests.txt";
227my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
228my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
Patrick Jenkins26ba6092006-07-23 22:57:28 +0000229my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000230my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
231my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
232my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
233if (! -d $WebDir) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000234 mkdir $WebDir, 0777;
Patrick Jenkins03137752006-08-21 20:45:57 +0000235 if($VERBOSE){
236 warn "$WebDir did not exist; creating it.\n";
237 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000238}
239
240if ($VERBOSE) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000241 print "INITIALIZED\n";
242 print "CVS Root = $CVSRootDir\n";
243 print "BuildDir = $BuildDir\n";
244 print "WebDir = $WebDir\n";
245 print "Prefix = $Prefix\n";
246 print "CVSLog = $CVSLog\n";
247 print "BuildLog = $BuildLog\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000248}
249
250##############################################################
251#
252# Helper functions
253#
254##############################################################
255sub GetDir {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000256 my $Suffix = shift;
257 opendir DH, $WebDir;
258 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
259 closedir DH;
260 return @Result;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000261}
262
263#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
264#
265# DiffFiles - Diff the current version of the file against the last version of
266# the file, reporting things added and removed. This is used to report, for
267# example, added and removed warnings. This returns a pair (added, removed)
268#
269#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
270sub DiffFiles {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000271 my $Suffix = shift;
272 my @Others = GetDir $Suffix;
273 if (@Others == 0) { # No other files? We added all entries...
274 return (`cat $WebDir/$DATE$Suffix`, "");
275 }
276# Diff the files now...
277 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
278 my $Added = join "\n", grep /^</, @Diffs;
279 my $Removed = join "\n", grep /^>/, @Diffs;
280 $Added =~ s/^< //gm;
281 $Removed =~ s/^> //gm;
282 return ($Added, $Removed);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000283}
284
285#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
286#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
287sub GetRegex { # (Regex with ()'s, value)
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000288 $_[1] =~ /$_[0]/m;
289 return $1
290 if (defined($1));
291 return "0";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000292}
293
294#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
295#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
296sub GetRegexNum {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000297 my ($Regex, $Num, $Regex2, $File) = @_;
298 my @Items = split "\n", `grep '$Regex' $File`;
299 return GetRegex $Regex2, $Items[$Num];
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000300}
301
302#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
303#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
304sub ChangeDir { # directory, logical name
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000305 my ($dir,$name) = @_;
306 chomp($dir);
307 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
308 $result = chdir($dir);
309 if (!$result) {
310 print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
311 return false;
312 }
313 return true;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000314}
315
316#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
317#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
318sub ReadFile {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000319 if (open (FILE, $_[0])) {
320 undef $/;
321 my $Ret = <FILE>;
322 close FILE;
323 $/ = '\n';
324 return $Ret;
325 } else {
326 print "Could not open file '$_[0]' for reading!\n";
327 return "";
328 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000329}
330
331#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
332#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
333sub WriteFile { # (filename, contents)
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000334 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
335 print FILE $_[1];
336 close FILE;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000337}
338
339#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
340#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
341sub CopyFile { #filename, newfile
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000342 my ($file, $newfile) = @_;
343 chomp($file);
344 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
345 copy($file, $newfile);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000346}
347
348#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
349#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
350sub AddRecord {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000351 my ($Val, $Filename,$WebDir) = @_;
352 my @Records;
353 if (open FILE, "$WebDir/$Filename") {
354 @Records = grep !/$DATE/, split "\n", <FILE>;
355 close FILE;
356 }
357 push @Records, "$DATE: $Val";
358 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000359}
360
361#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
362#
363# FormatTime - Convert a time from 1m23.45 into 83.45
364#
365#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
366sub FormatTime {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000367 my $Time = shift;
368 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
369 $Time = sprintf("%7.4f", $1*60.0+$2);
370 }
371 return $Time;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000372}
373
374#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000375#
376# This function is meant to read in the dejagnu sum file and
377# return a string with only the results (i.e. PASS/FAIL/XPASS/
378# XFAIL).
379#
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000380#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
381sub GetDejagnuTestResults { # (filename, log)
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000382 my ($filename, $DejagnuLog) = @_;
383 my @lines;
384 $/ = "\n"; #Make sure we're going line at a time.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000385
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000386 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000387
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000388 if (open SRCHFILE, $filename) {
389 # Process test results
390 while ( <SRCHFILE> ) {
391 if ( length($_) > 1 ) {
392 chomp($_);
Jim Laskey01d7bcf2006-09-20 09:20:22 +0000393 if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\/test\/(.*)$/ ) {
394 push(@lines, "$1: test/$2");
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000395 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000396 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000397 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000398 }
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000399 close SRCHFILE;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000400
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000401 my $content = join("\n", @lines);
402 return $content;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000403}
404
405
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000406
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000407#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
408#
409# This function acts as a mini web browswer submitting data
410# to our central server via the post method
411#
412#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
413sub SendData{
414 $host = $_[0];
415 $file = $_[1];
416 $variables=$_[2];
417
418 $port=80;
419 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
Patrick Jenkinsadea55e2006-07-17 16:41:19 +0000420 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000421 die "Bad socket\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000422 connect SOCK, $socketaddr or die "Bad connection\n";
423 select((select(SOCK), $| = 1)[0]);
424
425 #creating content here
426 my $content;
427 foreach $key (keys (%$variables)){
428 $value = $variables->{$key};
429 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
430 $content .= "$key=$value&";
431 }
432
433 $length = length($content);
434
435 my $send= "POST $file HTTP/1.0\n";
436 $send.= "Content-Type: application/x-www-form-urlencoded\n";
437 $send.= "Content-length: $length\n\n";
438 $send.= "$content";
439
Patrick Jenkinse8501eb2006-08-07 01:54:37 +0000440 print SOCK $send;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000441 my $result;
442 while(<SOCK>){
443 $result .= $_;
444 }
445 close(SOCK);
446
447 my $sentdata="";
Patrick Jenkins4c4e3562006-07-07 21:40:34 +0000448 foreach $x (keys (%$variables)){
Patrick Jenkins7267bd62006-07-10 18:35:41 +0000449 $value = $variables->{$x};
450 $sentdata.= "$x => $value\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000451 }
452 WriteFile "$Prefix-sentdata.txt", $sentdata;
Patrick Jenkins4c4e3562006-07-07 21:40:34 +0000453
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000454
455 return $result;
456}
457
Patrick Jenkins215b48f2006-07-07 18:50:51 +0000458##############################################################
459#
460# Getting Start timestamp
461#
462##############################################################
Patrick Jenkinsb67e1182006-07-21 21:43:09 +0000463$starttime = `date "+20%y-%m-%d %H:%M:%S"`;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000464
465##############################################################
466#
467# Create the CVS repository directory
468#
469##############################################################
470if (!$NOCHECKOUT) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000471 if (-d $BuildDir) {
472 if (!$NOREMOVE) {
473 if ( $VERBOSE ) {
474 print "Build directory exists! Removing it\n";
475 }
476 system "rm -rf $BuildDir";
Jim Laskey6d8a1b72006-09-15 17:03:36 +0000477 mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000478 } else {
Jim Laskey6d8a1b72006-09-15 17:03:36 +0000479 if ( $VERBOSE ) {
480 print "Build directory exists!\n";
481 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000482 }
Jim Laskey6d8a1b72006-09-15 17:03:36 +0000483 } else {
484 mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000485 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000486}
487ChangeDir( $BuildDir, "CVS checkout directory" );
488
489
490##############################################################
491#
492# Check out the llvm tree, saving CVS messages to the cvs log...
493#
494##############################################################
495my $CVSOPT = "";
496# Use compression if going over ssh.
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000497$CVSOPT = "-z3"
498 if $CVSRootDir =~ /^:ext:/;
Evan Cheng71899662006-08-29 18:01:18 +0000499my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co -P $CVSCOOPT";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000500if (!$NOCHECKOUT) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000501 if ( $VERBOSE ) {
502 print "CHECKOUT STAGE:\n";
503 print "( time -p $CVSCMD llvm; cd llvm/projects ; $CVSCMD llvm-test ) " .
504 "> $CVSLog 2>&1\n";
505 }
506 system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
507 "$CVSCMD llvm-test ) > $CVSLog 2>&1";
508 ChangeDir( $BuildDir , "CVS Checkout directory") ;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000509}
510ChangeDir( "llvm" , "llvm source directory") ;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000511
512##############################################################
513#
514# Get some static statistics about the current state of CVS
515#
516# This can probably be put on the server side
517#
518##############################################################
519my $CVSCheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $CVSLog`;
520my $CVSCheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $CVSLog`;
521my $CVSCheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $CVSLog`;
522my $CVSCheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
523
524my $NumFilesInCVS = `egrep '^U' $CVSLog | wc -l` + 0;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000525my $NumDirsInCVS =
526 `egrep '^cvs (checkout|server|update):' $CVSLog | wc -l` + 0;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000527
528##############################################################
529#
530# Extract some information from the CVS history... use a hash so no duplicate
531# stuff is stored. This gets the history from the previous days worth
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000532# of cvs activity and parses it.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000533#
534##############################################################
535
536my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
537
538if(!$NOCVSSTATS){
539
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000540 if ($VERBOSE) { print "CVS HISTORY ANALYSIS STAGE\n"; }
541 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000542#print join "\n", @CVSHistory; print "\n";
543
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000544 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000545
546# Loop over every record from the CVS history, filling in the hashes.
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000547 foreach $File (@CVSHistory) {
548 my ($Type, $Date, $UID, $Rev, $Filename);
549 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
550 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
551 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
552 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
553 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
554 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
555 } else {
556 print "UNMATCHABLE: $File\n";
557 next;
558 }
559 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
560
561 if ($Filename =~ /^llvm/) {
562 if ($Type eq 'M') { # Modified
563 $ModifiedFiles{$Filename} = 1;
564 $UsersCommitted{$UID} = 1;
565 } elsif ($Type eq 'A') { # Added
566 $AddedFiles{$Filename} = 1;
567 $UsersCommitted{$UID} = 1;
568 } elsif ($Type eq 'R') { # Removed
569 $RemovedFiles{$Filename} = 1;
570 $UsersCommitted{$UID} = 1;
571 } else {
572 $UsersUpdated{$UID} = 1;
573 }
574 }
575 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000576
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000577 my $TestError = 1;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000578
579}#!NOCVSSTATS
580
581my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
582my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
583my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
584my $UserCommitList = join "\n", sort keys %UsersCommitted;
585my $UserUpdateList = join "\n", sort keys %UsersUpdated;
586
587##############################################################
588#
589# Build the entire tree, saving build messages to the build log
590#
591##############################################################
592if (!$NOCHECKOUT && !$NOBUILD) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000593 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
594 if ( $VERBOSE ) {
595 print "CONFIGURE STAGE:\n";
596 print "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
597 "> $BuildLog 2>&1\n";
598 }
599 system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
600 "> $BuildLog 2>&1";
601 if ( $VERBOSE ) {
602 print "BUILD STAGE:\n";
603 print "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1\n";
604 }
605 # Build the entire tree, capturing the output into $BuildLog
606 system "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000607}
608
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000609##############################################################
610#
611# Get some statistics about the build...
612#
613##############################################################
614#this can de done on server
615#my @Linked = split '\n', `grep Linking $BuildLog`;
616#my $NumExecutables = scalar(grep(/executable/, @Linked));
617#my $NumLibraries = scalar(grep(!/executable/, @Linked));
618#my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
619
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000620# Get the number of lines of source code. Must be here after the build is done
621# because countloc.sh uses the llvm-config script which must be built.
Patrick Jenkinsb993b0a2006-08-16 22:18:41 +0000622my $LOC = `utils/countloc.sh -topdir $BuildDir/llvm`;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000623
624# Get the time taken by the configure script
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000625my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
626my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
627my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
628my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
629
630$ConfigTime=-1 unless $ConfigTime;
631$ConfigWallTime=-1 unless $ConfigWallTime;
632
633my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
634my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
635my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
636my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
637
638$BuildTime=-1 unless $BuildTime;
639$BuildWallTime=-1 unless $BuildWallTime;
640
641my $BuildError = 0, $BuildStatus = "OK";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000642if ($NOBUILD) {
643 $BuildStatus = "Skipped by user";
644 $BuildError = 1;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000645}
Patrick Jenkinsf58473f2006-07-27 01:03:46 +0000646elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000647 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
648 $BuildStatus = "Error: compilation aborted";
649 $BuildError = 1;
650 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000651}
652if ($BuildError) { $NODEJAGNU=1; }
653
Patrick Jenkins169357e2006-07-23 21:38:07 +0000654my $a_file_sizes="";
655my $o_file_sizes="";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000656if (!$BuildError) {
657 print "Organizing size of .o and .a files\n"
658 if ( $VERBOSE );
659 ChangeDir( "$BuildDir/llvm", "Build Directory" );
660 $afiles.= `find utils/ -iname '*.a' -ls`;
661 $afiles.= `find lib/ -iname '*.a' -ls`;
662 $afiles.= `find tools/ -iname '*.a' -ls`;
663 if($BUILDTYPE eq "release"){
Jim Laskey7a8efce2006-09-29 17:31:45 +0000664 $afiles.= `find Release/ -iname '*.a' -ls`;
Jim Laskey27b8ba02006-09-28 17:49:20 +0000665 } elsif($BUILDTYPE eq "release-asserts") {
666 $afiles.= `find Release-Asserts/ -iname '*.a' -ls`;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000667 } else {
668 $afiles.= `find Debug/ -iname '*.a' -ls`;
669 }
670
671 $ofiles.= `find utils/ -iname '*.o' -ls`;
672 $ofiles.= `find lib/ -iname '*.o' -ls`;
673 $ofiles.= `find tools/ -iname '*.o' -ls`;
674 if($BUILDTYPE eq "release"){
Jim Laskey7a8efce2006-09-29 17:31:45 +0000675 $ofiles.= `find Release/ -iname '*.o' -ls`;
Jim Laskey27b8ba02006-09-28 17:49:20 +0000676 } elsif($BUILDTYPE eq "release-asserts") {
677 $ofiles.= `find Release-Asserts/ -iname '*.o' -ls`;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000678 } else {
679 $ofiles.= `find Debug/ -iname '*.o' -ls`;
680 }
681
682 @AFILES = split "\n", $afiles;
683 $a_file_sizes="";
684 foreach $x (@AFILES){
685 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
686 $a_file_sizes.="$1 $2 $BUILDTYPE\n";
687 }
688 @OFILES = split "\n", $ofiles;
689 $o_file_sizes="";
690 foreach $x (@OFILES){
691 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
692 $o_file_sizes.="$1 $2 $BUILDTYPE\n";
693 }
694} else {
695 $a_file_sizes="No data due to a bad build.";
696 $o_file_sizes="No data due to a bad build.";
Patrick Jenkins169357e2006-07-23 21:38:07 +0000697}
Patrick Jenkins169357e2006-07-23 21:38:07 +0000698
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000699##############################################################
700#
701# Running dejagnu tests
702#
703##############################################################
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000704my $DejangnuTestResults=""; # String containing the results of the dejagnu
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000705my $dejagnu_output = "$DejagnuTestsLog";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000706if (!$NODEJAGNU) {
707 if($VERBOSE) {
708 print "DEJAGNU FEATURE/REGRESSION TEST STAGE:\n";
709 print "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1\n";
710 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000711
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000712 #Run the feature and regression tests, results are put into testrun.sum
713 #Full log in testrun.log
714 system "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1";
715
716 #Copy the testrun.log and testrun.sum to our webdir
717 CopyFile("test/testrun.log", $DejagnuLog);
718 CopyFile("test/testrun.sum", $DejagnuSum);
719 #can be done on server
720 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
721 $unexpfail_tests = $DejagnuTestResults;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000722}
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000723
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000724#Extract time of dejagnu tests
725my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
726my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
727$DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
728$DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000729$DejagnuTestResults =
730 "Dejagnu skipped by user choice." unless $DejagnuTestResults;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000731$DejagnuTime = "0.0" unless $DejagnuTime;
732$DejagnuWallTime = "0.0" unless $DejagnuWallTime;
733
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000734##############################################################
735#
736# Get warnings from the build
737#
738##############################################################
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000739if (!$NODEJAGNU) {
740 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
741 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
742 my @Warnings;
743 my $CurDir = "";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000744
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000745 foreach $Warning (@Warn) {
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000746 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000747 $CurDir = $1; # Keep track of directory warning is in...
748 # Remove buildir prefix if included
749 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { $CurDir = $1; }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000750 } else {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000751 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000752 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000753 }
754 my $WarningsFile = join "\n", @Warnings;
755 $WarningsFile =~ s/:[0-9]+:/::/g;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000756
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000757 # Emit the warnings file, so we can diff...
758 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
759 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000760
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000761 # Output something to stdout if something has changed
762 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
763 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000764
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000765 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
766 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000767
768} #endif !NODEGAGNU
769
770##############################################################
771#
772# If we built the tree successfully, run the nightly programs tests...
773#
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000774# A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
775# "External")
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000776#
777##############################################################
778sub TestDirectory {
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000779 my $SubDir = shift;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000780 ChangeDir( "$BuildDir/llvm/projects/llvm-test/$SubDir",
781 "Programs Test Subdirectory" ) || return ("", "");
782
783 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
784
785 # Run the programs tests... creating a report.nightly.csv file
786 if (!$NOTEST) {
787 if( $VERBOSE) {
788 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
789 "TEST=nightly > $ProgramTestLog 2>&1\n";
790 }
791 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000792 "TEST=nightly > $ProgramTestLog 2>&1";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000793 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
794 }
795
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000796 my $ProgramsTable;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000797 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000798 $TestError = 1;
799 $ProgramsTable="Error running test $SubDir\n";
800 print "ERROR TESTING\n";
801 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
802 $TestError = 1;
803 $ProgramsTable="Makefile error running tests $SubDir!\n";
804 print "ERROR TESTING\n";
805 } else {
806 $TestError = 0;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000807 #
808 # Create a list of the tests which were run...
809 #
810 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000811 "| sort > $Prefix-$SubDir-Tests.txt";
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000812 }
813 $ProgramsTable = ReadFile "report.nightly.csv";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000814
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000815 ChangeDir( "../../..", "Programs Test Parent Directory" );
816 return ($ProgramsTable, $llcbeta_options);
Patrick Jenkins9e384ab2006-08-14 16:07:14 +0000817} #end sub TestDirectory
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000818
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000819##############################################################
820#
821# Calling sub TestDirectory
822#
823##############################################################
Patrick Jenkinsc281b0d2006-07-27 19:00:01 +0000824if (!$BuildError) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000825 if ( $VERBOSE ) {
Patrick Jenkinse631c4a2006-08-04 17:55:01 +0000826 print "SingleSource TEST STAGE\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000827 }
828 ($SingleSourceProgramsTable, $llcbeta_options) =
829 TestDirectory("SingleSource");
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000830 WriteFile "$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
Patrick Jenkins4257ccb2006-08-08 02:03:53 +0000831 if ( $VERBOSE ) {
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000832 print "MultiSource TEST STAGE\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000833 }
834 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000835 WriteFile "$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000836 if ( ! $NOEXTERNALS ) {
837 if ( $VERBOSE ) {
838 print "External TEST STAGE\n";
839 }
840 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000841 WriteFile "$Prefix-External-Performance.txt", $ExternalProgramsTable;
842 system "cat $Prefix-SingleSource-Tests.txt " .
843 "$Prefix-MultiSource-Tests.txt ".
844 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
845 system "cat $Prefix-SingleSource-Performance.txt " .
846 "$Prefix-MultiSource-Performance.txt ".
847 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000848 } else {
849 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
850 if ( $VERBOSE ) {
851 print "External TEST STAGE SKIPPED\n";
852 }
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000853 system "cat $Prefix-SingleSource-Tests.txt " .
854 "$Prefix-MultiSource-Tests.txt ".
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000855 " | sort > $Prefix-Tests.txt";
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000856 system "cat $Prefix-SingleSource-Performance.txt " .
857 "$Prefix-MultiSource-Performance.txt ".
858 " | sort > $Prefix-Performance.txt";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000859 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000860
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000861 ##############################################################
862 #
863 #
864 # gathering tests added removed broken information here
865 #
866 #
867 ##############################################################
868 my $dejagnu_test_list = ReadFile "$Prefix-Tests.txt";
869 my @DEJAGNU = split "\n", $dejagnu_test_list;
870 my ($passes, $fails, $xfails) = "";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000871
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000872 if(!$NODEJAGNU) {
873 for ($x=0; $x<@DEJAGNU; $x++) {
874 if ($DEJAGNU[$x] =~ m/^PASS:/) {
875 $passes.="$DEJAGNU[$x]\n";
876 }
877 elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
878 $fails.="$DEJAGNU[$x]\n";
879 }
880 elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
881 $xfails.="$DEJAGNU[$x]\n";
882 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000883 }
884 }
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000885
886} #end if !$BuildError
887
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000888
889##############################################################
890#
891# If we built the tree successfully, runs of the Olden suite with
892# LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
893#
894##############################################################
895if (!$BuildError) {
Patrick Jenkinsd7210f92006-08-02 18:37:40 +0000896 if ( $VERBOSE ) { print "OLDEN TEST SUITE STAGE\n"; }
897 my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
898 $MachCodeSize) = ("","","","","","","");
899 if (!$NORUNNINGTESTS) {
900 ChangeDir( "$BuildDir/llvm/projects/llvm-test/MultiSource/Benchmarks/Olden",
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000901 "Olden Test Directory");
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000902
Patrick Jenkinsd7210f92006-08-02 18:37:40 +0000903 # Clean out previous results...
904 system "$NICE $MAKECMD $MAKEOPTS clean > /dev/null 2>&1";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000905
Patrick Jenkinsd7210f92006-08-02 18:37:40 +0000906 # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE and
907 # GET_STABLE_NUMBERS enabled!
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000908 if( $VERBOSE ) {
909 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
910 "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
911 "> /dev/null 2>&1\n";
912 }
913 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
914 "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
915 "> /dev/null 2>&1";
916 system "cp report.nightly.csv $OldenTestsLog";
Patrick Jenkinsd7210f92006-08-02 18:37:40 +0000917 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000918}
919
Patrick Jenkins215b48f2006-07-07 18:50:51 +0000920##############################################################
921#
922# Getting end timestamp
923#
924##############################################################
Patrick Jenkinsb67e1182006-07-21 21:43:09 +0000925$endtime = `date "+20%y-%m-%d %H:%M:%S"`;
Patrick Jenkins215b48f2006-07-07 18:50:51 +0000926
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000927
928##############################################################
929#
930# Place all the logs neatly into one humungous file
931#
932##############################################################
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000933if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
934
935$machine_data = "uname: ".`uname -a`.
936 "hardware: ".`uname -m`.
937 "os: ".`uname -sr`.
938 "name: ".`uname -n`.
939 "date: ".`date \"+20%y-%m-%d\"`.
940 "time: ".`date +\"%H:%M:%S\"`;
941
942my @CVS_DATA;
943my $cvs_data;
944@CVS_DATA = ReadFile "$CVSLog";
945$cvs_data = join("\n", @CVS_DATA);
946
947my @BUILD_DATA;
948my $build_data;
949@BUILD_DATA = ReadFile "$BuildLog";
950$build_data = join("\n", @BUILD_DATA);
951
Patrick Jenkins03137752006-08-21 20:45:57 +0000952my (@DEJAGNU_LOG, @DEJAGNU_SUM, @DEJAGNULOG_FULL, @GCC_VERSION);
953my ($dejagnutests_log ,$dejagnutests_sum, $dejagnulog_full) = "";
954my ($gcc_version, $gcc_version_long) = "";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000955
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000956$gcc_version_long="";
957if ($GCCPATH ne "") {
958 $gcc_version_long = `$GCCPATH/gcc --version`;
959} else {
960 $gcc_version_long = `gcc --version`;
961}
962@GCC_VERSION = split '\n', $gcc_version_long;
963$gcc_version = $GCC_VERSION[0];
964
Patrick Jenkins03137752006-08-21 20:45:57 +0000965if(!$BuildError){
966 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
967 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
968 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
969 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000970
Patrick Jenkins03137752006-08-21 20:45:57 +0000971 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
972 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
Patrick Jenkins79fbf7f2006-07-14 20:44:09 +0000973}
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000974
975##############################################################
976#
977# Send data via a post request
978#
979##############################################################
980
981if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
982
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000983my %hash_of_data = (
984 'machine_data' => $machine_data,
985 'build_data' => $build_data,
986 'gcc_version' => $gcc_version,
987 'nickname' => $nickname,
988 'dejagnutime_wall' => $DejagnuWallTime,
989 'dejagnutime_cpu' => $DejagnuTime,
990 'cvscheckouttime_wall' => $CVSCheckoutTime_Wall,
991 'cvscheckouttime_cpu' => $CVSCheckoutTime_CPU,
992 'configtime_wall' => $ConfigWallTime,
993 'configtime_cpu'=> $ConfigTime,
994 'buildtime_wall' => $BuildWallTime,
995 'buildtime_cpu' => $BuildTime,
996 'warnings' => $WarningsFile,
997 'cvsusercommitlist' => $UserCommitList,
998 'cvsuserupdatelist' => $UserUpdateList,
999 'cvsaddedfiles' => $CVSAddedFiles,
1000 'cvsmodifiedfiles' => $CVSModifiedFiles,
1001 'cvsremovedfiles' => $CVSRemovedFiles,
1002 'lines_of_code' => $LOC,
1003 'cvs_file_count' => $NumFilesInCVS,
1004 'cvs_dir_count' => $NumDirsInCVS,
1005 'buildstatus' => $BuildStatus,
1006 'singlesource_programstable' => $SingleSourceProgramsTable,
1007 'multisource_programstable' => $MultiSourceProgramsTable,
1008 'externalsource_programstable' => $ExternalProgramsTable,
1009 'llcbeta_options' => $multisource_llcbeta_options,
1010 'warnings_removed' => $WarningsRemoved,
1011 'warnings_added' => $WarningsAdded,
1012 'passing_tests' => $passes,
1013 'expfail_tests' => $xfails,
1014 'unexpfail_tests' => $fails,
1015 'all_tests' => $dejagnu_test_list,
1016 'new_tests' => "",
1017 'removed_tests' => "",
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +00001018 'dejagnutests_results' => $DejagnuTestResults,
1019 'dejagnutests_log' => $dejagnulog_full,
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001020 'starttime' => $starttime,
1021 'endtime' => $endtime,
1022 'o_file_sizes' => $o_file_sizes,
1023 'a_file_sizes' => $a_file_sizes
1024);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001025
1026$TESTING = 0;
1027
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001028if ($TESTING) {
1029 print "============================\n";
1030 foreach $x(keys %hash_of_data){
1031 print "$x => $hash_of_data{$x}\n";
1032 }
1033} else {
1034 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
1035 if( $VERBOSE) { print "============================\n$response"; }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001036}
1037
1038##############################################################
1039#
1040# Remove the cvs tree...
1041#
1042##############################################################
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001043system ( "$NICE rm -rf $BuildDir")
1044 if (!$NOCHECKOUT and !$NOREMOVE);
1045system ( "$NICE rm -rf $WebDir")
1046 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);