blob: 5e93ddd4869b5dd9d0996002f8865e3e46a3d0c1 [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
32# -enable-llcbeta Enable testing of beta features in llc.
33# -disable-llc Disable LLC tests in the nightly tester.
34# -disable-jit Disable JIT tests in the nightly tester.
35# -disable-cbe Disable C backend tests in the nightly tester.
36# -verbose Turn on some debug output
37# -debug Print information useful only to maintainers of this script.
38# -nice Checkout/Configure/Build with "nice" to reduce impact
39# on busy servers.
40# -f2c Next argument specifies path to F2C utility
41# -nickname The next argument specifieds the nickname this script
42# will submit to the nightlytest results repository.
43# -gccpath Path to gcc/g++ used to build LLVM
44# -cvstag Check out a specific CVS tag to build LLVM (useful for
45# testing release branches)
46# -target Specify the target triplet
47# -cflags Next argument specifies that C compilation options that
48# override the default.
49# -cxxflags Next argument specifies that C++ compilation options that
50# override the default.
51# -ldflags Next argument specifies that linker options that override
52# the default.
Patrick Jenkins215b48f2006-07-07 18:50:51 +000053# -compileflags Next argument specifies extra options passed to make when
54# building LLVM.
Patrick Jenkins0e9402f2006-08-11 23:02:09 +000055# -use-gmake Use gmake instead of the default make command to build
Patrick Jenkins1cd46912006-07-27 01:17:17 +000056# llvm and run tests.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000057#
58# ---------------- Options to configure llvm-test ----------------------------
Patrick Jenkins215b48f2006-07-07 18:50:51 +000059# -extraflags Next argument specifies extra options that are passed to
60# compile the tests.
61# -noexternals Do not run the external tests (for cases where povray
62# or SPEC are not installed)
63# -with-externals Specify a directory where the external tests are located.
Patrick Jenkins0e9402f2006-08-11 23:02:09 +000064# -submit-server Specifies a server to submit the test results too. If this
65# option is not specified it defaults to
66# llvm.org. This is basically just the address of the
67# webserver
68# -submit-script Specifies which script to call on the submit server. If
69# this option is not specified it defaults to
Jim Laskey6d8a1b72006-09-15 17:03:36 +000070# /nightlytest/NightlyTestAccept.php. This is basically
Patrick Jenkins0e9402f2006-08-11 23:02:09 +000071# everything after the www.yourserver.org.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000072#
73# CVSROOT is the CVS repository from which the tree will be checked out,
74# specified either in the full :method:user@host:/dir syntax, or
75# just /dir if using a local repo.
76# BUILDDIR is the directory where sources for this test run will be checked out
77# AND objects for this test run will be built. This directory MUST NOT
78# exist before the script is run; it will be created by the cvs checkout
79# process and erased (unless -noremove is specified; see above.)
80# WEBDIR is the directory into which the test results web page will be written,
81# AND in which the "index.html" is assumed to be a symlink to the most recent
82# copy of the results. This directory will be created if it does not exist.
83# LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
84# to. This is the same as you would have for a normal LLVM build.
85#
86##############################################################
87#
88# Getting environment variables
89#
90##############################################################
Reid Spencerfa34d7b2006-08-13 09:53:02 +000091my $HOME = $ENV{'HOME'};
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000092my $CVSRootDir = $ENV{'CVSROOT'};
Reid Spencerfa34d7b2006-08-13 09:53:02 +000093$CVSRootDir = "/home/vadve/shared/PublicCVS" unless $CVSRootDir;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000094my $BuildDir = $ENV{'BUILDDIR'};
Reid Spencerfa34d7b2006-08-13 09:53:02 +000095$BuildDir = "$HOME/buildtest" unless $BuildDir;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000096my $WebDir = $ENV{'WEBDIR'};
Reid Spencerfa34d7b2006-08-13 09:53:02 +000097$WebDir = "$HOME/cvs/testresults-X86" unless $WebDir;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000098
99##############################################################
100#
101# Calculate the date prefix...
102#
103##############################################################
104@TIME = localtime;
105my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
106my $DateString = strftime "%B %d, %Y", localtime;
107my $TestStartTime = gmtime() . "GMT<br>" . localtime() . " (local)";
108
109##############################################################
110#
111# Parse arguments...
112#
113##############################################################
114$CONFIGUREARGS="";
Patrick Jenkins49717a42006-07-21 01:39:42 +0000115$nickname="";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000116$NOTEST=0;
117$NORUNNINGTESTS=0;
Patrick Jenkins1cd46912006-07-27 01:17:17 +0000118$MAKECMD="make";
Patrick Jenkins0e9402f2006-08-11 23:02:09 +0000119$SUBMITSERVER = "llvm.org";
Jim Laskey6d8a1b72006-09-15 17:03:36 +0000120$SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000121
122while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000123 shift;
124 last if /^--$/; # Stop processing arguments on --
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000125
126 # List command line options here...
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000127 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
128 if (/^-nocvsstats$/) { $NOCVSSTATS = 1; next; }
129 if (/^-noremove$/) { $NOREMOVE = 1; next; }
130 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
131 if (/^-notest$/) { $NOTEST = 1; $NORUNNINGTESTS = 1; next; }
132 if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
133 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j2 -l3.0"; next; }
134 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
135 "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
136 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
137 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
138 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
139 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
140 $CONFIGUREARGS .= " --disable-jit"; next; }
141 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
142 if (/^-verbose$/) { $VERBOSE = 1; next; }
143 if (/^-debug$/) { $DEBUG = 1; next; }
144 if (/^-nice$/) { $NICE = "nice "; next; }
145 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
146 shift; next; }
147 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
148 shift; next; }
149 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
150 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
151 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
152 if (/^-gccpath/) { $CONFIGUREARGS .=
153 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
154 $GCCPATH=$ARGV[0]; shift; next; }
155 else { $GCCPATH=""; }
156 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
157 else { $CVSCOOPT="";}
158 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
159 shift; next; }
160 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
161 shift; next; }
162 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
163 shift; next; }
164 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
165 shift; next; }
166 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
167 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
168 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
169 if (/^-extraflags/) { $CONFIGUREARGS .=
170 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
171 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
172 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
173 if (/^-nobuild$/) { $NOBUILD = 1; next; }
174 print "Unknown option: $_ : ignoring!\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000175}
176
177if ($ENV{'LLVMGCCDIR'}) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000178 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000179}
180if ($CONFIGUREARGS !~ /--disable-jit/) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000181 $CONFIGUREARGS .= " --enable-jit";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000182}
183
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000184if (@ARGV != 0 and @ARGV != 3 and $VERBOSE) {
185 foreach $x (@ARGV) {
186 print "$x\n";
187 }
188 print "Must specify 0 or 3 options!";
Patrick Jenkinsf58473f2006-07-27 01:03:46 +0000189}
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000190
191if (@ARGV == 3) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000192 $CVSRootDir = $ARGV[0];
193 $BuildDir = $ARGV[1];
194 $WebDir = $ARGV[2];
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000195}
196
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000197if ($CVSRootDir eq "" or
198 $BuildDir eq "" or
199 $WebDir eq "") {
200 die("please specify a cvs root directory, a build directory, and a ".
Patrick Jenkinsf58473f2006-07-27 01:03:46 +0000201 "web directory");
202 }
203
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000204if ($nickname eq "") {
205 die ("Please invoke NewNightlyTest.pl with command line option " .
206 "\"-nickname <nickname>\"");
Patrick Jenkins514e2582006-07-20 22:28:43 +0000207}
Patrick Jenkins1cd46912006-07-27 01:17:17 +0000208
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000209if ($BUILDTYPE ne "release") {
210 $BUILDTYPE = "debug";
Patrick Jenkins26ba6092006-07-23 22:57:28 +0000211}
Patrick Jenkins514e2582006-07-20 22:28:43 +0000212
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000213##############################################################
214#
215#define the file names we'll use
216#
217##############################################################
218my $Prefix = "$WebDir/$DATE";
219my $BuildLog = "$Prefix-Build-Log.txt";
220my $CVSLog = "$Prefix-CVS-Log.txt";
221my $OldenTestsLog = "$Prefix-Olden-tests.txt";
222my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
223my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
Patrick Jenkins26ba6092006-07-23 22:57:28 +0000224my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000225my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
226my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
227my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
228if (! -d $WebDir) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000229 mkdir $WebDir, 0777;
Patrick Jenkins03137752006-08-21 20:45:57 +0000230 if($VERBOSE){
231 warn "$WebDir did not exist; creating it.\n";
232 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000233}
234
235if ($VERBOSE) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000236 print "INITIALIZED\n";
237 print "CVS Root = $CVSRootDir\n";
238 print "BuildDir = $BuildDir\n";
239 print "WebDir = $WebDir\n";
240 print "Prefix = $Prefix\n";
241 print "CVSLog = $CVSLog\n";
242 print "BuildLog = $BuildLog\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000243}
244
245##############################################################
246#
247# Helper functions
248#
249##############################################################
250sub GetDir {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000251 my $Suffix = shift;
252 opendir DH, $WebDir;
253 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
254 closedir DH;
255 return @Result;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000256}
257
258#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
259#
260# DiffFiles - Diff the current version of the file against the last version of
261# the file, reporting things added and removed. This is used to report, for
262# example, added and removed warnings. This returns a pair (added, removed)
263#
264#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
265sub DiffFiles {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000266 my $Suffix = shift;
267 my @Others = GetDir $Suffix;
268 if (@Others == 0) { # No other files? We added all entries...
269 return (`cat $WebDir/$DATE$Suffix`, "");
270 }
271# Diff the files now...
272 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
273 my $Added = join "\n", grep /^</, @Diffs;
274 my $Removed = join "\n", grep /^>/, @Diffs;
275 $Added =~ s/^< //gm;
276 $Removed =~ s/^> //gm;
277 return ($Added, $Removed);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000278}
279
280#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
281#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
282sub GetRegex { # (Regex with ()'s, value)
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000283 $_[1] =~ /$_[0]/m;
284 return $1
285 if (defined($1));
286 return "0";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000287}
288
289#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
290#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
291sub GetRegexNum {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000292 my ($Regex, $Num, $Regex2, $File) = @_;
293 my @Items = split "\n", `grep '$Regex' $File`;
294 return GetRegex $Regex2, $Items[$Num];
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000295}
296
297#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
298#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
299sub ChangeDir { # directory, logical name
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000300 my ($dir,$name) = @_;
301 chomp($dir);
302 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
303 $result = chdir($dir);
304 if (!$result) {
305 print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
306 return false;
307 }
308 return true;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000309}
310
311#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
312#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
313sub ReadFile {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000314 if (open (FILE, $_[0])) {
315 undef $/;
316 my $Ret = <FILE>;
317 close FILE;
318 $/ = '\n';
319 return $Ret;
320 } else {
321 print "Could not open file '$_[0]' for reading!\n";
322 return "";
323 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000324}
325
326#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
327#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
328sub WriteFile { # (filename, contents)
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000329 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
330 print FILE $_[1];
331 close FILE;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000332}
333
334#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
335#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
336sub CopyFile { #filename, newfile
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000337 my ($file, $newfile) = @_;
338 chomp($file);
339 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
340 copy($file, $newfile);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000341}
342
343#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
344#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
345sub AddRecord {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000346 my ($Val, $Filename,$WebDir) = @_;
347 my @Records;
348 if (open FILE, "$WebDir/$Filename") {
349 @Records = grep !/$DATE/, split "\n", <FILE>;
350 close FILE;
351 }
352 push @Records, "$DATE: $Val";
353 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000354}
355
356#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
357#
358# FormatTime - Convert a time from 1m23.45 into 83.45
359#
360#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
361sub FormatTime {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000362 my $Time = shift;
363 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
364 $Time = sprintf("%7.4f", $1*60.0+$2);
365 }
366 return $Time;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000367}
368
369#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000370#
371# This function is meant to read in the dejagnu sum file and
372# return a string with only the results (i.e. PASS/FAIL/XPASS/
373# XFAIL).
374#
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000375#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
376sub GetDejagnuTestResults { # (filename, log)
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000377 my ($filename, $DejagnuLog) = @_;
378 my @lines;
379 $/ = "\n"; #Make sure we're going line at a time.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000380
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000381 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000382
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000383 if (open SRCHFILE, $filename) {
384 # Process test results
385 while ( <SRCHFILE> ) {
386 if ( length($_) > 1 ) {
387 chomp($_);
388 if ( m/^PASS:/ || m/^XPASS:/ ||
389 m/^FAIL:/ || m/^XFAIL:/) {
390 push(@lines, "$_");
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000391 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000392 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000393 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000394 }
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000395 close SRCHFILE;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000396
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000397 my $content = join("\n", @lines);
398 return $content;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000399}
400
401
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000402
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000403#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
404#
405# This function acts as a mini web browswer submitting data
406# to our central server via the post method
407#
408#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
409sub SendData{
410 $host = $_[0];
411 $file = $_[1];
412 $variables=$_[2];
413
414 $port=80;
415 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
Patrick Jenkinsadea55e2006-07-17 16:41:19 +0000416 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000417 die "Bad socket\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000418 connect SOCK, $socketaddr or die "Bad connection\n";
419 select((select(SOCK), $| = 1)[0]);
420
421 #creating content here
422 my $content;
423 foreach $key (keys (%$variables)){
424 $value = $variables->{$key};
425 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
426 $content .= "$key=$value&";
427 }
428
429 $length = length($content);
430
431 my $send= "POST $file HTTP/1.0\n";
432 $send.= "Content-Type: application/x-www-form-urlencoded\n";
433 $send.= "Content-length: $length\n\n";
434 $send.= "$content";
435
Patrick Jenkinse8501eb2006-08-07 01:54:37 +0000436 print SOCK $send;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000437 my $result;
438 while(<SOCK>){
439 $result .= $_;
440 }
441 close(SOCK);
442
443 my $sentdata="";
Patrick Jenkins4c4e3562006-07-07 21:40:34 +0000444 foreach $x (keys (%$variables)){
Patrick Jenkins7267bd62006-07-10 18:35:41 +0000445 $value = $variables->{$x};
446 $sentdata.= "$x => $value\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000447 }
448 WriteFile "$Prefix-sentdata.txt", $sentdata;
Patrick Jenkins4c4e3562006-07-07 21:40:34 +0000449
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000450
451 return $result;
452}
453
Patrick Jenkins215b48f2006-07-07 18:50:51 +0000454##############################################################
455#
456# Getting Start timestamp
457#
458##############################################################
Patrick Jenkinsb67e1182006-07-21 21:43:09 +0000459$starttime = `date "+20%y-%m-%d %H:%M:%S"`;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000460
461##############################################################
462#
463# Create the CVS repository directory
464#
465##############################################################
466if (!$NOCHECKOUT) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000467 if (-d $BuildDir) {
468 if (!$NOREMOVE) {
469 if ( $VERBOSE ) {
470 print "Build directory exists! Removing it\n";
471 }
472 system "rm -rf $BuildDir";
Jim Laskey6d8a1b72006-09-15 17:03:36 +0000473 mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000474 } else {
Jim Laskey6d8a1b72006-09-15 17:03:36 +0000475 if ( $VERBOSE ) {
476 print "Build directory exists!\n";
477 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000478 }
Jim Laskey6d8a1b72006-09-15 17:03:36 +0000479 } else {
480 mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000481 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000482}
483ChangeDir( $BuildDir, "CVS checkout directory" );
484
485
486##############################################################
487#
488# Check out the llvm tree, saving CVS messages to the cvs log...
489#
490##############################################################
491my $CVSOPT = "";
492# Use compression if going over ssh.
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000493$CVSOPT = "-z3"
494 if $CVSRootDir =~ /^:ext:/;
Evan Cheng71899662006-08-29 18:01:18 +0000495my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co -P $CVSCOOPT";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000496if (!$NOCHECKOUT) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000497 if ( $VERBOSE ) {
498 print "CHECKOUT STAGE:\n";
499 print "( time -p $CVSCMD llvm; cd llvm/projects ; $CVSCMD llvm-test ) " .
500 "> $CVSLog 2>&1\n";
501 }
502 system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
503 "$CVSCMD llvm-test ) > $CVSLog 2>&1";
504 ChangeDir( $BuildDir , "CVS Checkout directory") ;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000505}
506ChangeDir( "llvm" , "llvm source directory") ;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000507
508##############################################################
509#
510# Get some static statistics about the current state of CVS
511#
512# This can probably be put on the server side
513#
514##############################################################
515my $CVSCheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $CVSLog`;
516my $CVSCheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $CVSLog`;
517my $CVSCheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $CVSLog`;
518my $CVSCheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
519
520my $NumFilesInCVS = `egrep '^U' $CVSLog | wc -l` + 0;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000521my $NumDirsInCVS =
522 `egrep '^cvs (checkout|server|update):' $CVSLog | wc -l` + 0;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000523
524##############################################################
525#
526# Extract some information from the CVS history... use a hash so no duplicate
527# stuff is stored. This gets the history from the previous days worth
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000528# of cvs activity and parses it.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000529#
530##############################################################
531
532my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
533
534if(!$NOCVSSTATS){
535
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000536 if ($VERBOSE) { print "CVS HISTORY ANALYSIS STAGE\n"; }
537 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000538#print join "\n", @CVSHistory; print "\n";
539
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000540 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000541
542# Loop over every record from the CVS history, filling in the hashes.
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000543 foreach $File (@CVSHistory) {
544 my ($Type, $Date, $UID, $Rev, $Filename);
545 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
546 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
547 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
548 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
549 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
550 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
551 } else {
552 print "UNMATCHABLE: $File\n";
553 next;
554 }
555 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
556
557 if ($Filename =~ /^llvm/) {
558 if ($Type eq 'M') { # Modified
559 $ModifiedFiles{$Filename} = 1;
560 $UsersCommitted{$UID} = 1;
561 } elsif ($Type eq 'A') { # Added
562 $AddedFiles{$Filename} = 1;
563 $UsersCommitted{$UID} = 1;
564 } elsif ($Type eq 'R') { # Removed
565 $RemovedFiles{$Filename} = 1;
566 $UsersCommitted{$UID} = 1;
567 } else {
568 $UsersUpdated{$UID} = 1;
569 }
570 }
571 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000572
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000573 my $TestError = 1;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000574
575}#!NOCVSSTATS
576
577my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
578my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
579my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
580my $UserCommitList = join "\n", sort keys %UsersCommitted;
581my $UserUpdateList = join "\n", sort keys %UsersUpdated;
582
583##############################################################
584#
585# Build the entire tree, saving build messages to the build log
586#
587##############################################################
588if (!$NOCHECKOUT && !$NOBUILD) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000589 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
590 if ( $VERBOSE ) {
591 print "CONFIGURE STAGE:\n";
592 print "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
593 "> $BuildLog 2>&1\n";
594 }
595 system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
596 "> $BuildLog 2>&1";
597 if ( $VERBOSE ) {
598 print "BUILD STAGE:\n";
599 print "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1\n";
600 }
601 # Build the entire tree, capturing the output into $BuildLog
602 system "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000603}
604
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000605##############################################################
606#
607# Get some statistics about the build...
608#
609##############################################################
610#this can de done on server
611#my @Linked = split '\n', `grep Linking $BuildLog`;
612#my $NumExecutables = scalar(grep(/executable/, @Linked));
613#my $NumLibraries = scalar(grep(!/executable/, @Linked));
614#my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
615
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000616# Get the number of lines of source code. Must be here after the build is done
617# because countloc.sh uses the llvm-config script which must be built.
Patrick Jenkinsb993b0a2006-08-16 22:18:41 +0000618my $LOC = `utils/countloc.sh -topdir $BuildDir/llvm`;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000619
620# Get the time taken by the configure script
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000621my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
622my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
623my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
624my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
625
626$ConfigTime=-1 unless $ConfigTime;
627$ConfigWallTime=-1 unless $ConfigWallTime;
628
629my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
630my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
631my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
632my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
633
634$BuildTime=-1 unless $BuildTime;
635$BuildWallTime=-1 unless $BuildWallTime;
636
637my $BuildError = 0, $BuildStatus = "OK";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000638if ($NOBUILD) {
639 $BuildStatus = "Skipped by user";
640 $BuildError = 1;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000641}
Patrick Jenkinsf58473f2006-07-27 01:03:46 +0000642elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000643 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
644 $BuildStatus = "Error: compilation aborted";
645 $BuildError = 1;
646 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000647}
648if ($BuildError) { $NODEJAGNU=1; }
649
Patrick Jenkins169357e2006-07-23 21:38:07 +0000650my $a_file_sizes="";
651my $o_file_sizes="";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000652if (!$BuildError) {
653 print "Organizing size of .o and .a files\n"
654 if ( $VERBOSE );
655 ChangeDir( "$BuildDir/llvm", "Build Directory" );
656 $afiles.= `find utils/ -iname '*.a' -ls`;
657 $afiles.= `find lib/ -iname '*.a' -ls`;
658 $afiles.= `find tools/ -iname '*.a' -ls`;
659 if($BUILDTYPE eq "release"){
660 $afiles.= `find Release/ -iname '*.a' -ls`;
661 } else {
662 $afiles.= `find Debug/ -iname '*.a' -ls`;
663 }
664
665 $ofiles.= `find utils/ -iname '*.o' -ls`;
666 $ofiles.= `find lib/ -iname '*.o' -ls`;
667 $ofiles.= `find tools/ -iname '*.o' -ls`;
668 if($BUILDTYPE eq "release"){
669 $ofiles.= `find Release/ -iname '*.o' -ls`;
670 } else {
671 $ofiles.= `find Debug/ -iname '*.o' -ls`;
672 }
673
674 @AFILES = split "\n", $afiles;
675 $a_file_sizes="";
676 foreach $x (@AFILES){
677 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
678 $a_file_sizes.="$1 $2 $BUILDTYPE\n";
679 }
680 @OFILES = split "\n", $ofiles;
681 $o_file_sizes="";
682 foreach $x (@OFILES){
683 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
684 $o_file_sizes.="$1 $2 $BUILDTYPE\n";
685 }
686} else {
687 $a_file_sizes="No data due to a bad build.";
688 $o_file_sizes="No data due to a bad build.";
Patrick Jenkins169357e2006-07-23 21:38:07 +0000689}
Patrick Jenkins169357e2006-07-23 21:38:07 +0000690
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000691##############################################################
692#
693# Running dejagnu tests
694#
695##############################################################
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000696my $DejangnuTestResults=""; # String containing the results of the dejagnu
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000697my $dejagnu_output = "$DejagnuTestsLog";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000698if (!$NODEJAGNU) {
699 if($VERBOSE) {
700 print "DEJAGNU FEATURE/REGRESSION TEST STAGE:\n";
701 print "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1\n";
702 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000703
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000704 #Run the feature and regression tests, results are put into testrun.sum
705 #Full log in testrun.log
706 system "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1";
707
708 #Copy the testrun.log and testrun.sum to our webdir
709 CopyFile("test/testrun.log", $DejagnuLog);
710 CopyFile("test/testrun.sum", $DejagnuSum);
711 #can be done on server
712 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
713 $unexpfail_tests = $DejagnuTestResults;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000714}
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000715
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000716#Extract time of dejagnu tests
717my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
718my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
719$DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
720$DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000721$DejagnuTestResults =
722 "Dejagnu skipped by user choice." unless $DejagnuTestResults;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000723$DejagnuTime = "0.0" unless $DejagnuTime;
724$DejagnuWallTime = "0.0" unless $DejagnuWallTime;
725
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000726##############################################################
727#
728# Get warnings from the build
729#
730##############################################################
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000731if (!$NODEJAGNU) {
732 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
733 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
734 my @Warnings;
735 my $CurDir = "";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000736
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000737 foreach $Warning (@Warn) {
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000738 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000739 $CurDir = $1; # Keep track of directory warning is in...
740 # Remove buildir prefix if included
741 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { $CurDir = $1; }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000742 } else {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000743 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000744 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000745 }
746 my $WarningsFile = join "\n", @Warnings;
747 $WarningsFile =~ s/:[0-9]+:/::/g;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000748
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000749 # Emit the warnings file, so we can diff...
750 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
751 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000752
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000753 # Output something to stdout if something has changed
754 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
755 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000756
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000757 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
758 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000759
760} #endif !NODEGAGNU
761
762##############################################################
763#
764# If we built the tree successfully, run the nightly programs tests...
765#
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000766# A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
767# "External")
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000768#
769##############################################################
770sub TestDirectory {
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000771 my $SubDir = shift;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000772 ChangeDir( "$BuildDir/llvm/projects/llvm-test/$SubDir",
773 "Programs Test Subdirectory" ) || return ("", "");
774
775 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
776
777 # Run the programs tests... creating a report.nightly.csv file
778 if (!$NOTEST) {
779 if( $VERBOSE) {
780 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
781 "TEST=nightly > $ProgramTestLog 2>&1\n";
782 }
783 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000784 "TEST=nightly > $ProgramTestLog 2>&1";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000785 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
786 }
787
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000788 my $ProgramsTable;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000789 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000790 $TestError = 1;
791 $ProgramsTable="Error running test $SubDir\n";
792 print "ERROR TESTING\n";
793 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
794 $TestError = 1;
795 $ProgramsTable="Makefile error running tests $SubDir!\n";
796 print "ERROR TESTING\n";
797 } else {
798 $TestError = 0;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000799 #
800 # Create a list of the tests which were run...
801 #
802 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000803 "| sort > $Prefix-$SubDir-Tests.txt";
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000804 }
805 $ProgramsTable = ReadFile "report.nightly.csv";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000806
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000807 ChangeDir( "../../..", "Programs Test Parent Directory" );
808 return ($ProgramsTable, $llcbeta_options);
Patrick Jenkins9e384ab2006-08-14 16:07:14 +0000809} #end sub TestDirectory
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000810
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000811##############################################################
812#
813# Calling sub TestDirectory
814#
815##############################################################
Patrick Jenkinsc281b0d2006-07-27 19:00:01 +0000816if (!$BuildError) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000817 if ( $VERBOSE ) {
Patrick Jenkinse631c4a2006-08-04 17:55:01 +0000818 print "SingleSource TEST STAGE\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000819 }
820 ($SingleSourceProgramsTable, $llcbeta_options) =
821 TestDirectory("SingleSource");
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000822 WriteFile "$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
Patrick Jenkins4257ccb2006-08-08 02:03:53 +0000823 if ( $VERBOSE ) {
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000824 print "MultiSource TEST STAGE\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000825 }
826 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000827 WriteFile "$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000828 if ( ! $NOEXTERNALS ) {
829 if ( $VERBOSE ) {
830 print "External TEST STAGE\n";
831 }
832 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000833 WriteFile "$Prefix-External-Performance.txt", $ExternalProgramsTable;
834 system "cat $Prefix-SingleSource-Tests.txt " .
835 "$Prefix-MultiSource-Tests.txt ".
836 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
837 system "cat $Prefix-SingleSource-Performance.txt " .
838 "$Prefix-MultiSource-Performance.txt ".
839 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000840 } else {
841 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
842 if ( $VERBOSE ) {
843 print "External TEST STAGE SKIPPED\n";
844 }
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000845 system "cat $Prefix-SingleSource-Tests.txt " .
846 "$Prefix-MultiSource-Tests.txt ".
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000847 " | sort > $Prefix-Tests.txt";
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000848 system "cat $Prefix-SingleSource-Performance.txt " .
849 "$Prefix-MultiSource-Performance.txt ".
850 " | sort > $Prefix-Performance.txt";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000851 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000852
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000853 ##############################################################
854 #
855 #
856 # gathering tests added removed broken information here
857 #
858 #
859 ##############################################################
860 my $dejagnu_test_list = ReadFile "$Prefix-Tests.txt";
861 my @DEJAGNU = split "\n", $dejagnu_test_list;
862 my ($passes, $fails, $xfails) = "";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000863
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000864 if(!$NODEJAGNU) {
865 for ($x=0; $x<@DEJAGNU; $x++) {
866 if ($DEJAGNU[$x] =~ m/^PASS:/) {
867 $passes.="$DEJAGNU[$x]\n";
868 }
869 elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
870 $fails.="$DEJAGNU[$x]\n";
871 }
872 elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
873 $xfails.="$DEJAGNU[$x]\n";
874 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000875 }
876 }
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000877
878} #end if !$BuildError
879
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000880
881##############################################################
882#
883# If we built the tree successfully, runs of the Olden suite with
884# LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
885#
886##############################################################
887if (!$BuildError) {
Patrick Jenkinsd7210f92006-08-02 18:37:40 +0000888 if ( $VERBOSE ) { print "OLDEN TEST SUITE STAGE\n"; }
889 my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
890 $MachCodeSize) = ("","","","","","","");
891 if (!$NORUNNINGTESTS) {
892 ChangeDir( "$BuildDir/llvm/projects/llvm-test/MultiSource/Benchmarks/Olden",
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000893 "Olden Test Directory");
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000894
Patrick Jenkinsd7210f92006-08-02 18:37:40 +0000895 # Clean out previous results...
896 system "$NICE $MAKECMD $MAKEOPTS clean > /dev/null 2>&1";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000897
Patrick Jenkinsd7210f92006-08-02 18:37:40 +0000898 # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE and
899 # GET_STABLE_NUMBERS enabled!
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000900 if( $VERBOSE ) {
901 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
902 "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
903 "> /dev/null 2>&1\n";
904 }
905 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
906 "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
907 "> /dev/null 2>&1";
908 system "cp report.nightly.csv $OldenTestsLog";
Patrick Jenkinsd7210f92006-08-02 18:37:40 +0000909 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000910}
911
Patrick Jenkins215b48f2006-07-07 18:50:51 +0000912##############################################################
913#
914# Getting end timestamp
915#
916##############################################################
Patrick Jenkinsb67e1182006-07-21 21:43:09 +0000917$endtime = `date "+20%y-%m-%d %H:%M:%S"`;
Patrick Jenkins215b48f2006-07-07 18:50:51 +0000918
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000919
920##############################################################
921#
922# Place all the logs neatly into one humungous file
923#
924##############################################################
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000925if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
926
927$machine_data = "uname: ".`uname -a`.
928 "hardware: ".`uname -m`.
929 "os: ".`uname -sr`.
930 "name: ".`uname -n`.
931 "date: ".`date \"+20%y-%m-%d\"`.
932 "time: ".`date +\"%H:%M:%S\"`;
933
934my @CVS_DATA;
935my $cvs_data;
936@CVS_DATA = ReadFile "$CVSLog";
937$cvs_data = join("\n", @CVS_DATA);
938
939my @BUILD_DATA;
940my $build_data;
941@BUILD_DATA = ReadFile "$BuildLog";
942$build_data = join("\n", @BUILD_DATA);
943
Patrick Jenkins03137752006-08-21 20:45:57 +0000944my (@DEJAGNU_LOG, @DEJAGNU_SUM, @DEJAGNULOG_FULL, @GCC_VERSION);
945my ($dejagnutests_log ,$dejagnutests_sum, $dejagnulog_full) = "";
946my ($gcc_version, $gcc_version_long) = "";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000947
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000948$gcc_version_long="";
949if ($GCCPATH ne "") {
950 $gcc_version_long = `$GCCPATH/gcc --version`;
951} else {
952 $gcc_version_long = `gcc --version`;
953}
954@GCC_VERSION = split '\n', $gcc_version_long;
955$gcc_version = $GCC_VERSION[0];
956
Patrick Jenkins03137752006-08-21 20:45:57 +0000957if(!$BuildError){
958 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
959 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
960 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
961 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000962
Patrick Jenkins03137752006-08-21 20:45:57 +0000963 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
964 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
Patrick Jenkins79fbf7f2006-07-14 20:44:09 +0000965}
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000966
967##############################################################
968#
969# Send data via a post request
970#
971##############################################################
972
973if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
974
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000975my %hash_of_data = (
976 'machine_data' => $machine_data,
977 'build_data' => $build_data,
978 'gcc_version' => $gcc_version,
979 'nickname' => $nickname,
980 'dejagnutime_wall' => $DejagnuWallTime,
981 'dejagnutime_cpu' => $DejagnuTime,
982 'cvscheckouttime_wall' => $CVSCheckoutTime_Wall,
983 'cvscheckouttime_cpu' => $CVSCheckoutTime_CPU,
984 'configtime_wall' => $ConfigWallTime,
985 'configtime_cpu'=> $ConfigTime,
986 'buildtime_wall' => $BuildWallTime,
987 'buildtime_cpu' => $BuildTime,
988 'warnings' => $WarningsFile,
989 'cvsusercommitlist' => $UserCommitList,
990 'cvsuserupdatelist' => $UserUpdateList,
991 'cvsaddedfiles' => $CVSAddedFiles,
992 'cvsmodifiedfiles' => $CVSModifiedFiles,
993 'cvsremovedfiles' => $CVSRemovedFiles,
994 'lines_of_code' => $LOC,
995 'cvs_file_count' => $NumFilesInCVS,
996 'cvs_dir_count' => $NumDirsInCVS,
997 'buildstatus' => $BuildStatus,
998 'singlesource_programstable' => $SingleSourceProgramsTable,
999 'multisource_programstable' => $MultiSourceProgramsTable,
1000 'externalsource_programstable' => $ExternalProgramsTable,
1001 'llcbeta_options' => $multisource_llcbeta_options,
1002 'warnings_removed' => $WarningsRemoved,
1003 'warnings_added' => $WarningsAdded,
1004 'passing_tests' => $passes,
1005 'expfail_tests' => $xfails,
1006 'unexpfail_tests' => $fails,
1007 'all_tests' => $dejagnu_test_list,
1008 'new_tests' => "",
1009 'removed_tests' => "",
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +00001010 'dejagnutests_results' => $DejagnuTestResults,
1011 'dejagnutests_log' => $dejagnulog_full,
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001012 'starttime' => $starttime,
1013 'endtime' => $endtime,
1014 'o_file_sizes' => $o_file_sizes,
1015 'a_file_sizes' => $a_file_sizes
1016);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001017
1018$TESTING = 0;
1019
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001020if ($TESTING) {
1021 print "============================\n";
1022 foreach $x(keys %hash_of_data){
1023 print "$x => $hash_of_data{$x}\n";
1024 }
1025} else {
1026 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
1027 if( $VERBOSE) { print "============================\n$response"; }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001028}
1029
1030##############################################################
1031#
1032# Remove the cvs tree...
1033#
1034##############################################################
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001035system ( "$NICE rm -rf $BuildDir")
1036 if (!$NOCHECKOUT and !$NOREMOVE);
1037system ( "$NICE rm -rf $WebDir")
1038 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);