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