blob: b4906504936a68b3abc258213343df098b85843c [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;
Daniel Dunbar93ad6a82009-07-01 14:52:59 +0000125my $DATE = sprintf "%4d-%02d-%02d_%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3], $TIME[1], $TIME[0];
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000126
127##############################################################
128#
129# Parse arguments...
130#
131##############################################################
132$CONFIGUREARGS="";
133$nickname="";
134$NOTEST=0;
135$USESVN=1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000136$MAKECMD="make";
137$SUBMITSERVER = "llvm.org";
138$SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
Daniel Dunbar016a4bb2009-05-18 23:24:26 +0000139$SUBMITAUX="";
Tanya Lattner084a3ee2008-03-10 07:28:08 +0000140$SUBMIT = 1;
Daniel Dunbarf8cdaec2009-05-28 22:45:24 +0000141$PARALLELJOBS = "2";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000142
143while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
144 shift;
145 last if /^--$/; # Stop processing arguments on --
146
147 # List command line options here...
148 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
149 if (/^-nocvsstats$/) { $NOCVSSTATS = 1; next; }
150 if (/^-noremove$/) { $NOREMOVE = 1; next; }
151 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
Daniel Dunbar2041d9a2009-06-02 21:14:15 +0000152 if (/^-notest$/) { $NOTEST = 1; next; }
153 if (/^-norunningtests$/) { next; } # Backward compatibility, ignored.
Daniel Dunbarf8cdaec2009-05-28 22:45:24 +0000154 if (/^-parallel-jobs$/) { $PARALLELJOBS = "$ARGV[0]"; shift; next;}
155 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j$PARALLELJOBS -l3.0"; next; }
Duncan Sands01388f92009-06-12 13:02:52 +0000156 if (/^-with-clang$/) { $WITHCLANG = 1; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000157 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
158 "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
159 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
Dan Gohmanbd399762008-10-30 01:08:03 +0000160 "DISABLE_ASSERTIONS=1 ".
Misha Brukmanafa1e862009-01-02 16:28:18 +0000161 "OPTIMIZE_OPTION=-O2";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000162 $BUILDTYPE="release-asserts"; next;}
163 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
Duncan Sands01388f92009-06-12 13:02:52 +0000164 if (/^-disable-pic$/) { $CONFIGUREARGS .= " --enable-pic=no"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000165 if (/^-enable-lli$/) { $PROGTESTOPTS .= " ENABLE_LLI=1";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000166 $CONFIGUREARGS .= " --enable-lli"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000167 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000168 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000169 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
170 $CONFIGUREARGS .= " --disable-jit"; next; }
Daniel Dunbar31a1f1c2009-03-10 19:33:13 +0000171 if (/^-disable-bindings$/) { $CONFIGUREARGS .= " --disable-bindings"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000172 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
Evan Cheng32efae02008-01-12 04:27:18 +0000173 if (/^-disable-lto$/) { $PROGTESTOPTS .= " DISABLE_LTO=1"; next; }
Evan Cheng08206772008-01-14 17:58:03 +0000174 if (/^-test-opts$/) { $PROGTESTOPTS .= " $ARGV[0]"; shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000175 if (/^-verbose$/) { $VERBOSE = 1; next; }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000176 if (/^-teelogs$/) { $TEELOGS = 1; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000177 if (/^-debug$/) { $DEBUG = 1; next; }
178 if (/^-nice$/) { $NICE = "nice "; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000179 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000180 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000181 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000182 shift; next; }
183 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
184 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
Daniel Dunbar016a4bb2009-05-18 23:24:26 +0000185 if (/^-submit-aux/) { $SUBMITAUX = "$ARGV[0]"; shift; next; }
Tanya Lattner084a3ee2008-03-10 07:28:08 +0000186 if (/^-nosubmit$/) { $SUBMIT = 0; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000187 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
188 if (/^-gccpath/) { $CONFIGUREARGS .=
189 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000190 $GCCPATH=$ARGV[0]; shift; next; }
191 else { $GCCPATH=""; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000192 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000193 else { $CVSCOOPT="";}
194 if (/^-usecvs/) { $USESVN = 0; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000195 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000196 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000197 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000198 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000199 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000200 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000201 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000202 shift; next; }
203 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
204 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000205 if (/^-extraflags/) { $CONFIGUREARGS .=
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000206 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
207 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
208 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
209 if (/^-nobuild$/) { $NOBUILD = 1; next; }
210 print "Unknown option: $_ : ignoring!\n";
211}
212
213if ($ENV{'LLVMGCCDIR'}) {
214 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
Bob Wilsonc6d296b2009-03-12 19:47:24 +0000215 $LLVMGCCPATH = $ENV{'LLVMGCCDIR'} . '/bin';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000216}
217else {
218 $LLVMGCCPATH = "";
219}
220
221if ($CONFIGUREARGS !~ /--disable-jit/) {
222 $CONFIGUREARGS .= " --enable-jit";
223}
224
225if (@ARGV != 0 and @ARGV != 3 and $VERBOSE) {
226 foreach $x (@ARGV) {
227 print "$x\n";
228 }
229 print "Must specify 0 or 3 options!";
230}
231
232if (@ARGV == 3) {
233 $CVSRootDir = $ARGV[0];
234 $BuildDir = $ARGV[1];
235 $WebDir = $ARGV[2];
236}
237
238if ($CVSRootDir eq "" or
239 $BuildDir eq "" or
240 $WebDir eq "") {
241 die("please specify a cvs root directory, a build directory, and a ".
242 "web directory");
243 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000244
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000245if ($nickname eq "") {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000246 die ("Please invoke NewNightlyTest.pl with command line option " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000247 "\"-nickname <nickname>\"");
248}
249
250if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
251 $BUILDTYPE = "debug";
252}
253
254##############################################################
255#
256#define the file names we'll use
257#
258##############################################################
259my $Prefix = "$WebDir/$DATE";
260my $BuildLog = "$Prefix-Build-Log.txt";
261my $COLog = "$Prefix-CVS-Log.txt";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000262my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
263my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
264my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
265my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
266my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
267my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
268if (! -d $WebDir) {
269 mkdir $WebDir, 0777;
270 if($VERBOSE){
271 warn "$WebDir did not exist; creating it.\n";
272 }
273}
274
275if ($VERBOSE) {
276 print "INITIALIZED\n";
277 if ($USESVN) {
278 print "SVN URL = $SVNURL\n";
279 } else {
280 print "CVS Root = $CVSRootDir\n";
281 }
282 print "COLog = $COLog\n";
283 print "BuildDir = $BuildDir\n";
284 print "WebDir = $WebDir\n";
285 print "Prefix = $Prefix\n";
286 print "BuildLog = $BuildLog\n";
287}
288
289##############################################################
290#
291# Helper functions
292#
293##############################################################
294sub GetDir {
295 my $Suffix = shift;
296 opendir DH, $WebDir;
297 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
298 closedir DH;
299 return @Result;
300}
301
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000302sub RunLoggedCommand {
303 my $Command = shift;
304 my $Log = shift;
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000305 my $Title = shift;
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000306 if ($TEELOGS) {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000307 if ($VERBOSE) {
308 print "$Title\n";
309 print "$Command 2>&1 | tee $Log\n";
310 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000311 system "$Command 2>&1 | tee $Log";
312 } else {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000313 if ($VERBOSE) {
314 print "$Title\n";
315 print "$Command 2>&1 > $Log\n";
316 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000317 system "$Command 2>&1 > $Log";
318 }
319}
320
321sub RunAppendingLoggedCommand {
322 my $Command = shift;
323 my $Log = shift;
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000324 my $Title = shift;
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000325 if ($TEELOGS) {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000326 if ($VERBOSE) {
327 print "$Title\n";
328 print "$Command 2>&1 | tee -a $Log\n";
329 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000330 system "$Command 2>&1 | tee -a $Log";
331 } else {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000332 if ($VERBOSE) {
333 print "$Title\n";
334 print "$Command 2>&1 > $Log\n";
335 }
336 system "$Command 2>&1 >> $Log";
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000337 }
338}
339
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000340#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
341#
342# DiffFiles - Diff the current version of the file against the last version of
343# the file, reporting things added and removed. This is used to report, for
344# example, added and removed warnings. This returns a pair (added, removed)
345#
346#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
347sub DiffFiles {
348 my $Suffix = shift;
349 my @Others = GetDir $Suffix;
350 if (@Others == 0) { # No other files? We added all entries...
351 return (`cat $WebDir/$DATE$Suffix`, "");
352 }
353# Diff the files now...
354 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
355 my $Added = join "\n", grep /^</, @Diffs;
356 my $Removed = join "\n", grep /^>/, @Diffs;
357 $Added =~ s/^< //gm;
358 $Removed =~ s/^> //gm;
359 return ($Added, $Removed);
360}
361
362#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
363#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
364sub GetRegex { # (Regex with ()'s, value)
365 $_[1] =~ /$_[0]/m;
Misha Brukmanafa1e862009-01-02 16:28:18 +0000366 return $1
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000367 if (defined($1));
368 return "0";
369}
370
371#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
372#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
373sub GetRegexNum {
374 my ($Regex, $Num, $Regex2, $File) = @_;
375 my @Items = split "\n", `grep '$Regex' $File`;
376 return GetRegex $Regex2, $Items[$Num];
377}
378
379#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
380#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
381sub ChangeDir { # directory, logical name
382 my ($dir,$name) = @_;
383 chomp($dir);
384 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
385 $result = chdir($dir);
386 if (!$result) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000387 print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000388 return false;
389 }
390 return true;
391}
392
393#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
394#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
395sub ReadFile {
396 if (open (FILE, $_[0])) {
397 undef $/;
398 my $Ret = <FILE>;
399 close FILE;
400 $/ = '\n';
401 return $Ret;
402 } else {
403 print "Could not open file '$_[0]' for reading!\n";
404 return "";
405 }
406}
407
408#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
409#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
410sub WriteFile { # (filename, contents)
411 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
412 print FILE $_[1];
413 close FILE;
414}
415
416#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
417#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
418sub CopyFile { #filename, newfile
419 my ($file, $newfile) = @_;
420 chomp($file);
421 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
422 copy($file, $newfile);
423}
424
425#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
426#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
427sub AddRecord {
428 my ($Val, $Filename,$WebDir) = @_;
429 my @Records;
430 if (open FILE, "$WebDir/$Filename") {
431 @Records = grep !/$DATE/, split "\n", <FILE>;
432 close FILE;
433 }
434 push @Records, "$DATE: $Val";
435 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
436}
437
438#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
439#
440# FormatTime - Convert a time from 1m23.45 into 83.45
441#
442#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
443sub FormatTime {
444 my $Time = shift;
445 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
446 $Time = sprintf("%7.4f", $1*60.0+$2);
447 }
448 return $Time;
449}
450
451#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
452#
Misha Brukmanafa1e862009-01-02 16:28:18 +0000453# This function is meant to read in the dejagnu sum file and
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000454# return a string with only the results (i.e. PASS/FAIL/XPASS/
455# XFAIL).
456#
457#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
458sub GetDejagnuTestResults { # (filename, log)
459 my ($filename, $DejagnuLog) = @_;
460 my @lines;
461 $/ = "\n"; #Make sure we're going line at a time.
462
463 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
464
465 if (open SRCHFILE, $filename) {
466 # Process test results
467 while ( <SRCHFILE> ) {
468 if ( length($_) > 1 ) {
469 chomp($_);
470 if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\/test\/(.*)$/ ) {
471 push(@lines, "$1: test/$2");
472 }
473 }
474 }
475 }
476 close SRCHFILE;
477
478 my $content = join("\n", @lines);
479 return $content;
480}
481
482
483
484#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
485#
486# This function acts as a mini web browswer submitting data
487# to our central server via the post method
488#
489#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
490sub SendData{
491 $host = $_[0];
492 $file = $_[1];
493 $variables=$_[2];
494
Daniel Dunbara2533002009-05-28 18:31:40 +0000495 # Write out the "...-sentdata.txt" file.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000496
Daniel Dunbara2533002009-05-28 18:31:40 +0000497 my $sentdata="";
498 foreach $x (keys (%$variables)){
499 $value = $variables->{$x};
500 $sentdata.= "$x => $value\n";
501 }
502 WriteFile "$Prefix-sentdata.txt", $sentdata;
503
504 if (!($SUBMITAUX eq "")) {
Daniel Dunbar3b377ef2009-06-26 22:33:28 +0000505 system "$SUBMITAUX \"$Prefix-sentdata.txt\"";
506 }
507
508 if (!$SUBMIT) {
509 return "Skipped standard submit.\n";
Daniel Dunbara2533002009-05-28 18:31:40 +0000510 }
511
512 # Create the content to send to the server.
513
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000514 my $content;
515 foreach $key (keys (%$variables)){
516 $value = $variables->{$key};
517 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
518 $content .= "$key=$value&";
519 }
520
Daniel Dunbara2533002009-05-28 18:31:40 +0000521 # Send the data to the server.
522 #
523 # FIXME: This code should be more robust?
524
525 $port=80;
526 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
527 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
528 die "Bad socket\n";
529 connect SOCK, $socketaddr or die "Bad connection\n";
530 select((select(SOCK), $| = 1)[0]);
531
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000532 $length = length($content);
533
534 my $send= "POST $file HTTP/1.0\n";
535 $send.= "Host: $host\n";
536 $send.= "Content-Type: application/x-www-form-urlencoded\n";
537 $send.= "Content-length: $length\n\n";
538 $send.= "$content";
539
540 print SOCK $send;
541 my $result;
542 while(<SOCK>){
543 $result .= $_;
544 }
545 close(SOCK);
546
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000547 return $result;
548}
549
550##############################################################
551#
552# Getting Start timestamp
553#
554##############################################################
555$starttime = `date "+20%y-%m-%d %H:%M:%S"`;
556
557##############################################################
558#
559# Create the CVS repository directory
560#
561##############################################################
562if (!$NOCHECKOUT) {
563 if (-d $BuildDir) {
564 if (!$NOREMOVE) {
565 if ( $VERBOSE ) {
566 print "Build directory exists! Removing it\n";
567 }
568 system "rm -rf $BuildDir";
569 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
570 } else {
571 if ( $VERBOSE ) {
572 print "Build directory exists!\n";
573 }
574 }
575 } else {
576 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
577 }
578}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000579
580
581##############################################################
582#
Misha Brukmanafa1e862009-01-02 16:28:18 +0000583# Check out the llvm tree, using either SVN or CVS
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000584#
585##############################################################
586if (!$NOCHECKOUT) {
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000587 ChangeDir( $BuildDir, "checkout directory" );
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000588 if ($USESVN) {
Duncan Sands01388f92009-06-12 13:02:52 +0000589 my $SVNCMD = "$NICE svn co --non-interactive $SVNURL";
Evan Chengb6d7fc32009-06-18 21:39:50 +0000590 my $SVNCMD2 = "$NICE svn co --non-interactive $TestSVNURL";
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000591 RunLoggedCommand("( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000592 "$SVNCMD2/test-suite/trunk llvm-test )", $COLog,
593 "CHECKOUT LLVM");
Evan Chengb6d7fc32009-06-18 21:39:50 +0000594 if ($WITHCLANG) {
595 my $SVNCMD = "$NICE svn co --non-interactive $SVNURL/cfe/trunk";
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000596 RunLoggedCommand("( time -p cd llvm/tools ; $SVNCMD clang )", $COLog,
597 "CHECKOUT CLANG");
Evan Chengb6d7fc32009-06-18 21:39:50 +0000598 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000599 } else {
600 my $CVSOPT = "";
601 $CVSOPT = "-z3" # Use compression if going over ssh.
602 if $CVSRootDir =~ /^:ext:/;
603 my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co -P $CVSCOOPT";
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000604 RunLoggedCommand("( time -p $CVSCMD llvm; cd llvm/projects ; " .
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000605 "$CVSCMD llvm-test )", $COLog,
606 "CHECKOUT LLVM-TEST");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000607 }
608}
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000609ChangeDir( $LLVMSrcDir , "llvm source directory") ;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000610
611##############################################################
612#
613# Get some static statistics about the current state of CVS
614#
615# This can probably be put on the server side
616#
617##############################################################
618my $CheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $COLog`;
619my $CheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $COLog`;
620my $CheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $COLog`;
621my $CheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
622
623my $NumFilesInCVS = 0;
624my $NumDirsInCVS = 0;
625if ($USESVN) {
626 $NumFilesInCVS = `egrep '^A' $COLog | wc -l` + 0;
Nick Lewyckye45e2c82008-06-05 12:54:44 +0000627 $NumDirsInCVS = `sed -e 's#/[^/]*\$##' $COLog | sort | uniq | wc -l` + 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000628} else {
629 $NumFilesInCVS = `egrep '^U' $COLog | wc -l` + 0;
630 $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $COLog | wc -l` + 0;
631}
632
633##############################################################
634#
635# Extract some information from the CVS history... use a hash so no duplicate
636# stuff is stored. This gets the history from the previous days worth
637# of cvs activity and parses it.
638#
639##############################################################
640
641# This just computes a reasonably accurate #of seconds since 2000. It doesn't
642# have to be perfect as its only used for comparing date ranges within a couple
643# of days.
644sub ConvertToSeconds {
645 my ($sec, $min, $hour, $day, $mon, $yr) = @_;
646 my $Result = ($yr - 2000) * 12;
647 $Result += $mon;
648 $Result *= 31;
649 $Result += $day;
650 $Result *= 24;
651 $Result += $hour;
652 $Result *= 60;
653 $Result += $min;
654 $Result *= 60;
655 $Result += $sec;
656 return $Result;
657}
658
659my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
660
661if (!$NOCVSSTATS) {
662 if ($VERBOSE) { print "CHANGE HISTORY ANALYSIS STAGE\n"; }
663
664 if ($USESVN) {
Duncan Sands01388f92009-06-12 13:02:52 +0000665 @SVNHistory = split /<logentry/, `svn log --non-interactive --xml --verbose -r{$DATE}:HEAD`;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000666 # Skip very first entry because it is the XML header cruft
667 shift @SVNHistory;
668 my $Now = time();
669 foreach $Record (@SVNHistory) {
670 my @Lines = split "\n", $Record;
671 my ($Author, $Date, $Revision);
672 # Get the date and see if its one we want to process.
673 my ($Year, $Month, $Day, $Hour, $Min, $Sec);
674 if ($Lines[3] =~ /<date>(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/){
675 $Year = $1; $Month = $2; $Day = $3; $Hour = $4; $Min = $5; $Sec = $6;
676 }
677 my $Then = ConvertToSeconds($Sec, $Min, $Hour, $Day, $Month, $Year);
678 # Get the current date and compute when "yesterday" is.
679 my ($NSec, $NMin, $NHour, $NDay, $NMon, $NYear) = gmtime();
680 my $Now = ConvertToSeconds( $NSec, $NMin, $NHour, $NDay, $NMon, $NYear);
681 if (($Now - 24*60*60) > $Then) {
682 next;
683 }
684 if ($Lines[1] =~ / revision="([0-9]*)">/) {
685 $Revision = $1;
686 }
687 if ($Lines[2] =~ /<author>([^<]*)<\/author>/) {
688 $Author = $1;
689 }
690 $UsersCommitted{$Author} = 1;
691 $Date = $Year . "-" . $Month . "-" . $Day;
692 $Time = $Hour . ":" . $Min . ":" . $Sec;
693 print "Rev: $Revision, Author: $Author, Date: $Date, Time: $Time\n";
694 for ($i = 6; $i < $#Lines; $i += 2 ) {
695 if ($Lines[$i] =~ /^ action="(.)">([^<]*)</) {
696 if ($1 == "A") {
697 $AddedFiles{$2} = 1;
698 } elsif ($1 == 'D') {
699 $RemovedFiles{$2} = 1;
700 } elsif ($1 == 'M' || $1 == 'R' || $1 == 'C') {
701 $ModifiedFiles{$2} = 1;
702 } else {
703 print "UNMATCHABLE: $Lines[$i]\n";
704 }
705 }
706 }
707 }
708 } else {
709 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
710#print join "\n", @CVSHistory; print "\n";
711
712 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
713
714# Loop over every record from the CVS history, filling in the hashes.
715 foreach $File (@CVSHistory) {
716 my ($Type, $Date, $UID, $Rev, $Filename);
717 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
718 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
719 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
720 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
721 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
722 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
723 } else {
724 print "UNMATCHABLE: $File\n";
725 next;
726 }
727 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000728
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000729 if ($Filename =~ /^llvm/) {
730 if ($Type eq 'M') { # Modified
731 $ModifiedFiles{$Filename} = 1;
732 $UsersCommitted{$UID} = 1;
733 } elsif ($Type eq 'A') { # Added
734 $AddedFiles{$Filename} = 1;
735 $UsersCommitted{$UID} = 1;
736 } elsif ($Type eq 'R') { # Removed
737 $RemovedFiles{$Filename} = 1;
738 $UsersCommitted{$UID} = 1;
739 } else {
740 $UsersUpdated{$UID} = 1;
741 }
742 }
743 }
744
745 my $TestError = 1;
746 } #$USESVN
747}#!NOCVSSTATS
748
749my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
750my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
751my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
752my $UserCommitList = join "\n", sort keys %UsersCommitted;
753my $UserUpdateList = join "\n", sort keys %UsersUpdated;
754
755##############################################################
756#
757# Build the entire tree, saving build messages to the build log
758#
759##############################################################
760if (!$NOCHECKOUT && !$NOBUILD) {
761 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000762 RunLoggedCommand("(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) ",
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000763 $BuildLog, "CONFIGURE");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000764 # Build the entire tree, capturing the output into $BuildLog
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000765 RunAppendingLoggedCommand("(time -p $NICE $MAKECMD clean)", $BuildLog, "BUILD CLEAN");
766 RunAppendingLoggedCommand("(time -p $NICE $MAKECMD $MAKEOPTS)", $BuildLog, "BUILD");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000767}
768
769##############################################################
770#
771# Get some statistics about the build...
772#
773##############################################################
774#this can de done on server
775#my @Linked = split '\n', `grep Linking $BuildLog`;
776#my $NumExecutables = scalar(grep(/executable/, @Linked));
777#my $NumLibraries = scalar(grep(!/executable/, @Linked));
778#my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
779
780# Get the number of lines of source code. Must be here after the build is done
781# because countloc.sh uses the llvm-config script which must be built.
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000782my $LOC = `utils/countloc.sh -topdir $LLVMSrcDir`;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000783
784# Get the time taken by the configure script
785my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
786my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
787my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
788my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
789
790$ConfigTime=-1 unless $ConfigTime;
791$ConfigWallTime=-1 unless $ConfigWallTime;
792
793my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
794my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
795my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
796my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
797
798$BuildTime=-1 unless $BuildTime;
799$BuildWallTime=-1 unless $BuildWallTime;
800
801my $BuildError = 0, $BuildStatus = "OK";
802if ($NOBUILD) {
803 $BuildStatus = "Skipped by user";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000804}
805elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
806 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
807 $BuildStatus = "Error: compilation aborted";
808 $BuildError = 1;
809 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
810}
811if ($BuildError) { $NODEJAGNU=1; }
812
813my $a_file_sizes="";
814my $o_file_sizes="";
815if (!$BuildError) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000816 print "Organizing size of .o and .a files\n"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000817 if ( $VERBOSE );
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000818 ChangeDir( "$LLVMObjDir", "Build Directory" );
Bob Wilson722d58b2009-06-19 17:19:38 +0000819
820 my @dirs = ('utils', 'lib', 'tools');
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000821 if($BUILDTYPE eq "release"){
Bob Wilson722d58b2009-06-19 17:19:38 +0000822 push @dirs, 'Release';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000823 } elsif($BUILDTYPE eq "release-asserts") {
Bob Wilson722d58b2009-06-19 17:19:38 +0000824 push @dirs, 'Release-Asserts';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000825 } else {
Bob Wilson722d58b2009-06-19 17:19:38 +0000826 push @dirs, 'Debug';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000827 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000828
Bob Wilson722d58b2009-06-19 17:19:38 +0000829 find(sub {
830 $a_file_sizes .= (-s $_)." $File::Find::name $BUILDTYPE\n" if /\.a$/i;
831 $o_file_sizes .= (-s $_)." $File::Find::name $BUILDTYPE\n" if /\.o$/i;
832 }, @dirs);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000833} else {
834 $a_file_sizes="No data due to a bad build.";
835 $o_file_sizes="No data due to a bad build.";
836}
837
838##############################################################
839#
840# Running dejagnu tests
841#
842##############################################################
843my $DejangnuTestResults=""; # String containing the results of the dejagnu
844my $dejagnu_output = "$DejagnuTestsLog";
845if (!$NODEJAGNU) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000846 #Run the feature and regression tests, results are put into testrun.sum
847 #Full log in testrun.log
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000848 RunLoggedCommand("(time -p $MAKECMD $MAKEOPTS check)", $dejagnu_output, "DEJAGNU");
Misha Brukmanafa1e862009-01-02 16:28:18 +0000849
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000850 #Copy the testrun.log and testrun.sum to our webdir
851 CopyFile("test/testrun.log", $DejagnuLog);
852 CopyFile("test/testrun.sum", $DejagnuSum);
853 #can be done on server
854 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
855 $unexpfail_tests = $DejagnuTestResults;
856}
857
858#Extract time of dejagnu tests
859my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
860my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
861$DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
Misha Brukmanafa1e862009-01-02 16:28:18 +0000862$DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
863$DejagnuTestResults =
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000864 "Dejagnu skipped by user choice." unless $DejagnuTestResults;
865$DejagnuTime = "0.0" unless $DejagnuTime;
866$DejagnuWallTime = "0.0" unless $DejagnuWallTime;
867
868##############################################################
869#
870# Get warnings from the build
871#
872##############################################################
873if (!$NODEJAGNU) {
874 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
875 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
876 my @Warnings;
877 my $CurDir = "";
878
879 foreach $Warning (@Warn) {
880 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
881 $CurDir = $1; # Keep track of directory warning is in...
882 # Remove buildir prefix if included
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000883 if ($CurDir =~ m#$LLVMSrcDir/(.*)#) { $CurDir = $1; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000884 } else {
885 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
886 }
887 }
888 my $WarningsFile = join "\n", @Warnings;
889 $WarningsFile =~ s/:[0-9]+:/::/g;
890
891 # Emit the warnings file, so we can diff...
892 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
893 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
894
895 # Output something to stdout if something has changed
896 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
897 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
898
899 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
900 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
901
902} #endif !NODEGAGNU
903
904##############################################################
905#
906# If we built the tree successfully, run the nightly programs tests...
907#
Misha Brukmanafa1e862009-01-02 16:28:18 +0000908# A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000909# "External")
910#
911##############################################################
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000912
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000913sub TestDirectory {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000914 my $SubDir = shift;
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000915 ChangeDir( "$LLVMTestDir/$SubDir",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000916 "Programs Test Subdirectory" ) || return ("", "");
Misha Brukmanafa1e862009-01-02 16:28:18 +0000917
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000918 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000919
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000920 # Run the programs tests... creating a report.nightly.csv file
921 if (!$NOTEST) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000922 if( $VERBOSE) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000923 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
Misha Brukmanafa1e862009-01-02 16:28:18 +0000924 "TEST=nightly > $ProgramTestLog 2>&1\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000925 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000926 RunLoggedCommand("$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000927 "TEST=nightly", $ProgramTestLog, "TEST DIRECTORY $SubDir");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000928 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
Misha Brukmanafa1e862009-01-02 16:28:18 +0000929 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000930
931 my $ProgramsTable;
932 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
933 $TestError = 1;
934 $ProgramsTable="Error running test $SubDir\n";
935 print "ERROR TESTING\n";
936 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
937 $TestError = 1;
938 $ProgramsTable="Makefile error running tests $SubDir!\n";
939 print "ERROR TESTING\n";
940 } else {
941 $TestError = 0;
942 #
943 # Create a list of the tests which were run...
944 #
945 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
946 "| sort > $Prefix-$SubDir-Tests.txt";
947 }
948 $ProgramsTable = ReadFile "report.nightly.csv";
949
950 ChangeDir( "../../..", "Programs Test Parent Directory" );
951 return ($ProgramsTable, $llcbeta_options);
952} #end sub TestDirectory
953
954##############################################################
955#
956# Calling sub TestDirectory
957#
958##############################################################
959if (!$BuildError) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000960 ($SingleSourceProgramsTable, $llcbeta_options) =
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000961 TestDirectory("SingleSource");
962 WriteFile "$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000963 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
964 WriteFile "$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
965 if ( ! $NOEXTERNALS ) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000966 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
967 WriteFile "$Prefix-External-Performance.txt", $ExternalProgramsTable;
Misha Brukmanafa1e862009-01-02 16:28:18 +0000968 system "cat $Prefix-SingleSource-Tests.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000969 "$Prefix-MultiSource-Tests.txt ".
970 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000971 system "cat $Prefix-SingleSource-Performance.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000972 "$Prefix-MultiSource-Performance.txt ".
973 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
974 } else {
975 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
976 if ( $VERBOSE ) {
977 print "External TEST STAGE SKIPPED\n";
978 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000979 system "cat $Prefix-SingleSource-Tests.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000980 "$Prefix-MultiSource-Tests.txt ".
981 " | sort > $Prefix-Tests.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000982 system "cat $Prefix-SingleSource-Performance.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000983 "$Prefix-MultiSource-Performance.txt ".
984 " | sort > $Prefix-Performance.txt";
985 }
986
987 ##############################################################
988 #
Misha Brukmanafa1e862009-01-02 16:28:18 +0000989 #
990 # gathering tests added removed broken information here
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000991 #
992 #
993 ##############################################################
994 my $dejagnu_test_list = ReadFile "$Prefix-Tests.txt";
995 my @DEJAGNU = split "\n", $dejagnu_test_list;
996 my ($passes, $fails, $xfails) = "";
997
998 if(!$NODEJAGNU) {
999 for ($x=0; $x<@DEJAGNU; $x++) {
1000 if ($DEJAGNU[$x] =~ m/^PASS:/) {
1001 $passes.="$DEJAGNU[$x]\n";
1002 }
1003 elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
1004 $fails.="$DEJAGNU[$x]\n";
1005 }
1006 elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
1007 $xfails.="$DEJAGNU[$x]\n";
1008 }
1009 }
1010 }
Misha Brukmanafa1e862009-01-02 16:28:18 +00001011
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001012} #end if !$BuildError
1013
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001014##############################################################
1015#
1016# Getting end timestamp
1017#
1018##############################################################
1019$endtime = `date "+20%y-%m-%d %H:%M:%S"`;
1020
1021
1022##############################################################
1023#
1024# Place all the logs neatly into one humungous file
1025#
1026##############################################################
1027if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
1028
Misha Brukmanafa1e862009-01-02 16:28:18 +00001029$machine_data = "uname: ".`uname -a`.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001030 "hardware: ".`uname -m`.
1031 "os: ".`uname -sr`.
1032 "name: ".`uname -n`.
1033 "date: ".`date \"+20%y-%m-%d\"`.
Misha Brukmanafa1e862009-01-02 16:28:18 +00001034 "time: ".`date +\"%H:%M:%S\"`;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001035
1036my @CVS_DATA;
1037my $cvs_data;
1038@CVS_DATA = ReadFile "$COLog";
1039$cvs_data = join("\n", @CVS_DATA);
1040
1041my @BUILD_DATA;
1042my $build_data;
1043@BUILD_DATA = ReadFile "$BuildLog";
1044$build_data = join("\n", @BUILD_DATA);
1045
1046my (@DEJAGNU_LOG, @DEJAGNU_SUM, @DEJAGNULOG_FULL, @GCC_VERSION);
1047my ($dejagnutests_log ,$dejagnutests_sum, $dejagnulog_full) = "";
1048my ($gcc_version, $gcc_version_long) = "";
1049
1050$gcc_version_long="";
1051if ($GCCPATH ne "") {
1052 $gcc_version_long = `$GCCPATH/gcc --version`;
1053} elsif ($ENV{"CC"}) {
1054 $gcc_version_long = `$ENV{"CC"} --version`;
1055} else {
1056 $gcc_version_long = `gcc --version`;
1057}
1058@GCC_VERSION = split '\n', $gcc_version_long;
1059$gcc_version = $GCC_VERSION[0];
1060
1061$llvmgcc_version_long="";
1062if ($LLVMGCCPATH ne "") {
1063 $llvmgcc_version_long = `$LLVMGCCPATH/llvm-gcc -v 2>&1`;
1064} else {
1065 $llvmgcc_version_long = `llvm-gcc -v 2>&1`;
1066}
1067@LLVMGCC_VERSION = split '\n', $llvmgcc_version_long;
1068$llvmgcc_versionTarget = $LLVMGCC_VERSION[1];
1069$llvmgcc_versionTarget =~ /Target: (.+)/;
1070$targetTriple = $1;
1071
1072if(!$BuildError){
1073 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
1074 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
1075 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
1076 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
1077
1078 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
1079 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
1080}
1081
1082##############################################################
1083#
1084# Send data via a post request
1085#
1086##############################################################
1087
1088if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
1089
1090my %hash_of_data = (
1091 'machine_data' => $machine_data,
1092 'build_data' => $build_data,
1093 'gcc_version' => $gcc_version,
1094 'nickname' => $nickname,
1095 'dejagnutime_wall' => $DejagnuWallTime,
1096 'dejagnutime_cpu' => $DejagnuTime,
1097 'cvscheckouttime_wall' => $CheckoutTime_Wall,
1098 'cvscheckouttime_cpu' => $CheckoutTime_CPU,
1099 'configtime_wall' => $ConfigWallTime,
1100 'configtime_cpu'=> $ConfigTime,
1101 'buildtime_wall' => $BuildWallTime,
1102 'buildtime_cpu' => $BuildTime,
1103 'warnings' => $WarningsFile,
1104 'cvsusercommitlist' => $UserCommitList,
1105 'cvsuserupdatelist' => $UserUpdateList,
1106 'cvsaddedfiles' => $CVSAddedFiles,
1107 'cvsmodifiedfiles' => $CVSModifiedFiles,
1108 'cvsremovedfiles' => $CVSRemovedFiles,
1109 'lines_of_code' => $LOC,
1110 'cvs_file_count' => $NumFilesInCVS,
1111 'cvs_dir_count' => $NumDirsInCVS,
1112 'buildstatus' => $BuildStatus,
1113 'singlesource_programstable' => $SingleSourceProgramsTable,
1114 'multisource_programstable' => $MultiSourceProgramsTable,
1115 'externalsource_programstable' => $ExternalProgramsTable,
1116 'llcbeta_options' => $multisource_llcbeta_options,
1117 'warnings_removed' => $WarningsRemoved,
1118 'warnings_added' => $WarningsAdded,
1119 'passing_tests' => $passes,
1120 'expfail_tests' => $xfails,
1121 'unexpfail_tests' => $fails,
1122 'all_tests' => $dejagnu_test_list,
1123 'new_tests' => "",
1124 'removed_tests' => "",
1125 'dejagnutests_results' => $DejagnuTestResults,
1126 'dejagnutests_log' => $dejagnulog_full,
1127 'starttime' => $starttime,
1128 'endtime' => $endtime,
1129 'o_file_sizes' => $o_file_sizes,
1130 'a_file_sizes' => $a_file_sizes,
1131 'target_triple' => $targetTriple
1132);
1133
Daniel Dunbar3b377ef2009-06-26 22:33:28 +00001134if ($SUBMIT || !($SUBMITAUX eq "")) {
Tanya Lattner084a3ee2008-03-10 07:28:08 +00001135 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
1136 if( $VERBOSE) { print "============================\n$response"; }
1137} else {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001138 print "============================\n";
1139 foreach $x(keys %hash_of_data){
1140 print "$x => $hash_of_data{$x}\n";
1141 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001142}
1143
1144##############################################################
1145#
1146# Remove the cvs tree...
1147#
1148##############################################################
Misha Brukmanafa1e862009-01-02 16:28:18 +00001149system ( "$NICE rm -rf $BuildDir")
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001150 if (!$NOCHECKOUT and !$NOREMOVE);
Misha Brukmanafa1e862009-01-02 16:28:18 +00001151system ( "$NICE rm -rf $WebDir")
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001152 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);