blob: c005bcbfb1e725580c16301aa71bf3c7f523b04e [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001#!/usr/bin/perl
2use POSIX qw(strftime);
3use File::Copy;
Bob Wilson722d58b2009-06-19 17:19:38 +00004use File::Find;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005use Socket;
6
7#
8# Program: NewNightlyTest.pl
9#
10# Synopsis: Perform a series of tests which are designed to be run nightly.
11# This is used to keep track of the status of the LLVM tree, tracking
Misha Brukmanafa1e862009-01-02 16:28:18 +000012# regressions and performance changes. Submits this information
Dan Gohmanf17a25c2007-07-18 16:29:46 +000013# to llvm.org where it is placed into the nightlytestresults database.
14#
Dan Gohmanf17a25c2007-07-18 16:29:46 +000015# Syntax: NightlyTest.pl [OPTIONS] [CVSROOT BUILDDIR WEBDIR]
16# where
17# OPTIONS may include one or more of the following:
18# -nocheckout Do not create, checkout, update, or configure
19# the source tree.
20# -noremove Do not remove the BUILDDIR after it has been built.
21# -noremoveresults Do not remove the WEBDIR after it has been built.
22# -nobuild Do not build llvm. If tests are enabled perform them
23# on the llvm build specified in the build directory
Daniel Dunbar2041d9a2009-06-02 21:14:15 +000024# -notest Do not even attempt to run the test programs.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000025# -nodejagnu Do not run feature or regression tests
Daniel Dunbarf8cdaec2009-05-28 22:45:24 +000026# -parallel Run parallel jobs with GNU Make (see -parallel-jobs).
27# -parallel-jobs The number of parallel Make jobs to use (default is two).
Duncan Sands01388f92009-06-12 13:02:52 +000028# -with-clang Checkout Clang source into tools/clang.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000029# -release Build an LLVM Release version
30# -release-asserts Build an LLVM ReleaseAsserts version
31# -enable-llcbeta Enable testing of beta features in llc.
32# -enable-lli Enable testing of lli (interpreter) features, default is off
Duncan Sands01388f92009-06-12 13:02:52 +000033# -disable-pic Disable building with Position Independent Code.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000034# -disable-llc Disable LLC tests in the nightly tester.
35# -disable-jit Disable JIT tests in the nightly tester.
36# -disable-cbe Disable C backend tests in the nightly tester.
Evan Cheng32efae02008-01-12 04:27:18 +000037# -disable-lto Disable link time optimization.
Daniel Dunbar31a1f1c2009-03-10 19:33:13 +000038# -disable-bindings Disable building LLVM bindings.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000039# -verbose Turn on some debug output
40# -debug Print information useful only to maintainers of this script.
41# -nice Checkout/Configure/Build with "nice" to reduce impact
42# on busy servers.
43# -f2c Next argument specifies path to F2C utility
44# -nickname The next argument specifieds the nickname this script
45# will submit to the nightlytest results repository.
46# -gccpath Path to gcc/g++ used to build LLVM
47# -cvstag Check out a specific CVS tag to build LLVM (useful for
48# testing release branches)
49# -usecvs Check code out from the (old) CVS Repository instead of from
50# the standard Subversion repository.
51# -target Specify the target triplet
52# -cflags Next argument specifies that C compilation options that
53# override the default.
54# -cxxflags Next argument specifies that C++ compilation options that
55# override the default.
56# -ldflags Next argument specifies that linker options that override
57# the default.
58# -compileflags Next argument specifies extra options passed to make when
59# building LLVM.
60# -use-gmake Use gmake instead of the default make command to build
61# llvm and run tests.
62#
63# ---------------- Options to configure llvm-test ----------------------------
64# -extraflags Next argument specifies extra options that are passed to
65# compile the tests.
66# -noexternals Do not run the external tests (for cases where povray
67# or SPEC are not installed)
68# -with-externals Specify a directory where the external tests are located.
69# -submit-server Specifies a server to submit the test results too. If this
Misha Brukmanafa1e862009-01-02 16:28:18 +000070# option is not specified it defaults to
71# llvm.org. This is basically just the address of the
Dan Gohmanf17a25c2007-07-18 16:29:46 +000072# webserver
73# -submit-script Specifies which script to call on the submit server. If
74# this option is not specified it defaults to
Misha Brukmanafa1e862009-01-02 16:28:18 +000075# /nightlytest/NightlyTestAccept.php. This is basically
Dan Gohmanf17a25c2007-07-18 16:29:46 +000076# everything after the www.yourserver.org.
Daniel Dunbar016a4bb2009-05-18 23:24:26 +000077# -submit-aux If specified, an auxiliary script to run in addition to the
78# normal submit script. The script will be passed the path to
79# the "sentdata.txt" file as its sole argument.
Tanya Lattner084a3ee2008-03-10 07:28:08 +000080# -nosubmit Do not report the test results back to a submit server.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000081#
82# CVSROOT is the CVS repository from which the tree will be checked out,
83# specified either in the full :method:user@host:/dir syntax, or
84# just /dir if using a local repo.
85# BUILDDIR is the directory where sources for this test run will be checked out
86# AND objects for this test run will be built. This directory MUST NOT
87# exist before the script is run; it will be created by the cvs checkout
88# process and erased (unless -noremove is specified; see above.)
89# WEBDIR is the directory into which the test results web page will be written,
90# AND in which the "index.html" is assumed to be a symlink to the most recent
91# copy of the results. This directory will be created if it does not exist.
92# LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
93# to. This is the same as you would have for a normal LLVM build.
94#
95##############################################################
96#
97# Getting environment variables
98#
99##############################################################
100my $HOME = $ENV{'HOME'};
101my $SVNURL = $ENV{"SVNURL"};
Duncan Sands01388f92009-06-12 13:02:52 +0000102$SVNURL = 'http://llvm.org/svn/llvm-project' unless $SVNURL;
Evan Chengb6d7fc32009-06-18 21:39:50 +0000103my $TestSVNURL = $ENV{"TestSVNURL"};
104$TestSVNURL = 'https://llvm.org/svn/llvm-project' unless $TestSVNURL;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000105my $CVSRootDir = $ENV{'CVSROOT'};
106$CVSRootDir = "/home/vadve/shared/PublicCVS" unless $CVSRootDir;
107my $BuildDir = $ENV{'BUILDDIR'};
108$BuildDir = "$HOME/buildtest" unless $BuildDir;
109my $WebDir = $ENV{'WEBDIR'};
110$WebDir = "$HOME/cvs/testresults-X86" unless $WebDir;
111
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000112my $LLVMSrcDir = $ENV{'LLVMSRCDIR'};
113$LLVMSrcDir = "$BuildDir/llvm" unless $LLVMSrcDir;
114my $LLVMObjDir = $ENV{'LLVMOBJDIR'};
115$LLVMObjDir = "$BuildDir/llvm" unless $LLVMObjDir;
116my $LLVMTestDir = $ENV{'LLVMTESTDIR'};
117$LLVMTestDir = "$BuildDir/llvm/projects/llvm-test" unless $LLVMTestDir;
118
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000119##############################################################
120#
121# Calculate the date prefix...
122#
123##############################################################
124@TIME = localtime;
125my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
126my $DateString = strftime "%B %d, %Y", localtime;
127my $TestStartTime = gmtime() . "GMT<br>" . localtime() . " (local)";
128
129##############################################################
130#
131# Parse arguments...
132#
133##############################################################
134$CONFIGUREARGS="";
135$nickname="";
136$NOTEST=0;
137$USESVN=1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000138$MAKECMD="make";
139$SUBMITSERVER = "llvm.org";
140$SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
Daniel Dunbar016a4bb2009-05-18 23:24:26 +0000141$SUBMITAUX="";
Tanya Lattner084a3ee2008-03-10 07:28:08 +0000142$SUBMIT = 1;
Daniel Dunbarf8cdaec2009-05-28 22:45:24 +0000143$PARALLELJOBS = "2";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000144
145while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
146 shift;
147 last if /^--$/; # Stop processing arguments on --
148
149 # List command line options here...
150 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
151 if (/^-nocvsstats$/) { $NOCVSSTATS = 1; next; }
152 if (/^-noremove$/) { $NOREMOVE = 1; next; }
153 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
Daniel Dunbar2041d9a2009-06-02 21:14:15 +0000154 if (/^-notest$/) { $NOTEST = 1; next; }
155 if (/^-norunningtests$/) { next; } # Backward compatibility, ignored.
Daniel Dunbarf8cdaec2009-05-28 22:45:24 +0000156 if (/^-parallel-jobs$/) { $PARALLELJOBS = "$ARGV[0]"; shift; next;}
157 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j$PARALLELJOBS -l3.0"; next; }
Duncan Sands01388f92009-06-12 13:02:52 +0000158 if (/^-with-clang$/) { $WITHCLANG = 1; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000159 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
160 "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
161 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
Dan Gohmanbd399762008-10-30 01:08:03 +0000162 "DISABLE_ASSERTIONS=1 ".
Misha Brukmanafa1e862009-01-02 16:28:18 +0000163 "OPTIMIZE_OPTION=-O2";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000164 $BUILDTYPE="release-asserts"; next;}
165 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
Duncan Sands01388f92009-06-12 13:02:52 +0000166 if (/^-disable-pic$/) { $CONFIGUREARGS .= " --enable-pic=no"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000167 if (/^-enable-lli$/) { $PROGTESTOPTS .= " ENABLE_LLI=1";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000168 $CONFIGUREARGS .= " --enable-lli"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000169 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000170 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000171 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
172 $CONFIGUREARGS .= " --disable-jit"; next; }
Daniel Dunbar31a1f1c2009-03-10 19:33:13 +0000173 if (/^-disable-bindings$/) { $CONFIGUREARGS .= " --disable-bindings"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000174 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
Evan Cheng32efae02008-01-12 04:27:18 +0000175 if (/^-disable-lto$/) { $PROGTESTOPTS .= " DISABLE_LTO=1"; next; }
Evan Cheng08206772008-01-14 17:58:03 +0000176 if (/^-test-opts$/) { $PROGTESTOPTS .= " $ARGV[0]"; shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000177 if (/^-verbose$/) { $VERBOSE = 1; next; }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000178 if (/^-teelogs$/) { $TEELOGS = 1; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000179 if (/^-debug$/) { $DEBUG = 1; next; }
180 if (/^-nice$/) { $NICE = "nice "; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000181 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000182 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000183 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000184 shift; next; }
185 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
186 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
Daniel Dunbar016a4bb2009-05-18 23:24:26 +0000187 if (/^-submit-aux/) { $SUBMITAUX = "$ARGV[0]"; shift; next; }
Tanya Lattner084a3ee2008-03-10 07:28:08 +0000188 if (/^-nosubmit$/) { $SUBMIT = 0; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000189 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
190 if (/^-gccpath/) { $CONFIGUREARGS .=
191 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000192 $GCCPATH=$ARGV[0]; shift; next; }
193 else { $GCCPATH=""; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000194 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000195 else { $CVSCOOPT="";}
196 if (/^-usecvs/) { $USESVN = 0; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000197 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000198 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000199 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000200 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000201 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000202 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000203 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000204 shift; next; }
205 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
206 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000207 if (/^-extraflags/) { $CONFIGUREARGS .=
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000208 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
209 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
210 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
211 if (/^-nobuild$/) { $NOBUILD = 1; next; }
212 print "Unknown option: $_ : ignoring!\n";
213}
214
215if ($ENV{'LLVMGCCDIR'}) {
216 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
Bob Wilsonc6d296b2009-03-12 19:47:24 +0000217 $LLVMGCCPATH = $ENV{'LLVMGCCDIR'} . '/bin';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000218}
219else {
220 $LLVMGCCPATH = "";
221}
222
223if ($CONFIGUREARGS !~ /--disable-jit/) {
224 $CONFIGUREARGS .= " --enable-jit";
225}
226
227if (@ARGV != 0 and @ARGV != 3 and $VERBOSE) {
228 foreach $x (@ARGV) {
229 print "$x\n";
230 }
231 print "Must specify 0 or 3 options!";
232}
233
234if (@ARGV == 3) {
235 $CVSRootDir = $ARGV[0];
236 $BuildDir = $ARGV[1];
237 $WebDir = $ARGV[2];
238}
239
240if ($CVSRootDir eq "" or
241 $BuildDir eq "" or
242 $WebDir eq "") {
243 die("please specify a cvs root directory, a build directory, and a ".
244 "web directory");
245 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000246
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000247if ($nickname eq "") {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000248 die ("Please invoke NewNightlyTest.pl with command line option " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000249 "\"-nickname <nickname>\"");
250}
251
252if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
253 $BUILDTYPE = "debug";
254}
255
256##############################################################
257#
258#define the file names we'll use
259#
260##############################################################
261my $Prefix = "$WebDir/$DATE";
262my $BuildLog = "$Prefix-Build-Log.txt";
263my $COLog = "$Prefix-CVS-Log.txt";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000264my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
265my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
266my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
267my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
268my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
269my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
270if (! -d $WebDir) {
271 mkdir $WebDir, 0777;
272 if($VERBOSE){
273 warn "$WebDir did not exist; creating it.\n";
274 }
275}
276
277if ($VERBOSE) {
278 print "INITIALIZED\n";
279 if ($USESVN) {
280 print "SVN URL = $SVNURL\n";
281 } else {
282 print "CVS Root = $CVSRootDir\n";
283 }
284 print "COLog = $COLog\n";
285 print "BuildDir = $BuildDir\n";
286 print "WebDir = $WebDir\n";
287 print "Prefix = $Prefix\n";
288 print "BuildLog = $BuildLog\n";
289}
290
291##############################################################
292#
293# Helper functions
294#
295##############################################################
296sub GetDir {
297 my $Suffix = shift;
298 opendir DH, $WebDir;
299 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
300 closedir DH;
301 return @Result;
302}
303
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000304sub RunLoggedCommand {
305 my $Command = shift;
306 my $Log = shift;
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000307 my $Title = shift;
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000308 if ($TEELOGS) {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000309 if ($VERBOSE) {
310 print "$Title\n";
311 print "$Command 2>&1 | tee $Log\n";
312 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000313 system "$Command 2>&1 | tee $Log";
314 } else {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000315 if ($VERBOSE) {
316 print "$Title\n";
317 print "$Command 2>&1 > $Log\n";
318 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000319 system "$Command 2>&1 > $Log";
320 }
321}
322
323sub RunAppendingLoggedCommand {
324 my $Command = shift;
325 my $Log = shift;
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000326 my $Title = shift;
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000327 if ($TEELOGS) {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000328 if ($VERBOSE) {
329 print "$Title\n";
330 print "$Command 2>&1 | tee -a $Log\n";
331 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000332 system "$Command 2>&1 | tee -a $Log";
333 } else {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000334 if ($VERBOSE) {
335 print "$Title\n";
336 print "$Command 2>&1 > $Log\n";
337 }
338 system "$Command 2>&1 >> $Log";
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000339 }
340}
341
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000342#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
343#
344# DiffFiles - Diff the current version of the file against the last version of
345# the file, reporting things added and removed. This is used to report, for
346# example, added and removed warnings. This returns a pair (added, removed)
347#
348#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
349sub DiffFiles {
350 my $Suffix = shift;
351 my @Others = GetDir $Suffix;
352 if (@Others == 0) { # No other files? We added all entries...
353 return (`cat $WebDir/$DATE$Suffix`, "");
354 }
355# Diff the files now...
356 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
357 my $Added = join "\n", grep /^</, @Diffs;
358 my $Removed = join "\n", grep /^>/, @Diffs;
359 $Added =~ s/^< //gm;
360 $Removed =~ s/^> //gm;
361 return ($Added, $Removed);
362}
363
364#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
365#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
366sub GetRegex { # (Regex with ()'s, value)
367 $_[1] =~ /$_[0]/m;
Misha Brukmanafa1e862009-01-02 16:28:18 +0000368 return $1
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000369 if (defined($1));
370 return "0";
371}
372
373#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
374#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
375sub GetRegexNum {
376 my ($Regex, $Num, $Regex2, $File) = @_;
377 my @Items = split "\n", `grep '$Regex' $File`;
378 return GetRegex $Regex2, $Items[$Num];
379}
380
381#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
382#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
383sub ChangeDir { # directory, logical name
384 my ($dir,$name) = @_;
385 chomp($dir);
386 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
387 $result = chdir($dir);
388 if (!$result) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000389 print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000390 return false;
391 }
392 return true;
393}
394
395#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
396#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
397sub ReadFile {
398 if (open (FILE, $_[0])) {
399 undef $/;
400 my $Ret = <FILE>;
401 close FILE;
402 $/ = '\n';
403 return $Ret;
404 } else {
405 print "Could not open file '$_[0]' for reading!\n";
406 return "";
407 }
408}
409
410#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
411#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
412sub WriteFile { # (filename, contents)
413 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
414 print FILE $_[1];
415 close FILE;
416}
417
418#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
419#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
420sub CopyFile { #filename, newfile
421 my ($file, $newfile) = @_;
422 chomp($file);
423 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
424 copy($file, $newfile);
425}
426
427#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
428#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
429sub AddRecord {
430 my ($Val, $Filename,$WebDir) = @_;
431 my @Records;
432 if (open FILE, "$WebDir/$Filename") {
433 @Records = grep !/$DATE/, split "\n", <FILE>;
434 close FILE;
435 }
436 push @Records, "$DATE: $Val";
437 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
438}
439
440#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
441#
442# FormatTime - Convert a time from 1m23.45 into 83.45
443#
444#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
445sub FormatTime {
446 my $Time = shift;
447 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
448 $Time = sprintf("%7.4f", $1*60.0+$2);
449 }
450 return $Time;
451}
452
453#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
454#
Misha Brukmanafa1e862009-01-02 16:28:18 +0000455# This function is meant to read in the dejagnu sum file and
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000456# return a string with only the results (i.e. PASS/FAIL/XPASS/
457# XFAIL).
458#
459#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
460sub GetDejagnuTestResults { # (filename, log)
461 my ($filename, $DejagnuLog) = @_;
462 my @lines;
463 $/ = "\n"; #Make sure we're going line at a time.
464
465 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
466
467 if (open SRCHFILE, $filename) {
468 # Process test results
469 while ( <SRCHFILE> ) {
470 if ( length($_) > 1 ) {
471 chomp($_);
472 if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\/test\/(.*)$/ ) {
473 push(@lines, "$1: test/$2");
474 }
475 }
476 }
477 }
478 close SRCHFILE;
479
480 my $content = join("\n", @lines);
481 return $content;
482}
483
484
485
486#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
487#
488# This function acts as a mini web browswer submitting data
489# to our central server via the post method
490#
491#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
492sub SendData{
493 $host = $_[0];
494 $file = $_[1];
495 $variables=$_[2];
496
Daniel Dunbara2533002009-05-28 18:31:40 +0000497 # Write out the "...-sentdata.txt" file.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000498
Daniel Dunbara2533002009-05-28 18:31:40 +0000499 my $sentdata="";
500 foreach $x (keys (%$variables)){
501 $value = $variables->{$x};
502 $sentdata.= "$x => $value\n";
503 }
504 WriteFile "$Prefix-sentdata.txt", $sentdata;
505
506 if (!($SUBMITAUX eq "")) {
Daniel Dunbar3b377ef2009-06-26 22:33:28 +0000507 system "$SUBMITAUX \"$Prefix-sentdata.txt\"";
508 }
509
510 if (!$SUBMIT) {
511 return "Skipped standard submit.\n";
Daniel Dunbara2533002009-05-28 18:31:40 +0000512 }
513
514 # Create the content to send to the server.
515
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000516 my $content;
517 foreach $key (keys (%$variables)){
518 $value = $variables->{$key};
519 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
520 $content .= "$key=$value&";
521 }
522
Daniel Dunbara2533002009-05-28 18:31:40 +0000523 # Send the data to the server.
524 #
525 # FIXME: This code should be more robust?
526
527 $port=80;
528 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
529 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
530 die "Bad socket\n";
531 connect SOCK, $socketaddr or die "Bad connection\n";
532 select((select(SOCK), $| = 1)[0]);
533
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000534 $length = length($content);
535
536 my $send= "POST $file HTTP/1.0\n";
537 $send.= "Host: $host\n";
538 $send.= "Content-Type: application/x-www-form-urlencoded\n";
539 $send.= "Content-length: $length\n\n";
540 $send.= "$content";
541
542 print SOCK $send;
543 my $result;
544 while(<SOCK>){
545 $result .= $_;
546 }
547 close(SOCK);
548
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000549 return $result;
550}
551
552##############################################################
553#
554# Getting Start timestamp
555#
556##############################################################
557$starttime = `date "+20%y-%m-%d %H:%M:%S"`;
558
559##############################################################
560#
561# Create the CVS repository directory
562#
563##############################################################
564if (!$NOCHECKOUT) {
565 if (-d $BuildDir) {
566 if (!$NOREMOVE) {
567 if ( $VERBOSE ) {
568 print "Build directory exists! Removing it\n";
569 }
570 system "rm -rf $BuildDir";
571 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
572 } else {
573 if ( $VERBOSE ) {
574 print "Build directory exists!\n";
575 }
576 }
577 } else {
578 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
579 }
580}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000581
582
583##############################################################
584#
Misha Brukmanafa1e862009-01-02 16:28:18 +0000585# Check out the llvm tree, using either SVN or CVS
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000586#
587##############################################################
588if (!$NOCHECKOUT) {
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000589 ChangeDir( $BuildDir, "checkout directory" );
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000590 if ($USESVN) {
Duncan Sands01388f92009-06-12 13:02:52 +0000591 my $SVNCMD = "$NICE svn co --non-interactive $SVNURL";
Evan Chengb6d7fc32009-06-18 21:39:50 +0000592 my $SVNCMD2 = "$NICE svn co --non-interactive $TestSVNURL";
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000593 RunLoggedCommand("( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000594 "$SVNCMD2/test-suite/trunk llvm-test )", $COLog,
595 "CHECKOUT LLVM");
Evan Chengb6d7fc32009-06-18 21:39:50 +0000596 if ($WITHCLANG) {
597 my $SVNCMD = "$NICE svn co --non-interactive $SVNURL/cfe/trunk";
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000598 RunLoggedCommand("( time -p cd llvm/tools ; $SVNCMD clang )", $COLog,
599 "CHECKOUT CLANG");
Evan Chengb6d7fc32009-06-18 21:39:50 +0000600 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000601 } else {
602 my $CVSOPT = "";
603 $CVSOPT = "-z3" # Use compression if going over ssh.
604 if $CVSRootDir =~ /^:ext:/;
605 my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co -P $CVSCOOPT";
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000606 RunLoggedCommand("( time -p $CVSCMD llvm; cd llvm/projects ; " .
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000607 "$CVSCMD llvm-test )", $COLog,
608 "CHECKOUT LLVM-TEST");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000609 }
610}
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000611ChangeDir( $LLVMSrcDir , "llvm source directory") ;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000612
613##############################################################
614#
615# Get some static statistics about the current state of CVS
616#
617# This can probably be put on the server side
618#
619##############################################################
620my $CheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $COLog`;
621my $CheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $COLog`;
622my $CheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $COLog`;
623my $CheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
624
625my $NumFilesInCVS = 0;
626my $NumDirsInCVS = 0;
627if ($USESVN) {
628 $NumFilesInCVS = `egrep '^A' $COLog | wc -l` + 0;
Nick Lewyckye45e2c82008-06-05 12:54:44 +0000629 $NumDirsInCVS = `sed -e 's#/[^/]*\$##' $COLog | sort | uniq | wc -l` + 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000630} else {
631 $NumFilesInCVS = `egrep '^U' $COLog | wc -l` + 0;
632 $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $COLog | wc -l` + 0;
633}
634
635##############################################################
636#
637# Extract some information from the CVS history... use a hash so no duplicate
638# stuff is stored. This gets the history from the previous days worth
639# of cvs activity and parses it.
640#
641##############################################################
642
643# This just computes a reasonably accurate #of seconds since 2000. It doesn't
644# have to be perfect as its only used for comparing date ranges within a couple
645# of days.
646sub ConvertToSeconds {
647 my ($sec, $min, $hour, $day, $mon, $yr) = @_;
648 my $Result = ($yr - 2000) * 12;
649 $Result += $mon;
650 $Result *= 31;
651 $Result += $day;
652 $Result *= 24;
653 $Result += $hour;
654 $Result *= 60;
655 $Result += $min;
656 $Result *= 60;
657 $Result += $sec;
658 return $Result;
659}
660
661my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
662
663if (!$NOCVSSTATS) {
664 if ($VERBOSE) { print "CHANGE HISTORY ANALYSIS STAGE\n"; }
665
666 if ($USESVN) {
Duncan Sands01388f92009-06-12 13:02:52 +0000667 @SVNHistory = split /<logentry/, `svn log --non-interactive --xml --verbose -r{$DATE}:HEAD`;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000668 # Skip very first entry because it is the XML header cruft
669 shift @SVNHistory;
670 my $Now = time();
671 foreach $Record (@SVNHistory) {
672 my @Lines = split "\n", $Record;
673 my ($Author, $Date, $Revision);
674 # Get the date and see if its one we want to process.
675 my ($Year, $Month, $Day, $Hour, $Min, $Sec);
676 if ($Lines[3] =~ /<date>(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/){
677 $Year = $1; $Month = $2; $Day = $3; $Hour = $4; $Min = $5; $Sec = $6;
678 }
679 my $Then = ConvertToSeconds($Sec, $Min, $Hour, $Day, $Month, $Year);
680 # Get the current date and compute when "yesterday" is.
681 my ($NSec, $NMin, $NHour, $NDay, $NMon, $NYear) = gmtime();
682 my $Now = ConvertToSeconds( $NSec, $NMin, $NHour, $NDay, $NMon, $NYear);
683 if (($Now - 24*60*60) > $Then) {
684 next;
685 }
686 if ($Lines[1] =~ / revision="([0-9]*)">/) {
687 $Revision = $1;
688 }
689 if ($Lines[2] =~ /<author>([^<]*)<\/author>/) {
690 $Author = $1;
691 }
692 $UsersCommitted{$Author} = 1;
693 $Date = $Year . "-" . $Month . "-" . $Day;
694 $Time = $Hour . ":" . $Min . ":" . $Sec;
695 print "Rev: $Revision, Author: $Author, Date: $Date, Time: $Time\n";
696 for ($i = 6; $i < $#Lines; $i += 2 ) {
697 if ($Lines[$i] =~ /^ action="(.)">([^<]*)</) {
698 if ($1 == "A") {
699 $AddedFiles{$2} = 1;
700 } elsif ($1 == 'D') {
701 $RemovedFiles{$2} = 1;
702 } elsif ($1 == 'M' || $1 == 'R' || $1 == 'C') {
703 $ModifiedFiles{$2} = 1;
704 } else {
705 print "UNMATCHABLE: $Lines[$i]\n";
706 }
707 }
708 }
709 }
710 } else {
711 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
712#print join "\n", @CVSHistory; print "\n";
713
714 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
715
716# Loop over every record from the CVS history, filling in the hashes.
717 foreach $File (@CVSHistory) {
718 my ($Type, $Date, $UID, $Rev, $Filename);
719 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
720 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
721 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
722 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
723 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
724 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
725 } else {
726 print "UNMATCHABLE: $File\n";
727 next;
728 }
729 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000730
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000731 if ($Filename =~ /^llvm/) {
732 if ($Type eq 'M') { # Modified
733 $ModifiedFiles{$Filename} = 1;
734 $UsersCommitted{$UID} = 1;
735 } elsif ($Type eq 'A') { # Added
736 $AddedFiles{$Filename} = 1;
737 $UsersCommitted{$UID} = 1;
738 } elsif ($Type eq 'R') { # Removed
739 $RemovedFiles{$Filename} = 1;
740 $UsersCommitted{$UID} = 1;
741 } else {
742 $UsersUpdated{$UID} = 1;
743 }
744 }
745 }
746
747 my $TestError = 1;
748 } #$USESVN
749}#!NOCVSSTATS
750
751my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
752my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
753my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
754my $UserCommitList = join "\n", sort keys %UsersCommitted;
755my $UserUpdateList = join "\n", sort keys %UsersUpdated;
756
757##############################################################
758#
759# Build the entire tree, saving build messages to the build log
760#
761##############################################################
762if (!$NOCHECKOUT && !$NOBUILD) {
763 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000764 RunLoggedCommand("(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) ",
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000765 $BuildLog, "CONFIGURE");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000766 # Build the entire tree, capturing the output into $BuildLog
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000767 RunAppendingLoggedCommand("(time -p $NICE $MAKECMD clean)", $BuildLog, "BUILD CLEAN");
768 RunAppendingLoggedCommand("(time -p $NICE $MAKECMD $MAKEOPTS)", $BuildLog, "BUILD");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000769}
770
771##############################################################
772#
773# Get some statistics about the build...
774#
775##############################################################
776#this can de done on server
777#my @Linked = split '\n', `grep Linking $BuildLog`;
778#my $NumExecutables = scalar(grep(/executable/, @Linked));
779#my $NumLibraries = scalar(grep(!/executable/, @Linked));
780#my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
781
782# Get the number of lines of source code. Must be here after the build is done
783# because countloc.sh uses the llvm-config script which must be built.
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000784my $LOC = `utils/countloc.sh -topdir $LLVMSrcDir`;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000785
786# Get the time taken by the configure script
787my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
788my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
789my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
790my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
791
792$ConfigTime=-1 unless $ConfigTime;
793$ConfigWallTime=-1 unless $ConfigWallTime;
794
795my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
796my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
797my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
798my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
799
800$BuildTime=-1 unless $BuildTime;
801$BuildWallTime=-1 unless $BuildWallTime;
802
803my $BuildError = 0, $BuildStatus = "OK";
804if ($NOBUILD) {
805 $BuildStatus = "Skipped by user";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000806}
807elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
808 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
809 $BuildStatus = "Error: compilation aborted";
810 $BuildError = 1;
811 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
812}
813if ($BuildError) { $NODEJAGNU=1; }
814
815my $a_file_sizes="";
816my $o_file_sizes="";
817if (!$BuildError) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000818 print "Organizing size of .o and .a files\n"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000819 if ( $VERBOSE );
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000820 ChangeDir( "$LLVMObjDir", "Build Directory" );
Bob Wilson722d58b2009-06-19 17:19:38 +0000821
822 my @dirs = ('utils', 'lib', 'tools');
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000823 if($BUILDTYPE eq "release"){
Bob Wilson722d58b2009-06-19 17:19:38 +0000824 push @dirs, 'Release';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000825 } elsif($BUILDTYPE eq "release-asserts") {
Bob Wilson722d58b2009-06-19 17:19:38 +0000826 push @dirs, 'Release-Asserts';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000827 } else {
Bob Wilson722d58b2009-06-19 17:19:38 +0000828 push @dirs, 'Debug';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000829 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000830
Bob Wilson722d58b2009-06-19 17:19:38 +0000831 find(sub {
832 $a_file_sizes .= (-s $_)." $File::Find::name $BUILDTYPE\n" if /\.a$/i;
833 $o_file_sizes .= (-s $_)." $File::Find::name $BUILDTYPE\n" if /\.o$/i;
834 }, @dirs);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000835} else {
836 $a_file_sizes="No data due to a bad build.";
837 $o_file_sizes="No data due to a bad build.";
838}
839
840##############################################################
841#
842# Running dejagnu tests
843#
844##############################################################
845my $DejangnuTestResults=""; # String containing the results of the dejagnu
846my $dejagnu_output = "$DejagnuTestsLog";
847if (!$NODEJAGNU) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000848 #Run the feature and regression tests, results are put into testrun.sum
849 #Full log in testrun.log
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000850 RunLoggedCommand("(time -p $MAKECMD $MAKEOPTS check)", $dejagnu_output, "DEJAGNU");
Misha Brukmanafa1e862009-01-02 16:28:18 +0000851
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000852 #Copy the testrun.log and testrun.sum to our webdir
853 CopyFile("test/testrun.log", $DejagnuLog);
854 CopyFile("test/testrun.sum", $DejagnuSum);
855 #can be done on server
856 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
857 $unexpfail_tests = $DejagnuTestResults;
858}
859
860#Extract time of dejagnu tests
861my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
862my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
863$DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
Misha Brukmanafa1e862009-01-02 16:28:18 +0000864$DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
865$DejagnuTestResults =
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000866 "Dejagnu skipped by user choice." unless $DejagnuTestResults;
867$DejagnuTime = "0.0" unless $DejagnuTime;
868$DejagnuWallTime = "0.0" unless $DejagnuWallTime;
869
870##############################################################
871#
872# Get warnings from the build
873#
874##############################################################
875if (!$NODEJAGNU) {
876 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
877 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
878 my @Warnings;
879 my $CurDir = "";
880
881 foreach $Warning (@Warn) {
882 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
883 $CurDir = $1; # Keep track of directory warning is in...
884 # Remove buildir prefix if included
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000885 if ($CurDir =~ m#$LLVMSrcDir/(.*)#) { $CurDir = $1; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000886 } else {
887 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
888 }
889 }
890 my $WarningsFile = join "\n", @Warnings;
891 $WarningsFile =~ s/:[0-9]+:/::/g;
892
893 # Emit the warnings file, so we can diff...
894 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
895 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
896
897 # Output something to stdout if something has changed
898 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
899 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
900
901 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
902 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
903
904} #endif !NODEGAGNU
905
906##############################################################
907#
908# If we built the tree successfully, run the nightly programs tests...
909#
Misha Brukmanafa1e862009-01-02 16:28:18 +0000910# A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000911# "External")
912#
913##############################################################
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000914
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000915sub TestDirectory {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000916 my $SubDir = shift;
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000917 ChangeDir( "$LLVMTestDir/$SubDir",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000918 "Programs Test Subdirectory" ) || return ("", "");
Misha Brukmanafa1e862009-01-02 16:28:18 +0000919
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000920 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000921
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000922 # Run the programs tests... creating a report.nightly.csv file
923 if (!$NOTEST) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000924 if( $VERBOSE) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000925 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
Misha Brukmanafa1e862009-01-02 16:28:18 +0000926 "TEST=nightly > $ProgramTestLog 2>&1\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000927 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000928 RunLoggedCommand("$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000929 "TEST=nightly", $ProgramTestLog, "TEST DIRECTORY $SubDir");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000930 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
Misha Brukmanafa1e862009-01-02 16:28:18 +0000931 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000932
933 my $ProgramsTable;
934 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
935 $TestError = 1;
936 $ProgramsTable="Error running test $SubDir\n";
937 print "ERROR TESTING\n";
938 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
939 $TestError = 1;
940 $ProgramsTable="Makefile error running tests $SubDir!\n";
941 print "ERROR TESTING\n";
942 } else {
943 $TestError = 0;
944 #
945 # Create a list of the tests which were run...
946 #
947 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
948 "| sort > $Prefix-$SubDir-Tests.txt";
949 }
950 $ProgramsTable = ReadFile "report.nightly.csv";
951
952 ChangeDir( "../../..", "Programs Test Parent Directory" );
953 return ($ProgramsTable, $llcbeta_options);
954} #end sub TestDirectory
955
956##############################################################
957#
958# Calling sub TestDirectory
959#
960##############################################################
961if (!$BuildError) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000962 ($SingleSourceProgramsTable, $llcbeta_options) =
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000963 TestDirectory("SingleSource");
964 WriteFile "$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000965 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
966 WriteFile "$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
967 if ( ! $NOEXTERNALS ) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000968 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
969 WriteFile "$Prefix-External-Performance.txt", $ExternalProgramsTable;
Misha Brukmanafa1e862009-01-02 16:28:18 +0000970 system "cat $Prefix-SingleSource-Tests.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000971 "$Prefix-MultiSource-Tests.txt ".
972 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000973 system "cat $Prefix-SingleSource-Performance.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000974 "$Prefix-MultiSource-Performance.txt ".
975 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
976 } else {
977 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
978 if ( $VERBOSE ) {
979 print "External TEST STAGE SKIPPED\n";
980 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000981 system "cat $Prefix-SingleSource-Tests.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000982 "$Prefix-MultiSource-Tests.txt ".
983 " | sort > $Prefix-Tests.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000984 system "cat $Prefix-SingleSource-Performance.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000985 "$Prefix-MultiSource-Performance.txt ".
986 " | sort > $Prefix-Performance.txt";
987 }
988
989 ##############################################################
990 #
Misha Brukmanafa1e862009-01-02 16:28:18 +0000991 #
992 # gathering tests added removed broken information here
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000993 #
994 #
995 ##############################################################
996 my $dejagnu_test_list = ReadFile "$Prefix-Tests.txt";
997 my @DEJAGNU = split "\n", $dejagnu_test_list;
998 my ($passes, $fails, $xfails) = "";
999
1000 if(!$NODEJAGNU) {
1001 for ($x=0; $x<@DEJAGNU; $x++) {
1002 if ($DEJAGNU[$x] =~ m/^PASS:/) {
1003 $passes.="$DEJAGNU[$x]\n";
1004 }
1005 elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
1006 $fails.="$DEJAGNU[$x]\n";
1007 }
1008 elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
1009 $xfails.="$DEJAGNU[$x]\n";
1010 }
1011 }
1012 }
Misha Brukmanafa1e862009-01-02 16:28:18 +00001013
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001014} #end if !$BuildError
1015
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001016##############################################################
1017#
1018# Getting end timestamp
1019#
1020##############################################################
1021$endtime = `date "+20%y-%m-%d %H:%M:%S"`;
1022
1023
1024##############################################################
1025#
1026# Place all the logs neatly into one humungous file
1027#
1028##############################################################
1029if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
1030
Misha Brukmanafa1e862009-01-02 16:28:18 +00001031$machine_data = "uname: ".`uname -a`.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001032 "hardware: ".`uname -m`.
1033 "os: ".`uname -sr`.
1034 "name: ".`uname -n`.
1035 "date: ".`date \"+20%y-%m-%d\"`.
Misha Brukmanafa1e862009-01-02 16:28:18 +00001036 "time: ".`date +\"%H:%M:%S\"`;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001037
1038my @CVS_DATA;
1039my $cvs_data;
1040@CVS_DATA = ReadFile "$COLog";
1041$cvs_data = join("\n", @CVS_DATA);
1042
1043my @BUILD_DATA;
1044my $build_data;
1045@BUILD_DATA = ReadFile "$BuildLog";
1046$build_data = join("\n", @BUILD_DATA);
1047
1048my (@DEJAGNU_LOG, @DEJAGNU_SUM, @DEJAGNULOG_FULL, @GCC_VERSION);
1049my ($dejagnutests_log ,$dejagnutests_sum, $dejagnulog_full) = "";
1050my ($gcc_version, $gcc_version_long) = "";
1051
1052$gcc_version_long="";
1053if ($GCCPATH ne "") {
1054 $gcc_version_long = `$GCCPATH/gcc --version`;
1055} elsif ($ENV{"CC"}) {
1056 $gcc_version_long = `$ENV{"CC"} --version`;
1057} else {
1058 $gcc_version_long = `gcc --version`;
1059}
1060@GCC_VERSION = split '\n', $gcc_version_long;
1061$gcc_version = $GCC_VERSION[0];
1062
1063$llvmgcc_version_long="";
1064if ($LLVMGCCPATH ne "") {
1065 $llvmgcc_version_long = `$LLVMGCCPATH/llvm-gcc -v 2>&1`;
1066} else {
1067 $llvmgcc_version_long = `llvm-gcc -v 2>&1`;
1068}
1069@LLVMGCC_VERSION = split '\n', $llvmgcc_version_long;
1070$llvmgcc_versionTarget = $LLVMGCC_VERSION[1];
1071$llvmgcc_versionTarget =~ /Target: (.+)/;
1072$targetTriple = $1;
1073
1074if(!$BuildError){
1075 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
1076 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
1077 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
1078 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
1079
1080 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
1081 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
1082}
1083
1084##############################################################
1085#
1086# Send data via a post request
1087#
1088##############################################################
1089
1090if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
1091
1092my %hash_of_data = (
1093 'machine_data' => $machine_data,
1094 'build_data' => $build_data,
1095 'gcc_version' => $gcc_version,
1096 'nickname' => $nickname,
1097 'dejagnutime_wall' => $DejagnuWallTime,
1098 'dejagnutime_cpu' => $DejagnuTime,
1099 'cvscheckouttime_wall' => $CheckoutTime_Wall,
1100 'cvscheckouttime_cpu' => $CheckoutTime_CPU,
1101 'configtime_wall' => $ConfigWallTime,
1102 'configtime_cpu'=> $ConfigTime,
1103 'buildtime_wall' => $BuildWallTime,
1104 'buildtime_cpu' => $BuildTime,
1105 'warnings' => $WarningsFile,
1106 'cvsusercommitlist' => $UserCommitList,
1107 'cvsuserupdatelist' => $UserUpdateList,
1108 'cvsaddedfiles' => $CVSAddedFiles,
1109 'cvsmodifiedfiles' => $CVSModifiedFiles,
1110 'cvsremovedfiles' => $CVSRemovedFiles,
1111 'lines_of_code' => $LOC,
1112 'cvs_file_count' => $NumFilesInCVS,
1113 'cvs_dir_count' => $NumDirsInCVS,
1114 'buildstatus' => $BuildStatus,
1115 'singlesource_programstable' => $SingleSourceProgramsTable,
1116 'multisource_programstable' => $MultiSourceProgramsTable,
1117 'externalsource_programstable' => $ExternalProgramsTable,
1118 'llcbeta_options' => $multisource_llcbeta_options,
1119 'warnings_removed' => $WarningsRemoved,
1120 'warnings_added' => $WarningsAdded,
1121 'passing_tests' => $passes,
1122 'expfail_tests' => $xfails,
1123 'unexpfail_tests' => $fails,
1124 'all_tests' => $dejagnu_test_list,
1125 'new_tests' => "",
1126 'removed_tests' => "",
1127 'dejagnutests_results' => $DejagnuTestResults,
1128 'dejagnutests_log' => $dejagnulog_full,
1129 'starttime' => $starttime,
1130 'endtime' => $endtime,
1131 'o_file_sizes' => $o_file_sizes,
1132 'a_file_sizes' => $a_file_sizes,
1133 'target_triple' => $targetTriple
1134);
1135
Daniel Dunbar3b377ef2009-06-26 22:33:28 +00001136if ($SUBMIT || !($SUBMITAUX eq "")) {
Tanya Lattner084a3ee2008-03-10 07:28:08 +00001137 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
1138 if( $VERBOSE) { print "============================\n$response"; }
1139} else {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001140 print "============================\n";
1141 foreach $x(keys %hash_of_data){
1142 print "$x => $hash_of_data{$x}\n";
1143 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001144}
1145
1146##############################################################
1147#
1148# Remove the cvs tree...
1149#
1150##############################################################
Misha Brukmanafa1e862009-01-02 16:28:18 +00001151system ( "$NICE rm -rf $BuildDir")
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001152 if (!$NOCHECKOUT and !$NOREMOVE);
Misha Brukmanafa1e862009-01-02 16:28:18 +00001153system ( "$NICE rm -rf $WebDir")
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001154 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);