blob: 21492e4d25872c50973a1b2303b97589900eaacc [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
70# /nightlytest/NightlyTestAccept.cgi. This is basically
71# 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";
Patrick Jenkinsb993b0a2006-08-16 22:18:41 +0000120$SUBMITSCRIPT = "/nightlytest/NightlyTestAccept2.cgi";
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;
230 warn "$WebDir did not exist; creating it.\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000231}
232
233if ($VERBOSE) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000234 print "INITIALIZED\n";
235 print "CVS Root = $CVSRootDir\n";
236 print "BuildDir = $BuildDir\n";
237 print "WebDir = $WebDir\n";
238 print "Prefix = $Prefix\n";
239 print "CVSLog = $CVSLog\n";
240 print "BuildLog = $BuildLog\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000241}
242
243##############################################################
244#
245# Helper functions
246#
247##############################################################
248sub GetDir {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000249 my $Suffix = shift;
250 opendir DH, $WebDir;
251 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
252 closedir DH;
253 return @Result;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000254}
255
256#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
257#
258# DiffFiles - Diff the current version of the file against the last version of
259# the file, reporting things added and removed. This is used to report, for
260# example, added and removed warnings. This returns a pair (added, removed)
261#
262#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
263sub DiffFiles {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000264 my $Suffix = shift;
265 my @Others = GetDir $Suffix;
266 if (@Others == 0) { # No other files? We added all entries...
267 return (`cat $WebDir/$DATE$Suffix`, "");
268 }
269# Diff the files now...
270 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
271 my $Added = join "\n", grep /^</, @Diffs;
272 my $Removed = join "\n", grep /^>/, @Diffs;
273 $Added =~ s/^< //gm;
274 $Removed =~ s/^> //gm;
275 return ($Added, $Removed);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000276}
277
278#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
279#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
280sub GetRegex { # (Regex with ()'s, value)
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000281 $_[1] =~ /$_[0]/m;
282 return $1
283 if (defined($1));
284 return "0";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000285}
286
287#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
288#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
289sub GetRegexNum {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000290 my ($Regex, $Num, $Regex2, $File) = @_;
291 my @Items = split "\n", `grep '$Regex' $File`;
292 return GetRegex $Regex2, $Items[$Num];
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000293}
294
295#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
296#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
297sub ChangeDir { # directory, logical name
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000298 my ($dir,$name) = @_;
299 chomp($dir);
300 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
301 $result = chdir($dir);
302 if (!$result) {
303 print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
304 return false;
305 }
306 return true;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000307}
308
309#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
310#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
311sub ReadFile {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000312 if (open (FILE, $_[0])) {
313 undef $/;
314 my $Ret = <FILE>;
315 close FILE;
316 $/ = '\n';
317 return $Ret;
318 } else {
319 print "Could not open file '$_[0]' for reading!\n";
320 return "";
321 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000322}
323
324#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
325#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
326sub WriteFile { # (filename, contents)
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000327 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
328 print FILE $_[1];
329 close FILE;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000330}
331
332#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
333#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
334sub CopyFile { #filename, newfile
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000335 my ($file, $newfile) = @_;
336 chomp($file);
337 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
338 copy($file, $newfile);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000339}
340
341#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
342#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
343sub AddRecord {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000344 my ($Val, $Filename,$WebDir) = @_;
345 my @Records;
346 if (open FILE, "$WebDir/$Filename") {
347 @Records = grep !/$DATE/, split "\n", <FILE>;
348 close FILE;
349 }
350 push @Records, "$DATE: $Val";
351 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000352}
353
354#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
355#
356# FormatTime - Convert a time from 1m23.45 into 83.45
357#
358#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
359sub FormatTime {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000360 my $Time = shift;
361 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
362 $Time = sprintf("%7.4f", $1*60.0+$2);
363 }
364 return $Time;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000365}
366
367#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
368#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
369sub GetDejagnuTestResults { # (filename, log)
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000370 my ($filename, $DejagnuLog) = @_;
371 my @lines;
372 my $firstline;
373 $/ = "\n"; #Make sure we're going line at a time.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000374
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000375 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000376
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000377 if (open SRCHFILE, $filename) {
378# Process test results
379 my $first_list = 1;
380 my $should_break = 1;
381 my $nocopy = 0;
382 my $readingsum = 0;
383 while ( <SRCHFILE> ) {
384 if ( length($_) > 1 ) {
385 chomp($_);
386 if ( m/^XPASS:/ || m/^FAIL:/ ) {
387 $nocopy = 0;
388 if ( $first_list ) {
389 push(@lines, "UNEXPECTED TEST RESULTS\n");
390 $first_list = 0;
391 $should_break = 1;
392 push(@lines, "$_\n");
393 if( $VERBOSE) { print " $_\n"; }
394 } else {
395 push(@lines, "$_\n");
396 if( $VERBOSE) { print " $_\n"; }
397 }
398 } #elsif ( m/Summary/ ) {
399 # if ( $first_list ) {
400 # push(@lines, "PERFECT!");
401 # print " PERFECT!\n";
402 # } else {
403 # push(@lines, "</li></ol>\n");
404 # }
405 # push(@lines, "STATISTICS\n");
406 # print "\nDEJAGNU STATISTICS:\n";
407 # $should_break = 0;
408 # $nocopy = 0;
409 # $readingsum = 1;
410 #}
411 elsif ( $readingsum ) {
412 push(@lines,"$_\n");
413 if( $VERBOSE) { print " $_\n"; }
414 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000415
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000416 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000417 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000418 }
419 close SRCHFILE;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000420
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000421 my $content = join("", @lines);
422 return $content;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000423}
424
425
426#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
427#
428# This function acts as a mini web browswer submitting data
429# to our central server via the post method
430#
431#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
432sub SendData{
433 $host = $_[0];
434 $file = $_[1];
435 $variables=$_[2];
436
437 $port=80;
438 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
Patrick Jenkinsadea55e2006-07-17 16:41:19 +0000439 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000440 die "Bad socket\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000441 connect SOCK, $socketaddr or die "Bad connection\n";
442 select((select(SOCK), $| = 1)[0]);
443
444 #creating content here
445 my $content;
446 foreach $key (keys (%$variables)){
447 $value = $variables->{$key};
448 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
449 $content .= "$key=$value&";
450 }
451
452 $length = length($content);
453
454 my $send= "POST $file HTTP/1.0\n";
455 $send.= "Content-Type: application/x-www-form-urlencoded\n";
456 $send.= "Content-length: $length\n\n";
457 $send.= "$content";
458
Patrick Jenkinse8501eb2006-08-07 01:54:37 +0000459 print SOCK $send;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000460 my $result;
461 while(<SOCK>){
462 $result .= $_;
463 }
464 close(SOCK);
465
466 my $sentdata="";
Patrick Jenkins4c4e3562006-07-07 21:40:34 +0000467 foreach $x (keys (%$variables)){
Patrick Jenkins7267bd62006-07-10 18:35:41 +0000468 $value = $variables->{$x};
469 $sentdata.= "$x => $value\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000470 }
471 WriteFile "$Prefix-sentdata.txt", $sentdata;
Patrick Jenkins4c4e3562006-07-07 21:40:34 +0000472
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000473
474 return $result;
475}
476
Patrick Jenkins215b48f2006-07-07 18:50:51 +0000477##############################################################
478#
479# Getting Start timestamp
480#
481##############################################################
Patrick Jenkinsb67e1182006-07-21 21:43:09 +0000482$starttime = `date "+20%y-%m-%d %H:%M:%S"`;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000483
484##############################################################
485#
486# Create the CVS repository directory
487#
488##############################################################
489if (!$NOCHECKOUT) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000490 if (-d $BuildDir) {
491 if (!$NOREMOVE) {
492 if ( $VERBOSE ) {
493 print "Build directory exists! Removing it\n";
494 }
495 system "rm -rf $BuildDir";
496 } else {
497 die "CVS checkout directory $BuildDir already exists!";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000498 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000499 }
500 mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000501}
502ChangeDir( $BuildDir, "CVS checkout directory" );
503
504
505##############################################################
506#
507# Check out the llvm tree, saving CVS messages to the cvs log...
508#
509##############################################################
510my $CVSOPT = "";
511# Use compression if going over ssh.
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000512$CVSOPT = "-z3"
513 if $CVSRootDir =~ /^:ext:/;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000514my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co $CVSCOOPT";
515if (!$NOCHECKOUT) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000516 if ( $VERBOSE ) {
517 print "CHECKOUT STAGE:\n";
518 print "( time -p $CVSCMD llvm; cd llvm/projects ; $CVSCMD llvm-test ) " .
519 "> $CVSLog 2>&1\n";
520 }
521 system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
522 "$CVSCMD llvm-test ) > $CVSLog 2>&1";
523 ChangeDir( $BuildDir , "CVS Checkout directory") ;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000524}
525ChangeDir( "llvm" , "llvm source directory") ;
526if (!$NOCHECKOUT) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000527 if ( $VERBOSE ) { print "UPDATE STAGE\n"; }
528 system "$NICE cvs update -PdRA >> $CVSLog 2>&1" ;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000529}
530
531##############################################################
532#
533# Get some static statistics about the current state of CVS
534#
535# This can probably be put on the server side
536#
537##############################################################
538my $CVSCheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $CVSLog`;
539my $CVSCheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $CVSLog`;
540my $CVSCheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $CVSLog`;
541my $CVSCheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
542
543my $NumFilesInCVS = `egrep '^U' $CVSLog | wc -l` + 0;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000544my $NumDirsInCVS =
545 `egrep '^cvs (checkout|server|update):' $CVSLog | wc -l` + 0;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000546
547##############################################################
548#
549# Extract some information from the CVS history... use a hash so no duplicate
550# stuff is stored. This gets the history from the previous days worth
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000551# of cvs activity and parses it.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000552#
553##############################################################
554
555my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
556
557if(!$NOCVSSTATS){
558
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000559 if ($VERBOSE) { print "CVS HISTORY ANALYSIS STAGE\n"; }
560 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000561#print join "\n", @CVSHistory; print "\n";
562
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000563 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000564
565# Loop over every record from the CVS history, filling in the hashes.
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000566 foreach $File (@CVSHistory) {
567 my ($Type, $Date, $UID, $Rev, $Filename);
568 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
569 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
570 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
571 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
572 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
573 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
574 } else {
575 print "UNMATCHABLE: $File\n";
576 next;
577 }
578 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
579
580 if ($Filename =~ /^llvm/) {
581 if ($Type eq 'M') { # Modified
582 $ModifiedFiles{$Filename} = 1;
583 $UsersCommitted{$UID} = 1;
584 } elsif ($Type eq 'A') { # Added
585 $AddedFiles{$Filename} = 1;
586 $UsersCommitted{$UID} = 1;
587 } elsif ($Type eq 'R') { # Removed
588 $RemovedFiles{$Filename} = 1;
589 $UsersCommitted{$UID} = 1;
590 } else {
591 $UsersUpdated{$UID} = 1;
592 }
593 }
594 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000595
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000596 my $TestError = 1;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000597
598}#!NOCVSSTATS
599
600my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
601my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
602my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
603my $UserCommitList = join "\n", sort keys %UsersCommitted;
604my $UserUpdateList = join "\n", sort keys %UsersUpdated;
605
606##############################################################
607#
608# Build the entire tree, saving build messages to the build log
609#
610##############################################################
611if (!$NOCHECKOUT && !$NOBUILD) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000612 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
613 if ( $VERBOSE ) {
614 print "CONFIGURE STAGE:\n";
615 print "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
616 "> $BuildLog 2>&1\n";
617 }
618 system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
619 "> $BuildLog 2>&1";
620 if ( $VERBOSE ) {
621 print "BUILD STAGE:\n";
622 print "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1\n";
623 }
624 # Build the entire tree, capturing the output into $BuildLog
625 system "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000626}
627
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000628##############################################################
629#
630# Get some statistics about the build...
631#
632##############################################################
633#this can de done on server
634#my @Linked = split '\n', `grep Linking $BuildLog`;
635#my $NumExecutables = scalar(grep(/executable/, @Linked));
636#my $NumLibraries = scalar(grep(!/executable/, @Linked));
637#my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
638
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000639# Get the number of lines of source code. Must be here after the build is done
640# because countloc.sh uses the llvm-config script which must be built.
Patrick Jenkinsb993b0a2006-08-16 22:18:41 +0000641my $LOC = `utils/countloc.sh -topdir $BuildDir/llvm`;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000642
643# Get the time taken by the configure script
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000644my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
645my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
646my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
647my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
648
649$ConfigTime=-1 unless $ConfigTime;
650$ConfigWallTime=-1 unless $ConfigWallTime;
651
652my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
653my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
654my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
655my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
656
657$BuildTime=-1 unless $BuildTime;
658$BuildWallTime=-1 unless $BuildWallTime;
659
660my $BuildError = 0, $BuildStatus = "OK";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000661if ($NOBUILD) {
662 $BuildStatus = "Skipped by user";
663 $BuildError = 1;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000664}
Patrick Jenkinsf58473f2006-07-27 01:03:46 +0000665elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000666 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
667 $BuildStatus = "Error: compilation aborted";
668 $BuildError = 1;
669 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000670}
671if ($BuildError) { $NODEJAGNU=1; }
672
Patrick Jenkins169357e2006-07-23 21:38:07 +0000673my $a_file_sizes="";
674my $o_file_sizes="";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000675if (!$BuildError) {
676 print "Organizing size of .o and .a files\n"
677 if ( $VERBOSE );
678 ChangeDir( "$BuildDir/llvm", "Build Directory" );
679 $afiles.= `find utils/ -iname '*.a' -ls`;
680 $afiles.= `find lib/ -iname '*.a' -ls`;
681 $afiles.= `find tools/ -iname '*.a' -ls`;
682 if($BUILDTYPE eq "release"){
683 $afiles.= `find Release/ -iname '*.a' -ls`;
684 } else {
685 $afiles.= `find Debug/ -iname '*.a' -ls`;
686 }
687
688 $ofiles.= `find utils/ -iname '*.o' -ls`;
689 $ofiles.= `find lib/ -iname '*.o' -ls`;
690 $ofiles.= `find tools/ -iname '*.o' -ls`;
691 if($BUILDTYPE eq "release"){
692 $ofiles.= `find Release/ -iname '*.o' -ls`;
693 } else {
694 $ofiles.= `find Debug/ -iname '*.o' -ls`;
695 }
696
697 @AFILES = split "\n", $afiles;
698 $a_file_sizes="";
699 foreach $x (@AFILES){
700 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
701 $a_file_sizes.="$1 $2 $BUILDTYPE\n";
702 }
703 @OFILES = split "\n", $ofiles;
704 $o_file_sizes="";
705 foreach $x (@OFILES){
706 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
707 $o_file_sizes.="$1 $2 $BUILDTYPE\n";
708 }
709} else {
710 $a_file_sizes="No data due to a bad build.";
711 $o_file_sizes="No data due to a bad build.";
Patrick Jenkins169357e2006-07-23 21:38:07 +0000712}
Patrick Jenkins169357e2006-07-23 21:38:07 +0000713
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000714##############################################################
715#
716# Running dejagnu tests
717#
718##############################################################
719my $DejangnuTestResults; # String containing the results of the dejagnu
720my $dejagnu_output = "$DejagnuTestsLog";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000721if (!$NODEJAGNU) {
722 if($VERBOSE) {
723 print "DEJAGNU FEATURE/REGRESSION TEST STAGE:\n";
724 print "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1\n";
725 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000726
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000727 #Run the feature and regression tests, results are put into testrun.sum
728 #Full log in testrun.log
729 system "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1";
730
731 #Copy the testrun.log and testrun.sum to our webdir
732 CopyFile("test/testrun.log", $DejagnuLog);
733 CopyFile("test/testrun.sum", $DejagnuSum);
734 #can be done on server
735 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
736 $unexpfail_tests = $DejagnuTestResults;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000737}
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000738
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000739#Extract time of dejagnu tests
740my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
741my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
742$DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
743$DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000744$DejagnuTestResults =
745 "Dejagnu skipped by user choice." unless $DejagnuTestResults;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000746$DejagnuTime = "0.0" unless $DejagnuTime;
747$DejagnuWallTime = "0.0" unless $DejagnuWallTime;
748
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000749##############################################################
750#
751# Get warnings from the build
752#
753##############################################################
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000754if (!$NODEJAGNU) {
755 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
756 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
757 my @Warnings;
758 my $CurDir = "";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000759
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000760 foreach $Warning (@Warn) {
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000761 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000762 $CurDir = $1; # Keep track of directory warning is in...
763 # Remove buildir prefix if included
764 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { $CurDir = $1; }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000765 } else {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000766 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000767 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000768 }
769 my $WarningsFile = join "\n", @Warnings;
770 $WarningsFile =~ s/:[0-9]+:/::/g;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000771
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000772 # Emit the warnings file, so we can diff...
773 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
774 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000775
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000776 # Output something to stdout if something has changed
777 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
778 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000779
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000780 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
781 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000782
783} #endif !NODEGAGNU
784
785##############################################################
786#
787# If we built the tree successfully, run the nightly programs tests...
788#
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000789# A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
790# "External")
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000791#
792##############################################################
793sub TestDirectory {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000794 my $SubDir = shift;
795
796 ChangeDir( "$BuildDir/llvm/projects/llvm-test/$SubDir",
797 "Programs Test Subdirectory" ) || return ("", "");
798
799 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
800
801 # Run the programs tests... creating a report.nightly.csv file
802 if (!$NOTEST) {
803 if( $VERBOSE) {
804 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
805 "TEST=nightly > $ProgramTestLog 2>&1\n";
806 }
807 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000808 "TEST=nightly > $ProgramTestLog 2>&1";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000809 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
810 }
811
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000812 my $ProgramsTable;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000813 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000814 $TestError = 1;
815 $ProgramsTable="Error running test $SubDir\n";
816 print "ERROR TESTING\n";
817 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
818 $TestError = 1;
819 $ProgramsTable="Makefile error running tests $SubDir!\n";
820 print "ERROR TESTING\n";
821 } else {
822 $TestError = 0;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000823 #
824 # Create a list of the tests which were run...
825 #
826 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
Patrick Jenkinsb993b0a2006-08-16 22:18:41 +0000827 "| sort > $Prefix-$SubDir-Tests.txt";
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000828 }
829 $ProgramsTable = ReadFile "report.nightly.csv";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000830
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000831 ChangeDir( "../../..", "Programs Test Parent Directory" );
832 return ($ProgramsTable, $llcbeta_options);
Patrick Jenkins9e384ab2006-08-14 16:07:14 +0000833} #end sub TestDirectory
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000834
Patrick Jenkinsc281b0d2006-07-27 19:00:01 +0000835if (!$BuildError) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000836 if ( $VERBOSE ) {
Patrick Jenkinse631c4a2006-08-04 17:55:01 +0000837 print "SingleSource TEST STAGE\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000838 }
839 ($SingleSourceProgramsTable, $llcbeta_options) =
840 TestDirectory("SingleSource");
Patrick Jenkinsb993b0a2006-08-16 22:18:41 +0000841 WriteFile "$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
Patrick Jenkins4257ccb2006-08-08 02:03:53 +0000842 if ( $VERBOSE ) {
843 print "MultiSource TEST STAGE\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000844 }
845 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
Patrick Jenkinsb993b0a2006-08-16 22:18:41 +0000846 WriteFile "$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000847 if ( ! $NOEXTERNALS ) {
848 if ( $VERBOSE ) {
849 print "External TEST STAGE\n";
850 }
851 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
Patrick Jenkinsb993b0a2006-08-16 22:18:41 +0000852 WriteFile "$Prefix-External-Performance.txt", $ExternalProgramsTable;
853 system "cat $Prefix-SingleSource-Tests.txt " .
854 "$Prefix-MultiSource-Tests.txt ".
855 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
856 system "cat $Prefix-SingleSource-Performance.txt " .
857 "$Prefix-MultiSource-Performance.txt ".
858 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000859 } else {
860 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
861 if ( $VERBOSE ) {
862 print "External TEST STAGE SKIPPED\n";
863 }
Patrick Jenkinsb993b0a2006-08-16 22:18:41 +0000864 system "cat $Prefix-SingleSource-Tests.txt " .
865 "$Prefix-MultiSource-Tests.txt ".
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000866 " | sort > $Prefix-Tests.txt";
Patrick Jenkinsb993b0a2006-08-16 22:18:41 +0000867 system "cat $Prefix-SingleSource-Performance.txt " .
868 "$Prefix-MultiSource-Performance.txt ".
869 " | sort > $Prefix-Performance.txt";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000870 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000871}
872
873##############################################################
874#
875#
876# gathering tests added removed broken information here
877#
878#
879##############################################################
Patrick Jenkinsb993b0a2006-08-16 22:18:41 +0000880my $dejagnu_test_list = ReadFile "$Prefix-Tests.txt";
881my @DEJAGNU = split "\n", $dejagnu_test_list;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000882
Patrick Jenkins65c7ea02006-07-19 17:52:51 +0000883my $passes="",
884my $fails="";
885my $xfails="";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000886
Patrick Jenkins25c2a2f2006-07-21 21:58:06 +0000887if(!$NODEJAGNU) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000888 for ($x=0; $x<@DEJAGNU; $x++) {
889 if ($DEJAGNU[$x] =~ m/^PASS:/) {
890 $passes.="$DEJAGNU[$x]\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000891 }
892 elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
893 $fails.="$DEJAGNU[$x]\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000894 }
895 elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
896 $xfails.="$DEJAGNU[$x]\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000897 }
898 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000899}
900
901##############################################################
902#
903# If we built the tree successfully, runs of the Olden suite with
904# LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
905#
906##############################################################
907if (!$BuildError) {
Patrick Jenkinsd7210f92006-08-02 18:37:40 +0000908 if ( $VERBOSE ) { print "OLDEN TEST SUITE STAGE\n"; }
909 my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
910 $MachCodeSize) = ("","","","","","","");
911 if (!$NORUNNINGTESTS) {
912 ChangeDir( "$BuildDir/llvm/projects/llvm-test/MultiSource/Benchmarks/Olden",
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000913 "Olden Test Directory");
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000914
Patrick Jenkinsd7210f92006-08-02 18:37:40 +0000915 # Clean out previous results...
916 system "$NICE $MAKECMD $MAKEOPTS clean > /dev/null 2>&1";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000917
Patrick Jenkinsd7210f92006-08-02 18:37:40 +0000918 # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE and
919 # GET_STABLE_NUMBERS enabled!
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000920 if( $VERBOSE ) {
921 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
922 "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
923 "> /dev/null 2>&1\n";
924 }
925 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
926 "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
927 "> /dev/null 2>&1";
928 system "cp report.nightly.csv $OldenTestsLog";
Patrick Jenkinsd7210f92006-08-02 18:37:40 +0000929 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000930}
931
Patrick Jenkins215b48f2006-07-07 18:50:51 +0000932##############################################################
933#
934# Getting end timestamp
935#
936##############################################################
Patrick Jenkinsb67e1182006-07-21 21:43:09 +0000937$endtime = `date "+20%y-%m-%d %H:%M:%S"`;
Patrick Jenkins215b48f2006-07-07 18:50:51 +0000938
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000939
940##############################################################
941#
942# Place all the logs neatly into one humungous file
943#
944##############################################################
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000945if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
946
947$machine_data = "uname: ".`uname -a`.
948 "hardware: ".`uname -m`.
949 "os: ".`uname -sr`.
950 "name: ".`uname -n`.
951 "date: ".`date \"+20%y-%m-%d\"`.
952 "time: ".`date +\"%H:%M:%S\"`;
953
954my @CVS_DATA;
955my $cvs_data;
956@CVS_DATA = ReadFile "$CVSLog";
957$cvs_data = join("\n", @CVS_DATA);
958
959my @BUILD_DATA;
960my $build_data;
961@BUILD_DATA = ReadFile "$BuildLog";
962$build_data = join("\n", @BUILD_DATA);
963
964my @DEJAGNU_LOG;
965my @DEJAGNU_SUM;
966my $dejagnutests_log;
967my $dejagnutests_sum;
968@DEJAGNU_LOG = ReadFile "$DejagnuLog";
969@DEJAGNU_SUM = ReadFile "$DejagnuSum";
970$dejagnutests_log = join("\n", @DEJAGNU_LOG);
971$dejagnutests_sum = join("\n", @DEJAGNU_SUM);
972
973my @DEJAGNULOG_FULL;
974my $dejagnulog_full;
975@DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
976$dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
977
Patrick Jenkinsba204712006-07-20 16:54:43 +0000978my $gcc_version_long="";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000979if ($GCCPATH ne "") {
Patrick Jenkins1b629442006-07-18 21:21:53 +0000980 $gcc_version_long = `$GCCPATH/gcc --version`;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000981} else {
Patrick Jenkins1b629442006-07-18 21:21:53 +0000982 $gcc_version_long = `gcc --version`;
Patrick Jenkins79fbf7f2006-07-14 20:44:09 +0000983}
Patrick Jenkins1b629442006-07-18 21:21:53 +0000984@GCC_VERSION = split '\n', $gcc_version_long;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000985my $gcc_version = $GCC_VERSION[0];
986
987##############################################################
988#
989# Send data via a post request
990#
991##############################################################
992
993if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
994
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000995my %hash_of_data = (
996 'machine_data' => $machine_data,
997 'build_data' => $build_data,
998 'gcc_version' => $gcc_version,
999 'nickname' => $nickname,
1000 'dejagnutime_wall' => $DejagnuWallTime,
1001 'dejagnutime_cpu' => $DejagnuTime,
1002 'cvscheckouttime_wall' => $CVSCheckoutTime_Wall,
1003 'cvscheckouttime_cpu' => $CVSCheckoutTime_CPU,
1004 'configtime_wall' => $ConfigWallTime,
1005 'configtime_cpu'=> $ConfigTime,
1006 'buildtime_wall' => $BuildWallTime,
1007 'buildtime_cpu' => $BuildTime,
1008 'warnings' => $WarningsFile,
1009 'cvsusercommitlist' => $UserCommitList,
1010 'cvsuserupdatelist' => $UserUpdateList,
1011 'cvsaddedfiles' => $CVSAddedFiles,
1012 'cvsmodifiedfiles' => $CVSModifiedFiles,
1013 'cvsremovedfiles' => $CVSRemovedFiles,
1014 'lines_of_code' => $LOC,
1015 'cvs_file_count' => $NumFilesInCVS,
1016 'cvs_dir_count' => $NumDirsInCVS,
1017 'buildstatus' => $BuildStatus,
1018 'singlesource_programstable' => $SingleSourceProgramsTable,
1019 'multisource_programstable' => $MultiSourceProgramsTable,
1020 'externalsource_programstable' => $ExternalProgramsTable,
1021 'llcbeta_options' => $multisource_llcbeta_options,
1022 'warnings_removed' => $WarningsRemoved,
1023 'warnings_added' => $WarningsAdded,
1024 'passing_tests' => $passes,
1025 'expfail_tests' => $xfails,
1026 'unexpfail_tests' => $fails,
1027 'all_tests' => $dejagnu_test_list,
1028 'new_tests' => "",
1029 'removed_tests' => "",
1030 'dejagnutests_log' => $dejagnutests_log,
1031 'dejagnutests_sum' => $dejagnutests_sum,
1032 'starttime' => $starttime,
1033 'endtime' => $endtime,
1034 'o_file_sizes' => $o_file_sizes,
1035 'a_file_sizes' => $a_file_sizes
1036);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001037
1038$TESTING = 0;
1039
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001040if ($TESTING) {
1041 print "============================\n";
1042 foreach $x(keys %hash_of_data){
1043 print "$x => $hash_of_data{$x}\n";
1044 }
1045} else {
1046 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
1047 if( $VERBOSE) { print "============================\n$response"; }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001048}
1049
1050##############################################################
1051#
1052# Remove the cvs tree...
1053#
1054##############################################################
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001055system ( "$NICE rm -rf $BuildDir")
1056 if (!$NOCHECKOUT and !$NOREMOVE);
1057system ( "$NICE rm -rf $WebDir")
1058 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);