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