blob: 9672632fa273ed60eb3eb15dc0ebe6c2c095433c [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001#!/usr/bin/perl
2use 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
Misha Brukmanafa1e862009-01-02 16:28:18 +000011# regressions and performance changes. Submits this information
Dan Gohmanf17a25c2007-07-18 16:29:46 +000012# to llvm.org where it is placed into the nightlytestresults database.
13#
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.
22# -noremoveresults Do not remove the WEBDIR after it has been built.
23# -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.
29# -nodejagnu Do not run feature or regression tests
Daniel Dunbarf8cdaec2009-05-28 22:45:24 +000030# -parallel Run parallel jobs with GNU Make (see -parallel-jobs).
31# -parallel-jobs The number of parallel Make jobs to use (default is two).
Dan Gohmanf17a25c2007-07-18 16:29:46 +000032# -release Build an LLVM Release version
33# -release-asserts Build an LLVM ReleaseAsserts version
34# -enable-llcbeta Enable testing of beta features in llc.
35# -enable-lli Enable testing of lli (interpreter) features, default is off
36# -disable-llc Disable LLC tests in the nightly tester.
37# -disable-jit Disable JIT tests in the nightly tester.
38# -disable-cbe Disable C backend tests in the nightly tester.
Evan Cheng32efae02008-01-12 04:27:18 +000039# -disable-lto Disable link time optimization.
Daniel Dunbar31a1f1c2009-03-10 19:33:13 +000040# -disable-bindings Disable building LLVM bindings.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000041# -verbose Turn on some debug output
42# -debug Print information useful only to maintainers of this script.
43# -nice Checkout/Configure/Build with "nice" to reduce impact
44# on busy servers.
45# -f2c Next argument specifies path to F2C utility
46# -nickname The next argument specifieds the nickname this script
47# will submit to the nightlytest results repository.
48# -gccpath Path to gcc/g++ used to build LLVM
49# -cvstag Check out a specific CVS tag to build LLVM (useful for
50# testing release branches)
51# -usecvs Check code out from the (old) CVS Repository instead of from
52# the standard Subversion repository.
53# -target Specify the target triplet
54# -cflags Next argument specifies that C compilation options that
55# override the default.
56# -cxxflags Next argument specifies that C++ compilation options that
57# override the default.
58# -ldflags Next argument specifies that linker options that override
59# the default.
60# -compileflags Next argument specifies extra options passed to make when
61# building LLVM.
62# -use-gmake Use gmake instead of the default make command to build
63# llvm and run tests.
64#
65# ---------------- Options to configure llvm-test ----------------------------
66# -extraflags Next argument specifies extra options that are passed to
67# compile the tests.
68# -noexternals Do not run the external tests (for cases where povray
69# or SPEC are not installed)
70# -with-externals Specify a directory where the external tests are located.
71# -submit-server Specifies a server to submit the test results too. If this
Misha Brukmanafa1e862009-01-02 16:28:18 +000072# option is not specified it defaults to
73# llvm.org. This is basically just the address of the
Dan Gohmanf17a25c2007-07-18 16:29:46 +000074# webserver
75# -submit-script Specifies which script to call on the submit server. If
76# this option is not specified it defaults to
Misha Brukmanafa1e862009-01-02 16:28:18 +000077# /nightlytest/NightlyTestAccept.php. This is basically
Dan Gohmanf17a25c2007-07-18 16:29:46 +000078# everything after the www.yourserver.org.
Daniel Dunbar016a4bb2009-05-18 23:24:26 +000079# -submit-aux If specified, an auxiliary script to run in addition to the
80# normal submit script. The script will be passed the path to
81# the "sentdata.txt" file as its sole argument.
Tanya Lattner084a3ee2008-03-10 07:28:08 +000082# -nosubmit Do not report the test results back to a submit server.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000083#
84# CVSROOT is the CVS repository from which the tree will be checked out,
85# specified either in the full :method:user@host:/dir syntax, or
86# just /dir if using a local repo.
87# BUILDDIR is the directory where sources for this test run will be checked out
88# AND objects for this test run will be built. This directory MUST NOT
89# exist before the script is run; it will be created by the cvs checkout
90# process and erased (unless -noremove is specified; see above.)
91# WEBDIR is the directory into which the test results web page will be written,
92# AND in which the "index.html" is assumed to be a symlink to the most recent
93# copy of the results. This directory will be created if it does not exist.
94# LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
95# to. This is the same as you would have for a normal LLVM build.
96#
97##############################################################
98#
99# Getting environment variables
100#
101##############################################################
102my $HOME = $ENV{'HOME'};
103my $SVNURL = $ENV{"SVNURL"};
104$SVNURL = 'https://llvm.org/svn/llvm-project' unless $SVNURL;
105my $CVSRootDir = $ENV{'CVSROOT'};
106$CVSRootDir = "/home/vadve/shared/PublicCVS" unless $CVSRootDir;
107my $BuildDir = $ENV{'BUILDDIR'};
108$BuildDir = "$HOME/buildtest" unless $BuildDir;
109my $WebDir = $ENV{'WEBDIR'};
110$WebDir = "$HOME/cvs/testresults-X86" unless $WebDir;
111
112##############################################################
113#
114# Calculate the date prefix...
115#
116##############################################################
117@TIME = localtime;
118my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
119my $DateString = strftime "%B %d, %Y", localtime;
120my $TestStartTime = gmtime() . "GMT<br>" . localtime() . " (local)";
121
122##############################################################
123#
124# Parse arguments...
125#
126##############################################################
127$CONFIGUREARGS="";
128$nickname="";
129$NOTEST=0;
130$USESVN=1;
131$NORUNNINGTESTS=0;
132$MAKECMD="make";
133$SUBMITSERVER = "llvm.org";
134$SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
Daniel Dunbar016a4bb2009-05-18 23:24:26 +0000135$SUBMITAUX="";
Tanya Lattner084a3ee2008-03-10 07:28:08 +0000136$SUBMIT = 1;
Daniel Dunbarf8cdaec2009-05-28 22:45:24 +0000137$PARALLELJOBS = "2";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000138
139while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
140 shift;
141 last if /^--$/; # Stop processing arguments on --
142
143 # List command line options here...
144 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
145 if (/^-nocvsstats$/) { $NOCVSSTATS = 1; next; }
146 if (/^-noremove$/) { $NOREMOVE = 1; next; }
147 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
148 if (/^-notest$/) { $NOTEST = 1; $NORUNNINGTESTS = 1; next; }
149 if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
Daniel Dunbarf8cdaec2009-05-28 22:45:24 +0000150 if (/^-parallel-jobs$/) { $PARALLELJOBS = "$ARGV[0]"; shift; next;}
151 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j$PARALLELJOBS -l3.0"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000152 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
153 "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
154 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
Dan Gohmanbd399762008-10-30 01:08:03 +0000155 "DISABLE_ASSERTIONS=1 ".
Misha Brukmanafa1e862009-01-02 16:28:18 +0000156 "OPTIMIZE_OPTION=-O2";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000157 $BUILDTYPE="release-asserts"; next;}
158 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
159 if (/^-enable-lli$/) { $PROGTESTOPTS .= " ENABLE_LLI=1";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000160 $CONFIGUREARGS .= " --enable-lli"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000161 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000162 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000163 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
164 $CONFIGUREARGS .= " --disable-jit"; next; }
Daniel Dunbar31a1f1c2009-03-10 19:33:13 +0000165 if (/^-disable-bindings$/) { $CONFIGUREARGS .= " --disable-bindings"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000166 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
Evan Cheng32efae02008-01-12 04:27:18 +0000167 if (/^-disable-lto$/) { $PROGTESTOPTS .= " DISABLE_LTO=1"; next; }
Evan Cheng08206772008-01-14 17:58:03 +0000168 if (/^-test-opts$/) { $PROGTESTOPTS .= " $ARGV[0]"; shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000169 if (/^-verbose$/) { $VERBOSE = 1; next; }
170 if (/^-debug$/) { $DEBUG = 1; next; }
171 if (/^-nice$/) { $NICE = "nice "; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000172 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000173 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000174 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000175 shift; next; }
176 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
177 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
Daniel Dunbar016a4bb2009-05-18 23:24:26 +0000178 if (/^-submit-aux/) { $SUBMITAUX = "$ARGV[0]"; shift; next; }
Tanya Lattner084a3ee2008-03-10 07:28:08 +0000179 if (/^-nosubmit$/) { $SUBMIT = 0; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000180 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
181 if (/^-gccpath/) { $CONFIGUREARGS .=
182 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000183 $GCCPATH=$ARGV[0]; shift; next; }
184 else { $GCCPATH=""; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000185 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000186 else { $CVSCOOPT="";}
187 if (/^-usecvs/) { $USESVN = 0; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000188 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000189 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000190 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000191 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000192 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000193 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000194 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000195 shift; next; }
196 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
197 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000198 if (/^-extraflags/) { $CONFIGUREARGS .=
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000199 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
200 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
201 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
202 if (/^-nobuild$/) { $NOBUILD = 1; next; }
203 print "Unknown option: $_ : ignoring!\n";
204}
205
206if ($ENV{'LLVMGCCDIR'}) {
207 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
Bob Wilsonc6d296b2009-03-12 19:47:24 +0000208 $LLVMGCCPATH = $ENV{'LLVMGCCDIR'} . '/bin';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000209}
210else {
211 $LLVMGCCPATH = "";
212}
213
214if ($CONFIGUREARGS !~ /--disable-jit/) {
215 $CONFIGUREARGS .= " --enable-jit";
216}
217
218if (@ARGV != 0 and @ARGV != 3 and $VERBOSE) {
219 foreach $x (@ARGV) {
220 print "$x\n";
221 }
222 print "Must specify 0 or 3 options!";
223}
224
225if (@ARGV == 3) {
226 $CVSRootDir = $ARGV[0];
227 $BuildDir = $ARGV[1];
228 $WebDir = $ARGV[2];
229}
230
231if ($CVSRootDir eq "" or
232 $BuildDir eq "" or
233 $WebDir eq "") {
234 die("please specify a cvs root directory, a build directory, and a ".
235 "web directory");
236 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000237
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000238if ($nickname eq "") {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000239 die ("Please invoke NewNightlyTest.pl with command line option " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000240 "\"-nickname <nickname>\"");
241}
242
243if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
244 $BUILDTYPE = "debug";
245}
246
247##############################################################
248#
249#define the file names we'll use
250#
251##############################################################
252my $Prefix = "$WebDir/$DATE";
253my $BuildLog = "$Prefix-Build-Log.txt";
254my $COLog = "$Prefix-CVS-Log.txt";
255my $OldenTestsLog = "$Prefix-Olden-tests.txt";
256my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
257my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
258my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
259my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
260my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
261my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
262if (! -d $WebDir) {
263 mkdir $WebDir, 0777;
264 if($VERBOSE){
265 warn "$WebDir did not exist; creating it.\n";
266 }
267}
268
269if ($VERBOSE) {
270 print "INITIALIZED\n";
271 if ($USESVN) {
272 print "SVN URL = $SVNURL\n";
273 } else {
274 print "CVS Root = $CVSRootDir\n";
275 }
276 print "COLog = $COLog\n";
277 print "BuildDir = $BuildDir\n";
278 print "WebDir = $WebDir\n";
279 print "Prefix = $Prefix\n";
280 print "BuildLog = $BuildLog\n";
281}
282
283##############################################################
284#
285# Helper functions
286#
287##############################################################
288sub GetDir {
289 my $Suffix = shift;
290 opendir DH, $WebDir;
291 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
292 closedir DH;
293 return @Result;
294}
295
296#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
297#
298# DiffFiles - Diff the current version of the file against the last version of
299# the file, reporting things added and removed. This is used to report, for
300# example, added and removed warnings. This returns a pair (added, removed)
301#
302#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
303sub DiffFiles {
304 my $Suffix = shift;
305 my @Others = GetDir $Suffix;
306 if (@Others == 0) { # No other files? We added all entries...
307 return (`cat $WebDir/$DATE$Suffix`, "");
308 }
309# Diff the files now...
310 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
311 my $Added = join "\n", grep /^</, @Diffs;
312 my $Removed = join "\n", grep /^>/, @Diffs;
313 $Added =~ s/^< //gm;
314 $Removed =~ s/^> //gm;
315 return ($Added, $Removed);
316}
317
318#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
319#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
320sub GetRegex { # (Regex with ()'s, value)
321 $_[1] =~ /$_[0]/m;
Misha Brukmanafa1e862009-01-02 16:28:18 +0000322 return $1
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000323 if (defined($1));
324 return "0";
325}
326
327#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
328#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
329sub GetRegexNum {
330 my ($Regex, $Num, $Regex2, $File) = @_;
331 my @Items = split "\n", `grep '$Regex' $File`;
332 return GetRegex $Regex2, $Items[$Num];
333}
334
335#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
336#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
337sub ChangeDir { # directory, logical name
338 my ($dir,$name) = @_;
339 chomp($dir);
340 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
341 $result = chdir($dir);
342 if (!$result) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000343 print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000344 return false;
345 }
346 return true;
347}
348
349#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
350#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
351sub ReadFile {
352 if (open (FILE, $_[0])) {
353 undef $/;
354 my $Ret = <FILE>;
355 close FILE;
356 $/ = '\n';
357 return $Ret;
358 } else {
359 print "Could not open file '$_[0]' for reading!\n";
360 return "";
361 }
362}
363
364#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
365#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
366sub WriteFile { # (filename, contents)
367 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
368 print FILE $_[1];
369 close FILE;
370}
371
372#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
373#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
374sub CopyFile { #filename, newfile
375 my ($file, $newfile) = @_;
376 chomp($file);
377 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
378 copy($file, $newfile);
379}
380
381#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
382#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
383sub AddRecord {
384 my ($Val, $Filename,$WebDir) = @_;
385 my @Records;
386 if (open FILE, "$WebDir/$Filename") {
387 @Records = grep !/$DATE/, split "\n", <FILE>;
388 close FILE;
389 }
390 push @Records, "$DATE: $Val";
391 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
392}
393
394#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
395#
396# FormatTime - Convert a time from 1m23.45 into 83.45
397#
398#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
399sub FormatTime {
400 my $Time = shift;
401 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
402 $Time = sprintf("%7.4f", $1*60.0+$2);
403 }
404 return $Time;
405}
406
407#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
408#
Misha Brukmanafa1e862009-01-02 16:28:18 +0000409# This function is meant to read in the dejagnu sum file and
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000410# return a string with only the results (i.e. PASS/FAIL/XPASS/
411# XFAIL).
412#
413#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
414sub GetDejagnuTestResults { # (filename, log)
415 my ($filename, $DejagnuLog) = @_;
416 my @lines;
417 $/ = "\n"; #Make sure we're going line at a time.
418
419 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
420
421 if (open SRCHFILE, $filename) {
422 # Process test results
423 while ( <SRCHFILE> ) {
424 if ( length($_) > 1 ) {
425 chomp($_);
426 if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\/test\/(.*)$/ ) {
427 push(@lines, "$1: test/$2");
428 }
429 }
430 }
431 }
432 close SRCHFILE;
433
434 my $content = join("\n", @lines);
435 return $content;
436}
437
438
439
440#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
441#
442# This function acts as a mini web browswer submitting data
443# to our central server via the post method
444#
445#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
446sub SendData{
447 $host = $_[0];
448 $file = $_[1];
449 $variables=$_[2];
450
Daniel Dunbara2533002009-05-28 18:31:40 +0000451 # Write out the "...-sentdata.txt" file.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000452
Daniel Dunbara2533002009-05-28 18:31:40 +0000453 my $sentdata="";
454 foreach $x (keys (%$variables)){
455 $value = $variables->{$x};
456 $sentdata.= "$x => $value\n";
457 }
458 WriteFile "$Prefix-sentdata.txt", $sentdata;
459
460 if (!($SUBMITAUX eq "")) {
461 system "$SUBMITAUX \"$Prefix-sentdata.txt\"";
462 }
463
464 # Create the content to send to the server.
465
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000466 my $content;
467 foreach $key (keys (%$variables)){
468 $value = $variables->{$key};
469 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
470 $content .= "$key=$value&";
471 }
472
Daniel Dunbara2533002009-05-28 18:31:40 +0000473 # Send the data to the server.
474 #
475 # FIXME: This code should be more robust?
476
477 $port=80;
478 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
479 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
480 die "Bad socket\n";
481 connect SOCK, $socketaddr or die "Bad connection\n";
482 select((select(SOCK), $| = 1)[0]);
483
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000484 $length = length($content);
485
486 my $send= "POST $file HTTP/1.0\n";
487 $send.= "Host: $host\n";
488 $send.= "Content-Type: application/x-www-form-urlencoded\n";
489 $send.= "Content-length: $length\n\n";
490 $send.= "$content";
491
492 print SOCK $send;
493 my $result;
494 while(<SOCK>){
495 $result .= $_;
496 }
497 close(SOCK);
498
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000499 return $result;
500}
501
502##############################################################
503#
504# Getting Start timestamp
505#
506##############################################################
507$starttime = `date "+20%y-%m-%d %H:%M:%S"`;
508
509##############################################################
510#
511# Create the CVS repository directory
512#
513##############################################################
514if (!$NOCHECKOUT) {
515 if (-d $BuildDir) {
516 if (!$NOREMOVE) {
517 if ( $VERBOSE ) {
518 print "Build directory exists! Removing it\n";
519 }
520 system "rm -rf $BuildDir";
521 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
522 } else {
523 if ( $VERBOSE ) {
524 print "Build directory exists!\n";
525 }
526 }
527 } else {
528 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
529 }
530}
531ChangeDir( $BuildDir, "checkout directory" );
532
533
534##############################################################
535#
Misha Brukmanafa1e862009-01-02 16:28:18 +0000536# Check out the llvm tree, using either SVN or CVS
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000537#
538##############################################################
539if (!$NOCHECKOUT) {
540 if ( $VERBOSE ) { print "CHECKOUT STAGE:\n"; }
541 if ($USESVN) {
542 my $SVNCMD = "$NICE svn co $SVNURL";
543 if ($VERBOSE) {
544 print "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
545 "$SVNCMD/test-suite/trunk llvm-test ) > $COLog 2>&1\n";
546 }
547 system "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
548 "$SVNCMD/test-suite/trunk llvm-test ) > $COLog 2>&1\n";
549 } else {
550 my $CVSOPT = "";
551 $CVSOPT = "-z3" # Use compression if going over ssh.
552 if $CVSRootDir =~ /^:ext:/;
553 my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co -P $CVSCOOPT";
554 if ($VERBOSE) {
555 print "( time -p $CVSCMD llvm; cd llvm/projects ; " .
556 "$CVSCMD llvm-test ) > $COLog 2>&1\n";
557 }
558 system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
559 "$CVSCMD llvm-test ) > $COLog 2>&1\n";
560 }
561}
562ChangeDir( $BuildDir , "Checkout directory") ;
563ChangeDir( "llvm" , "llvm source directory") ;
564
565##############################################################
566#
567# Get some static statistics about the current state of CVS
568#
569# This can probably be put on the server side
570#
571##############################################################
572my $CheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $COLog`;
573my $CheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $COLog`;
574my $CheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $COLog`;
575my $CheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
576
577my $NumFilesInCVS = 0;
578my $NumDirsInCVS = 0;
579if ($USESVN) {
580 $NumFilesInCVS = `egrep '^A' $COLog | wc -l` + 0;
Nick Lewyckye45e2c82008-06-05 12:54:44 +0000581 $NumDirsInCVS = `sed -e 's#/[^/]*\$##' $COLog | sort | uniq | wc -l` + 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000582} else {
583 $NumFilesInCVS = `egrep '^U' $COLog | wc -l` + 0;
584 $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $COLog | wc -l` + 0;
585}
586
587##############################################################
588#
589# Extract some information from the CVS history... use a hash so no duplicate
590# stuff is stored. This gets the history from the previous days worth
591# of cvs activity and parses it.
592#
593##############################################################
594
595# This just computes a reasonably accurate #of seconds since 2000. It doesn't
596# have to be perfect as its only used for comparing date ranges within a couple
597# of days.
598sub ConvertToSeconds {
599 my ($sec, $min, $hour, $day, $mon, $yr) = @_;
600 my $Result = ($yr - 2000) * 12;
601 $Result += $mon;
602 $Result *= 31;
603 $Result += $day;
604 $Result *= 24;
605 $Result += $hour;
606 $Result *= 60;
607 $Result += $min;
608 $Result *= 60;
609 $Result += $sec;
610 return $Result;
611}
612
613my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
614
615if (!$NOCVSSTATS) {
616 if ($VERBOSE) { print "CHANGE HISTORY ANALYSIS STAGE\n"; }
617
618 if ($USESVN) {
619 @SVNHistory = split /<logentry/, `svn log --xml --verbose -r{$DATE}:HEAD`;
620 # Skip very first entry because it is the XML header cruft
621 shift @SVNHistory;
622 my $Now = time();
623 foreach $Record (@SVNHistory) {
624 my @Lines = split "\n", $Record;
625 my ($Author, $Date, $Revision);
626 # Get the date and see if its one we want to process.
627 my ($Year, $Month, $Day, $Hour, $Min, $Sec);
628 if ($Lines[3] =~ /<date>(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/){
629 $Year = $1; $Month = $2; $Day = $3; $Hour = $4; $Min = $5; $Sec = $6;
630 }
631 my $Then = ConvertToSeconds($Sec, $Min, $Hour, $Day, $Month, $Year);
632 # Get the current date and compute when "yesterday" is.
633 my ($NSec, $NMin, $NHour, $NDay, $NMon, $NYear) = gmtime();
634 my $Now = ConvertToSeconds( $NSec, $NMin, $NHour, $NDay, $NMon, $NYear);
635 if (($Now - 24*60*60) > $Then) {
636 next;
637 }
638 if ($Lines[1] =~ / revision="([0-9]*)">/) {
639 $Revision = $1;
640 }
641 if ($Lines[2] =~ /<author>([^<]*)<\/author>/) {
642 $Author = $1;
643 }
644 $UsersCommitted{$Author} = 1;
645 $Date = $Year . "-" . $Month . "-" . $Day;
646 $Time = $Hour . ":" . $Min . ":" . $Sec;
647 print "Rev: $Revision, Author: $Author, Date: $Date, Time: $Time\n";
648 for ($i = 6; $i < $#Lines; $i += 2 ) {
649 if ($Lines[$i] =~ /^ action="(.)">([^<]*)</) {
650 if ($1 == "A") {
651 $AddedFiles{$2} = 1;
652 } elsif ($1 == 'D') {
653 $RemovedFiles{$2} = 1;
654 } elsif ($1 == 'M' || $1 == 'R' || $1 == 'C') {
655 $ModifiedFiles{$2} = 1;
656 } else {
657 print "UNMATCHABLE: $Lines[$i]\n";
658 }
659 }
660 }
661 }
662 } else {
663 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
664#print join "\n", @CVSHistory; print "\n";
665
666 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
667
668# Loop over every record from the CVS history, filling in the hashes.
669 foreach $File (@CVSHistory) {
670 my ($Type, $Date, $UID, $Rev, $Filename);
671 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
672 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
673 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
674 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
675 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
676 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
677 } else {
678 print "UNMATCHABLE: $File\n";
679 next;
680 }
681 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000682
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000683 if ($Filename =~ /^llvm/) {
684 if ($Type eq 'M') { # Modified
685 $ModifiedFiles{$Filename} = 1;
686 $UsersCommitted{$UID} = 1;
687 } elsif ($Type eq 'A') { # Added
688 $AddedFiles{$Filename} = 1;
689 $UsersCommitted{$UID} = 1;
690 } elsif ($Type eq 'R') { # Removed
691 $RemovedFiles{$Filename} = 1;
692 $UsersCommitted{$UID} = 1;
693 } else {
694 $UsersUpdated{$UID} = 1;
695 }
696 }
697 }
698
699 my $TestError = 1;
700 } #$USESVN
701}#!NOCVSSTATS
702
703my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
704my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
705my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
706my $UserCommitList = join "\n", sort keys %UsersCommitted;
707my $UserUpdateList = join "\n", sort keys %UsersUpdated;
708
709##############################################################
710#
711# Build the entire tree, saving build messages to the build log
712#
713##############################################################
714if (!$NOCHECKOUT && !$NOBUILD) {
715 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
716 if ( $VERBOSE ) {
717 print "CONFIGURE STAGE:\n";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000718 print "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000719 "> $BuildLog 2>&1\n";
720 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000721 system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000722 "> $BuildLog 2>&1";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000723 if ( $VERBOSE ) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000724 print "BUILD STAGE:\n";
725 print "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1\n";
726 }
727 # Build the entire tree, capturing the output into $BuildLog
728 system "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1";
729}
730
731##############################################################
732#
733# Get some statistics about the build...
734#
735##############################################################
736#this can de done on server
737#my @Linked = split '\n', `grep Linking $BuildLog`;
738#my $NumExecutables = scalar(grep(/executable/, @Linked));
739#my $NumLibraries = scalar(grep(!/executable/, @Linked));
740#my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
741
742# Get the number of lines of source code. Must be here after the build is done
743# because countloc.sh uses the llvm-config script which must be built.
744my $LOC = `utils/countloc.sh -topdir $BuildDir/llvm`;
745
746# Get the time taken by the configure script
747my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
748my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
749my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
750my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
751
752$ConfigTime=-1 unless $ConfigTime;
753$ConfigWallTime=-1 unless $ConfigWallTime;
754
755my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
756my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
757my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
758my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
759
760$BuildTime=-1 unless $BuildTime;
761$BuildWallTime=-1 unless $BuildWallTime;
762
763my $BuildError = 0, $BuildStatus = "OK";
764if ($NOBUILD) {
765 $BuildStatus = "Skipped by user";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000766}
767elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
768 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
769 $BuildStatus = "Error: compilation aborted";
770 $BuildError = 1;
771 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
772}
773if ($BuildError) { $NODEJAGNU=1; }
774
775my $a_file_sizes="";
776my $o_file_sizes="";
777if (!$BuildError) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000778 print "Organizing size of .o and .a files\n"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000779 if ( $VERBOSE );
780 ChangeDir( "$BuildDir/llvm", "Build Directory" );
781 $afiles.= `find utils/ -iname '*.a' -ls`;
782 $afiles.= `find lib/ -iname '*.a' -ls`;
783 $afiles.= `find tools/ -iname '*.a' -ls`;
784 if($BUILDTYPE eq "release"){
785 $afiles.= `find Release/ -iname '*.a' -ls`;
786 } elsif($BUILDTYPE eq "release-asserts") {
787 $afiles.= `find Release-Asserts/ -iname '*.a' -ls`;
788 } else {
789 $afiles.= `find Debug/ -iname '*.a' -ls`;
790 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000791
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000792 $ofiles.= `find utils/ -iname '*.o' -ls`;
793 $ofiles.= `find lib/ -iname '*.o' -ls`;
794 $ofiles.= `find tools/ -iname '*.o' -ls`;
795 if($BUILDTYPE eq "release"){
796 $ofiles.= `find Release/ -iname '*.o' -ls`;
797 } elsif($BUILDTYPE eq "release-asserts") {
798 $ofiles.= `find Release-Asserts/ -iname '*.o' -ls`;
799 } else {
800 $ofiles.= `find Debug/ -iname '*.o' -ls`;
801 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000802
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000803 @AFILES = split "\n", $afiles;
804 $a_file_sizes="";
805 foreach $x (@AFILES){
806 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
807 $a_file_sizes.="$1 $2 $BUILDTYPE\n";
808 }
809 @OFILES = split "\n", $ofiles;
810 $o_file_sizes="";
811 foreach $x (@OFILES){
812 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
813 $o_file_sizes.="$1 $2 $BUILDTYPE\n";
814 }
815} else {
816 $a_file_sizes="No data due to a bad build.";
817 $o_file_sizes="No data due to a bad build.";
818}
819
820##############################################################
821#
822# Running dejagnu tests
823#
824##############################################################
825my $DejangnuTestResults=""; # String containing the results of the dejagnu
826my $dejagnu_output = "$DejagnuTestsLog";
827if (!$NODEJAGNU) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000828 if($VERBOSE) {
829 print "DEJAGNU FEATURE/REGRESSION TEST STAGE:\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000830 print "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1\n";
831 }
832
833 #Run the feature and regression tests, results are put into testrun.sum
834 #Full log in testrun.log
835 system "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000836
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000837 #Copy the testrun.log and testrun.sum to our webdir
838 CopyFile("test/testrun.log", $DejagnuLog);
839 CopyFile("test/testrun.sum", $DejagnuSum);
840 #can be done on server
841 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
842 $unexpfail_tests = $DejagnuTestResults;
843}
844
845#Extract time of dejagnu tests
846my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
847my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
848$DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
Misha Brukmanafa1e862009-01-02 16:28:18 +0000849$DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
850$DejagnuTestResults =
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000851 "Dejagnu skipped by user choice." unless $DejagnuTestResults;
852$DejagnuTime = "0.0" unless $DejagnuTime;
853$DejagnuWallTime = "0.0" unless $DejagnuWallTime;
854
855##############################################################
856#
857# Get warnings from the build
858#
859##############################################################
860if (!$NODEJAGNU) {
861 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
862 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
863 my @Warnings;
864 my $CurDir = "";
865
866 foreach $Warning (@Warn) {
867 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
868 $CurDir = $1; # Keep track of directory warning is in...
869 # Remove buildir prefix if included
870 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { $CurDir = $1; }
871 } else {
872 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
873 }
874 }
875 my $WarningsFile = join "\n", @Warnings;
876 $WarningsFile =~ s/:[0-9]+:/::/g;
877
878 # Emit the warnings file, so we can diff...
879 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
880 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
881
882 # Output something to stdout if something has changed
883 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
884 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
885
886 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
887 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
888
889} #endif !NODEGAGNU
890
891##############################################################
892#
893# If we built the tree successfully, run the nightly programs tests...
894#
Misha Brukmanafa1e862009-01-02 16:28:18 +0000895# A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000896# "External")
897#
898##############################################################
899sub TestDirectory {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000900 my $SubDir = shift;
901 ChangeDir( "$BuildDir/llvm/projects/llvm-test/$SubDir",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000902 "Programs Test Subdirectory" ) || return ("", "");
Misha Brukmanafa1e862009-01-02 16:28:18 +0000903
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000904 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000905
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000906 # Run the programs tests... creating a report.nightly.csv file
907 if (!$NOTEST) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000908 if( $VERBOSE) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000909 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
Misha Brukmanafa1e862009-01-02 16:28:18 +0000910 "TEST=nightly > $ProgramTestLog 2>&1\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000911 }
912 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
913 "TEST=nightly > $ProgramTestLog 2>&1";
914 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
Misha Brukmanafa1e862009-01-02 16:28:18 +0000915 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000916
917 my $ProgramsTable;
918 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
919 $TestError = 1;
920 $ProgramsTable="Error running test $SubDir\n";
921 print "ERROR TESTING\n";
922 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
923 $TestError = 1;
924 $ProgramsTable="Makefile error running tests $SubDir!\n";
925 print "ERROR TESTING\n";
926 } else {
927 $TestError = 0;
928 #
929 # Create a list of the tests which were run...
930 #
931 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
932 "| sort > $Prefix-$SubDir-Tests.txt";
933 }
934 $ProgramsTable = ReadFile "report.nightly.csv";
935
936 ChangeDir( "../../..", "Programs Test Parent Directory" );
937 return ($ProgramsTable, $llcbeta_options);
938} #end sub TestDirectory
939
940##############################################################
941#
942# Calling sub TestDirectory
943#
944##############################################################
945if (!$BuildError) {
946 if ( $VERBOSE ) {
947 print "SingleSource TEST STAGE\n";
948 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000949 ($SingleSourceProgramsTable, $llcbeta_options) =
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000950 TestDirectory("SingleSource");
951 WriteFile "$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
952 if ( $VERBOSE ) {
953 print "MultiSource TEST STAGE\n";
954 }
955 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
956 WriteFile "$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
957 if ( ! $NOEXTERNALS ) {
958 if ( $VERBOSE ) {
959 print "External TEST STAGE\n";
960 }
961 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
962 WriteFile "$Prefix-External-Performance.txt", $ExternalProgramsTable;
Misha Brukmanafa1e862009-01-02 16:28:18 +0000963 system "cat $Prefix-SingleSource-Tests.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000964 "$Prefix-MultiSource-Tests.txt ".
965 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000966 system "cat $Prefix-SingleSource-Performance.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000967 "$Prefix-MultiSource-Performance.txt ".
968 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
969 } else {
970 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
971 if ( $VERBOSE ) {
972 print "External TEST STAGE SKIPPED\n";
973 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000974 system "cat $Prefix-SingleSource-Tests.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000975 "$Prefix-MultiSource-Tests.txt ".
976 " | sort > $Prefix-Tests.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000977 system "cat $Prefix-SingleSource-Performance.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000978 "$Prefix-MultiSource-Performance.txt ".
979 " | sort > $Prefix-Performance.txt";
980 }
981
982 ##############################################################
983 #
Misha Brukmanafa1e862009-01-02 16:28:18 +0000984 #
985 # gathering tests added removed broken information here
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000986 #
987 #
988 ##############################################################
989 my $dejagnu_test_list = ReadFile "$Prefix-Tests.txt";
990 my @DEJAGNU = split "\n", $dejagnu_test_list;
991 my ($passes, $fails, $xfails) = "";
992
993 if(!$NODEJAGNU) {
994 for ($x=0; $x<@DEJAGNU; $x++) {
995 if ($DEJAGNU[$x] =~ m/^PASS:/) {
996 $passes.="$DEJAGNU[$x]\n";
997 }
998 elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
999 $fails.="$DEJAGNU[$x]\n";
1000 }
1001 elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
1002 $xfails.="$DEJAGNU[$x]\n";
1003 }
1004 }
1005 }
Misha Brukmanafa1e862009-01-02 16:28:18 +00001006
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001007} #end if !$BuildError
1008
1009
1010##############################################################
1011#
1012# If we built the tree successfully, runs of the Olden suite with
1013# LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
1014#
1015##############################################################
1016if (!$BuildError) {
1017 if ( $VERBOSE ) { print "OLDEN TEST SUITE STAGE\n"; }
1018 my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
1019 $MachCodeSize) = ("","","","","","","");
1020 if (!$NORUNNINGTESTS) {
1021 ChangeDir( "$BuildDir/llvm/projects/llvm-test/MultiSource/Benchmarks/Olden",
1022 "Olden Test Directory");
1023
1024 # Clean out previous results...
1025 system "$NICE $MAKECMD $MAKEOPTS clean > /dev/null 2>&1";
1026
1027 # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE and
1028 # GET_STABLE_NUMBERS enabled!
Misha Brukmanafa1e862009-01-02 16:28:18 +00001029 if( $VERBOSE ) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001030 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
1031 "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
Misha Brukmanafa1e862009-01-02 16:28:18 +00001032 "> /dev/null 2>&1\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001033 }
1034 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
1035 "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
1036 "> /dev/null 2>&1";
1037 system "cp report.nightly.csv $OldenTestsLog";
Misha Brukmanafa1e862009-01-02 16:28:18 +00001038 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001039}
1040
1041##############################################################
1042#
1043# Getting end timestamp
1044#
1045##############################################################
1046$endtime = `date "+20%y-%m-%d %H:%M:%S"`;
1047
1048
1049##############################################################
1050#
1051# Place all the logs neatly into one humungous file
1052#
1053##############################################################
1054if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
1055
Misha Brukmanafa1e862009-01-02 16:28:18 +00001056$machine_data = "uname: ".`uname -a`.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001057 "hardware: ".`uname -m`.
1058 "os: ".`uname -sr`.
1059 "name: ".`uname -n`.
1060 "date: ".`date \"+20%y-%m-%d\"`.
Misha Brukmanafa1e862009-01-02 16:28:18 +00001061 "time: ".`date +\"%H:%M:%S\"`;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001062
1063my @CVS_DATA;
1064my $cvs_data;
1065@CVS_DATA = ReadFile "$COLog";
1066$cvs_data = join("\n", @CVS_DATA);
1067
1068my @BUILD_DATA;
1069my $build_data;
1070@BUILD_DATA = ReadFile "$BuildLog";
1071$build_data = join("\n", @BUILD_DATA);
1072
1073my (@DEJAGNU_LOG, @DEJAGNU_SUM, @DEJAGNULOG_FULL, @GCC_VERSION);
1074my ($dejagnutests_log ,$dejagnutests_sum, $dejagnulog_full) = "";
1075my ($gcc_version, $gcc_version_long) = "";
1076
1077$gcc_version_long="";
1078if ($GCCPATH ne "") {
1079 $gcc_version_long = `$GCCPATH/gcc --version`;
1080} elsif ($ENV{"CC"}) {
1081 $gcc_version_long = `$ENV{"CC"} --version`;
1082} else {
1083 $gcc_version_long = `gcc --version`;
1084}
1085@GCC_VERSION = split '\n', $gcc_version_long;
1086$gcc_version = $GCC_VERSION[0];
1087
1088$llvmgcc_version_long="";
1089if ($LLVMGCCPATH ne "") {
1090 $llvmgcc_version_long = `$LLVMGCCPATH/llvm-gcc -v 2>&1`;
1091} else {
1092 $llvmgcc_version_long = `llvm-gcc -v 2>&1`;
1093}
1094@LLVMGCC_VERSION = split '\n', $llvmgcc_version_long;
1095$llvmgcc_versionTarget = $LLVMGCC_VERSION[1];
1096$llvmgcc_versionTarget =~ /Target: (.+)/;
1097$targetTriple = $1;
1098
1099if(!$BuildError){
1100 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
1101 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
1102 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
1103 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
1104
1105 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
1106 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
1107}
1108
1109##############################################################
1110#
1111# Send data via a post request
1112#
1113##############################################################
1114
1115if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
1116
1117my %hash_of_data = (
1118 'machine_data' => $machine_data,
1119 'build_data' => $build_data,
1120 'gcc_version' => $gcc_version,
1121 'nickname' => $nickname,
1122 'dejagnutime_wall' => $DejagnuWallTime,
1123 'dejagnutime_cpu' => $DejagnuTime,
1124 'cvscheckouttime_wall' => $CheckoutTime_Wall,
1125 'cvscheckouttime_cpu' => $CheckoutTime_CPU,
1126 'configtime_wall' => $ConfigWallTime,
1127 'configtime_cpu'=> $ConfigTime,
1128 'buildtime_wall' => $BuildWallTime,
1129 'buildtime_cpu' => $BuildTime,
1130 'warnings' => $WarningsFile,
1131 'cvsusercommitlist' => $UserCommitList,
1132 'cvsuserupdatelist' => $UserUpdateList,
1133 'cvsaddedfiles' => $CVSAddedFiles,
1134 'cvsmodifiedfiles' => $CVSModifiedFiles,
1135 'cvsremovedfiles' => $CVSRemovedFiles,
1136 'lines_of_code' => $LOC,
1137 'cvs_file_count' => $NumFilesInCVS,
1138 'cvs_dir_count' => $NumDirsInCVS,
1139 'buildstatus' => $BuildStatus,
1140 'singlesource_programstable' => $SingleSourceProgramsTable,
1141 'multisource_programstable' => $MultiSourceProgramsTable,
1142 'externalsource_programstable' => $ExternalProgramsTable,
1143 'llcbeta_options' => $multisource_llcbeta_options,
1144 'warnings_removed' => $WarningsRemoved,
1145 'warnings_added' => $WarningsAdded,
1146 'passing_tests' => $passes,
1147 'expfail_tests' => $xfails,
1148 'unexpfail_tests' => $fails,
1149 'all_tests' => $dejagnu_test_list,
1150 'new_tests' => "",
1151 'removed_tests' => "",
1152 'dejagnutests_results' => $DejagnuTestResults,
1153 'dejagnutests_log' => $dejagnulog_full,
1154 'starttime' => $starttime,
1155 'endtime' => $endtime,
1156 'o_file_sizes' => $o_file_sizes,
1157 'a_file_sizes' => $a_file_sizes,
1158 'target_triple' => $targetTriple
1159);
1160
Tanya Lattner084a3ee2008-03-10 07:28:08 +00001161if ($SUBMIT) {
1162 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
1163 if( $VERBOSE) { print "============================\n$response"; }
1164} else {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001165 print "============================\n";
1166 foreach $x(keys %hash_of_data){
1167 print "$x => $hash_of_data{$x}\n";
1168 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001169}
1170
1171##############################################################
1172#
1173# Remove the cvs tree...
1174#
1175##############################################################
Misha Brukmanafa1e862009-01-02 16:28:18 +00001176system ( "$NICE rm -rf $BuildDir")
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001177 if (!$NOCHECKOUT and !$NOREMOVE);
Misha Brukmanafa1e862009-01-02 16:28:18 +00001178system ( "$NICE rm -rf $WebDir")
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001179 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);