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