blob: 7331069e32e048d58b30a564c9a04ee9bc082f55 [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:
Dan Gohmanf17a25c2007-07-18 16:29:46 +000018#
Daniel Dunbarae3faf12009-10-19 09:18:24 +000019# MAIN OPTIONS:
20# -config LLVMPATH If specified, use an existing LLVM build and only run and
21# report the test information. The LLVMCONFIG argument should
22# be the path to the llvm-config executable in the LLVM build.
23# This should be the first argument if given. NOT YET
24# IMPLEMENTED.
25# -nickname NAME The NAME argument specifieds the nickname this script
26# will submit to the nightlytest results repository.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000027# -submit-server Specifies a server to submit the test results too. If this
Misha Brukmanafa1e862009-01-02 16:28:18 +000028# option is not specified it defaults to
29# llvm.org. This is basically just the address of the
Dan Gohmanf17a25c2007-07-18 16:29:46 +000030# webserver
31# -submit-script Specifies which script to call on the submit server. If
32# this option is not specified it defaults to
Misha Brukmanafa1e862009-01-02 16:28:18 +000033# /nightlytest/NightlyTestAccept.php. This is basically
Dan Gohmanf17a25c2007-07-18 16:29:46 +000034# everything after the www.yourserver.org.
Daniel Dunbar016a4bb2009-05-18 23:24:26 +000035# -submit-aux If specified, an auxiliary script to run in addition to the
36# normal submit script. The script will be passed the path to
37# the "sentdata.txt" file as its sole argument.
Tanya Lattner084a3ee2008-03-10 07:28:08 +000038# -nosubmit Do not report the test results back to a submit server.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000039#
Daniel Dunbarae3faf12009-10-19 09:18:24 +000040#
41# BUILD OPTIONS (not used with -config):
42# -nocheckout Do not create, checkout, update, or configure
43# the source tree.
44# -noremove Do not remove the BUILDDIR after it has been built.
45# -noremoveresults Do not remove the WEBDIR after it has been built.
46# -nobuild Do not build llvm. If tests are enabled perform them
47# on the llvm build specified in the build directory
48# -release Build an LLVM Release version
49# -release-asserts Build an LLVM ReleaseAsserts version
50# -disable-bindings Disable building LLVM bindings.
51# -cvstag Check out a specific CVS tag to build LLVM (useful for
52# testing release branches)
53# -usecvs Check code out from the (old) CVS Repository instead of from
54# the standard Subversion repository.
55# -with-clang Checkout Clang source into tools/clang.
56# -compileflags Next argument specifies extra options passed to make when
57# building LLVM.
58# -use-gmake Use gmake instead of the default make command to build
59# llvm and run tests.
60#
61# TESTING OPTIONS:
62# -notest Do not even attempt to run the test programs.
63# -nodejagnu Do not run feature or regression tests
64# -enable-llcbeta Enable testing of beta features in llc.
65# -enable-lli Enable testing of lli (interpreter) features, default is off
66# -disable-pic Disable building with Position Independent Code.
67# -disable-llc Disable LLC tests in the nightly tester.
68# -disable-jit Disable JIT tests in the nightly tester.
69# -disable-cbe Disable C backend tests in the nightly tester.
70# -disable-lto Disable link time optimization.
71# -test-cflags Next argument specifies that C compilation options that
72# override the default when running the testsuite.
73# -test-cxxflags Next argument specifies that C++ compilation options that
74# override the default when running the testsuite.
75# -extraflags Next argument specifies extra options that are passed to
76# compile the tests.
77# -noexternals Do not run the external tests (for cases where povray
78# or SPEC are not installed)
79# -with-externals Specify a directory where the external tests are located.
80#
81# OTHER OPTIONS:
82# -parallel Run parallel jobs with GNU Make (see -parallel-jobs).
83# -parallel-jobs The number of parallel Make jobs to use (default is two).
84# -verbose Turn on some debug output
85# -debug Print information useful only to maintainers of this script.
86# -nice Checkout/Configure/Build with "nice" to reduce impact
87# on busy servers.
88# -f2c Next argument specifies path to F2C utility
89# -gccpath Path to gcc/g++ used to build LLVM
90# -target Specify the target triplet
91# -cflags Next argument specifies that C compilation options that
92# override the default.
93# -cxxflags Next argument specifies that C++ compilation options that
94# override the default.
95# -ldflags Next argument specifies that linker options that override
96# the default.
97#
Dan Gohmanf17a25c2007-07-18 16:29:46 +000098# CVSROOT is the CVS repository from which the tree will be checked out,
99# specified either in the full :method:user@host:/dir syntax, or
100# just /dir if using a local repo.
101# BUILDDIR is the directory where sources for this test run will be checked out
102# AND objects for this test run will be built. This directory MUST NOT
103# exist before the script is run; it will be created by the cvs checkout
104# process and erased (unless -noremove is specified; see above.)
105# WEBDIR is the directory into which the test results web page will be written,
106# AND in which the "index.html" is assumed to be a symlink to the most recent
107# copy of the results. This directory will be created if it does not exist.
108# LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
109# to. This is the same as you would have for a normal LLVM build.
110#
111##############################################################
112#
113# Getting environment variables
114#
115##############################################################
116my $HOME = $ENV{'HOME'};
117my $SVNURL = $ENV{"SVNURL"};
Duncan Sands01388f92009-06-12 13:02:52 +0000118$SVNURL = 'http://llvm.org/svn/llvm-project' unless $SVNURL;
Evan Chengb6d7fc32009-06-18 21:39:50 +0000119my $TestSVNURL = $ENV{"TestSVNURL"};
Evan Chenge45329e2009-07-14 06:23:41 +0000120$TestSVNURL = 'http://llvm.org/svn/llvm-project' unless $TestSVNURL;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000121my $CVSRootDir = $ENV{'CVSROOT'};
122$CVSRootDir = "/home/vadve/shared/PublicCVS" unless $CVSRootDir;
123my $BuildDir = $ENV{'BUILDDIR'};
124$BuildDir = "$HOME/buildtest" unless $BuildDir;
125my $WebDir = $ENV{'WEBDIR'};
126$WebDir = "$HOME/cvs/testresults-X86" unless $WebDir;
127
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000128my $LLVMSrcDir = $ENV{'LLVMSRCDIR'};
129$LLVMSrcDir = "$BuildDir/llvm" unless $LLVMSrcDir;
130my $LLVMObjDir = $ENV{'LLVMOBJDIR'};
131$LLVMObjDir = "$BuildDir/llvm" unless $LLVMObjDir;
132my $LLVMTestDir = $ENV{'LLVMTESTDIR'};
133$LLVMTestDir = "$BuildDir/llvm/projects/llvm-test" unless $LLVMTestDir;
134
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000135##############################################################
136#
137# Calculate the date prefix...
138#
139##############################################################
140@TIME = localtime;
Daniel Dunbar93ad6a82009-07-01 14:52:59 +0000141my $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 +0000142
143##############################################################
144#
145# Parse arguments...
146#
147##############################################################
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000148$CONFIG_PATH="";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000149$CONFIGUREARGS="";
150$nickname="";
151$NOTEST=0;
152$USESVN=1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000153$MAKECMD="make";
154$SUBMITSERVER = "llvm.org";
155$SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
Daniel Dunbar016a4bb2009-05-18 23:24:26 +0000156$SUBMITAUX="";
Tanya Lattner084a3ee2008-03-10 07:28:08 +0000157$SUBMIT = 1;
Daniel Dunbarf8cdaec2009-05-28 22:45:24 +0000158$PARALLELJOBS = "2";
Bill Wendling085ff3f2009-07-16 22:59:17 +0000159my $TESTFLAGS="";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000160
161while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
162 shift;
163 last if /^--$/; # Stop processing arguments on --
164
165 # List command line options here...
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000166 if (/^-config$/) { $CONFIG_PATH = "$ARGV[0]"; shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000167 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
168 if (/^-nocvsstats$/) { $NOCVSSTATS = 1; next; }
169 if (/^-noremove$/) { $NOREMOVE = 1; next; }
Daniel Dunbard3ecefe2009-07-13 22:17:49 +0000170 if (/^-noremoveatend$/) { $NOREMOVEATEND = 1; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000171 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
Daniel Dunbar2041d9a2009-06-02 21:14:15 +0000172 if (/^-notest$/) { $NOTEST = 1; next; }
173 if (/^-norunningtests$/) { next; } # Backward compatibility, ignored.
Daniel Dunbarf8cdaec2009-05-28 22:45:24 +0000174 if (/^-parallel-jobs$/) { $PARALLELJOBS = "$ARGV[0]"; shift; next;}
175 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j$PARALLELJOBS -l3.0"; next; }
Duncan Sands01388f92009-06-12 13:02:52 +0000176 if (/^-with-clang$/) { $WITHCLANG = 1; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000177 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
178 "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
179 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
Dan Gohmanbd399762008-10-30 01:08:03 +0000180 "DISABLE_ASSERTIONS=1 ".
Misha Brukmanafa1e862009-01-02 16:28:18 +0000181 "OPTIMIZE_OPTION=-O2";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000182 $BUILDTYPE="release-asserts"; next;}
183 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
Duncan Sands01388f92009-06-12 13:02:52 +0000184 if (/^-disable-pic$/) { $CONFIGUREARGS .= " --enable-pic=no"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000185 if (/^-enable-lli$/) { $PROGTESTOPTS .= " ENABLE_LLI=1";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000186 $CONFIGUREARGS .= " --enable-lli"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000187 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000188 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000189 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
190 $CONFIGUREARGS .= " --disable-jit"; next; }
Daniel Dunbar31a1f1c2009-03-10 19:33:13 +0000191 if (/^-disable-bindings$/) { $CONFIGUREARGS .= " --disable-bindings"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000192 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
Evan Cheng32efae02008-01-12 04:27:18 +0000193 if (/^-disable-lto$/) { $PROGTESTOPTS .= " DISABLE_LTO=1"; next; }
Evan Cheng08206772008-01-14 17:58:03 +0000194 if (/^-test-opts$/) { $PROGTESTOPTS .= " $ARGV[0]"; shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000195 if (/^-verbose$/) { $VERBOSE = 1; next; }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000196 if (/^-teelogs$/) { $TEELOGS = 1; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000197 if (/^-debug$/) { $DEBUG = 1; next; }
198 if (/^-nice$/) { $NICE = "nice "; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000199 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000200 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000201 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000202 shift; next; }
Daniel Dunbardd9c4aa2009-07-13 22:31:58 +0000203 if (/^-configure-args$/) { $CONFIGUREARGS .= " $ARGV[0]";
204 shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000205 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
206 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
Daniel Dunbar016a4bb2009-05-18 23:24:26 +0000207 if (/^-submit-aux/) { $SUBMITAUX = "$ARGV[0]"; shift; next; }
Tanya Lattner084a3ee2008-03-10 07:28:08 +0000208 if (/^-nosubmit$/) { $SUBMIT = 0; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000209 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
210 if (/^-gccpath/) { $CONFIGUREARGS .=
211 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000212 $GCCPATH=$ARGV[0]; shift; next; }
213 else { $GCCPATH=""; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000214 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000215 else { $CVSCOOPT="";}
216 if (/^-usecvs/) { $USESVN = 0; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000217 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000218 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000219 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000220 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000221 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000222 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000223 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000224 shift; next; }
Bill Wendling085ff3f2009-07-16 22:59:17 +0000225 if (/^-test-cflags/) { $TESTFLAGS = "$TESTFLAGS CFLAGS=\'$ARGV[0]\'";
226 shift; next; }
227 if (/^-test-cxxflags/) { $TESTFLAGS = "$TESTFLAGS CXXFLAGS=\'$ARGV[0]\'";
228 shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000229 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
230 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000231 if (/^-extraflags/) { $CONFIGUREARGS .=
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000232 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
233 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
234 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
235 if (/^-nobuild$/) { $NOBUILD = 1; next; }
236 print "Unknown option: $_ : ignoring!\n";
237}
238
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000239if (!($CONFIG_PATH eq "")) {
240 die "error: -config mode is not yet implemented,";
241}
242
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000243if ($ENV{'LLVMGCCDIR'}) {
244 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
Bob Wilsonc6d296b2009-03-12 19:47:24 +0000245 $LLVMGCCPATH = $ENV{'LLVMGCCDIR'} . '/bin';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000246}
247else {
248 $LLVMGCCPATH = "";
249}
250
251if ($CONFIGUREARGS !~ /--disable-jit/) {
252 $CONFIGUREARGS .= " --enable-jit";
253}
254
255if (@ARGV != 0 and @ARGV != 3 and $VERBOSE) {
256 foreach $x (@ARGV) {
257 print "$x\n";
258 }
259 print "Must specify 0 or 3 options!";
260}
261
262if (@ARGV == 3) {
263 $CVSRootDir = $ARGV[0];
264 $BuildDir = $ARGV[1];
265 $WebDir = $ARGV[2];
266}
267
268if ($CVSRootDir eq "" or
269 $BuildDir eq "" or
270 $WebDir eq "") {
271 die("please specify a cvs root directory, a build directory, and a ".
272 "web directory");
273 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000274
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000275if ($nickname eq "") {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000276 die ("Please invoke NewNightlyTest.pl with command line option " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000277 "\"-nickname <nickname>\"");
278}
279
280if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
281 $BUILDTYPE = "debug";
282}
283
284##############################################################
285#
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000286# Define the file names we'll use
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000287#
288##############################################################
289my $Prefix = "$WebDir/$DATE";
290my $BuildLog = "$Prefix-Build-Log.txt";
291my $COLog = "$Prefix-CVS-Log.txt";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000292my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
293my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
294my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
295my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
296my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
297my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
298if (! -d $WebDir) {
299 mkdir $WebDir, 0777;
300 if($VERBOSE){
301 warn "$WebDir did not exist; creating it.\n";
302 }
303}
304
305if ($VERBOSE) {
306 print "INITIALIZED\n";
307 if ($USESVN) {
308 print "SVN URL = $SVNURL\n";
309 } else {
310 print "CVS Root = $CVSRootDir\n";
311 }
312 print "COLog = $COLog\n";
313 print "BuildDir = $BuildDir\n";
314 print "WebDir = $WebDir\n";
315 print "Prefix = $Prefix\n";
316 print "BuildLog = $BuildLog\n";
317}
318
319##############################################################
320#
321# Helper functions
322#
323##############################################################
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000324
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000325sub GetDir {
326 my $Suffix = shift;
327 opendir DH, $WebDir;
328 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
329 closedir DH;
330 return @Result;
331}
332
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000333sub RunLoggedCommand {
334 my $Command = shift;
335 my $Log = shift;
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000336 my $Title = shift;
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000337 if ($TEELOGS) {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000338 if ($VERBOSE) {
339 print "$Title\n";
340 print "$Command 2>&1 | tee $Log\n";
341 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000342 system "$Command 2>&1 | tee $Log";
343 } else {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000344 if ($VERBOSE) {
345 print "$Title\n";
346 print "$Command 2>&1 > $Log\n";
347 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000348 system "$Command 2>&1 > $Log";
349 }
350}
351
352sub RunAppendingLoggedCommand {
353 my $Command = shift;
354 my $Log = shift;
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000355 my $Title = shift;
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000356 if ($TEELOGS) {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000357 if ($VERBOSE) {
358 print "$Title\n";
359 print "$Command 2>&1 | tee -a $Log\n";
360 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000361 system "$Command 2>&1 | tee -a $Log";
362 } else {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000363 if ($VERBOSE) {
364 print "$Title\n";
365 print "$Command 2>&1 > $Log\n";
366 }
367 system "$Command 2>&1 >> $Log";
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000368 }
369}
370
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000371#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
372#
373# DiffFiles - Diff the current version of the file against the last version of
374# the file, reporting things added and removed. This is used to report, for
375# example, added and removed warnings. This returns a pair (added, removed)
376#
377#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
378sub DiffFiles {
379 my $Suffix = shift;
380 my @Others = GetDir $Suffix;
381 if (@Others == 0) { # No other files? We added all entries...
382 return (`cat $WebDir/$DATE$Suffix`, "");
383 }
384# Diff the files now...
385 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
386 my $Added = join "\n", grep /^</, @Diffs;
387 my $Removed = join "\n", grep /^>/, @Diffs;
388 $Added =~ s/^< //gm;
389 $Removed =~ s/^> //gm;
390 return ($Added, $Removed);
391}
392
393#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
394#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
395sub GetRegex { # (Regex with ()'s, value)
396 $_[1] =~ /$_[0]/m;
Misha Brukmanafa1e862009-01-02 16:28:18 +0000397 return $1
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000398 if (defined($1));
399 return "0";
400}
401
402#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
403#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
404sub GetRegexNum {
405 my ($Regex, $Num, $Regex2, $File) = @_;
406 my @Items = split "\n", `grep '$Regex' $File`;
407 return GetRegex $Regex2, $Items[$Num];
408}
409
410#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
411#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
412sub ChangeDir { # directory, logical name
413 my ($dir,$name) = @_;
414 chomp($dir);
415 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
416 $result = chdir($dir);
417 if (!$result) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000418 print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000419 return false;
420 }
421 return true;
422}
423
424#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
425#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
426sub ReadFile {
427 if (open (FILE, $_[0])) {
428 undef $/;
429 my $Ret = <FILE>;
430 close FILE;
431 $/ = '\n';
432 return $Ret;
433 } else {
434 print "Could not open file '$_[0]' for reading!\n";
435 return "";
436 }
437}
438
439#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
440#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
441sub WriteFile { # (filename, contents)
442 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
443 print FILE $_[1];
444 close FILE;
445}
446
447#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
448#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
449sub CopyFile { #filename, newfile
450 my ($file, $newfile) = @_;
451 chomp($file);
452 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
453 copy($file, $newfile);
454}
455
456#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
457#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
458sub AddRecord {
459 my ($Val, $Filename,$WebDir) = @_;
460 my @Records;
461 if (open FILE, "$WebDir/$Filename") {
462 @Records = grep !/$DATE/, split "\n", <FILE>;
463 close FILE;
464 }
465 push @Records, "$DATE: $Val";
466 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
467}
468
469#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
470#
471# FormatTime - Convert a time from 1m23.45 into 83.45
472#
473#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
474sub FormatTime {
475 my $Time = shift;
476 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
477 $Time = sprintf("%7.4f", $1*60.0+$2);
478 }
479 return $Time;
480}
481
482#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
483#
Misha Brukmanafa1e862009-01-02 16:28:18 +0000484# This function is meant to read in the dejagnu sum file and
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000485# return a string with only the results (i.e. PASS/FAIL/XPASS/
486# XFAIL).
487#
488#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
489sub GetDejagnuTestResults { # (filename, log)
490 my ($filename, $DejagnuLog) = @_;
491 my @lines;
492 $/ = "\n"; #Make sure we're going line at a time.
493
494 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
495
496 if (open SRCHFILE, $filename) {
497 # Process test results
498 while ( <SRCHFILE> ) {
499 if ( length($_) > 1 ) {
500 chomp($_);
501 if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\/test\/(.*)$/ ) {
502 push(@lines, "$1: test/$2");
503 }
504 }
505 }
506 }
507 close SRCHFILE;
508
509 my $content = join("\n", @lines);
510 return $content;
511}
512
513
514
515#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
516#
517# This function acts as a mini web browswer submitting data
518# to our central server via the post method
519#
520#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000521sub SendData {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000522 $host = $_[0];
523 $file = $_[1];
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000524 $variables = $_[2];
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000525
Daniel Dunbara2533002009-05-28 18:31:40 +0000526 # Write out the "...-sentdata.txt" file.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000527
Daniel Dunbara2533002009-05-28 18:31:40 +0000528 my $sentdata="";
529 foreach $x (keys (%$variables)){
530 $value = $variables->{$x};
531 $sentdata.= "$x => $value\n";
532 }
533 WriteFile "$Prefix-sentdata.txt", $sentdata;
534
535 if (!($SUBMITAUX eq "")) {
Daniel Dunbar3b377ef2009-06-26 22:33:28 +0000536 system "$SUBMITAUX \"$Prefix-sentdata.txt\"";
537 }
538
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000539 if (!$SUBMIT) {
Daniel Dunbar3b377ef2009-06-26 22:33:28 +0000540 return "Skipped standard submit.\n";
Daniel Dunbara2533002009-05-28 18:31:40 +0000541 }
542
543 # Create the content to send to the server.
544
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000545 my $content;
546 foreach $key (keys (%$variables)){
547 $value = $variables->{$key};
548 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
549 $content .= "$key=$value&";
550 }
551
Daniel Dunbara2533002009-05-28 18:31:40 +0000552 # Send the data to the server.
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000553 #
Daniel Dunbara2533002009-05-28 18:31:40 +0000554 # FIXME: This code should be more robust?
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000555
Daniel Dunbara2533002009-05-28 18:31:40 +0000556 $port=80;
557 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
558 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
559 die "Bad socket\n";
560 connect SOCK, $socketaddr or die "Bad connection\n";
561 select((select(SOCK), $| = 1)[0]);
562
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000563 $length = length($content);
564
565 my $send= "POST $file HTTP/1.0\n";
566 $send.= "Host: $host\n";
567 $send.= "Content-Type: application/x-www-form-urlencoded\n";
568 $send.= "Content-length: $length\n\n";
569 $send.= "$content";
570
571 print SOCK $send;
572 my $result;
573 while(<SOCK>){
574 $result .= $_;
575 }
576 close(SOCK);
577
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000578 return $result;
579}
580
581##############################################################
582#
583# Getting Start timestamp
584#
585##############################################################
586$starttime = `date "+20%y-%m-%d %H:%M:%S"`;
587
588##############################################################
589#
590# Create the CVS repository directory
591#
592##############################################################
593if (!$NOCHECKOUT) {
594 if (-d $BuildDir) {
595 if (!$NOREMOVE) {
596 if ( $VERBOSE ) {
597 print "Build directory exists! Removing it\n";
598 }
599 system "rm -rf $BuildDir";
600 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
601 } else {
602 if ( $VERBOSE ) {
603 print "Build directory exists!\n";
604 }
605 }
606 } else {
607 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
608 }
609}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000610
611
612##############################################################
613#
Misha Brukmanafa1e862009-01-02 16:28:18 +0000614# Check out the llvm tree, using either SVN or CVS
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000615#
616##############################################################
617if (!$NOCHECKOUT) {
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000618 ChangeDir( $BuildDir, "checkout directory" );
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000619 if ($USESVN) {
Duncan Sands01388f92009-06-12 13:02:52 +0000620 my $SVNCMD = "$NICE svn co --non-interactive $SVNURL";
Evan Chengb6d7fc32009-06-18 21:39:50 +0000621 my $SVNCMD2 = "$NICE svn co --non-interactive $TestSVNURL";
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000622 RunLoggedCommand("( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000623 "$SVNCMD2/test-suite/trunk llvm-test )", $COLog,
624 "CHECKOUT LLVM");
Evan Chengb6d7fc32009-06-18 21:39:50 +0000625 if ($WITHCLANG) {
626 my $SVNCMD = "$NICE svn co --non-interactive $SVNURL/cfe/trunk";
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000627 RunLoggedCommand("( time -p cd llvm/tools ; $SVNCMD clang )", $COLog,
628 "CHECKOUT CLANG");
Evan Chengb6d7fc32009-06-18 21:39:50 +0000629 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000630 } else {
631 my $CVSOPT = "";
632 $CVSOPT = "-z3" # Use compression if going over ssh.
633 if $CVSRootDir =~ /^:ext:/;
634 my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co -P $CVSCOOPT";
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000635 RunLoggedCommand("( time -p $CVSCMD llvm; cd llvm/projects ; " .
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000636 "$CVSCMD llvm-test )", $COLog,
637 "CHECKOUT LLVM-TEST");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000638 }
639}
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000640ChangeDir( $LLVMSrcDir , "llvm source directory") ;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000641
642##############################################################
643#
644# Get some static statistics about the current state of CVS
645#
646# This can probably be put on the server side
647#
648##############################################################
649my $CheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $COLog`;
650my $CheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $COLog`;
651my $CheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $COLog`;
652my $CheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
653
654my $NumFilesInCVS = 0;
655my $NumDirsInCVS = 0;
656if ($USESVN) {
657 $NumFilesInCVS = `egrep '^A' $COLog | wc -l` + 0;
Nick Lewyckye45e2c82008-06-05 12:54:44 +0000658 $NumDirsInCVS = `sed -e 's#/[^/]*\$##' $COLog | sort | uniq | wc -l` + 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000659} else {
660 $NumFilesInCVS = `egrep '^U' $COLog | wc -l` + 0;
661 $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $COLog | wc -l` + 0;
662}
663
664##############################################################
665#
666# Extract some information from the CVS history... use a hash so no duplicate
667# stuff is stored. This gets the history from the previous days worth
668# of cvs activity and parses it.
669#
670##############################################################
671
672# This just computes a reasonably accurate #of seconds since 2000. It doesn't
673# have to be perfect as its only used for comparing date ranges within a couple
674# of days.
675sub ConvertToSeconds {
676 my ($sec, $min, $hour, $day, $mon, $yr) = @_;
677 my $Result = ($yr - 2000) * 12;
678 $Result += $mon;
679 $Result *= 31;
680 $Result += $day;
681 $Result *= 24;
682 $Result += $hour;
683 $Result *= 60;
684 $Result += $min;
685 $Result *= 60;
686 $Result += $sec;
687 return $Result;
688}
689
690my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
691
692if (!$NOCVSSTATS) {
693 if ($VERBOSE) { print "CHANGE HISTORY ANALYSIS STAGE\n"; }
694
695 if ($USESVN) {
Duncan Sands01388f92009-06-12 13:02:52 +0000696 @SVNHistory = split /<logentry/, `svn log --non-interactive --xml --verbose -r{$DATE}:HEAD`;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000697 # Skip very first entry because it is the XML header cruft
698 shift @SVNHistory;
699 my $Now = time();
700 foreach $Record (@SVNHistory) {
701 my @Lines = split "\n", $Record;
702 my ($Author, $Date, $Revision);
703 # Get the date and see if its one we want to process.
704 my ($Year, $Month, $Day, $Hour, $Min, $Sec);
705 if ($Lines[3] =~ /<date>(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/){
706 $Year = $1; $Month = $2; $Day = $3; $Hour = $4; $Min = $5; $Sec = $6;
707 }
708 my $Then = ConvertToSeconds($Sec, $Min, $Hour, $Day, $Month, $Year);
709 # Get the current date and compute when "yesterday" is.
710 my ($NSec, $NMin, $NHour, $NDay, $NMon, $NYear) = gmtime();
711 my $Now = ConvertToSeconds( $NSec, $NMin, $NHour, $NDay, $NMon, $NYear);
712 if (($Now - 24*60*60) > $Then) {
713 next;
714 }
715 if ($Lines[1] =~ / revision="([0-9]*)">/) {
716 $Revision = $1;
717 }
718 if ($Lines[2] =~ /<author>([^<]*)<\/author>/) {
719 $Author = $1;
720 }
721 $UsersCommitted{$Author} = 1;
722 $Date = $Year . "-" . $Month . "-" . $Day;
723 $Time = $Hour . ":" . $Min . ":" . $Sec;
724 print "Rev: $Revision, Author: $Author, Date: $Date, Time: $Time\n";
725 for ($i = 6; $i < $#Lines; $i += 2 ) {
726 if ($Lines[$i] =~ /^ action="(.)">([^<]*)</) {
727 if ($1 == "A") {
728 $AddedFiles{$2} = 1;
729 } elsif ($1 == 'D') {
730 $RemovedFiles{$2} = 1;
731 } elsif ($1 == 'M' || $1 == 'R' || $1 == 'C') {
732 $ModifiedFiles{$2} = 1;
733 } else {
734 print "UNMATCHABLE: $Lines[$i]\n";
735 }
736 }
737 }
738 }
739 } else {
740 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
741#print join "\n", @CVSHistory; print "\n";
742
743 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
744
745# Loop over every record from the CVS history, filling in the hashes.
746 foreach $File (@CVSHistory) {
747 my ($Type, $Date, $UID, $Rev, $Filename);
748 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
749 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
750 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
751 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
752 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
753 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
754 } else {
755 print "UNMATCHABLE: $File\n";
756 next;
757 }
758 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000759
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000760 if ($Filename =~ /^llvm/) {
761 if ($Type eq 'M') { # Modified
762 $ModifiedFiles{$Filename} = 1;
763 $UsersCommitted{$UID} = 1;
764 } elsif ($Type eq 'A') { # Added
765 $AddedFiles{$Filename} = 1;
766 $UsersCommitted{$UID} = 1;
767 } elsif ($Type eq 'R') { # Removed
768 $RemovedFiles{$Filename} = 1;
769 $UsersCommitted{$UID} = 1;
770 } else {
771 $UsersUpdated{$UID} = 1;
772 }
773 }
774 }
775
776 my $TestError = 1;
777 } #$USESVN
778}#!NOCVSSTATS
779
780my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
781my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
782my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
783my $UserCommitList = join "\n", sort keys %UsersCommitted;
784my $UserUpdateList = join "\n", sort keys %UsersUpdated;
785
786##############################################################
787#
788# Build the entire tree, saving build messages to the build log
789#
790##############################################################
791if (!$NOCHECKOUT && !$NOBUILD) {
792 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000793 RunLoggedCommand("(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) ",
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000794 $BuildLog, "CONFIGURE");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000795 # Build the entire tree, capturing the output into $BuildLog
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000796 RunAppendingLoggedCommand("(time -p $NICE $MAKECMD clean)", $BuildLog, "BUILD CLEAN");
797 RunAppendingLoggedCommand("(time -p $NICE $MAKECMD $MAKEOPTS)", $BuildLog, "BUILD");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000798}
799
800##############################################################
801#
802# Get some statistics about the build...
803#
804##############################################################
805#this can de done on server
806#my @Linked = split '\n', `grep Linking $BuildLog`;
807#my $NumExecutables = scalar(grep(/executable/, @Linked));
808#my $NumLibraries = scalar(grep(!/executable/, @Linked));
809#my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
810
811# Get the number of lines of source code. Must be here after the build is done
812# because countloc.sh uses the llvm-config script which must be built.
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000813my $LOC = `utils/countloc.sh -topdir $LLVMSrcDir`;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000814
815# Get the time taken by the configure script
816my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
817my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
818my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
819my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
820
821$ConfigTime=-1 unless $ConfigTime;
822$ConfigWallTime=-1 unless $ConfigWallTime;
823
824my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
825my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
826my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
827my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
828
829$BuildTime=-1 unless $BuildTime;
830$BuildWallTime=-1 unless $BuildWallTime;
831
832my $BuildError = 0, $BuildStatus = "OK";
833if ($NOBUILD) {
834 $BuildStatus = "Skipped by user";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000835}
836elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
837 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
838 $BuildStatus = "Error: compilation aborted";
839 $BuildError = 1;
840 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
841}
842if ($BuildError) { $NODEJAGNU=1; }
843
844my $a_file_sizes="";
845my $o_file_sizes="";
846if (!$BuildError) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000847 print "Organizing size of .o and .a files\n"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000848 if ( $VERBOSE );
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000849 ChangeDir( "$LLVMObjDir", "Build Directory" );
Bob Wilson722d58b2009-06-19 17:19:38 +0000850
851 my @dirs = ('utils', 'lib', 'tools');
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000852 if($BUILDTYPE eq "release"){
Bob Wilson722d58b2009-06-19 17:19:38 +0000853 push @dirs, 'Release';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000854 } elsif($BUILDTYPE eq "release-asserts") {
Bob Wilson722d58b2009-06-19 17:19:38 +0000855 push @dirs, 'Release-Asserts';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000856 } else {
Bob Wilson722d58b2009-06-19 17:19:38 +0000857 push @dirs, 'Debug';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000858 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000859
Bob Wilson722d58b2009-06-19 17:19:38 +0000860 find(sub {
861 $a_file_sizes .= (-s $_)." $File::Find::name $BUILDTYPE\n" if /\.a$/i;
862 $o_file_sizes .= (-s $_)." $File::Find::name $BUILDTYPE\n" if /\.o$/i;
863 }, @dirs);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000864} else {
865 $a_file_sizes="No data due to a bad build.";
866 $o_file_sizes="No data due to a bad build.";
867}
868
869##############################################################
870#
871# Running dejagnu tests
872#
873##############################################################
874my $DejangnuTestResults=""; # String containing the results of the dejagnu
875my $dejagnu_output = "$DejagnuTestsLog";
876if (!$NODEJAGNU) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000877 #Run the feature and regression tests, results are put into testrun.sum
878 #Full log in testrun.log
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000879 RunLoggedCommand("(time -p $MAKECMD $MAKEOPTS check)", $dejagnu_output, "DEJAGNU");
Misha Brukmanafa1e862009-01-02 16:28:18 +0000880
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000881 #Copy the testrun.log and testrun.sum to our webdir
882 CopyFile("test/testrun.log", $DejagnuLog);
883 CopyFile("test/testrun.sum", $DejagnuSum);
884 #can be done on server
885 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
886 $unexpfail_tests = $DejagnuTestResults;
887}
888
889#Extract time of dejagnu tests
890my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
891my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
892$DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
Misha Brukmanafa1e862009-01-02 16:28:18 +0000893$DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
894$DejagnuTestResults =
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000895 "Dejagnu skipped by user choice." unless $DejagnuTestResults;
896$DejagnuTime = "0.0" unless $DejagnuTime;
897$DejagnuWallTime = "0.0" unless $DejagnuWallTime;
898
899##############################################################
900#
901# Get warnings from the build
902#
903##############################################################
904if (!$NODEJAGNU) {
905 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
906 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
907 my @Warnings;
908 my $CurDir = "";
909
910 foreach $Warning (@Warn) {
911 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
912 $CurDir = $1; # Keep track of directory warning is in...
913 # Remove buildir prefix if included
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000914 if ($CurDir =~ m#$LLVMSrcDir/(.*)#) { $CurDir = $1; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000915 } else {
916 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
917 }
918 }
919 my $WarningsFile = join "\n", @Warnings;
920 $WarningsFile =~ s/:[0-9]+:/::/g;
921
922 # Emit the warnings file, so we can diff...
923 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
924 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
925
926 # Output something to stdout if something has changed
927 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
928 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
929
930 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
931 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
932
933} #endif !NODEGAGNU
934
935##############################################################
936#
937# If we built the tree successfully, run the nightly programs tests...
938#
Misha Brukmanafa1e862009-01-02 16:28:18 +0000939# A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000940# "External")
941#
942##############################################################
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000943
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000944sub TestDirectory {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000945 my $SubDir = shift;
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000946 ChangeDir( "$LLVMTestDir/$SubDir",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000947 "Programs Test Subdirectory" ) || return ("", "");
Misha Brukmanafa1e862009-01-02 16:28:18 +0000948
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000949 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000950
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000951 # Run the programs tests... creating a report.nightly.csv file
952 if (!$NOTEST) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000953 if( $VERBOSE) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000954 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
Bill Wendling085ff3f2009-07-16 22:59:17 +0000955 "$TESTFLAGS TEST=nightly > $ProgramTestLog 2>&1\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000956 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000957 RunLoggedCommand("$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
Bill Wendling085ff3f2009-07-16 22:59:17 +0000958 "$TESTFLAGS TEST=nightly",
959 $ProgramTestLog, "TEST DIRECTORY $SubDir");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000960 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
Misha Brukmanafa1e862009-01-02 16:28:18 +0000961 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000962
963 my $ProgramsTable;
964 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
965 $TestError = 1;
966 $ProgramsTable="Error running test $SubDir\n";
967 print "ERROR TESTING\n";
968 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
969 $TestError = 1;
970 $ProgramsTable="Makefile error running tests $SubDir!\n";
971 print "ERROR TESTING\n";
972 } else {
973 $TestError = 0;
974 #
975 # Create a list of the tests which were run...
976 #
977 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
978 "| sort > $Prefix-$SubDir-Tests.txt";
979 }
980 $ProgramsTable = ReadFile "report.nightly.csv";
981
982 ChangeDir( "../../..", "Programs Test Parent Directory" );
983 return ($ProgramsTable, $llcbeta_options);
984} #end sub TestDirectory
985
986##############################################################
987#
988# Calling sub TestDirectory
989#
990##############################################################
991if (!$BuildError) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000992 ($SingleSourceProgramsTable, $llcbeta_options) =
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000993 TestDirectory("SingleSource");
994 WriteFile "$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000995 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
996 WriteFile "$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
997 if ( ! $NOEXTERNALS ) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000998 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
999 WriteFile "$Prefix-External-Performance.txt", $ExternalProgramsTable;
Misha Brukmanafa1e862009-01-02 16:28:18 +00001000 system "cat $Prefix-SingleSource-Tests.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001001 "$Prefix-MultiSource-Tests.txt ".
1002 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +00001003 system "cat $Prefix-SingleSource-Performance.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001004 "$Prefix-MultiSource-Performance.txt ".
1005 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
1006 } else {
1007 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
1008 if ( $VERBOSE ) {
1009 print "External TEST STAGE SKIPPED\n";
1010 }
Misha Brukmanafa1e862009-01-02 16:28:18 +00001011 system "cat $Prefix-SingleSource-Tests.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001012 "$Prefix-MultiSource-Tests.txt ".
1013 " | sort > $Prefix-Tests.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +00001014 system "cat $Prefix-SingleSource-Performance.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001015 "$Prefix-MultiSource-Performance.txt ".
1016 " | sort > $Prefix-Performance.txt";
1017 }
1018
1019 ##############################################################
1020 #
Misha Brukmanafa1e862009-01-02 16:28:18 +00001021 #
1022 # gathering tests added removed broken information here
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001023 #
1024 #
1025 ##############################################################
1026 my $dejagnu_test_list = ReadFile "$Prefix-Tests.txt";
1027 my @DEJAGNU = split "\n", $dejagnu_test_list;
1028 my ($passes, $fails, $xfails) = "";
1029
1030 if(!$NODEJAGNU) {
1031 for ($x=0; $x<@DEJAGNU; $x++) {
1032 if ($DEJAGNU[$x] =~ m/^PASS:/) {
1033 $passes.="$DEJAGNU[$x]\n";
1034 }
1035 elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
1036 $fails.="$DEJAGNU[$x]\n";
1037 }
1038 elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
1039 $xfails.="$DEJAGNU[$x]\n";
1040 }
1041 }
1042 }
Misha Brukmanafa1e862009-01-02 16:28:18 +00001043
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001044} #end if !$BuildError
1045
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001046##############################################################
1047#
1048# Getting end timestamp
1049#
1050##############################################################
1051$endtime = `date "+20%y-%m-%d %H:%M:%S"`;
1052
1053
1054##############################################################
1055#
1056# Place all the logs neatly into one humungous file
1057#
1058##############################################################
1059if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
1060
Misha Brukmanafa1e862009-01-02 16:28:18 +00001061$machine_data = "uname: ".`uname -a`.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001062 "hardware: ".`uname -m`.
1063 "os: ".`uname -sr`.
1064 "name: ".`uname -n`.
1065 "date: ".`date \"+20%y-%m-%d\"`.
Misha Brukmanafa1e862009-01-02 16:28:18 +00001066 "time: ".`date +\"%H:%M:%S\"`;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001067
1068my @CVS_DATA;
1069my $cvs_data;
1070@CVS_DATA = ReadFile "$COLog";
1071$cvs_data = join("\n", @CVS_DATA);
1072
1073my @BUILD_DATA;
1074my $build_data;
1075@BUILD_DATA = ReadFile "$BuildLog";
1076$build_data = join("\n", @BUILD_DATA);
1077
1078my (@DEJAGNU_LOG, @DEJAGNU_SUM, @DEJAGNULOG_FULL, @GCC_VERSION);
1079my ($dejagnutests_log ,$dejagnutests_sum, $dejagnulog_full) = "";
1080my ($gcc_version, $gcc_version_long) = "";
1081
1082$gcc_version_long="";
1083if ($GCCPATH ne "") {
1084 $gcc_version_long = `$GCCPATH/gcc --version`;
1085} elsif ($ENV{"CC"}) {
1086 $gcc_version_long = `$ENV{"CC"} --version`;
1087} else {
1088 $gcc_version_long = `gcc --version`;
1089}
1090@GCC_VERSION = split '\n', $gcc_version_long;
1091$gcc_version = $GCC_VERSION[0];
1092
1093$llvmgcc_version_long="";
1094if ($LLVMGCCPATH ne "") {
1095 $llvmgcc_version_long = `$LLVMGCCPATH/llvm-gcc -v 2>&1`;
1096} else {
1097 $llvmgcc_version_long = `llvm-gcc -v 2>&1`;
1098}
1099@LLVMGCC_VERSION = split '\n', $llvmgcc_version_long;
1100$llvmgcc_versionTarget = $LLVMGCC_VERSION[1];
1101$llvmgcc_versionTarget =~ /Target: (.+)/;
1102$targetTriple = $1;
1103
1104if(!$BuildError){
1105 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
1106 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
1107 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
1108 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
1109
1110 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
1111 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
1112}
1113
1114##############################################################
1115#
1116# Send data via a post request
1117#
1118##############################################################
1119
1120if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
1121
1122my %hash_of_data = (
1123 'machine_data' => $machine_data,
1124 'build_data' => $build_data,
1125 'gcc_version' => $gcc_version,
1126 'nickname' => $nickname,
1127 'dejagnutime_wall' => $DejagnuWallTime,
1128 'dejagnutime_cpu' => $DejagnuTime,
1129 'cvscheckouttime_wall' => $CheckoutTime_Wall,
1130 'cvscheckouttime_cpu' => $CheckoutTime_CPU,
1131 'configtime_wall' => $ConfigWallTime,
1132 'configtime_cpu'=> $ConfigTime,
1133 'buildtime_wall' => $BuildWallTime,
1134 'buildtime_cpu' => $BuildTime,
1135 'warnings' => $WarningsFile,
1136 'cvsusercommitlist' => $UserCommitList,
1137 'cvsuserupdatelist' => $UserUpdateList,
1138 'cvsaddedfiles' => $CVSAddedFiles,
1139 'cvsmodifiedfiles' => $CVSModifiedFiles,
1140 'cvsremovedfiles' => $CVSRemovedFiles,
1141 'lines_of_code' => $LOC,
1142 'cvs_file_count' => $NumFilesInCVS,
1143 'cvs_dir_count' => $NumDirsInCVS,
1144 'buildstatus' => $BuildStatus,
1145 'singlesource_programstable' => $SingleSourceProgramsTable,
1146 'multisource_programstable' => $MultiSourceProgramsTable,
1147 'externalsource_programstable' => $ExternalProgramsTable,
1148 'llcbeta_options' => $multisource_llcbeta_options,
1149 'warnings_removed' => $WarningsRemoved,
1150 'warnings_added' => $WarningsAdded,
1151 'passing_tests' => $passes,
1152 'expfail_tests' => $xfails,
1153 'unexpfail_tests' => $fails,
1154 'all_tests' => $dejagnu_test_list,
1155 'new_tests' => "",
1156 'removed_tests' => "",
1157 'dejagnutests_results' => $DejagnuTestResults,
1158 'dejagnutests_log' => $dejagnulog_full,
1159 'starttime' => $starttime,
1160 'endtime' => $endtime,
1161 'o_file_sizes' => $o_file_sizes,
1162 'a_file_sizes' => $a_file_sizes,
1163 'target_triple' => $targetTriple
1164);
1165
Daniel Dunbar3b377ef2009-06-26 22:33:28 +00001166if ($SUBMIT || !($SUBMITAUX eq "")) {
Tanya Lattner084a3ee2008-03-10 07:28:08 +00001167 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
1168 if( $VERBOSE) { print "============================\n$response"; }
1169} else {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001170 print "============================\n";
1171 foreach $x(keys %hash_of_data){
1172 print "$x => $hash_of_data{$x}\n";
1173 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001174}
1175
1176##############################################################
1177#
1178# Remove the cvs tree...
1179#
1180##############################################################
Misha Brukmanafa1e862009-01-02 16:28:18 +00001181system ( "$NICE rm -rf $BuildDir")
Daniel Dunbard3ecefe2009-07-13 22:17:49 +00001182 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVEATEND);
Misha Brukmanafa1e862009-01-02 16:28:18 +00001183system ( "$NICE rm -rf $WebDir")
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001184 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);