blob: feac974be871b9eaf55801849ea5da8594d7c6e7 [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#
Dan Gohmanf17a25c2007-07-18 16:29:46 +000014# Syntax: NightlyTest.pl [OPTIONS] [CVSROOT BUILDDIR WEBDIR]
15# where
16# OPTIONS may include one or more of the following:
17# -nocheckout Do not create, checkout, update, or configure
18# the source tree.
19# -noremove Do not remove the BUILDDIR after it has been built.
20# -noremoveresults Do not remove the WEBDIR after it has been built.
21# -nobuild Do not build llvm. If tests are enabled perform them
22# on the llvm build specified in the build directory
Daniel Dunbar2041d9a2009-06-02 21:14:15 +000023# -notest Do not even attempt to run the test programs.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000024# -nodejagnu Do not run feature or regression tests
Daniel Dunbarf8cdaec2009-05-28 22:45:24 +000025# -parallel Run parallel jobs with GNU Make (see -parallel-jobs).
26# -parallel-jobs The number of parallel Make jobs to use (default is two).
Duncan Sands01388f92009-06-12 13:02:52 +000027# -with-clang Checkout Clang source into tools/clang.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000028# -release Build an LLVM Release version
29# -release-asserts Build an LLVM ReleaseAsserts version
30# -enable-llcbeta Enable testing of beta features in llc.
31# -enable-lli Enable testing of lli (interpreter) features, default is off
Duncan Sands01388f92009-06-12 13:02:52 +000032# -disable-pic Disable building with Position Independent Code.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000033# -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"};
Duncan Sands01388f92009-06-12 13:02:52 +0000101$SVNURL = 'http://llvm.org/svn/llvm-project' unless $SVNURL;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000102my $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; }
Duncan Sands01388f92009-06-12 13:02:52 +0000148 if (/^-with-clang$/) { $WITHCLANG = 1; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000149 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
150 "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
151 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
Dan Gohmanbd399762008-10-30 01:08:03 +0000152 "DISABLE_ASSERTIONS=1 ".
Misha Brukmanafa1e862009-01-02 16:28:18 +0000153 "OPTIMIZE_OPTION=-O2";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000154 $BUILDTYPE="release-asserts"; next;}
155 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
Duncan Sands01388f92009-06-12 13:02:52 +0000156 if (/^-disable-pic$/) { $CONFIGUREARGS .= " --enable-pic=no"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000157 if (/^-enable-lli$/) { $PROGTESTOPTS .= " ENABLE_LLI=1";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000158 $CONFIGUREARGS .= " --enable-lli"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000159 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000160 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000161 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
162 $CONFIGUREARGS .= " --disable-jit"; next; }
Daniel Dunbar31a1f1c2009-03-10 19:33:13 +0000163 if (/^-disable-bindings$/) { $CONFIGUREARGS .= " --disable-bindings"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000164 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
Evan Cheng32efae02008-01-12 04:27:18 +0000165 if (/^-disable-lto$/) { $PROGTESTOPTS .= " DISABLE_LTO=1"; next; }
Evan Cheng08206772008-01-14 17:58:03 +0000166 if (/^-test-opts$/) { $PROGTESTOPTS .= " $ARGV[0]"; shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000167 if (/^-verbose$/) { $VERBOSE = 1; next; }
168 if (/^-debug$/) { $DEBUG = 1; next; }
169 if (/^-nice$/) { $NICE = "nice "; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000170 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000171 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000172 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000173 shift; next; }
174 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
175 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
Daniel Dunbar016a4bb2009-05-18 23:24:26 +0000176 if (/^-submit-aux/) { $SUBMITAUX = "$ARGV[0]"; shift; next; }
Tanya Lattner084a3ee2008-03-10 07:28:08 +0000177 if (/^-nosubmit$/) { $SUBMIT = 0; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000178 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
179 if (/^-gccpath/) { $CONFIGUREARGS .=
180 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000181 $GCCPATH=$ARGV[0]; shift; next; }
182 else { $GCCPATH=""; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000183 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000184 else { $CVSCOOPT="";}
185 if (/^-usecvs/) { $USESVN = 0; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000186 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000187 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000188 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000189 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000190 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000191 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000192 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000193 shift; next; }
194 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
195 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000196 if (/^-extraflags/) { $CONFIGUREARGS .=
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000197 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
198 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
199 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
200 if (/^-nobuild$/) { $NOBUILD = 1; next; }
201 print "Unknown option: $_ : ignoring!\n";
202}
203
204if ($ENV{'LLVMGCCDIR'}) {
205 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
Bob Wilsonc6d296b2009-03-12 19:47:24 +0000206 $LLVMGCCPATH = $ENV{'LLVMGCCDIR'} . '/bin';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000207}
208else {
209 $LLVMGCCPATH = "";
210}
211
212if ($CONFIGUREARGS !~ /--disable-jit/) {
213 $CONFIGUREARGS .= " --enable-jit";
214}
215
216if (@ARGV != 0 and @ARGV != 3 and $VERBOSE) {
217 foreach $x (@ARGV) {
218 print "$x\n";
219 }
220 print "Must specify 0 or 3 options!";
221}
222
223if (@ARGV == 3) {
224 $CVSRootDir = $ARGV[0];
225 $BuildDir = $ARGV[1];
226 $WebDir = $ARGV[2];
227}
228
229if ($CVSRootDir eq "" or
230 $BuildDir eq "" or
231 $WebDir eq "") {
232 die("please specify a cvs root directory, a build directory, and a ".
233 "web directory");
234 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000235
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000236if ($nickname eq "") {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000237 die ("Please invoke NewNightlyTest.pl with command line option " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000238 "\"-nickname <nickname>\"");
239}
240
241if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
242 $BUILDTYPE = "debug";
243}
244
245##############################################################
246#
247#define the file names we'll use
248#
249##############################################################
250my $Prefix = "$WebDir/$DATE";
251my $BuildLog = "$Prefix-Build-Log.txt";
252my $COLog = "$Prefix-CVS-Log.txt";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000253my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
254my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
255my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
256my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
257my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
258my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
259if (! -d $WebDir) {
260 mkdir $WebDir, 0777;
261 if($VERBOSE){
262 warn "$WebDir did not exist; creating it.\n";
263 }
264}
265
266if ($VERBOSE) {
267 print "INITIALIZED\n";
268 if ($USESVN) {
269 print "SVN URL = $SVNURL\n";
270 } else {
271 print "CVS Root = $CVSRootDir\n";
272 }
273 print "COLog = $COLog\n";
274 print "BuildDir = $BuildDir\n";
275 print "WebDir = $WebDir\n";
276 print "Prefix = $Prefix\n";
277 print "BuildLog = $BuildLog\n";
278}
279
280##############################################################
281#
282# Helper functions
283#
284##############################################################
285sub GetDir {
286 my $Suffix = shift;
287 opendir DH, $WebDir;
288 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
289 closedir DH;
290 return @Result;
291}
292
293#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
294#
295# DiffFiles - Diff the current version of the file against the last version of
296# the file, reporting things added and removed. This is used to report, for
297# example, added and removed warnings. This returns a pair (added, removed)
298#
299#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
300sub DiffFiles {
301 my $Suffix = shift;
302 my @Others = GetDir $Suffix;
303 if (@Others == 0) { # No other files? We added all entries...
304 return (`cat $WebDir/$DATE$Suffix`, "");
305 }
306# Diff the files now...
307 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
308 my $Added = join "\n", grep /^</, @Diffs;
309 my $Removed = join "\n", grep /^>/, @Diffs;
310 $Added =~ s/^< //gm;
311 $Removed =~ s/^> //gm;
312 return ($Added, $Removed);
313}
314
315#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
316#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
317sub GetRegex { # (Regex with ()'s, value)
318 $_[1] =~ /$_[0]/m;
Misha Brukmanafa1e862009-01-02 16:28:18 +0000319 return $1
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000320 if (defined($1));
321 return "0";
322}
323
324#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
325#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
326sub GetRegexNum {
327 my ($Regex, $Num, $Regex2, $File) = @_;
328 my @Items = split "\n", `grep '$Regex' $File`;
329 return GetRegex $Regex2, $Items[$Num];
330}
331
332#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
333#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
334sub ChangeDir { # directory, logical name
335 my ($dir,$name) = @_;
336 chomp($dir);
337 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
338 $result = chdir($dir);
339 if (!$result) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000340 print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000341 return false;
342 }
343 return true;
344}
345
346#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
347#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
348sub ReadFile {
349 if (open (FILE, $_[0])) {
350 undef $/;
351 my $Ret = <FILE>;
352 close FILE;
353 $/ = '\n';
354 return $Ret;
355 } else {
356 print "Could not open file '$_[0]' for reading!\n";
357 return "";
358 }
359}
360
361#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
362#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
363sub WriteFile { # (filename, contents)
364 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
365 print FILE $_[1];
366 close FILE;
367}
368
369#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
370#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
371sub CopyFile { #filename, newfile
372 my ($file, $newfile) = @_;
373 chomp($file);
374 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
375 copy($file, $newfile);
376}
377
378#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
379#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
380sub AddRecord {
381 my ($Val, $Filename,$WebDir) = @_;
382 my @Records;
383 if (open FILE, "$WebDir/$Filename") {
384 @Records = grep !/$DATE/, split "\n", <FILE>;
385 close FILE;
386 }
387 push @Records, "$DATE: $Val";
388 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
389}
390
391#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
392#
393# FormatTime - Convert a time from 1m23.45 into 83.45
394#
395#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
396sub FormatTime {
397 my $Time = shift;
398 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
399 $Time = sprintf("%7.4f", $1*60.0+$2);
400 }
401 return $Time;
402}
403
404#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
405#
Misha Brukmanafa1e862009-01-02 16:28:18 +0000406# This function is meant to read in the dejagnu sum file and
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000407# return a string with only the results (i.e. PASS/FAIL/XPASS/
408# XFAIL).
409#
410#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
411sub GetDejagnuTestResults { # (filename, log)
412 my ($filename, $DejagnuLog) = @_;
413 my @lines;
414 $/ = "\n"; #Make sure we're going line at a time.
415
416 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
417
418 if (open SRCHFILE, $filename) {
419 # Process test results
420 while ( <SRCHFILE> ) {
421 if ( length($_) > 1 ) {
422 chomp($_);
423 if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\/test\/(.*)$/ ) {
424 push(@lines, "$1: test/$2");
425 }
426 }
427 }
428 }
429 close SRCHFILE;
430
431 my $content = join("\n", @lines);
432 return $content;
433}
434
435
436
437#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
438#
439# This function acts as a mini web browswer submitting data
440# to our central server via the post method
441#
442#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
443sub SendData{
444 $host = $_[0];
445 $file = $_[1];
446 $variables=$_[2];
447
Daniel Dunbara2533002009-05-28 18:31:40 +0000448 # Write out the "...-sentdata.txt" file.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000449
Daniel Dunbara2533002009-05-28 18:31:40 +0000450 my $sentdata="";
451 foreach $x (keys (%$variables)){
452 $value = $variables->{$x};
453 $sentdata.= "$x => $value\n";
454 }
455 WriteFile "$Prefix-sentdata.txt", $sentdata;
456
457 if (!($SUBMITAUX eq "")) {
458 system "$SUBMITAUX \"$Prefix-sentdata.txt\"";
459 }
460
461 # Create the content to send to the server.
462
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000463 my $content;
464 foreach $key (keys (%$variables)){
465 $value = $variables->{$key};
466 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
467 $content .= "$key=$value&";
468 }
469
Daniel Dunbara2533002009-05-28 18:31:40 +0000470 # Send the data to the server.
471 #
472 # FIXME: This code should be more robust?
473
474 $port=80;
475 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
476 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
477 die "Bad socket\n";
478 connect SOCK, $socketaddr or die "Bad connection\n";
479 select((select(SOCK), $| = 1)[0]);
480
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000481 $length = length($content);
482
483 my $send= "POST $file HTTP/1.0\n";
484 $send.= "Host: $host\n";
485 $send.= "Content-Type: application/x-www-form-urlencoded\n";
486 $send.= "Content-length: $length\n\n";
487 $send.= "$content";
488
489 print SOCK $send;
490 my $result;
491 while(<SOCK>){
492 $result .= $_;
493 }
494 close(SOCK);
495
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000496 return $result;
497}
498
499##############################################################
500#
501# Getting Start timestamp
502#
503##############################################################
504$starttime = `date "+20%y-%m-%d %H:%M:%S"`;
505
506##############################################################
507#
508# Create the CVS repository directory
509#
510##############################################################
511if (!$NOCHECKOUT) {
512 if (-d $BuildDir) {
513 if (!$NOREMOVE) {
514 if ( $VERBOSE ) {
515 print "Build directory exists! Removing it\n";
516 }
517 system "rm -rf $BuildDir";
518 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
519 } else {
520 if ( $VERBOSE ) {
521 print "Build directory exists!\n";
522 }
523 }
524 } else {
525 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
526 }
527}
528ChangeDir( $BuildDir, "checkout directory" );
529
530
531##############################################################
532#
Misha Brukmanafa1e862009-01-02 16:28:18 +0000533# Check out the llvm tree, using either SVN or CVS
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000534#
535##############################################################
536if (!$NOCHECKOUT) {
537 if ( $VERBOSE ) { print "CHECKOUT STAGE:\n"; }
538 if ($USESVN) {
Duncan Sands01388f92009-06-12 13:02:52 +0000539 my $SVNCMD = "$NICE svn co --non-interactive $SVNURL";
540 if ($VERBOSE) {
541 print "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
542 "$SVNCMD/test-suite/trunk llvm-test ) > $COLog 2>&1\n";
543 }
544 system "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000545 "$SVNCMD/test-suite/trunk llvm-test ) > $COLog 2>&1\n";
Duncan Sands01388f92009-06-12 13:02:52 +0000546 if ($WITHCLANG) {
547 my $SVNCMD = "$NICE svn co --non-interactive $SVNURL/cfe/trunk";
548 if ($VERBOSE) {
549 print "( time -p cd llvm/tools ; $SVNCMD clang ) > $COLog 2>&1\n";
550 }
551 system "( time -p cd llvm/tools ; $SVNCMD clang ) > $COLog 2>&1\n";
552 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000553 } else {
554 my $CVSOPT = "";
555 $CVSOPT = "-z3" # Use compression if going over ssh.
556 if $CVSRootDir =~ /^:ext:/;
557 my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co -P $CVSCOOPT";
558 if ($VERBOSE) {
559 print "( time -p $CVSCMD llvm; cd llvm/projects ; " .
560 "$CVSCMD llvm-test ) > $COLog 2>&1\n";
561 }
562 system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
563 "$CVSCMD llvm-test ) > $COLog 2>&1\n";
564 }
565}
566ChangeDir( $BuildDir , "Checkout directory") ;
567ChangeDir( "llvm" , "llvm source directory") ;
568
569##############################################################
570#
571# Get some static statistics about the current state of CVS
572#
573# This can probably be put on the server side
574#
575##############################################################
576my $CheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $COLog`;
577my $CheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $COLog`;
578my $CheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $COLog`;
579my $CheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
580
581my $NumFilesInCVS = 0;
582my $NumDirsInCVS = 0;
583if ($USESVN) {
584 $NumFilesInCVS = `egrep '^A' $COLog | wc -l` + 0;
Nick Lewyckye45e2c82008-06-05 12:54:44 +0000585 $NumDirsInCVS = `sed -e 's#/[^/]*\$##' $COLog | sort | uniq | wc -l` + 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000586} else {
587 $NumFilesInCVS = `egrep '^U' $COLog | wc -l` + 0;
588 $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $COLog | wc -l` + 0;
589}
590
591##############################################################
592#
593# Extract some information from the CVS history... use a hash so no duplicate
594# stuff is stored. This gets the history from the previous days worth
595# of cvs activity and parses it.
596#
597##############################################################
598
599# This just computes a reasonably accurate #of seconds since 2000. It doesn't
600# have to be perfect as its only used for comparing date ranges within a couple
601# of days.
602sub ConvertToSeconds {
603 my ($sec, $min, $hour, $day, $mon, $yr) = @_;
604 my $Result = ($yr - 2000) * 12;
605 $Result += $mon;
606 $Result *= 31;
607 $Result += $day;
608 $Result *= 24;
609 $Result += $hour;
610 $Result *= 60;
611 $Result += $min;
612 $Result *= 60;
613 $Result += $sec;
614 return $Result;
615}
616
617my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
618
619if (!$NOCVSSTATS) {
620 if ($VERBOSE) { print "CHANGE HISTORY ANALYSIS STAGE\n"; }
621
622 if ($USESVN) {
Duncan Sands01388f92009-06-12 13:02:52 +0000623 @SVNHistory = split /<logentry/, `svn log --non-interactive --xml --verbose -r{$DATE}:HEAD`;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000624 # Skip very first entry because it is the XML header cruft
625 shift @SVNHistory;
626 my $Now = time();
627 foreach $Record (@SVNHistory) {
628 my @Lines = split "\n", $Record;
629 my ($Author, $Date, $Revision);
630 # Get the date and see if its one we want to process.
631 my ($Year, $Month, $Day, $Hour, $Min, $Sec);
632 if ($Lines[3] =~ /<date>(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/){
633 $Year = $1; $Month = $2; $Day = $3; $Hour = $4; $Min = $5; $Sec = $6;
634 }
635 my $Then = ConvertToSeconds($Sec, $Min, $Hour, $Day, $Month, $Year);
636 # Get the current date and compute when "yesterday" is.
637 my ($NSec, $NMin, $NHour, $NDay, $NMon, $NYear) = gmtime();
638 my $Now = ConvertToSeconds( $NSec, $NMin, $NHour, $NDay, $NMon, $NYear);
639 if (($Now - 24*60*60) > $Then) {
640 next;
641 }
642 if ($Lines[1] =~ / revision="([0-9]*)">/) {
643 $Revision = $1;
644 }
645 if ($Lines[2] =~ /<author>([^<]*)<\/author>/) {
646 $Author = $1;
647 }
648 $UsersCommitted{$Author} = 1;
649 $Date = $Year . "-" . $Month . "-" . $Day;
650 $Time = $Hour . ":" . $Min . ":" . $Sec;
651 print "Rev: $Revision, Author: $Author, Date: $Date, Time: $Time\n";
652 for ($i = 6; $i < $#Lines; $i += 2 ) {
653 if ($Lines[$i] =~ /^ action="(.)">([^<]*)</) {
654 if ($1 == "A") {
655 $AddedFiles{$2} = 1;
656 } elsif ($1 == 'D') {
657 $RemovedFiles{$2} = 1;
658 } elsif ($1 == 'M' || $1 == 'R' || $1 == 'C') {
659 $ModifiedFiles{$2} = 1;
660 } else {
661 print "UNMATCHABLE: $Lines[$i]\n";
662 }
663 }
664 }
665 }
666 } else {
667 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
668#print join "\n", @CVSHistory; print "\n";
669
670 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
671
672# Loop over every record from the CVS history, filling in the hashes.
673 foreach $File (@CVSHistory) {
674 my ($Type, $Date, $UID, $Rev, $Filename);
675 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
676 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
677 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
678 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
679 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
680 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
681 } else {
682 print "UNMATCHABLE: $File\n";
683 next;
684 }
685 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000686
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000687 if ($Filename =~ /^llvm/) {
688 if ($Type eq 'M') { # Modified
689 $ModifiedFiles{$Filename} = 1;
690 $UsersCommitted{$UID} = 1;
691 } elsif ($Type eq 'A') { # Added
692 $AddedFiles{$Filename} = 1;
693 $UsersCommitted{$UID} = 1;
694 } elsif ($Type eq 'R') { # Removed
695 $RemovedFiles{$Filename} = 1;
696 $UsersCommitted{$UID} = 1;
697 } else {
698 $UsersUpdated{$UID} = 1;
699 }
700 }
701 }
702
703 my $TestError = 1;
704 } #$USESVN
705}#!NOCVSSTATS
706
707my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
708my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
709my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
710my $UserCommitList = join "\n", sort keys %UsersCommitted;
711my $UserUpdateList = join "\n", sort keys %UsersUpdated;
712
713##############################################################
714#
715# Build the entire tree, saving build messages to the build log
716#
717##############################################################
718if (!$NOCHECKOUT && !$NOBUILD) {
719 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
720 if ( $VERBOSE ) {
721 print "CONFIGURE STAGE:\n";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000722 print "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000723 "> $BuildLog 2>&1\n";
724 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000725 system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000726 "> $BuildLog 2>&1";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000727 if ( $VERBOSE ) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000728 print "BUILD STAGE:\n";
Duncan Sands01388f92009-06-12 13:02:52 +0000729 print "(time -p $NICE $MAKECMD clean) >> $BuildLog 2>&1\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000730 print "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1\n";
731 }
732 # Build the entire tree, capturing the output into $BuildLog
Duncan Sands01388f92009-06-12 13:02:52 +0000733 system "(time -p $NICE $MAKECMD clean) >> $BuildLog 2>&1";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000734 system "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1";
735}
736
737##############################################################
738#
739# Get some statistics about the build...
740#
741##############################################################
742#this can de done on server
743#my @Linked = split '\n', `grep Linking $BuildLog`;
744#my $NumExecutables = scalar(grep(/executable/, @Linked));
745#my $NumLibraries = scalar(grep(!/executable/, @Linked));
746#my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
747
748# Get the number of lines of source code. Must be here after the build is done
749# because countloc.sh uses the llvm-config script which must be built.
750my $LOC = `utils/countloc.sh -topdir $BuildDir/llvm`;
751
752# Get the time taken by the configure script
753my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
754my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
755my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
756my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
757
758$ConfigTime=-1 unless $ConfigTime;
759$ConfigWallTime=-1 unless $ConfigWallTime;
760
761my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
762my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
763my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
764my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
765
766$BuildTime=-1 unless $BuildTime;
767$BuildWallTime=-1 unless $BuildWallTime;
768
769my $BuildError = 0, $BuildStatus = "OK";
770if ($NOBUILD) {
771 $BuildStatus = "Skipped by user";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000772}
773elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
774 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
775 $BuildStatus = "Error: compilation aborted";
776 $BuildError = 1;
777 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
778}
779if ($BuildError) { $NODEJAGNU=1; }
780
781my $a_file_sizes="";
782my $o_file_sizes="";
783if (!$BuildError) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000784 print "Organizing size of .o and .a files\n"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000785 if ( $VERBOSE );
786 ChangeDir( "$BuildDir/llvm", "Build Directory" );
787 $afiles.= `find utils/ -iname '*.a' -ls`;
788 $afiles.= `find lib/ -iname '*.a' -ls`;
789 $afiles.= `find tools/ -iname '*.a' -ls`;
790 if($BUILDTYPE eq "release"){
791 $afiles.= `find Release/ -iname '*.a' -ls`;
792 } elsif($BUILDTYPE eq "release-asserts") {
793 $afiles.= `find Release-Asserts/ -iname '*.a' -ls`;
794 } else {
795 $afiles.= `find Debug/ -iname '*.a' -ls`;
796 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000797
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000798 $ofiles.= `find utils/ -iname '*.o' -ls`;
799 $ofiles.= `find lib/ -iname '*.o' -ls`;
800 $ofiles.= `find tools/ -iname '*.o' -ls`;
801 if($BUILDTYPE eq "release"){
802 $ofiles.= `find Release/ -iname '*.o' -ls`;
803 } elsif($BUILDTYPE eq "release-asserts") {
804 $ofiles.= `find Release-Asserts/ -iname '*.o' -ls`;
805 } else {
806 $ofiles.= `find Debug/ -iname '*.o' -ls`;
807 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000808
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000809 @AFILES = split "\n", $afiles;
810 $a_file_sizes="";
811 foreach $x (@AFILES){
812 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
813 $a_file_sizes.="$1 $2 $BUILDTYPE\n";
814 }
815 @OFILES = split "\n", $ofiles;
816 $o_file_sizes="";
817 foreach $x (@OFILES){
818 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
819 $o_file_sizes.="$1 $2 $BUILDTYPE\n";
820 }
821} else {
822 $a_file_sizes="No data due to a bad build.";
823 $o_file_sizes="No data due to a bad build.";
824}
825
826##############################################################
827#
828# Running dejagnu tests
829#
830##############################################################
831my $DejangnuTestResults=""; # String containing the results of the dejagnu
832my $dejagnu_output = "$DejagnuTestsLog";
833if (!$NODEJAGNU) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000834 if($VERBOSE) {
835 print "DEJAGNU FEATURE/REGRESSION TEST STAGE:\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000836 print "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1\n";
837 }
838
839 #Run the feature and regression tests, results are put into testrun.sum
840 #Full log in testrun.log
841 system "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000842
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000843 #Copy the testrun.log and testrun.sum to our webdir
844 CopyFile("test/testrun.log", $DejagnuLog);
845 CopyFile("test/testrun.sum", $DejagnuSum);
846 #can be done on server
847 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
848 $unexpfail_tests = $DejagnuTestResults;
849}
850
851#Extract time of dejagnu tests
852my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
853my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
854$DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
Misha Brukmanafa1e862009-01-02 16:28:18 +0000855$DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
856$DejagnuTestResults =
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000857 "Dejagnu skipped by user choice." unless $DejagnuTestResults;
858$DejagnuTime = "0.0" unless $DejagnuTime;
859$DejagnuWallTime = "0.0" unless $DejagnuWallTime;
860
861##############################################################
862#
863# Get warnings from the build
864#
865##############################################################
866if (!$NODEJAGNU) {
867 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
868 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
869 my @Warnings;
870 my $CurDir = "";
871
872 foreach $Warning (@Warn) {
873 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
874 $CurDir = $1; # Keep track of directory warning is in...
875 # Remove buildir prefix if included
876 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { $CurDir = $1; }
877 } else {
878 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
879 }
880 }
881 my $WarningsFile = join "\n", @Warnings;
882 $WarningsFile =~ s/:[0-9]+:/::/g;
883
884 # Emit the warnings file, so we can diff...
885 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
886 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
887
888 # Output something to stdout if something has changed
889 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
890 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
891
892 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
893 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
894
895} #endif !NODEGAGNU
896
897##############################################################
898#
899# If we built the tree successfully, run the nightly programs tests...
900#
Misha Brukmanafa1e862009-01-02 16:28:18 +0000901# A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000902# "External")
903#
904##############################################################
905sub TestDirectory {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000906 my $SubDir = shift;
907 ChangeDir( "$BuildDir/llvm/projects/llvm-test/$SubDir",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000908 "Programs Test Subdirectory" ) || return ("", "");
Misha Brukmanafa1e862009-01-02 16:28:18 +0000909
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000910 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000911
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000912 # Run the programs tests... creating a report.nightly.csv file
913 if (!$NOTEST) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000914 if( $VERBOSE) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000915 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
Misha Brukmanafa1e862009-01-02 16:28:18 +0000916 "TEST=nightly > $ProgramTestLog 2>&1\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000917 }
918 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
919 "TEST=nightly > $ProgramTestLog 2>&1";
920 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
Misha Brukmanafa1e862009-01-02 16:28:18 +0000921 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000922
923 my $ProgramsTable;
924 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
925 $TestError = 1;
926 $ProgramsTable="Error running test $SubDir\n";
927 print "ERROR TESTING\n";
928 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
929 $TestError = 1;
930 $ProgramsTable="Makefile error running tests $SubDir!\n";
931 print "ERROR TESTING\n";
932 } else {
933 $TestError = 0;
934 #
935 # Create a list of the tests which were run...
936 #
937 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
938 "| sort > $Prefix-$SubDir-Tests.txt";
939 }
940 $ProgramsTable = ReadFile "report.nightly.csv";
941
942 ChangeDir( "../../..", "Programs Test Parent Directory" );
943 return ($ProgramsTable, $llcbeta_options);
944} #end sub TestDirectory
945
946##############################################################
947#
948# Calling sub TestDirectory
949#
950##############################################################
951if (!$BuildError) {
952 if ( $VERBOSE ) {
953 print "SingleSource TEST STAGE\n";
954 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000955 ($SingleSourceProgramsTable, $llcbeta_options) =
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000956 TestDirectory("SingleSource");
957 WriteFile "$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
958 if ( $VERBOSE ) {
959 print "MultiSource TEST STAGE\n";
960 }
961 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
962 WriteFile "$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
963 if ( ! $NOEXTERNALS ) {
964 if ( $VERBOSE ) {
965 print "External TEST STAGE\n";
966 }
967 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
968 WriteFile "$Prefix-External-Performance.txt", $ExternalProgramsTable;
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 "$Prefix-External-Tests.txt | 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 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
975 } else {
976 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
977 if ( $VERBOSE ) {
978 print "External TEST STAGE SKIPPED\n";
979 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000980 system "cat $Prefix-SingleSource-Tests.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000981 "$Prefix-MultiSource-Tests.txt ".
982 " | sort > $Prefix-Tests.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000983 system "cat $Prefix-SingleSource-Performance.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000984 "$Prefix-MultiSource-Performance.txt ".
985 " | sort > $Prefix-Performance.txt";
986 }
987
988 ##############################################################
989 #
Misha Brukmanafa1e862009-01-02 16:28:18 +0000990 #
991 # gathering tests added removed broken information here
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000992 #
993 #
994 ##############################################################
995 my $dejagnu_test_list = ReadFile "$Prefix-Tests.txt";
996 my @DEJAGNU = split "\n", $dejagnu_test_list;
997 my ($passes, $fails, $xfails) = "";
998
999 if(!$NODEJAGNU) {
1000 for ($x=0; $x<@DEJAGNU; $x++) {
1001 if ($DEJAGNU[$x] =~ m/^PASS:/) {
1002 $passes.="$DEJAGNU[$x]\n";
1003 }
1004 elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
1005 $fails.="$DEJAGNU[$x]\n";
1006 }
1007 elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
1008 $xfails.="$DEJAGNU[$x]\n";
1009 }
1010 }
1011 }
Misha Brukmanafa1e862009-01-02 16:28:18 +00001012
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001013} #end if !$BuildError
1014
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001015##############################################################
1016#
1017# Getting end timestamp
1018#
1019##############################################################
1020$endtime = `date "+20%y-%m-%d %H:%M:%S"`;
1021
1022
1023##############################################################
1024#
1025# Place all the logs neatly into one humungous file
1026#
1027##############################################################
1028if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
1029
Misha Brukmanafa1e862009-01-02 16:28:18 +00001030$machine_data = "uname: ".`uname -a`.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001031 "hardware: ".`uname -m`.
1032 "os: ".`uname -sr`.
1033 "name: ".`uname -n`.
1034 "date: ".`date \"+20%y-%m-%d\"`.
Misha Brukmanafa1e862009-01-02 16:28:18 +00001035 "time: ".`date +\"%H:%M:%S\"`;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001036
1037my @CVS_DATA;
1038my $cvs_data;
1039@CVS_DATA = ReadFile "$COLog";
1040$cvs_data = join("\n", @CVS_DATA);
1041
1042my @BUILD_DATA;
1043my $build_data;
1044@BUILD_DATA = ReadFile "$BuildLog";
1045$build_data = join("\n", @BUILD_DATA);
1046
1047my (@DEJAGNU_LOG, @DEJAGNU_SUM, @DEJAGNULOG_FULL, @GCC_VERSION);
1048my ($dejagnutests_log ,$dejagnutests_sum, $dejagnulog_full) = "";
1049my ($gcc_version, $gcc_version_long) = "";
1050
1051$gcc_version_long="";
1052if ($GCCPATH ne "") {
1053 $gcc_version_long = `$GCCPATH/gcc --version`;
1054} elsif ($ENV{"CC"}) {
1055 $gcc_version_long = `$ENV{"CC"} --version`;
1056} else {
1057 $gcc_version_long = `gcc --version`;
1058}
1059@GCC_VERSION = split '\n', $gcc_version_long;
1060$gcc_version = $GCC_VERSION[0];
1061
1062$llvmgcc_version_long="";
1063if ($LLVMGCCPATH ne "") {
1064 $llvmgcc_version_long = `$LLVMGCCPATH/llvm-gcc -v 2>&1`;
1065} else {
1066 $llvmgcc_version_long = `llvm-gcc -v 2>&1`;
1067}
1068@LLVMGCC_VERSION = split '\n', $llvmgcc_version_long;
1069$llvmgcc_versionTarget = $LLVMGCC_VERSION[1];
1070$llvmgcc_versionTarget =~ /Target: (.+)/;
1071$targetTriple = $1;
1072
1073if(!$BuildError){
1074 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
1075 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
1076 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
1077 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
1078
1079 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
1080 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
1081}
1082
1083##############################################################
1084#
1085# Send data via a post request
1086#
1087##############################################################
1088
1089if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
1090
1091my %hash_of_data = (
1092 'machine_data' => $machine_data,
1093 'build_data' => $build_data,
1094 'gcc_version' => $gcc_version,
1095 'nickname' => $nickname,
1096 'dejagnutime_wall' => $DejagnuWallTime,
1097 'dejagnutime_cpu' => $DejagnuTime,
1098 'cvscheckouttime_wall' => $CheckoutTime_Wall,
1099 'cvscheckouttime_cpu' => $CheckoutTime_CPU,
1100 'configtime_wall' => $ConfigWallTime,
1101 'configtime_cpu'=> $ConfigTime,
1102 'buildtime_wall' => $BuildWallTime,
1103 'buildtime_cpu' => $BuildTime,
1104 'warnings' => $WarningsFile,
1105 'cvsusercommitlist' => $UserCommitList,
1106 'cvsuserupdatelist' => $UserUpdateList,
1107 'cvsaddedfiles' => $CVSAddedFiles,
1108 'cvsmodifiedfiles' => $CVSModifiedFiles,
1109 'cvsremovedfiles' => $CVSRemovedFiles,
1110 'lines_of_code' => $LOC,
1111 'cvs_file_count' => $NumFilesInCVS,
1112 'cvs_dir_count' => $NumDirsInCVS,
1113 'buildstatus' => $BuildStatus,
1114 'singlesource_programstable' => $SingleSourceProgramsTable,
1115 'multisource_programstable' => $MultiSourceProgramsTable,
1116 'externalsource_programstable' => $ExternalProgramsTable,
1117 'llcbeta_options' => $multisource_llcbeta_options,
1118 'warnings_removed' => $WarningsRemoved,
1119 'warnings_added' => $WarningsAdded,
1120 'passing_tests' => $passes,
1121 'expfail_tests' => $xfails,
1122 'unexpfail_tests' => $fails,
1123 'all_tests' => $dejagnu_test_list,
1124 'new_tests' => "",
1125 'removed_tests' => "",
1126 'dejagnutests_results' => $DejagnuTestResults,
1127 'dejagnutests_log' => $dejagnulog_full,
1128 'starttime' => $starttime,
1129 'endtime' => $endtime,
1130 'o_file_sizes' => $o_file_sizes,
1131 'a_file_sizes' => $a_file_sizes,
1132 'target_triple' => $targetTriple
1133);
1134
Tanya Lattner084a3ee2008-03-10 07:28:08 +00001135if ($SUBMIT) {
1136 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
1137 if( $VERBOSE) { print "============================\n$response"; }
1138} else {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001139 print "============================\n";
1140 foreach $x(keys %hash_of_data){
1141 print "$x => $hash_of_data{$x}\n";
1142 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001143}
1144
1145##############################################################
1146#
1147# Remove the cvs tree...
1148#
1149##############################################################
Misha Brukmanafa1e862009-01-02 16:28:18 +00001150system ( "$NICE rm -rf $BuildDir")
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001151 if (!$NOCHECKOUT and !$NOREMOVE);
Misha Brukmanafa1e862009-01-02 16:28:18 +00001152system ( "$NICE rm -rf $WebDir")
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001153 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);