blob: 41792d6da4b8fa30569062749a00b19c24d6231a [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
Daniel Dunbarae3faf12009-10-19 09:18:24 +000085# -nice Checkout/Configure/Build with "nice" to reduce impact
86# on busy servers.
87# -f2c Next argument specifies path to F2C utility
88# -gccpath Path to gcc/g++ used to build LLVM
89# -target Specify the target triplet
90# -cflags Next argument specifies that C compilation options that
91# override the default.
92# -cxxflags Next argument specifies that C++ compilation options that
93# override the default.
94# -ldflags Next argument specifies that linker options that override
95# the default.
96#
Dan Gohmanf17a25c2007-07-18 16:29:46 +000097# CVSROOT is the CVS repository from which the tree will be checked out,
98# specified either in the full :method:user@host:/dir syntax, or
99# just /dir if using a local repo.
100# BUILDDIR is the directory where sources for this test run will be checked out
101# AND objects for this test run will be built. This directory MUST NOT
102# exist before the script is run; it will be created by the cvs checkout
103# process and erased (unless -noremove is specified; see above.)
104# WEBDIR is the directory into which the test results web page will be written,
105# AND in which the "index.html" is assumed to be a symlink to the most recent
106# copy of the results. This directory will be created if it does not exist.
107# LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
108# to. This is the same as you would have for a normal LLVM build.
109#
110##############################################################
111#
112# Getting environment variables
113#
114##############################################################
115my $HOME = $ENV{'HOME'};
116my $SVNURL = $ENV{"SVNURL"};
Duncan Sands01388f92009-06-12 13:02:52 +0000117$SVNURL = 'http://llvm.org/svn/llvm-project' unless $SVNURL;
Evan Chengb6d7fc32009-06-18 21:39:50 +0000118my $TestSVNURL = $ENV{"TestSVNURL"};
Evan Chenge45329e2009-07-14 06:23:41 +0000119$TestSVNURL = 'http://llvm.org/svn/llvm-project' unless $TestSVNURL;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000120my $CVSRootDir = $ENV{'CVSROOT'};
121$CVSRootDir = "/home/vadve/shared/PublicCVS" unless $CVSRootDir;
122my $BuildDir = $ENV{'BUILDDIR'};
123$BuildDir = "$HOME/buildtest" unless $BuildDir;
124my $WebDir = $ENV{'WEBDIR'};
125$WebDir = "$HOME/cvs/testresults-X86" unless $WebDir;
126
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000127my $LLVMSrcDir = $ENV{'LLVMSRCDIR'};
128$LLVMSrcDir = "$BuildDir/llvm" unless $LLVMSrcDir;
129my $LLVMObjDir = $ENV{'LLVMOBJDIR'};
130$LLVMObjDir = "$BuildDir/llvm" unless $LLVMObjDir;
131my $LLVMTestDir = $ENV{'LLVMTESTDIR'};
132$LLVMTestDir = "$BuildDir/llvm/projects/llvm-test" unless $LLVMTestDir;
133
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000134##############################################################
135#
136# Calculate the date prefix...
137#
138##############################################################
139@TIME = localtime;
Daniel Dunbar93ad6a82009-07-01 14:52:59 +0000140my $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 +0000141
142##############################################################
143#
144# Parse arguments...
145#
146##############################################################
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000147$CONFIG_PATH="";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000148$CONFIGUREARGS="";
149$nickname="";
150$NOTEST=0;
151$USESVN=1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000152$MAKECMD="make";
153$SUBMITSERVER = "llvm.org";
154$SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
Daniel Dunbar016a4bb2009-05-18 23:24:26 +0000155$SUBMITAUX="";
Tanya Lattner084a3ee2008-03-10 07:28:08 +0000156$SUBMIT = 1;
Daniel Dunbarf8cdaec2009-05-28 22:45:24 +0000157$PARALLELJOBS = "2";
Bill Wendling085ff3f2009-07-16 22:59:17 +0000158my $TESTFLAGS="";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000159
160while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
161 shift;
162 last if /^--$/; # Stop processing arguments on --
163
164 # List command line options here...
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000165 if (/^-config$/) { $CONFIG_PATH = "$ARGV[0]"; shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000166 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
167 if (/^-nocvsstats$/) { $NOCVSSTATS = 1; next; }
168 if (/^-noremove$/) { $NOREMOVE = 1; next; }
Daniel Dunbard3ecefe2009-07-13 22:17:49 +0000169 if (/^-noremoveatend$/) { $NOREMOVEATEND = 1; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000170 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
Daniel Dunbar2041d9a2009-06-02 21:14:15 +0000171 if (/^-notest$/) { $NOTEST = 1; next; }
172 if (/^-norunningtests$/) { next; } # Backward compatibility, ignored.
Daniel Dunbarf8cdaec2009-05-28 22:45:24 +0000173 if (/^-parallel-jobs$/) { $PARALLELJOBS = "$ARGV[0]"; shift; next;}
174 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j$PARALLELJOBS -l3.0"; next; }
Duncan Sands01388f92009-06-12 13:02:52 +0000175 if (/^-with-clang$/) { $WITHCLANG = 1; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000176 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
177 "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
178 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
Dan Gohmanbd399762008-10-30 01:08:03 +0000179 "DISABLE_ASSERTIONS=1 ".
Misha Brukmanafa1e862009-01-02 16:28:18 +0000180 "OPTIMIZE_OPTION=-O2";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000181 $BUILDTYPE="release-asserts"; next;}
182 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
Duncan Sands01388f92009-06-12 13:02:52 +0000183 if (/^-disable-pic$/) { $CONFIGUREARGS .= " --enable-pic=no"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000184 if (/^-enable-lli$/) { $PROGTESTOPTS .= " ENABLE_LLI=1";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000185 $CONFIGUREARGS .= " --enable-lli"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000186 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000187 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000188 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
189 $CONFIGUREARGS .= " --disable-jit"; next; }
Daniel Dunbar31a1f1c2009-03-10 19:33:13 +0000190 if (/^-disable-bindings$/) { $CONFIGUREARGS .= " --disable-bindings"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000191 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
Evan Cheng32efae02008-01-12 04:27:18 +0000192 if (/^-disable-lto$/) { $PROGTESTOPTS .= " DISABLE_LTO=1"; next; }
Evan Cheng08206772008-01-14 17:58:03 +0000193 if (/^-test-opts$/) { $PROGTESTOPTS .= " $ARGV[0]"; shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000194 if (/^-verbose$/) { $VERBOSE = 1; next; }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000195 if (/^-teelogs$/) { $TEELOGS = 1; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000196 if (/^-nice$/) { $NICE = "nice "; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000197 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000198 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000199 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000200 shift; next; }
Daniel Dunbardd9c4aa2009-07-13 22:31:58 +0000201 if (/^-configure-args$/) { $CONFIGUREARGS .= " $ARGV[0]";
202 shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000203 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
204 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
Daniel Dunbar016a4bb2009-05-18 23:24:26 +0000205 if (/^-submit-aux/) { $SUBMITAUX = "$ARGV[0]"; shift; next; }
Tanya Lattner084a3ee2008-03-10 07:28:08 +0000206 if (/^-nosubmit$/) { $SUBMIT = 0; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000207 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
208 if (/^-gccpath/) { $CONFIGUREARGS .=
209 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000210 $GCCPATH=$ARGV[0]; shift; next; }
211 else { $GCCPATH=""; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000212 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000213 else { $CVSCOOPT="";}
214 if (/^-usecvs/) { $USESVN = 0; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000215 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000216 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000217 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000218 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000219 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000220 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000221 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000222 shift; next; }
Bill Wendling085ff3f2009-07-16 22:59:17 +0000223 if (/^-test-cflags/) { $TESTFLAGS = "$TESTFLAGS CFLAGS=\'$ARGV[0]\'";
224 shift; next; }
225 if (/^-test-cxxflags/) { $TESTFLAGS = "$TESTFLAGS CXXFLAGS=\'$ARGV[0]\'";
226 shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000227 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
228 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000229 if (/^-extraflags/) { $CONFIGUREARGS .=
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000230 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
231 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
232 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
233 if (/^-nobuild$/) { $NOBUILD = 1; next; }
234 print "Unknown option: $_ : ignoring!\n";
235}
236
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000237if (!($CONFIG_PATH eq "")) {
238 die "error: -config mode is not yet implemented,";
239}
240
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000241if ($ENV{'LLVMGCCDIR'}) {
242 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
Bob Wilsonc6d296b2009-03-12 19:47:24 +0000243 $LLVMGCCPATH = $ENV{'LLVMGCCDIR'} . '/bin';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000244}
245else {
246 $LLVMGCCPATH = "";
247}
248
249if ($CONFIGUREARGS !~ /--disable-jit/) {
250 $CONFIGUREARGS .= " --enable-jit";
251}
252
253if (@ARGV != 0 and @ARGV != 3 and $VERBOSE) {
254 foreach $x (@ARGV) {
255 print "$x\n";
256 }
257 print "Must specify 0 or 3 options!";
258}
259
260if (@ARGV == 3) {
261 $CVSRootDir = $ARGV[0];
262 $BuildDir = $ARGV[1];
263 $WebDir = $ARGV[2];
264}
265
266if ($CVSRootDir eq "" or
267 $BuildDir eq "" or
268 $WebDir eq "") {
269 die("please specify a cvs root directory, a build directory, and a ".
270 "web directory");
271 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000272
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000273if ($nickname eq "") {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000274 die ("Please invoke NewNightlyTest.pl with command line option " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000275 "\"-nickname <nickname>\"");
276}
277
278if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
279 $BUILDTYPE = "debug";
280}
281
282##############################################################
283#
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000284# Define the file names we'll use
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000285#
286##############################################################
287my $Prefix = "$WebDir/$DATE";
288my $BuildLog = "$Prefix-Build-Log.txt";
289my $COLog = "$Prefix-CVS-Log.txt";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000290my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
291my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
292my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
293my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
294my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
295my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
296if (! -d $WebDir) {
297 mkdir $WebDir, 0777;
298 if($VERBOSE){
299 warn "$WebDir did not exist; creating it.\n";
300 }
301}
302
303if ($VERBOSE) {
304 print "INITIALIZED\n";
305 if ($USESVN) {
306 print "SVN URL = $SVNURL\n";
307 } else {
308 print "CVS Root = $CVSRootDir\n";
309 }
310 print "COLog = $COLog\n";
311 print "BuildDir = $BuildDir\n";
312 print "WebDir = $WebDir\n";
313 print "Prefix = $Prefix\n";
314 print "BuildLog = $BuildLog\n";
315}
316
317##############################################################
318#
319# Helper functions
320#
321##############################################################
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000322
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000323sub GetDir {
324 my $Suffix = shift;
325 opendir DH, $WebDir;
326 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
327 closedir DH;
328 return @Result;
329}
330
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000331sub RunLoggedCommand {
332 my $Command = shift;
333 my $Log = shift;
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000334 my $Title = shift;
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000335 if ($TEELOGS) {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000336 if ($VERBOSE) {
337 print "$Title\n";
338 print "$Command 2>&1 | tee $Log\n";
339 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000340 system "$Command 2>&1 | tee $Log";
341 } else {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000342 if ($VERBOSE) {
343 print "$Title\n";
344 print "$Command 2>&1 > $Log\n";
345 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000346 system "$Command 2>&1 > $Log";
347 }
348}
349
350sub RunAppendingLoggedCommand {
351 my $Command = shift;
352 my $Log = shift;
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000353 my $Title = shift;
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000354 if ($TEELOGS) {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000355 if ($VERBOSE) {
356 print "$Title\n";
357 print "$Command 2>&1 | tee -a $Log\n";
358 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000359 system "$Command 2>&1 | tee -a $Log";
360 } else {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000361 if ($VERBOSE) {
362 print "$Title\n";
363 print "$Command 2>&1 > $Log\n";
364 }
365 system "$Command 2>&1 >> $Log";
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000366 }
367}
368
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000369#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
370#
371# DiffFiles - Diff the current version of the file against the last version of
372# the file, reporting things added and removed. This is used to report, for
373# example, added and removed warnings. This returns a pair (added, removed)
374#
375#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
376sub DiffFiles {
377 my $Suffix = shift;
378 my @Others = GetDir $Suffix;
379 if (@Others == 0) { # No other files? We added all entries...
380 return (`cat $WebDir/$DATE$Suffix`, "");
381 }
382# Diff the files now...
383 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
384 my $Added = join "\n", grep /^</, @Diffs;
385 my $Removed = join "\n", grep /^>/, @Diffs;
386 $Added =~ s/^< //gm;
387 $Removed =~ s/^> //gm;
388 return ($Added, $Removed);
389}
390
391#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
392#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
393sub GetRegex { # (Regex with ()'s, value)
394 $_[1] =~ /$_[0]/m;
Misha Brukmanafa1e862009-01-02 16:28:18 +0000395 return $1
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000396 if (defined($1));
397 return "0";
398}
399
400#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
401#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
402sub GetRegexNum {
403 my ($Regex, $Num, $Regex2, $File) = @_;
404 my @Items = split "\n", `grep '$Regex' $File`;
405 return GetRegex $Regex2, $Items[$Num];
406}
407
408#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
409#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
410sub ChangeDir { # directory, logical name
411 my ($dir,$name) = @_;
412 chomp($dir);
413 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
414 $result = chdir($dir);
415 if (!$result) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000416 print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000417 return false;
418 }
419 return true;
420}
421
422#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
423#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
424sub ReadFile {
425 if (open (FILE, $_[0])) {
426 undef $/;
427 my $Ret = <FILE>;
428 close FILE;
429 $/ = '\n';
430 return $Ret;
431 } else {
432 print "Could not open file '$_[0]' for reading!\n";
433 return "";
434 }
435}
436
437#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
438#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
439sub WriteFile { # (filename, contents)
440 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
441 print FILE $_[1];
442 close FILE;
443}
444
445#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
446#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
447sub CopyFile { #filename, newfile
448 my ($file, $newfile) = @_;
449 chomp($file);
450 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
451 copy($file, $newfile);
452}
453
454#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
455#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
456sub AddRecord {
457 my ($Val, $Filename,$WebDir) = @_;
458 my @Records;
459 if (open FILE, "$WebDir/$Filename") {
460 @Records = grep !/$DATE/, split "\n", <FILE>;
461 close FILE;
462 }
463 push @Records, "$DATE: $Val";
464 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
465}
466
467#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
468#
469# FormatTime - Convert a time from 1m23.45 into 83.45
470#
471#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
472sub FormatTime {
473 my $Time = shift;
474 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
475 $Time = sprintf("%7.4f", $1*60.0+$2);
476 }
477 return $Time;
478}
479
480#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
481#
Misha Brukmanafa1e862009-01-02 16:28:18 +0000482# This function is meant to read in the dejagnu sum file and
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000483# return a string with only the results (i.e. PASS/FAIL/XPASS/
484# XFAIL).
485#
486#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
487sub GetDejagnuTestResults { # (filename, log)
488 my ($filename, $DejagnuLog) = @_;
489 my @lines;
490 $/ = "\n"; #Make sure we're going line at a time.
491
492 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
493
494 if (open SRCHFILE, $filename) {
495 # Process test results
496 while ( <SRCHFILE> ) {
497 if ( length($_) > 1 ) {
498 chomp($_);
499 if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\/test\/(.*)$/ ) {
500 push(@lines, "$1: test/$2");
501 }
502 }
503 }
504 }
505 close SRCHFILE;
506
507 my $content = join("\n", @lines);
508 return $content;
509}
510
511
512
513#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
514#
515# This function acts as a mini web browswer submitting data
516# to our central server via the post method
517#
518#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000519sub SendData {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000520 $host = $_[0];
521 $file = $_[1];
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000522 $variables = $_[2];
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000523
Daniel Dunbara2533002009-05-28 18:31:40 +0000524 # Write out the "...-sentdata.txt" file.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000525
Daniel Dunbara2533002009-05-28 18:31:40 +0000526 my $sentdata="";
527 foreach $x (keys (%$variables)){
528 $value = $variables->{$x};
529 $sentdata.= "$x => $value\n";
530 }
531 WriteFile "$Prefix-sentdata.txt", $sentdata;
532
533 if (!($SUBMITAUX eq "")) {
Daniel Dunbar3b377ef2009-06-26 22:33:28 +0000534 system "$SUBMITAUX \"$Prefix-sentdata.txt\"";
535 }
536
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000537 if (!$SUBMIT) {
Daniel Dunbar3b377ef2009-06-26 22:33:28 +0000538 return "Skipped standard submit.\n";
Daniel Dunbara2533002009-05-28 18:31:40 +0000539 }
540
541 # Create the content to send to the server.
542
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000543 my $content;
544 foreach $key (keys (%$variables)){
545 $value = $variables->{$key};
546 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
547 $content .= "$key=$value&";
548 }
549
Daniel Dunbara2533002009-05-28 18:31:40 +0000550 # Send the data to the server.
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000551 #
Daniel Dunbara2533002009-05-28 18:31:40 +0000552 # FIXME: This code should be more robust?
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000553
Daniel Dunbara2533002009-05-28 18:31:40 +0000554 $port=80;
555 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
556 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
557 die "Bad socket\n";
558 connect SOCK, $socketaddr or die "Bad connection\n";
559 select((select(SOCK), $| = 1)[0]);
560
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000561 $length = length($content);
562
563 my $send= "POST $file HTTP/1.0\n";
564 $send.= "Host: $host\n";
565 $send.= "Content-Type: application/x-www-form-urlencoded\n";
566 $send.= "Content-length: $length\n\n";
567 $send.= "$content";
568
569 print SOCK $send;
570 my $result;
571 while(<SOCK>){
572 $result .= $_;
573 }
574 close(SOCK);
575
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000576 return $result;
577}
578
579##############################################################
580#
581# Getting Start timestamp
582#
583##############################################################
584$starttime = `date "+20%y-%m-%d %H:%M:%S"`;
585
586##############################################################
587#
588# Create the CVS repository directory
589#
590##############################################################
591if (!$NOCHECKOUT) {
592 if (-d $BuildDir) {
593 if (!$NOREMOVE) {
594 if ( $VERBOSE ) {
595 print "Build directory exists! Removing it\n";
596 }
597 system "rm -rf $BuildDir";
598 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
599 } else {
600 if ( $VERBOSE ) {
601 print "Build directory exists!\n";
602 }
603 }
604 } else {
605 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
606 }
607}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000608
609
610##############################################################
611#
Misha Brukmanafa1e862009-01-02 16:28:18 +0000612# Check out the llvm tree, using either SVN or CVS
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000613#
614##############################################################
615if (!$NOCHECKOUT) {
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000616 ChangeDir( $BuildDir, "checkout directory" );
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000617 if ($USESVN) {
Duncan Sands01388f92009-06-12 13:02:52 +0000618 my $SVNCMD = "$NICE svn co --non-interactive $SVNURL";
Evan Chengb6d7fc32009-06-18 21:39:50 +0000619 my $SVNCMD2 = "$NICE svn co --non-interactive $TestSVNURL";
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000620 RunLoggedCommand("( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000621 "$SVNCMD2/test-suite/trunk llvm-test )", $COLog,
622 "CHECKOUT LLVM");
Evan Chengb6d7fc32009-06-18 21:39:50 +0000623 if ($WITHCLANG) {
624 my $SVNCMD = "$NICE svn co --non-interactive $SVNURL/cfe/trunk";
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000625 RunLoggedCommand("( time -p cd llvm/tools ; $SVNCMD clang )", $COLog,
626 "CHECKOUT CLANG");
Evan Chengb6d7fc32009-06-18 21:39:50 +0000627 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000628 } else {
629 my $CVSOPT = "";
630 $CVSOPT = "-z3" # Use compression if going over ssh.
631 if $CVSRootDir =~ /^:ext:/;
632 my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co -P $CVSCOOPT";
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000633 RunLoggedCommand("( time -p $CVSCMD llvm; cd llvm/projects ; " .
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000634 "$CVSCMD llvm-test )", $COLog,
635 "CHECKOUT LLVM-TEST");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000636 }
637}
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000638ChangeDir( $LLVMSrcDir , "llvm source directory") ;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000639
640##############################################################
641#
642# Get some static statistics about the current state of CVS
643#
644# This can probably be put on the server side
645#
646##############################################################
647my $CheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $COLog`;
648my $CheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $COLog`;
649my $CheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $COLog`;
650my $CheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
651
652my $NumFilesInCVS = 0;
653my $NumDirsInCVS = 0;
654if ($USESVN) {
655 $NumFilesInCVS = `egrep '^A' $COLog | wc -l` + 0;
Nick Lewyckye45e2c82008-06-05 12:54:44 +0000656 $NumDirsInCVS = `sed -e 's#/[^/]*\$##' $COLog | sort | uniq | wc -l` + 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000657} else {
658 $NumFilesInCVS = `egrep '^U' $COLog | wc -l` + 0;
659 $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $COLog | wc -l` + 0;
660}
661
662##############################################################
663#
664# Extract some information from the CVS history... use a hash so no duplicate
665# stuff is stored. This gets the history from the previous days worth
666# of cvs activity and parses it.
667#
668##############################################################
669
670# This just computes a reasonably accurate #of seconds since 2000. It doesn't
671# have to be perfect as its only used for comparing date ranges within a couple
672# of days.
673sub ConvertToSeconds {
674 my ($sec, $min, $hour, $day, $mon, $yr) = @_;
675 my $Result = ($yr - 2000) * 12;
676 $Result += $mon;
677 $Result *= 31;
678 $Result += $day;
679 $Result *= 24;
680 $Result += $hour;
681 $Result *= 60;
682 $Result += $min;
683 $Result *= 60;
684 $Result += $sec;
685 return $Result;
686}
687
688my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
689
690if (!$NOCVSSTATS) {
691 if ($VERBOSE) { print "CHANGE HISTORY ANALYSIS STAGE\n"; }
692
693 if ($USESVN) {
Duncan Sands01388f92009-06-12 13:02:52 +0000694 @SVNHistory = split /<logentry/, `svn log --non-interactive --xml --verbose -r{$DATE}:HEAD`;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000695 # Skip very first entry because it is the XML header cruft
696 shift @SVNHistory;
697 my $Now = time();
698 foreach $Record (@SVNHistory) {
699 my @Lines = split "\n", $Record;
700 my ($Author, $Date, $Revision);
701 # Get the date and see if its one we want to process.
702 my ($Year, $Month, $Day, $Hour, $Min, $Sec);
703 if ($Lines[3] =~ /<date>(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/){
704 $Year = $1; $Month = $2; $Day = $3; $Hour = $4; $Min = $5; $Sec = $6;
705 }
706 my $Then = ConvertToSeconds($Sec, $Min, $Hour, $Day, $Month, $Year);
707 # Get the current date and compute when "yesterday" is.
708 my ($NSec, $NMin, $NHour, $NDay, $NMon, $NYear) = gmtime();
709 my $Now = ConvertToSeconds( $NSec, $NMin, $NHour, $NDay, $NMon, $NYear);
710 if (($Now - 24*60*60) > $Then) {
711 next;
712 }
713 if ($Lines[1] =~ / revision="([0-9]*)">/) {
714 $Revision = $1;
715 }
716 if ($Lines[2] =~ /<author>([^<]*)<\/author>/) {
717 $Author = $1;
718 }
719 $UsersCommitted{$Author} = 1;
720 $Date = $Year . "-" . $Month . "-" . $Day;
721 $Time = $Hour . ":" . $Min . ":" . $Sec;
722 print "Rev: $Revision, Author: $Author, Date: $Date, Time: $Time\n";
723 for ($i = 6; $i < $#Lines; $i += 2 ) {
724 if ($Lines[$i] =~ /^ action="(.)">([^<]*)</) {
725 if ($1 == "A") {
726 $AddedFiles{$2} = 1;
727 } elsif ($1 == 'D') {
728 $RemovedFiles{$2} = 1;
729 } elsif ($1 == 'M' || $1 == 'R' || $1 == 'C') {
730 $ModifiedFiles{$2} = 1;
731 } else {
732 print "UNMATCHABLE: $Lines[$i]\n";
733 }
734 }
735 }
736 }
737 } else {
738 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
739#print join "\n", @CVSHistory; print "\n";
740
741 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
742
743# Loop over every record from the CVS history, filling in the hashes.
744 foreach $File (@CVSHistory) {
745 my ($Type, $Date, $UID, $Rev, $Filename);
746 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
747 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
748 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
749 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
750 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
751 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
752 } else {
753 print "UNMATCHABLE: $File\n";
754 next;
755 }
756 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000757
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000758 if ($Filename =~ /^llvm/) {
759 if ($Type eq 'M') { # Modified
760 $ModifiedFiles{$Filename} = 1;
761 $UsersCommitted{$UID} = 1;
762 } elsif ($Type eq 'A') { # Added
763 $AddedFiles{$Filename} = 1;
764 $UsersCommitted{$UID} = 1;
765 } elsif ($Type eq 'R') { # Removed
766 $RemovedFiles{$Filename} = 1;
767 $UsersCommitted{$UID} = 1;
768 } else {
769 $UsersUpdated{$UID} = 1;
770 }
771 }
772 }
773
774 my $TestError = 1;
775 } #$USESVN
776}#!NOCVSSTATS
777
778my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
779my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
780my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
781my $UserCommitList = join "\n", sort keys %UsersCommitted;
782my $UserUpdateList = join "\n", sort keys %UsersUpdated;
783
784##############################################################
785#
786# Build the entire tree, saving build messages to the build log
787#
788##############################################################
789if (!$NOCHECKOUT && !$NOBUILD) {
790 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000791 RunLoggedCommand("(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) ",
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000792 $BuildLog, "CONFIGURE");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000793 # Build the entire tree, capturing the output into $BuildLog
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000794 RunAppendingLoggedCommand("(time -p $NICE $MAKECMD clean)", $BuildLog, "BUILD CLEAN");
795 RunAppendingLoggedCommand("(time -p $NICE $MAKECMD $MAKEOPTS)", $BuildLog, "BUILD");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000796}
797
798##############################################################
799#
800# Get some statistics about the build...
801#
802##############################################################
803#this can de done on server
804#my @Linked = split '\n', `grep Linking $BuildLog`;
805#my $NumExecutables = scalar(grep(/executable/, @Linked));
806#my $NumLibraries = scalar(grep(!/executable/, @Linked));
807#my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
808
809# Get the number of lines of source code. Must be here after the build is done
810# because countloc.sh uses the llvm-config script which must be built.
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000811my $LOC = `utils/countloc.sh -topdir $LLVMSrcDir`;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000812
813# Get the time taken by the configure script
814my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
815my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
816my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
817my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
818
819$ConfigTime=-1 unless $ConfigTime;
820$ConfigWallTime=-1 unless $ConfigWallTime;
821
822my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
823my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
824my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
825my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
826
827$BuildTime=-1 unless $BuildTime;
828$BuildWallTime=-1 unless $BuildWallTime;
829
830my $BuildError = 0, $BuildStatus = "OK";
831if ($NOBUILD) {
832 $BuildStatus = "Skipped by user";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000833}
834elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
835 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
836 $BuildStatus = "Error: compilation aborted";
837 $BuildError = 1;
838 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
839}
840if ($BuildError) { $NODEJAGNU=1; }
841
842my $a_file_sizes="";
843my $o_file_sizes="";
844if (!$BuildError) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000845 print "Organizing size of .o and .a files\n"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000846 if ( $VERBOSE );
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000847 ChangeDir( "$LLVMObjDir", "Build Directory" );
Bob Wilson722d58b2009-06-19 17:19:38 +0000848
849 my @dirs = ('utils', 'lib', 'tools');
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000850 if($BUILDTYPE eq "release"){
Bob Wilson722d58b2009-06-19 17:19:38 +0000851 push @dirs, 'Release';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000852 } elsif($BUILDTYPE eq "release-asserts") {
Bob Wilson722d58b2009-06-19 17:19:38 +0000853 push @dirs, 'Release-Asserts';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000854 } else {
Bob Wilson722d58b2009-06-19 17:19:38 +0000855 push @dirs, 'Debug';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000856 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000857
Bob Wilson722d58b2009-06-19 17:19:38 +0000858 find(sub {
859 $a_file_sizes .= (-s $_)." $File::Find::name $BUILDTYPE\n" if /\.a$/i;
860 $o_file_sizes .= (-s $_)." $File::Find::name $BUILDTYPE\n" if /\.o$/i;
861 }, @dirs);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000862} else {
863 $a_file_sizes="No data due to a bad build.";
864 $o_file_sizes="No data due to a bad build.";
865}
866
867##############################################################
868#
869# Running dejagnu tests
870#
871##############################################################
872my $DejangnuTestResults=""; # String containing the results of the dejagnu
873my $dejagnu_output = "$DejagnuTestsLog";
874if (!$NODEJAGNU) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000875 #Run the feature and regression tests, results are put into testrun.sum
876 #Full log in testrun.log
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000877 RunLoggedCommand("(time -p $MAKECMD $MAKEOPTS check)", $dejagnu_output, "DEJAGNU");
Misha Brukmanafa1e862009-01-02 16:28:18 +0000878
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000879 #Copy the testrun.log and testrun.sum to our webdir
880 CopyFile("test/testrun.log", $DejagnuLog);
881 CopyFile("test/testrun.sum", $DejagnuSum);
882 #can be done on server
883 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
884 $unexpfail_tests = $DejagnuTestResults;
885}
886
887#Extract time of dejagnu tests
888my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
889my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
890$DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
Misha Brukmanafa1e862009-01-02 16:28:18 +0000891$DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
892$DejagnuTestResults =
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000893 "Dejagnu skipped by user choice." unless $DejagnuTestResults;
894$DejagnuTime = "0.0" unless $DejagnuTime;
895$DejagnuWallTime = "0.0" unless $DejagnuWallTime;
896
897##############################################################
898#
899# Get warnings from the build
900#
901##############################################################
902if (!$NODEJAGNU) {
903 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
904 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
905 my @Warnings;
906 my $CurDir = "";
907
908 foreach $Warning (@Warn) {
909 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
910 $CurDir = $1; # Keep track of directory warning is in...
911 # Remove buildir prefix if included
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000912 if ($CurDir =~ m#$LLVMSrcDir/(.*)#) { $CurDir = $1; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000913 } else {
914 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
915 }
916 }
917 my $WarningsFile = join "\n", @Warnings;
918 $WarningsFile =~ s/:[0-9]+:/::/g;
919
920 # Emit the warnings file, so we can diff...
921 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
922 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
923
924 # Output something to stdout if something has changed
925 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
926 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
927
928 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
929 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
930
931} #endif !NODEGAGNU
932
933##############################################################
934#
935# If we built the tree successfully, run the nightly programs tests...
936#
Misha Brukmanafa1e862009-01-02 16:28:18 +0000937# A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000938# "External")
939#
940##############################################################
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000941
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000942sub TestDirectory {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000943 my $SubDir = shift;
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000944 ChangeDir( "$LLVMTestDir/$SubDir",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000945 "Programs Test Subdirectory" ) || return ("", "");
Misha Brukmanafa1e862009-01-02 16:28:18 +0000946
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000947 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000948
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000949 # Run the programs tests... creating a report.nightly.csv file
950 if (!$NOTEST) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000951 if( $VERBOSE) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000952 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
Bill Wendling085ff3f2009-07-16 22:59:17 +0000953 "$TESTFLAGS TEST=nightly > $ProgramTestLog 2>&1\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000954 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000955 RunLoggedCommand("$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
Bill Wendling085ff3f2009-07-16 22:59:17 +0000956 "$TESTFLAGS TEST=nightly",
957 $ProgramTestLog, "TEST DIRECTORY $SubDir");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000958 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
Misha Brukmanafa1e862009-01-02 16:28:18 +0000959 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000960
961 my $ProgramsTable;
962 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
963 $TestError = 1;
964 $ProgramsTable="Error running test $SubDir\n";
965 print "ERROR TESTING\n";
966 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
967 $TestError = 1;
968 $ProgramsTable="Makefile error running tests $SubDir!\n";
969 print "ERROR TESTING\n";
970 } else {
971 $TestError = 0;
972 #
973 # Create a list of the tests which were run...
974 #
975 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
976 "| sort > $Prefix-$SubDir-Tests.txt";
977 }
978 $ProgramsTable = ReadFile "report.nightly.csv";
979
980 ChangeDir( "../../..", "Programs Test Parent Directory" );
981 return ($ProgramsTable, $llcbeta_options);
982} #end sub TestDirectory
983
984##############################################################
985#
986# Calling sub TestDirectory
987#
988##############################################################
989if (!$BuildError) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000990 ($SingleSourceProgramsTable, $llcbeta_options) =
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000991 TestDirectory("SingleSource");
992 WriteFile "$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000993 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
994 WriteFile "$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
995 if ( ! $NOEXTERNALS ) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000996 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
997 WriteFile "$Prefix-External-Performance.txt", $ExternalProgramsTable;
Misha Brukmanafa1e862009-01-02 16:28:18 +0000998 system "cat $Prefix-SingleSource-Tests.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000999 "$Prefix-MultiSource-Tests.txt ".
1000 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +00001001 system "cat $Prefix-SingleSource-Performance.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001002 "$Prefix-MultiSource-Performance.txt ".
1003 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
1004 } else {
1005 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
1006 if ( $VERBOSE ) {
1007 print "External TEST STAGE SKIPPED\n";
1008 }
Misha Brukmanafa1e862009-01-02 16:28:18 +00001009 system "cat $Prefix-SingleSource-Tests.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001010 "$Prefix-MultiSource-Tests.txt ".
1011 " | sort > $Prefix-Tests.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +00001012 system "cat $Prefix-SingleSource-Performance.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001013 "$Prefix-MultiSource-Performance.txt ".
1014 " | sort > $Prefix-Performance.txt";
1015 }
1016
1017 ##############################################################
1018 #
Misha Brukmanafa1e862009-01-02 16:28:18 +00001019 #
1020 # gathering tests added removed broken information here
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001021 #
1022 #
1023 ##############################################################
1024 my $dejagnu_test_list = ReadFile "$Prefix-Tests.txt";
1025 my @DEJAGNU = split "\n", $dejagnu_test_list;
1026 my ($passes, $fails, $xfails) = "";
1027
1028 if(!$NODEJAGNU) {
1029 for ($x=0; $x<@DEJAGNU; $x++) {
1030 if ($DEJAGNU[$x] =~ m/^PASS:/) {
1031 $passes.="$DEJAGNU[$x]\n";
1032 }
1033 elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
1034 $fails.="$DEJAGNU[$x]\n";
1035 }
1036 elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
1037 $xfails.="$DEJAGNU[$x]\n";
1038 }
1039 }
1040 }
Misha Brukmanafa1e862009-01-02 16:28:18 +00001041
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001042} #end if !$BuildError
1043
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001044##############################################################
1045#
1046# Getting end timestamp
1047#
1048##############################################################
1049$endtime = `date "+20%y-%m-%d %H:%M:%S"`;
1050
1051
1052##############################################################
1053#
1054# Place all the logs neatly into one humungous file
1055#
1056##############################################################
1057if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
1058
Misha Brukmanafa1e862009-01-02 16:28:18 +00001059$machine_data = "uname: ".`uname -a`.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001060 "hardware: ".`uname -m`.
1061 "os: ".`uname -sr`.
1062 "name: ".`uname -n`.
1063 "date: ".`date \"+20%y-%m-%d\"`.
Misha Brukmanafa1e862009-01-02 16:28:18 +00001064 "time: ".`date +\"%H:%M:%S\"`;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001065
1066my @CVS_DATA;
1067my $cvs_data;
1068@CVS_DATA = ReadFile "$COLog";
1069$cvs_data = join("\n", @CVS_DATA);
1070
1071my @BUILD_DATA;
1072my $build_data;
1073@BUILD_DATA = ReadFile "$BuildLog";
1074$build_data = join("\n", @BUILD_DATA);
1075
1076my (@DEJAGNU_LOG, @DEJAGNU_SUM, @DEJAGNULOG_FULL, @GCC_VERSION);
1077my ($dejagnutests_log ,$dejagnutests_sum, $dejagnulog_full) = "";
1078my ($gcc_version, $gcc_version_long) = "";
1079
1080$gcc_version_long="";
1081if ($GCCPATH ne "") {
1082 $gcc_version_long = `$GCCPATH/gcc --version`;
1083} elsif ($ENV{"CC"}) {
1084 $gcc_version_long = `$ENV{"CC"} --version`;
1085} else {
1086 $gcc_version_long = `gcc --version`;
1087}
1088@GCC_VERSION = split '\n', $gcc_version_long;
1089$gcc_version = $GCC_VERSION[0];
1090
1091$llvmgcc_version_long="";
1092if ($LLVMGCCPATH ne "") {
1093 $llvmgcc_version_long = `$LLVMGCCPATH/llvm-gcc -v 2>&1`;
1094} else {
1095 $llvmgcc_version_long = `llvm-gcc -v 2>&1`;
1096}
1097@LLVMGCC_VERSION = split '\n', $llvmgcc_version_long;
1098$llvmgcc_versionTarget = $LLVMGCC_VERSION[1];
1099$llvmgcc_versionTarget =~ /Target: (.+)/;
1100$targetTriple = $1;
1101
1102if(!$BuildError){
1103 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
1104 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
1105 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
1106 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
1107
1108 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
1109 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
1110}
1111
1112##############################################################
1113#
1114# Send data via a post request
1115#
1116##############################################################
1117
1118if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
1119
1120my %hash_of_data = (
1121 'machine_data' => $machine_data,
1122 'build_data' => $build_data,
1123 'gcc_version' => $gcc_version,
1124 'nickname' => $nickname,
1125 'dejagnutime_wall' => $DejagnuWallTime,
1126 'dejagnutime_cpu' => $DejagnuTime,
1127 'cvscheckouttime_wall' => $CheckoutTime_Wall,
1128 'cvscheckouttime_cpu' => $CheckoutTime_CPU,
1129 'configtime_wall' => $ConfigWallTime,
1130 'configtime_cpu'=> $ConfigTime,
1131 'buildtime_wall' => $BuildWallTime,
1132 'buildtime_cpu' => $BuildTime,
1133 'warnings' => $WarningsFile,
1134 'cvsusercommitlist' => $UserCommitList,
1135 'cvsuserupdatelist' => $UserUpdateList,
1136 'cvsaddedfiles' => $CVSAddedFiles,
1137 'cvsmodifiedfiles' => $CVSModifiedFiles,
1138 'cvsremovedfiles' => $CVSRemovedFiles,
1139 'lines_of_code' => $LOC,
1140 'cvs_file_count' => $NumFilesInCVS,
1141 'cvs_dir_count' => $NumDirsInCVS,
1142 'buildstatus' => $BuildStatus,
1143 'singlesource_programstable' => $SingleSourceProgramsTable,
1144 'multisource_programstable' => $MultiSourceProgramsTable,
1145 'externalsource_programstable' => $ExternalProgramsTable,
1146 'llcbeta_options' => $multisource_llcbeta_options,
1147 'warnings_removed' => $WarningsRemoved,
1148 'warnings_added' => $WarningsAdded,
1149 'passing_tests' => $passes,
1150 'expfail_tests' => $xfails,
1151 'unexpfail_tests' => $fails,
1152 'all_tests' => $dejagnu_test_list,
1153 'new_tests' => "",
1154 'removed_tests' => "",
1155 'dejagnutests_results' => $DejagnuTestResults,
1156 'dejagnutests_log' => $dejagnulog_full,
1157 'starttime' => $starttime,
1158 'endtime' => $endtime,
1159 'o_file_sizes' => $o_file_sizes,
1160 'a_file_sizes' => $a_file_sizes,
1161 'target_triple' => $targetTriple
1162);
1163
Daniel Dunbar3b377ef2009-06-26 22:33:28 +00001164if ($SUBMIT || !($SUBMITAUX eq "")) {
Tanya Lattner084a3ee2008-03-10 07:28:08 +00001165 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
1166 if( $VERBOSE) { print "============================\n$response"; }
1167} else {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001168 print "============================\n";
1169 foreach $x(keys %hash_of_data){
1170 print "$x => $hash_of_data{$x}\n";
1171 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001172}
1173
1174##############################################################
1175#
1176# Remove the cvs tree...
1177#
1178##############################################################
Misha Brukmanafa1e862009-01-02 16:28:18 +00001179system ( "$NICE rm -rf $BuildDir")
Daniel Dunbard3ecefe2009-07-13 22:17:49 +00001180 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVEATEND);
Misha Brukmanafa1e862009-01-02 16:28:18 +00001181system ( "$NICE rm -rf $WebDir")
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001182 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);