blob: 3976554f0e884f9453a368a413666dfad6493875 [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;
Evan Chengb6d7fc32009-06-18 21:39:50 +0000102my $TestSVNURL = $ENV{"TestSVNURL"};
103$TestSVNURL = 'https://llvm.org/svn/llvm-project' unless $TestSVNURL;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000104my $CVSRootDir = $ENV{'CVSROOT'};
105$CVSRootDir = "/home/vadve/shared/PublicCVS" unless $CVSRootDir;
106my $BuildDir = $ENV{'BUILDDIR'};
107$BuildDir = "$HOME/buildtest" unless $BuildDir;
108my $WebDir = $ENV{'WEBDIR'};
109$WebDir = "$HOME/cvs/testresults-X86" unless $WebDir;
110
111##############################################################
112#
113# Calculate the date prefix...
114#
115##############################################################
116@TIME = localtime;
117my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
118my $DateString = strftime "%B %d, %Y", localtime;
119my $TestStartTime = gmtime() . "GMT<br>" . localtime() . " (local)";
120
121##############################################################
122#
123# Parse arguments...
124#
125##############################################################
126$CONFIGUREARGS="";
127$nickname="";
128$NOTEST=0;
129$USESVN=1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000130$MAKECMD="make";
131$SUBMITSERVER = "llvm.org";
132$SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
Daniel Dunbar016a4bb2009-05-18 23:24:26 +0000133$SUBMITAUX="";
Tanya Lattner084a3ee2008-03-10 07:28:08 +0000134$SUBMIT = 1;
Daniel Dunbarf8cdaec2009-05-28 22:45:24 +0000135$PARALLELJOBS = "2";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000136
137while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
138 shift;
139 last if /^--$/; # Stop processing arguments on --
140
141 # List command line options here...
142 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
143 if (/^-nocvsstats$/) { $NOCVSSTATS = 1; next; }
144 if (/^-noremove$/) { $NOREMOVE = 1; next; }
145 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
Daniel Dunbar2041d9a2009-06-02 21:14:15 +0000146 if (/^-notest$/) { $NOTEST = 1; next; }
147 if (/^-norunningtests$/) { next; } # Backward compatibility, ignored.
Daniel Dunbarf8cdaec2009-05-28 22:45:24 +0000148 if (/^-parallel-jobs$/) { $PARALLELJOBS = "$ARGV[0]"; shift; next;}
149 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j$PARALLELJOBS -l3.0"; next; }
Duncan Sands01388f92009-06-12 13:02:52 +0000150 if (/^-with-clang$/) { $WITHCLANG = 1; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000151 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
152 "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
153 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
Dan Gohmanbd399762008-10-30 01:08:03 +0000154 "DISABLE_ASSERTIONS=1 ".
Misha Brukmanafa1e862009-01-02 16:28:18 +0000155 "OPTIMIZE_OPTION=-O2";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000156 $BUILDTYPE="release-asserts"; next;}
157 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
Duncan Sands01388f92009-06-12 13:02:52 +0000158 if (/^-disable-pic$/) { $CONFIGUREARGS .= " --enable-pic=no"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000159 if (/^-enable-lli$/) { $PROGTESTOPTS .= " ENABLE_LLI=1";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000160 $CONFIGUREARGS .= " --enable-lli"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000161 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000162 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000163 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
164 $CONFIGUREARGS .= " --disable-jit"; next; }
Daniel Dunbar31a1f1c2009-03-10 19:33:13 +0000165 if (/^-disable-bindings$/) { $CONFIGUREARGS .= " --disable-bindings"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000166 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
Evan Cheng32efae02008-01-12 04:27:18 +0000167 if (/^-disable-lto$/) { $PROGTESTOPTS .= " DISABLE_LTO=1"; next; }
Evan Cheng08206772008-01-14 17:58:03 +0000168 if (/^-test-opts$/) { $PROGTESTOPTS .= " $ARGV[0]"; shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000169 if (/^-verbose$/) { $VERBOSE = 1; next; }
170 if (/^-debug$/) { $DEBUG = 1; next; }
171 if (/^-nice$/) { $NICE = "nice "; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000172 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000173 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000174 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000175 shift; next; }
176 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
177 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
Daniel Dunbar016a4bb2009-05-18 23:24:26 +0000178 if (/^-submit-aux/) { $SUBMITAUX = "$ARGV[0]"; shift; next; }
Tanya Lattner084a3ee2008-03-10 07:28:08 +0000179 if (/^-nosubmit$/) { $SUBMIT = 0; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000180 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
181 if (/^-gccpath/) { $CONFIGUREARGS .=
182 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000183 $GCCPATH=$ARGV[0]; shift; next; }
184 else { $GCCPATH=""; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000185 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000186 else { $CVSCOOPT="";}
187 if (/^-usecvs/) { $USESVN = 0; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000188 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000189 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000190 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000191 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000192 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000193 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000194 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000195 shift; next; }
196 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
197 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000198 if (/^-extraflags/) { $CONFIGUREARGS .=
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000199 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
200 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
201 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
202 if (/^-nobuild$/) { $NOBUILD = 1; next; }
203 print "Unknown option: $_ : ignoring!\n";
204}
205
206if ($ENV{'LLVMGCCDIR'}) {
207 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
Bob Wilsonc6d296b2009-03-12 19:47:24 +0000208 $LLVMGCCPATH = $ENV{'LLVMGCCDIR'} . '/bin';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000209}
210else {
211 $LLVMGCCPATH = "";
212}
213
214if ($CONFIGUREARGS !~ /--disable-jit/) {
215 $CONFIGUREARGS .= " --enable-jit";
216}
217
218if (@ARGV != 0 and @ARGV != 3 and $VERBOSE) {
219 foreach $x (@ARGV) {
220 print "$x\n";
221 }
222 print "Must specify 0 or 3 options!";
223}
224
225if (@ARGV == 3) {
226 $CVSRootDir = $ARGV[0];
227 $BuildDir = $ARGV[1];
228 $WebDir = $ARGV[2];
229}
230
231if ($CVSRootDir eq "" or
232 $BuildDir eq "" or
233 $WebDir eq "") {
234 die("please specify a cvs root directory, a build directory, and a ".
235 "web directory");
236 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000237
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000238if ($nickname eq "") {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000239 die ("Please invoke NewNightlyTest.pl with command line option " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000240 "\"-nickname <nickname>\"");
241}
242
243if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
244 $BUILDTYPE = "debug";
245}
246
247##############################################################
248#
249#define the file names we'll use
250#
251##############################################################
252my $Prefix = "$WebDir/$DATE";
253my $BuildLog = "$Prefix-Build-Log.txt";
254my $COLog = "$Prefix-CVS-Log.txt";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000255my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
256my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
257my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
258my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
259my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
260my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
261if (! -d $WebDir) {
262 mkdir $WebDir, 0777;
263 if($VERBOSE){
264 warn "$WebDir did not exist; creating it.\n";
265 }
266}
267
268if ($VERBOSE) {
269 print "INITIALIZED\n";
270 if ($USESVN) {
271 print "SVN URL = $SVNURL\n";
272 } else {
273 print "CVS Root = $CVSRootDir\n";
274 }
275 print "COLog = $COLog\n";
276 print "BuildDir = $BuildDir\n";
277 print "WebDir = $WebDir\n";
278 print "Prefix = $Prefix\n";
279 print "BuildLog = $BuildLog\n";
280}
281
282##############################################################
283#
284# Helper functions
285#
286##############################################################
287sub GetDir {
288 my $Suffix = shift;
289 opendir DH, $WebDir;
290 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
291 closedir DH;
292 return @Result;
293}
294
295#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
296#
297# DiffFiles - Diff the current version of the file against the last version of
298# the file, reporting things added and removed. This is used to report, for
299# example, added and removed warnings. This returns a pair (added, removed)
300#
301#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
302sub DiffFiles {
303 my $Suffix = shift;
304 my @Others = GetDir $Suffix;
305 if (@Others == 0) { # No other files? We added all entries...
306 return (`cat $WebDir/$DATE$Suffix`, "");
307 }
308# Diff the files now...
309 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
310 my $Added = join "\n", grep /^</, @Diffs;
311 my $Removed = join "\n", grep /^>/, @Diffs;
312 $Added =~ s/^< //gm;
313 $Removed =~ s/^> //gm;
314 return ($Added, $Removed);
315}
316
317#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
318#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
319sub GetRegex { # (Regex with ()'s, value)
320 $_[1] =~ /$_[0]/m;
Misha Brukmanafa1e862009-01-02 16:28:18 +0000321 return $1
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000322 if (defined($1));
323 return "0";
324}
325
326#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
327#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
328sub GetRegexNum {
329 my ($Regex, $Num, $Regex2, $File) = @_;
330 my @Items = split "\n", `grep '$Regex' $File`;
331 return GetRegex $Regex2, $Items[$Num];
332}
333
334#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
335#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
336sub ChangeDir { # directory, logical name
337 my ($dir,$name) = @_;
338 chomp($dir);
339 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
340 $result = chdir($dir);
341 if (!$result) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000342 print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000343 return false;
344 }
345 return true;
346}
347
348#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
349#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
350sub ReadFile {
351 if (open (FILE, $_[0])) {
352 undef $/;
353 my $Ret = <FILE>;
354 close FILE;
355 $/ = '\n';
356 return $Ret;
357 } else {
358 print "Could not open file '$_[0]' for reading!\n";
359 return "";
360 }
361}
362
363#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
364#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
365sub WriteFile { # (filename, contents)
366 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
367 print FILE $_[1];
368 close FILE;
369}
370
371#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
372#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
373sub CopyFile { #filename, newfile
374 my ($file, $newfile) = @_;
375 chomp($file);
376 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
377 copy($file, $newfile);
378}
379
380#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
381#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
382sub AddRecord {
383 my ($Val, $Filename,$WebDir) = @_;
384 my @Records;
385 if (open FILE, "$WebDir/$Filename") {
386 @Records = grep !/$DATE/, split "\n", <FILE>;
387 close FILE;
388 }
389 push @Records, "$DATE: $Val";
390 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
391}
392
393#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
394#
395# FormatTime - Convert a time from 1m23.45 into 83.45
396#
397#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
398sub FormatTime {
399 my $Time = shift;
400 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
401 $Time = sprintf("%7.4f", $1*60.0+$2);
402 }
403 return $Time;
404}
405
406#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
407#
Misha Brukmanafa1e862009-01-02 16:28:18 +0000408# This function is meant to read in the dejagnu sum file and
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000409# return a string with only the results (i.e. PASS/FAIL/XPASS/
410# XFAIL).
411#
412#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
413sub GetDejagnuTestResults { # (filename, log)
414 my ($filename, $DejagnuLog) = @_;
415 my @lines;
416 $/ = "\n"; #Make sure we're going line at a time.
417
418 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
419
420 if (open SRCHFILE, $filename) {
421 # Process test results
422 while ( <SRCHFILE> ) {
423 if ( length($_) > 1 ) {
424 chomp($_);
425 if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\/test\/(.*)$/ ) {
426 push(@lines, "$1: test/$2");
427 }
428 }
429 }
430 }
431 close SRCHFILE;
432
433 my $content = join("\n", @lines);
434 return $content;
435}
436
437
438
439#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
440#
441# This function acts as a mini web browswer submitting data
442# to our central server via the post method
443#
444#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
445sub SendData{
446 $host = $_[0];
447 $file = $_[1];
448 $variables=$_[2];
449
Daniel Dunbara2533002009-05-28 18:31:40 +0000450 # Write out the "...-sentdata.txt" file.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000451
Daniel Dunbara2533002009-05-28 18:31:40 +0000452 my $sentdata="";
453 foreach $x (keys (%$variables)){
454 $value = $variables->{$x};
455 $sentdata.= "$x => $value\n";
456 }
457 WriteFile "$Prefix-sentdata.txt", $sentdata;
458
459 if (!($SUBMITAUX eq "")) {
460 system "$SUBMITAUX \"$Prefix-sentdata.txt\"";
461 }
462
463 # Create the content to send to the server.
464
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000465 my $content;
466 foreach $key (keys (%$variables)){
467 $value = $variables->{$key};
468 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
469 $content .= "$key=$value&";
470 }
471
Daniel Dunbara2533002009-05-28 18:31:40 +0000472 # Send the data to the server.
473 #
474 # FIXME: This code should be more robust?
475
476 $port=80;
477 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
478 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
479 die "Bad socket\n";
480 connect SOCK, $socketaddr or die "Bad connection\n";
481 select((select(SOCK), $| = 1)[0]);
482
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000483 $length = length($content);
484
485 my $send= "POST $file HTTP/1.0\n";
486 $send.= "Host: $host\n";
487 $send.= "Content-Type: application/x-www-form-urlencoded\n";
488 $send.= "Content-length: $length\n\n";
489 $send.= "$content";
490
491 print SOCK $send;
492 my $result;
493 while(<SOCK>){
494 $result .= $_;
495 }
496 close(SOCK);
497
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000498 return $result;
499}
500
501##############################################################
502#
503# Getting Start timestamp
504#
505##############################################################
506$starttime = `date "+20%y-%m-%d %H:%M:%S"`;
507
508##############################################################
509#
510# Create the CVS repository directory
511#
512##############################################################
513if (!$NOCHECKOUT) {
514 if (-d $BuildDir) {
515 if (!$NOREMOVE) {
516 if ( $VERBOSE ) {
517 print "Build directory exists! Removing it\n";
518 }
519 system "rm -rf $BuildDir";
520 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
521 } else {
522 if ( $VERBOSE ) {
523 print "Build directory exists!\n";
524 }
525 }
526 } else {
527 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
528 }
529}
530ChangeDir( $BuildDir, "checkout directory" );
531
532
533##############################################################
534#
Misha Brukmanafa1e862009-01-02 16:28:18 +0000535# Check out the llvm tree, using either SVN or CVS
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000536#
537##############################################################
538if (!$NOCHECKOUT) {
539 if ( $VERBOSE ) { print "CHECKOUT STAGE:\n"; }
540 if ($USESVN) {
Duncan Sands01388f92009-06-12 13:02:52 +0000541 my $SVNCMD = "$NICE svn co --non-interactive $SVNURL";
Evan Chengb6d7fc32009-06-18 21:39:50 +0000542 my $SVNCMD2 = "$NICE svn co --non-interactive $TestSVNURL";
Duncan Sands01388f92009-06-12 13:02:52 +0000543 if ($VERBOSE) {
544 print "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
Evan Chengb6d7fc32009-06-18 21:39:50 +0000545 "$SVNCMD2/test-suite/trunk llvm-test ) > $COLog 2>&1\n";
Duncan Sands01388f92009-06-12 13:02:52 +0000546 }
547 system "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
Evan Chengb6d7fc32009-06-18 21:39:50 +0000548 "$SVNCMD2/test-suite/trunk llvm-test ) > $COLog 2>&1\n";
549 if ($WITHCLANG) {
550 my $SVNCMD = "$NICE svn co --non-interactive $SVNURL/cfe/trunk";
551 if ($VERBOSE) {
552 print "( time -p cd llvm/tools ; $SVNCMD clang ) > $COLog 2>&1\n";
553 }
554 system "( time -p cd llvm/tools ; $SVNCMD clang ) > $COLog 2>&1\n";
555 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000556 } else {
557 my $CVSOPT = "";
558 $CVSOPT = "-z3" # Use compression if going over ssh.
559 if $CVSRootDir =~ /^:ext:/;
560 my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co -P $CVSCOOPT";
561 if ($VERBOSE) {
562 print "( time -p $CVSCMD llvm; cd llvm/projects ; " .
563 "$CVSCMD llvm-test ) > $COLog 2>&1\n";
564 }
565 system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
566 "$CVSCMD llvm-test ) > $COLog 2>&1\n";
567 }
568}
569ChangeDir( $BuildDir , "Checkout directory") ;
570ChangeDir( "llvm" , "llvm source directory") ;
571
572##############################################################
573#
574# Get some static statistics about the current state of CVS
575#
576# This can probably be put on the server side
577#
578##############################################################
579my $CheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $COLog`;
580my $CheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $COLog`;
581my $CheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $COLog`;
582my $CheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
583
584my $NumFilesInCVS = 0;
585my $NumDirsInCVS = 0;
586if ($USESVN) {
587 $NumFilesInCVS = `egrep '^A' $COLog | wc -l` + 0;
Nick Lewyckye45e2c82008-06-05 12:54:44 +0000588 $NumDirsInCVS = `sed -e 's#/[^/]*\$##' $COLog | sort | uniq | wc -l` + 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000589} else {
590 $NumFilesInCVS = `egrep '^U' $COLog | wc -l` + 0;
591 $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $COLog | wc -l` + 0;
592}
593
594##############################################################
595#
596# Extract some information from the CVS history... use a hash so no duplicate
597# stuff is stored. This gets the history from the previous days worth
598# of cvs activity and parses it.
599#
600##############################################################
601
602# This just computes a reasonably accurate #of seconds since 2000. It doesn't
603# have to be perfect as its only used for comparing date ranges within a couple
604# of days.
605sub ConvertToSeconds {
606 my ($sec, $min, $hour, $day, $mon, $yr) = @_;
607 my $Result = ($yr - 2000) * 12;
608 $Result += $mon;
609 $Result *= 31;
610 $Result += $day;
611 $Result *= 24;
612 $Result += $hour;
613 $Result *= 60;
614 $Result += $min;
615 $Result *= 60;
616 $Result += $sec;
617 return $Result;
618}
619
620my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
621
622if (!$NOCVSSTATS) {
623 if ($VERBOSE) { print "CHANGE HISTORY ANALYSIS STAGE\n"; }
624
625 if ($USESVN) {
Duncan Sands01388f92009-06-12 13:02:52 +0000626 @SVNHistory = split /<logentry/, `svn log --non-interactive --xml --verbose -r{$DATE}:HEAD`;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000627 # Skip very first entry because it is the XML header cruft
628 shift @SVNHistory;
629 my $Now = time();
630 foreach $Record (@SVNHistory) {
631 my @Lines = split "\n", $Record;
632 my ($Author, $Date, $Revision);
633 # Get the date and see if its one we want to process.
634 my ($Year, $Month, $Day, $Hour, $Min, $Sec);
635 if ($Lines[3] =~ /<date>(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/){
636 $Year = $1; $Month = $2; $Day = $3; $Hour = $4; $Min = $5; $Sec = $6;
637 }
638 my $Then = ConvertToSeconds($Sec, $Min, $Hour, $Day, $Month, $Year);
639 # Get the current date and compute when "yesterday" is.
640 my ($NSec, $NMin, $NHour, $NDay, $NMon, $NYear) = gmtime();
641 my $Now = ConvertToSeconds( $NSec, $NMin, $NHour, $NDay, $NMon, $NYear);
642 if (($Now - 24*60*60) > $Then) {
643 next;
644 }
645 if ($Lines[1] =~ / revision="([0-9]*)">/) {
646 $Revision = $1;
647 }
648 if ($Lines[2] =~ /<author>([^<]*)<\/author>/) {
649 $Author = $1;
650 }
651 $UsersCommitted{$Author} = 1;
652 $Date = $Year . "-" . $Month . "-" . $Day;
653 $Time = $Hour . ":" . $Min . ":" . $Sec;
654 print "Rev: $Revision, Author: $Author, Date: $Date, Time: $Time\n";
655 for ($i = 6; $i < $#Lines; $i += 2 ) {
656 if ($Lines[$i] =~ /^ action="(.)">([^<]*)</) {
657 if ($1 == "A") {
658 $AddedFiles{$2} = 1;
659 } elsif ($1 == 'D') {
660 $RemovedFiles{$2} = 1;
661 } elsif ($1 == 'M' || $1 == 'R' || $1 == 'C') {
662 $ModifiedFiles{$2} = 1;
663 } else {
664 print "UNMATCHABLE: $Lines[$i]\n";
665 }
666 }
667 }
668 }
669 } else {
670 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
671#print join "\n", @CVSHistory; print "\n";
672
673 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
674
675# Loop over every record from the CVS history, filling in the hashes.
676 foreach $File (@CVSHistory) {
677 my ($Type, $Date, $UID, $Rev, $Filename);
678 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
679 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
680 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
681 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
682 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
683 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
684 } else {
685 print "UNMATCHABLE: $File\n";
686 next;
687 }
688 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000689
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000690 if ($Filename =~ /^llvm/) {
691 if ($Type eq 'M') { # Modified
692 $ModifiedFiles{$Filename} = 1;
693 $UsersCommitted{$UID} = 1;
694 } elsif ($Type eq 'A') { # Added
695 $AddedFiles{$Filename} = 1;
696 $UsersCommitted{$UID} = 1;
697 } elsif ($Type eq 'R') { # Removed
698 $RemovedFiles{$Filename} = 1;
699 $UsersCommitted{$UID} = 1;
700 } else {
701 $UsersUpdated{$UID} = 1;
702 }
703 }
704 }
705
706 my $TestError = 1;
707 } #$USESVN
708}#!NOCVSSTATS
709
710my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
711my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
712my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
713my $UserCommitList = join "\n", sort keys %UsersCommitted;
714my $UserUpdateList = join "\n", sort keys %UsersUpdated;
715
716##############################################################
717#
718# Build the entire tree, saving build messages to the build log
719#
720##############################################################
721if (!$NOCHECKOUT && !$NOBUILD) {
722 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
723 if ( $VERBOSE ) {
724 print "CONFIGURE STAGE:\n";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000725 print "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000726 "> $BuildLog 2>&1\n";
727 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000728 system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000729 "> $BuildLog 2>&1";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000730 if ( $VERBOSE ) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000731 print "BUILD STAGE:\n";
Duncan Sands01388f92009-06-12 13:02:52 +0000732 print "(time -p $NICE $MAKECMD clean) >> $BuildLog 2>&1\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000733 print "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1\n";
734 }
735 # Build the entire tree, capturing the output into $BuildLog
Duncan Sands01388f92009-06-12 13:02:52 +0000736 system "(time -p $NICE $MAKECMD clean) >> $BuildLog 2>&1";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000737 system "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1";
738}
739
740##############################################################
741#
742# Get some statistics about the build...
743#
744##############################################################
745#this can de done on server
746#my @Linked = split '\n', `grep Linking $BuildLog`;
747#my $NumExecutables = scalar(grep(/executable/, @Linked));
748#my $NumLibraries = scalar(grep(!/executable/, @Linked));
749#my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
750
751# Get the number of lines of source code. Must be here after the build is done
752# because countloc.sh uses the llvm-config script which must be built.
753my $LOC = `utils/countloc.sh -topdir $BuildDir/llvm`;
754
755# Get the time taken by the configure script
756my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
757my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
758my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
759my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
760
761$ConfigTime=-1 unless $ConfigTime;
762$ConfigWallTime=-1 unless $ConfigWallTime;
763
764my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
765my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
766my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
767my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
768
769$BuildTime=-1 unless $BuildTime;
770$BuildWallTime=-1 unless $BuildWallTime;
771
772my $BuildError = 0, $BuildStatus = "OK";
773if ($NOBUILD) {
774 $BuildStatus = "Skipped by user";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000775}
776elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
777 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
778 $BuildStatus = "Error: compilation aborted";
779 $BuildError = 1;
780 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
781}
782if ($BuildError) { $NODEJAGNU=1; }
783
784my $a_file_sizes="";
785my $o_file_sizes="";
786if (!$BuildError) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000787 print "Organizing size of .o and .a files\n"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000788 if ( $VERBOSE );
789 ChangeDir( "$BuildDir/llvm", "Build Directory" );
790 $afiles.= `find utils/ -iname '*.a' -ls`;
791 $afiles.= `find lib/ -iname '*.a' -ls`;
792 $afiles.= `find tools/ -iname '*.a' -ls`;
793 if($BUILDTYPE eq "release"){
794 $afiles.= `find Release/ -iname '*.a' -ls`;
795 } elsif($BUILDTYPE eq "release-asserts") {
796 $afiles.= `find Release-Asserts/ -iname '*.a' -ls`;
797 } else {
798 $afiles.= `find Debug/ -iname '*.a' -ls`;
799 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000800
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000801 $ofiles.= `find utils/ -iname '*.o' -ls`;
802 $ofiles.= `find lib/ -iname '*.o' -ls`;
803 $ofiles.= `find tools/ -iname '*.o' -ls`;
804 if($BUILDTYPE eq "release"){
805 $ofiles.= `find Release/ -iname '*.o' -ls`;
806 } elsif($BUILDTYPE eq "release-asserts") {
807 $ofiles.= `find Release-Asserts/ -iname '*.o' -ls`;
808 } else {
809 $ofiles.= `find Debug/ -iname '*.o' -ls`;
810 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000811
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000812 @AFILES = split "\n", $afiles;
813 $a_file_sizes="";
814 foreach $x (@AFILES){
815 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
816 $a_file_sizes.="$1 $2 $BUILDTYPE\n";
817 }
818 @OFILES = split "\n", $ofiles;
819 $o_file_sizes="";
820 foreach $x (@OFILES){
821 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
822 $o_file_sizes.="$1 $2 $BUILDTYPE\n";
823 }
824} else {
825 $a_file_sizes="No data due to a bad build.";
826 $o_file_sizes="No data due to a bad build.";
827}
828
829##############################################################
830#
831# Running dejagnu tests
832#
833##############################################################
834my $DejangnuTestResults=""; # String containing the results of the dejagnu
835my $dejagnu_output = "$DejagnuTestsLog";
836if (!$NODEJAGNU) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000837 if($VERBOSE) {
838 print "DEJAGNU FEATURE/REGRESSION TEST STAGE:\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000839 print "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1\n";
840 }
841
842 #Run the feature and regression tests, results are put into testrun.sum
843 #Full log in testrun.log
844 system "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000845
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000846 #Copy the testrun.log and testrun.sum to our webdir
847 CopyFile("test/testrun.log", $DejagnuLog);
848 CopyFile("test/testrun.sum", $DejagnuSum);
849 #can be done on server
850 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
851 $unexpfail_tests = $DejagnuTestResults;
852}
853
854#Extract time of dejagnu tests
855my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
856my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
857$DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
Misha Brukmanafa1e862009-01-02 16:28:18 +0000858$DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
859$DejagnuTestResults =
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000860 "Dejagnu skipped by user choice." unless $DejagnuTestResults;
861$DejagnuTime = "0.0" unless $DejagnuTime;
862$DejagnuWallTime = "0.0" unless $DejagnuWallTime;
863
864##############################################################
865#
866# Get warnings from the build
867#
868##############################################################
869if (!$NODEJAGNU) {
870 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
871 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
872 my @Warnings;
873 my $CurDir = "";
874
875 foreach $Warning (@Warn) {
876 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
877 $CurDir = $1; # Keep track of directory warning is in...
878 # Remove buildir prefix if included
879 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { $CurDir = $1; }
880 } else {
881 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
882 }
883 }
884 my $WarningsFile = join "\n", @Warnings;
885 $WarningsFile =~ s/:[0-9]+:/::/g;
886
887 # Emit the warnings file, so we can diff...
888 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
889 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
890
891 # Output something to stdout if something has changed
892 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
893 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
894
895 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
896 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
897
898} #endif !NODEGAGNU
899
900##############################################################
901#
902# If we built the tree successfully, run the nightly programs tests...
903#
Misha Brukmanafa1e862009-01-02 16:28:18 +0000904# A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000905# "External")
906#
907##############################################################
908sub TestDirectory {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000909 my $SubDir = shift;
910 ChangeDir( "$BuildDir/llvm/projects/llvm-test/$SubDir",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000911 "Programs Test Subdirectory" ) || return ("", "");
Misha Brukmanafa1e862009-01-02 16:28:18 +0000912
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000913 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000914
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000915 # Run the programs tests... creating a report.nightly.csv file
916 if (!$NOTEST) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000917 if( $VERBOSE) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000918 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
Misha Brukmanafa1e862009-01-02 16:28:18 +0000919 "TEST=nightly > $ProgramTestLog 2>&1\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000920 }
921 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
922 "TEST=nightly > $ProgramTestLog 2>&1";
923 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
Misha Brukmanafa1e862009-01-02 16:28:18 +0000924 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000925
926 my $ProgramsTable;
927 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
928 $TestError = 1;
929 $ProgramsTable="Error running test $SubDir\n";
930 print "ERROR TESTING\n";
931 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
932 $TestError = 1;
933 $ProgramsTable="Makefile error running tests $SubDir!\n";
934 print "ERROR TESTING\n";
935 } else {
936 $TestError = 0;
937 #
938 # Create a list of the tests which were run...
939 #
940 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
941 "| sort > $Prefix-$SubDir-Tests.txt";
942 }
943 $ProgramsTable = ReadFile "report.nightly.csv";
944
945 ChangeDir( "../../..", "Programs Test Parent Directory" );
946 return ($ProgramsTable, $llcbeta_options);
947} #end sub TestDirectory
948
949##############################################################
950#
951# Calling sub TestDirectory
952#
953##############################################################
954if (!$BuildError) {
955 if ( $VERBOSE ) {
956 print "SingleSource TEST STAGE\n";
957 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000958 ($SingleSourceProgramsTable, $llcbeta_options) =
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000959 TestDirectory("SingleSource");
960 WriteFile "$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
961 if ( $VERBOSE ) {
962 print "MultiSource TEST STAGE\n";
963 }
964 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
965 WriteFile "$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
966 if ( ! $NOEXTERNALS ) {
967 if ( $VERBOSE ) {
968 print "External TEST STAGE\n";
969 }
970 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
971 WriteFile "$Prefix-External-Performance.txt", $ExternalProgramsTable;
Misha Brukmanafa1e862009-01-02 16:28:18 +0000972 system "cat $Prefix-SingleSource-Tests.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000973 "$Prefix-MultiSource-Tests.txt ".
974 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000975 system "cat $Prefix-SingleSource-Performance.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000976 "$Prefix-MultiSource-Performance.txt ".
977 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
978 } else {
979 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
980 if ( $VERBOSE ) {
981 print "External TEST STAGE SKIPPED\n";
982 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000983 system "cat $Prefix-SingleSource-Tests.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000984 "$Prefix-MultiSource-Tests.txt ".
985 " | sort > $Prefix-Tests.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000986 system "cat $Prefix-SingleSource-Performance.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000987 "$Prefix-MultiSource-Performance.txt ".
988 " | sort > $Prefix-Performance.txt";
989 }
990
991 ##############################################################
992 #
Misha Brukmanafa1e862009-01-02 16:28:18 +0000993 #
994 # gathering tests added removed broken information here
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000995 #
996 #
997 ##############################################################
998 my $dejagnu_test_list = ReadFile "$Prefix-Tests.txt";
999 my @DEJAGNU = split "\n", $dejagnu_test_list;
1000 my ($passes, $fails, $xfails) = "";
1001
1002 if(!$NODEJAGNU) {
1003 for ($x=0; $x<@DEJAGNU; $x++) {
1004 if ($DEJAGNU[$x] =~ m/^PASS:/) {
1005 $passes.="$DEJAGNU[$x]\n";
1006 }
1007 elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
1008 $fails.="$DEJAGNU[$x]\n";
1009 }
1010 elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
1011 $xfails.="$DEJAGNU[$x]\n";
1012 }
1013 }
1014 }
Misha Brukmanafa1e862009-01-02 16:28:18 +00001015
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001016} #end if !$BuildError
1017
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001018##############################################################
1019#
1020# Getting end timestamp
1021#
1022##############################################################
1023$endtime = `date "+20%y-%m-%d %H:%M:%S"`;
1024
1025
1026##############################################################
1027#
1028# Place all the logs neatly into one humungous file
1029#
1030##############################################################
1031if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
1032
Misha Brukmanafa1e862009-01-02 16:28:18 +00001033$machine_data = "uname: ".`uname -a`.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001034 "hardware: ".`uname -m`.
1035 "os: ".`uname -sr`.
1036 "name: ".`uname -n`.
1037 "date: ".`date \"+20%y-%m-%d\"`.
Misha Brukmanafa1e862009-01-02 16:28:18 +00001038 "time: ".`date +\"%H:%M:%S\"`;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001039
1040my @CVS_DATA;
1041my $cvs_data;
1042@CVS_DATA = ReadFile "$COLog";
1043$cvs_data = join("\n", @CVS_DATA);
1044
1045my @BUILD_DATA;
1046my $build_data;
1047@BUILD_DATA = ReadFile "$BuildLog";
1048$build_data = join("\n", @BUILD_DATA);
1049
1050my (@DEJAGNU_LOG, @DEJAGNU_SUM, @DEJAGNULOG_FULL, @GCC_VERSION);
1051my ($dejagnutests_log ,$dejagnutests_sum, $dejagnulog_full) = "";
1052my ($gcc_version, $gcc_version_long) = "";
1053
1054$gcc_version_long="";
1055if ($GCCPATH ne "") {
1056 $gcc_version_long = `$GCCPATH/gcc --version`;
1057} elsif ($ENV{"CC"}) {
1058 $gcc_version_long = `$ENV{"CC"} --version`;
1059} else {
1060 $gcc_version_long = `gcc --version`;
1061}
1062@GCC_VERSION = split '\n', $gcc_version_long;
1063$gcc_version = $GCC_VERSION[0];
1064
1065$llvmgcc_version_long="";
1066if ($LLVMGCCPATH ne "") {
1067 $llvmgcc_version_long = `$LLVMGCCPATH/llvm-gcc -v 2>&1`;
1068} else {
1069 $llvmgcc_version_long = `llvm-gcc -v 2>&1`;
1070}
1071@LLVMGCC_VERSION = split '\n', $llvmgcc_version_long;
1072$llvmgcc_versionTarget = $LLVMGCC_VERSION[1];
1073$llvmgcc_versionTarget =~ /Target: (.+)/;
1074$targetTriple = $1;
1075
1076if(!$BuildError){
1077 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
1078 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
1079 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
1080 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
1081
1082 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
1083 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
1084}
1085
1086##############################################################
1087#
1088# Send data via a post request
1089#
1090##############################################################
1091
1092if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
1093
1094my %hash_of_data = (
1095 'machine_data' => $machine_data,
1096 'build_data' => $build_data,
1097 'gcc_version' => $gcc_version,
1098 'nickname' => $nickname,
1099 'dejagnutime_wall' => $DejagnuWallTime,
1100 'dejagnutime_cpu' => $DejagnuTime,
1101 'cvscheckouttime_wall' => $CheckoutTime_Wall,
1102 'cvscheckouttime_cpu' => $CheckoutTime_CPU,
1103 'configtime_wall' => $ConfigWallTime,
1104 'configtime_cpu'=> $ConfigTime,
1105 'buildtime_wall' => $BuildWallTime,
1106 'buildtime_cpu' => $BuildTime,
1107 'warnings' => $WarningsFile,
1108 'cvsusercommitlist' => $UserCommitList,
1109 'cvsuserupdatelist' => $UserUpdateList,
1110 'cvsaddedfiles' => $CVSAddedFiles,
1111 'cvsmodifiedfiles' => $CVSModifiedFiles,
1112 'cvsremovedfiles' => $CVSRemovedFiles,
1113 'lines_of_code' => $LOC,
1114 'cvs_file_count' => $NumFilesInCVS,
1115 'cvs_dir_count' => $NumDirsInCVS,
1116 'buildstatus' => $BuildStatus,
1117 'singlesource_programstable' => $SingleSourceProgramsTable,
1118 'multisource_programstable' => $MultiSourceProgramsTable,
1119 'externalsource_programstable' => $ExternalProgramsTable,
1120 'llcbeta_options' => $multisource_llcbeta_options,
1121 'warnings_removed' => $WarningsRemoved,
1122 'warnings_added' => $WarningsAdded,
1123 'passing_tests' => $passes,
1124 'expfail_tests' => $xfails,
1125 'unexpfail_tests' => $fails,
1126 'all_tests' => $dejagnu_test_list,
1127 'new_tests' => "",
1128 'removed_tests' => "",
1129 'dejagnutests_results' => $DejagnuTestResults,
1130 'dejagnutests_log' => $dejagnulog_full,
1131 'starttime' => $starttime,
1132 'endtime' => $endtime,
1133 'o_file_sizes' => $o_file_sizes,
1134 'a_file_sizes' => $a_file_sizes,
1135 'target_triple' => $targetTriple
1136);
1137
Tanya Lattner084a3ee2008-03-10 07:28:08 +00001138if ($SUBMIT) {
1139 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
1140 if( $VERBOSE) { print "============================\n$response"; }
1141} else {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001142 print "============================\n";
1143 foreach $x(keys %hash_of_data){
1144 print "$x => $hash_of_data{$x}\n";
1145 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001146}
1147
1148##############################################################
1149#
1150# Remove the cvs tree...
1151#
1152##############################################################
Misha Brukmanafa1e862009-01-02 16:28:18 +00001153system ( "$NICE rm -rf $BuildDir")
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001154 if (!$NOCHECKOUT and !$NOREMOVE);
Misha Brukmanafa1e862009-01-02 16:28:18 +00001155system ( "$NICE rm -rf $WebDir")
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001156 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);