blob: b29b6e735e0af359c15f6ee2b98be3175e791fbe [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)
Daniel Dunbarae3faf12009-10-19 09:18:24 +000053# -with-clang Checkout Clang source into tools/clang.
54# -compileflags Next argument specifies extra options passed to make when
55# building LLVM.
56# -use-gmake Use gmake instead of the default make command to build
57# llvm and run tests.
58#
59# TESTING OPTIONS:
60# -notest Do not even attempt to run the test programs.
61# -nodejagnu Do not run feature or regression tests
62# -enable-llcbeta Enable testing of beta features in llc.
63# -enable-lli Enable testing of lli (interpreter) features, default is off
64# -disable-pic Disable building with Position Independent Code.
65# -disable-llc Disable LLC tests in the nightly tester.
66# -disable-jit Disable JIT tests in the nightly tester.
67# -disable-cbe Disable C backend tests in the nightly tester.
68# -disable-lto Disable link time optimization.
69# -test-cflags Next argument specifies that C compilation options that
70# override the default when running the testsuite.
71# -test-cxxflags Next argument specifies that C++ compilation options that
72# override the default when running the testsuite.
73# -extraflags Next argument specifies extra options that are passed to
74# compile the tests.
75# -noexternals Do not run the external tests (for cases where povray
76# or SPEC are not installed)
77# -with-externals Specify a directory where the external tests are located.
78#
79# OTHER OPTIONS:
80# -parallel Run parallel jobs with GNU Make (see -parallel-jobs).
81# -parallel-jobs The number of parallel Make jobs to use (default is two).
82# -verbose Turn on some debug output
Daniel Dunbarae3faf12009-10-19 09:18:24 +000083# -nice Checkout/Configure/Build with "nice" to reduce impact
84# on busy servers.
85# -f2c Next argument specifies path to F2C utility
86# -gccpath Path to gcc/g++ used to build LLVM
87# -target Specify the target triplet
88# -cflags Next argument specifies that C compilation options that
89# override the default.
90# -cxxflags Next argument specifies that C++ compilation options that
91# override the default.
92# -ldflags Next argument specifies that linker options that override
93# the default.
94#
Dan Gohmanf17a25c2007-07-18 16:29:46 +000095# CVSROOT is the CVS repository from which the tree will be checked out,
96# specified either in the full :method:user@host:/dir syntax, or
97# just /dir if using a local repo.
98# BUILDDIR is the directory where sources for this test run will be checked out
99# AND objects for this test run will be built. This directory MUST NOT
100# exist before the script is run; it will be created by the cvs checkout
101# process and erased (unless -noremove is specified; see above.)
102# WEBDIR is the directory into which the test results web page will be written,
103# AND in which the "index.html" is assumed to be a symlink to the most recent
104# copy of the results. This directory will be created if it does not exist.
105# LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
106# to. This is the same as you would have for a normal LLVM build.
107#
108##############################################################
109#
110# Getting environment variables
111#
112##############################################################
113my $HOME = $ENV{'HOME'};
114my $SVNURL = $ENV{"SVNURL"};
Duncan Sands01388f92009-06-12 13:02:52 +0000115$SVNURL = 'http://llvm.org/svn/llvm-project' unless $SVNURL;
Evan Chengb6d7fc32009-06-18 21:39:50 +0000116my $TestSVNURL = $ENV{"TestSVNURL"};
Evan Chenge45329e2009-07-14 06:23:41 +0000117$TestSVNURL = 'http://llvm.org/svn/llvm-project' unless $TestSVNURL;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000118my $CVSRootDir = $ENV{'CVSROOT'};
119$CVSRootDir = "/home/vadve/shared/PublicCVS" unless $CVSRootDir;
120my $BuildDir = $ENV{'BUILDDIR'};
121$BuildDir = "$HOME/buildtest" unless $BuildDir;
122my $WebDir = $ENV{'WEBDIR'};
123$WebDir = "$HOME/cvs/testresults-X86" unless $WebDir;
124
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000125my $LLVMSrcDir = $ENV{'LLVMSRCDIR'};
126$LLVMSrcDir = "$BuildDir/llvm" unless $LLVMSrcDir;
127my $LLVMObjDir = $ENV{'LLVMOBJDIR'};
128$LLVMObjDir = "$BuildDir/llvm" unless $LLVMObjDir;
129my $LLVMTestDir = $ENV{'LLVMTESTDIR'};
130$LLVMTestDir = "$BuildDir/llvm/projects/llvm-test" unless $LLVMTestDir;
131
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000132##############################################################
133#
134# Calculate the date prefix...
135#
136##############################################################
137@TIME = localtime;
Daniel Dunbar93ad6a82009-07-01 14:52:59 +0000138my $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 +0000139
140##############################################################
141#
142# Parse arguments...
143#
144##############################################################
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000145$CONFIG_PATH="";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000146$CONFIGUREARGS="";
147$nickname="";
148$NOTEST=0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000149$MAKECMD="make";
150$SUBMITSERVER = "llvm.org";
151$SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
Daniel Dunbar016a4bb2009-05-18 23:24:26 +0000152$SUBMITAUX="";
Tanya Lattner084a3ee2008-03-10 07:28:08 +0000153$SUBMIT = 1;
Daniel Dunbarf8cdaec2009-05-28 22:45:24 +0000154$PARALLELJOBS = "2";
Bill Wendling085ff3f2009-07-16 22:59:17 +0000155my $TESTFLAGS="";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000156
157while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
158 shift;
159 last if /^--$/; # Stop processing arguments on --
160
161 # List command line options here...
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000162 if (/^-config$/) { $CONFIG_PATH = "$ARGV[0]"; shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000163 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
164 if (/^-nocvsstats$/) { $NOCVSSTATS = 1; next; }
165 if (/^-noremove$/) { $NOREMOVE = 1; next; }
Daniel Dunbard3ecefe2009-07-13 22:17:49 +0000166 if (/^-noremoveatend$/) { $NOREMOVEATEND = 1; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000167 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
Daniel Dunbar2041d9a2009-06-02 21:14:15 +0000168 if (/^-notest$/) { $NOTEST = 1; next; }
169 if (/^-norunningtests$/) { next; } # Backward compatibility, ignored.
Daniel Dunbarf8cdaec2009-05-28 22:45:24 +0000170 if (/^-parallel-jobs$/) { $PARALLELJOBS = "$ARGV[0]"; shift; next;}
171 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j$PARALLELJOBS -l3.0"; next; }
Duncan Sands01388f92009-06-12 13:02:52 +0000172 if (/^-with-clang$/) { $WITHCLANG = 1; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000173 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
174 "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
175 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
Dan Gohmanbd399762008-10-30 01:08:03 +0000176 "DISABLE_ASSERTIONS=1 ".
Misha Brukmanafa1e862009-01-02 16:28:18 +0000177 "OPTIMIZE_OPTION=-O2";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000178 $BUILDTYPE="release-asserts"; next;}
179 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
Duncan Sands01388f92009-06-12 13:02:52 +0000180 if (/^-disable-pic$/) { $CONFIGUREARGS .= " --enable-pic=no"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000181 if (/^-enable-lli$/) { $PROGTESTOPTS .= " ENABLE_LLI=1";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000182 $CONFIGUREARGS .= " --enable-lli"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000183 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000184 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000185 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
186 $CONFIGUREARGS .= " --disable-jit"; next; }
Daniel Dunbar31a1f1c2009-03-10 19:33:13 +0000187 if (/^-disable-bindings$/) { $CONFIGUREARGS .= " --disable-bindings"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000188 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
Evan Cheng32efae02008-01-12 04:27:18 +0000189 if (/^-disable-lto$/) { $PROGTESTOPTS .= " DISABLE_LTO=1"; next; }
Evan Cheng08206772008-01-14 17:58:03 +0000190 if (/^-test-opts$/) { $PROGTESTOPTS .= " $ARGV[0]"; shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000191 if (/^-verbose$/) { $VERBOSE = 1; next; }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000192 if (/^-teelogs$/) { $TEELOGS = 1; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000193 if (/^-nice$/) { $NICE = "nice "; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000194 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000195 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000196 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000197 shift; next; }
Daniel Dunbardd9c4aa2009-07-13 22:31:58 +0000198 if (/^-configure-args$/) { $CONFIGUREARGS .= " $ARGV[0]";
199 shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000200 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
201 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
Daniel Dunbar016a4bb2009-05-18 23:24:26 +0000202 if (/^-submit-aux/) { $SUBMITAUX = "$ARGV[0]"; shift; next; }
Tanya Lattner084a3ee2008-03-10 07:28:08 +0000203 if (/^-nosubmit$/) { $SUBMIT = 0; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000204 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
205 if (/^-gccpath/) { $CONFIGUREARGS .=
206 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000207 $GCCPATH=$ARGV[0]; shift; next; }
208 else { $GCCPATH=""; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000209 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000210 else { $CVSCOOPT="";}
Misha Brukmanafa1e862009-01-02 16:28:18 +0000211 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000212 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000213 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000214 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000215 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000216 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000217 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000218 shift; next; }
Bill Wendling085ff3f2009-07-16 22:59:17 +0000219 if (/^-test-cflags/) { $TESTFLAGS = "$TESTFLAGS CFLAGS=\'$ARGV[0]\'";
220 shift; next; }
221 if (/^-test-cxxflags/) { $TESTFLAGS = "$TESTFLAGS CXXFLAGS=\'$ARGV[0]\'";
222 shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000223 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
224 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000225 if (/^-extraflags/) { $CONFIGUREARGS .=
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000226 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
227 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
228 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
229 if (/^-nobuild$/) { $NOBUILD = 1; next; }
230 print "Unknown option: $_ : ignoring!\n";
231}
232
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000233if (!($CONFIG_PATH eq "")) {
234 die "error: -config mode is not yet implemented,";
235}
236
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000237if ($ENV{'LLVMGCCDIR'}) {
238 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
Bob Wilsonc6d296b2009-03-12 19:47:24 +0000239 $LLVMGCCPATH = $ENV{'LLVMGCCDIR'} . '/bin';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000240}
241else {
242 $LLVMGCCPATH = "";
243}
244
245if ($CONFIGUREARGS !~ /--disable-jit/) {
246 $CONFIGUREARGS .= " --enable-jit";
247}
248
249if (@ARGV != 0 and @ARGV != 3 and $VERBOSE) {
250 foreach $x (@ARGV) {
251 print "$x\n";
252 }
253 print "Must specify 0 or 3 options!";
254}
255
256if (@ARGV == 3) {
257 $CVSRootDir = $ARGV[0];
258 $BuildDir = $ARGV[1];
259 $WebDir = $ARGV[2];
260}
261
262if ($CVSRootDir eq "" or
263 $BuildDir eq "" or
264 $WebDir eq "") {
265 die("please specify a cvs root directory, a build directory, and a ".
266 "web directory");
267 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000268
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000269if ($nickname eq "") {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000270 die ("Please invoke NewNightlyTest.pl with command line option " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000271 "\"-nickname <nickname>\"");
272}
273
274if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
275 $BUILDTYPE = "debug";
276}
277
278##############################################################
279#
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000280# Define the file names we'll use
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000281#
282##############################################################
283my $Prefix = "$WebDir/$DATE";
284my $BuildLog = "$Prefix-Build-Log.txt";
285my $COLog = "$Prefix-CVS-Log.txt";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000286my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
287my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
288my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
289my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
290my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
291my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
292if (! -d $WebDir) {
293 mkdir $WebDir, 0777;
294 if($VERBOSE){
295 warn "$WebDir did not exist; creating it.\n";
296 }
297}
298
299if ($VERBOSE) {
300 print "INITIALIZED\n";
Daniel Dunbaraffc0a52009-10-19 09:18:46 +0000301 print "SVN URL = $SVNURL\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000302 print "COLog = $COLog\n";
303 print "BuildDir = $BuildDir\n";
304 print "WebDir = $WebDir\n";
305 print "Prefix = $Prefix\n";
306 print "BuildLog = $BuildLog\n";
307}
308
309##############################################################
310#
311# Helper functions
312#
313##############################################################
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000314
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000315sub GetDir {
316 my $Suffix = shift;
317 opendir DH, $WebDir;
318 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
319 closedir DH;
320 return @Result;
321}
322
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000323sub RunLoggedCommand {
324 my $Command = shift;
325 my $Log = shift;
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000326 my $Title = shift;
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000327 if ($TEELOGS) {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000328 if ($VERBOSE) {
329 print "$Title\n";
330 print "$Command 2>&1 | tee $Log\n";
331 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000332 system "$Command 2>&1 | tee $Log";
333 } else {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000334 if ($VERBOSE) {
335 print "$Title\n";
336 print "$Command 2>&1 > $Log\n";
337 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000338 system "$Command 2>&1 > $Log";
339 }
340}
341
342sub RunAppendingLoggedCommand {
343 my $Command = shift;
344 my $Log = shift;
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000345 my $Title = shift;
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000346 if ($TEELOGS) {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000347 if ($VERBOSE) {
348 print "$Title\n";
349 print "$Command 2>&1 | tee -a $Log\n";
350 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000351 system "$Command 2>&1 | tee -a $Log";
352 } else {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000353 if ($VERBOSE) {
354 print "$Title\n";
355 print "$Command 2>&1 > $Log\n";
356 }
357 system "$Command 2>&1 >> $Log";
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000358 }
359}
360
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000361#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
362#
363# DiffFiles - Diff the current version of the file against the last version of
364# the file, reporting things added and removed. This is used to report, for
365# example, added and removed warnings. This returns a pair (added, removed)
366#
367#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
368sub DiffFiles {
369 my $Suffix = shift;
370 my @Others = GetDir $Suffix;
371 if (@Others == 0) { # No other files? We added all entries...
372 return (`cat $WebDir/$DATE$Suffix`, "");
373 }
374# Diff the files now...
375 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
376 my $Added = join "\n", grep /^</, @Diffs;
377 my $Removed = join "\n", grep /^>/, @Diffs;
378 $Added =~ s/^< //gm;
379 $Removed =~ s/^> //gm;
380 return ($Added, $Removed);
381}
382
383#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
384#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
385sub GetRegex { # (Regex with ()'s, value)
386 $_[1] =~ /$_[0]/m;
Misha Brukmanafa1e862009-01-02 16:28:18 +0000387 return $1
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000388 if (defined($1));
389 return "0";
390}
391
392#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
393#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
394sub GetRegexNum {
395 my ($Regex, $Num, $Regex2, $File) = @_;
396 my @Items = split "\n", `grep '$Regex' $File`;
397 return GetRegex $Regex2, $Items[$Num];
398}
399
400#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
401#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
402sub ChangeDir { # directory, logical name
403 my ($dir,$name) = @_;
404 chomp($dir);
405 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
406 $result = chdir($dir);
407 if (!$result) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000408 print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000409 return false;
410 }
411 return true;
412}
413
414#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
415#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
416sub ReadFile {
417 if (open (FILE, $_[0])) {
418 undef $/;
419 my $Ret = <FILE>;
420 close FILE;
421 $/ = '\n';
422 return $Ret;
423 } else {
424 print "Could not open file '$_[0]' for reading!\n";
425 return "";
426 }
427}
428
429#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
430#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
431sub WriteFile { # (filename, contents)
432 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
433 print FILE $_[1];
434 close FILE;
435}
436
437#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
438#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
439sub CopyFile { #filename, newfile
440 my ($file, $newfile) = @_;
441 chomp($file);
442 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
443 copy($file, $newfile);
444}
445
446#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
447#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
448sub AddRecord {
449 my ($Val, $Filename,$WebDir) = @_;
450 my @Records;
451 if (open FILE, "$WebDir/$Filename") {
452 @Records = grep !/$DATE/, split "\n", <FILE>;
453 close FILE;
454 }
455 push @Records, "$DATE: $Val";
456 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
457}
458
459#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
460#
461# FormatTime - Convert a time from 1m23.45 into 83.45
462#
463#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
464sub FormatTime {
465 my $Time = shift;
466 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
467 $Time = sprintf("%7.4f", $1*60.0+$2);
468 }
469 return $Time;
470}
471
472#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
473#
Misha Brukmanafa1e862009-01-02 16:28:18 +0000474# This function is meant to read in the dejagnu sum file and
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000475# return a string with only the results (i.e. PASS/FAIL/XPASS/
476# XFAIL).
477#
478#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
479sub GetDejagnuTestResults { # (filename, log)
480 my ($filename, $DejagnuLog) = @_;
481 my @lines;
482 $/ = "\n"; #Make sure we're going line at a time.
483
484 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
485
486 if (open SRCHFILE, $filename) {
487 # Process test results
488 while ( <SRCHFILE> ) {
489 if ( length($_) > 1 ) {
490 chomp($_);
491 if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\/test\/(.*)$/ ) {
492 push(@lines, "$1: test/$2");
493 }
494 }
495 }
496 }
497 close SRCHFILE;
498
499 my $content = join("\n", @lines);
500 return $content;
501}
502
503
504
505#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
506#
507# This function acts as a mini web browswer submitting data
508# to our central server via the post method
509#
510#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000511sub SendData {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000512 $host = $_[0];
513 $file = $_[1];
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000514 $variables = $_[2];
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000515
Daniel Dunbara2533002009-05-28 18:31:40 +0000516 # Write out the "...-sentdata.txt" file.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000517
Daniel Dunbara2533002009-05-28 18:31:40 +0000518 my $sentdata="";
519 foreach $x (keys (%$variables)){
520 $value = $variables->{$x};
521 $sentdata.= "$x => $value\n";
522 }
523 WriteFile "$Prefix-sentdata.txt", $sentdata;
524
525 if (!($SUBMITAUX eq "")) {
Daniel Dunbar3b377ef2009-06-26 22:33:28 +0000526 system "$SUBMITAUX \"$Prefix-sentdata.txt\"";
527 }
528
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000529 if (!$SUBMIT) {
Daniel Dunbar3b377ef2009-06-26 22:33:28 +0000530 return "Skipped standard submit.\n";
Daniel Dunbara2533002009-05-28 18:31:40 +0000531 }
532
533 # Create the content to send to the server.
534
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000535 my $content;
536 foreach $key (keys (%$variables)){
537 $value = $variables->{$key};
538 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
539 $content .= "$key=$value&";
540 }
541
Daniel Dunbara2533002009-05-28 18:31:40 +0000542 # Send the data to the server.
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000543 #
Daniel Dunbara2533002009-05-28 18:31:40 +0000544 # FIXME: This code should be more robust?
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000545
Daniel Dunbara2533002009-05-28 18:31:40 +0000546 $port=80;
547 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
548 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
549 die "Bad socket\n";
550 connect SOCK, $socketaddr or die "Bad connection\n";
551 select((select(SOCK), $| = 1)[0]);
552
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000553 $length = length($content);
554
555 my $send= "POST $file HTTP/1.0\n";
556 $send.= "Host: $host\n";
557 $send.= "Content-Type: application/x-www-form-urlencoded\n";
558 $send.= "Content-length: $length\n\n";
559 $send.= "$content";
560
561 print SOCK $send;
562 my $result;
563 while(<SOCK>){
564 $result .= $_;
565 }
566 close(SOCK);
567
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000568 return $result;
569}
570
571##############################################################
572#
573# Getting Start timestamp
574#
575##############################################################
576$starttime = `date "+20%y-%m-%d %H:%M:%S"`;
577
578##############################################################
579#
580# Create the CVS repository directory
581#
582##############################################################
583if (!$NOCHECKOUT) {
584 if (-d $BuildDir) {
585 if (!$NOREMOVE) {
586 if ( $VERBOSE ) {
587 print "Build directory exists! Removing it\n";
588 }
589 system "rm -rf $BuildDir";
590 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
591 } else {
592 if ( $VERBOSE ) {
593 print "Build directory exists!\n";
594 }
595 }
596 } else {
597 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
598 }
599}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000600
601
602##############################################################
603#
Misha Brukmanafa1e862009-01-02 16:28:18 +0000604# Check out the llvm tree, using either SVN or CVS
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000605#
606##############################################################
607if (!$NOCHECKOUT) {
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000608 ChangeDir( $BuildDir, "checkout directory" );
Daniel Dunbaraffc0a52009-10-19 09:18:46 +0000609 my $SVNCMD = "$NICE svn co --non-interactive $SVNURL";
610 my $SVNCMD2 = "$NICE svn co --non-interactive $TestSVNURL";
611 RunLoggedCommand("( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
612 "$SVNCMD2/test-suite/trunk llvm-test )", $COLog,
613 "CHECKOUT LLVM");
614 if ($WITHCLANG) {
615 my $SVNCMD = "$NICE svn co --non-interactive $SVNURL/cfe/trunk";
616 RunLoggedCommand("( time -p cd llvm/tools ; $SVNCMD clang )", $COLog,
617 "CHECKOUT CLANG");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000618 }
619}
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000620ChangeDir( $LLVMSrcDir , "llvm source directory") ;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000621
622##############################################################
623#
624# Get some static statistics about the current state of CVS
625#
626# This can probably be put on the server side
627#
628##############################################################
629my $CheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $COLog`;
630my $CheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $COLog`;
631my $CheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $COLog`;
632my $CheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
633
634my $NumFilesInCVS = 0;
635my $NumDirsInCVS = 0;
Daniel Dunbaraffc0a52009-10-19 09:18:46 +0000636$NumFilesInCVS = `egrep '^A' $COLog | wc -l` + 0;
637$NumDirsInCVS = `sed -e 's#/[^/]*\$##' $COLog | sort | uniq | wc -l` + 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000638
639##############################################################
640#
641# Extract some information from the CVS history... use a hash so no duplicate
642# stuff is stored. This gets the history from the previous days worth
643# of cvs activity and parses it.
644#
645##############################################################
646
647# This just computes a reasonably accurate #of seconds since 2000. It doesn't
648# have to be perfect as its only used for comparing date ranges within a couple
649# of days.
650sub ConvertToSeconds {
651 my ($sec, $min, $hour, $day, $mon, $yr) = @_;
652 my $Result = ($yr - 2000) * 12;
653 $Result += $mon;
654 $Result *= 31;
655 $Result += $day;
656 $Result *= 24;
657 $Result += $hour;
658 $Result *= 60;
659 $Result += $min;
660 $Result *= 60;
661 $Result += $sec;
662 return $Result;
663}
664
665my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
666
667if (!$NOCVSSTATS) {
668 if ($VERBOSE) { print "CHANGE HISTORY ANALYSIS STAGE\n"; }
669
Daniel Dunbaraffc0a52009-10-19 09:18:46 +0000670 @SVNHistory = split /<logentry/, `svn log --non-interactive --xml --verbose -r{$DATE}:HEAD`;
671 # Skip very first entry because it is the XML header cruft
672 shift @SVNHistory;
673 my $Now = time();
674 foreach $Record (@SVNHistory) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000675 my @Lines = split "\n", $Record;
676 my ($Author, $Date, $Revision);
677 # Get the date and see if its one we want to process.
678 my ($Year, $Month, $Day, $Hour, $Min, $Sec);
679 if ($Lines[3] =~ /<date>(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/){
Daniel Dunbaraffc0a52009-10-19 09:18:46 +0000680 $Year = $1; $Month = $2; $Day = $3; $Hour = $4; $Min = $5; $Sec = $6;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000681 }
682 my $Then = ConvertToSeconds($Sec, $Min, $Hour, $Day, $Month, $Year);
683 # Get the current date and compute when "yesterday" is.
684 my ($NSec, $NMin, $NHour, $NDay, $NMon, $NYear) = gmtime();
685 my $Now = ConvertToSeconds( $NSec, $NMin, $NHour, $NDay, $NMon, $NYear);
686 if (($Now - 24*60*60) > $Then) {
Daniel Dunbaraffc0a52009-10-19 09:18:46 +0000687 next;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000688 }
689 if ($Lines[1] =~ / revision="([0-9]*)">/) {
Daniel Dunbaraffc0a52009-10-19 09:18:46 +0000690 $Revision = $1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000691 }
692 if ($Lines[2] =~ /<author>([^<]*)<\/author>/) {
Daniel Dunbaraffc0a52009-10-19 09:18:46 +0000693 $Author = $1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000694 }
695 $UsersCommitted{$Author} = 1;
696 $Date = $Year . "-" . $Month . "-" . $Day;
697 $Time = $Hour . ":" . $Min . ":" . $Sec;
698 print "Rev: $Revision, Author: $Author, Date: $Date, Time: $Time\n";
699 for ($i = 6; $i < $#Lines; $i += 2 ) {
Daniel Dunbaraffc0a52009-10-19 09:18:46 +0000700 if ($Lines[$i] =~ /^ action="(.)">([^<]*)</) {
701 if ($1 == "A") {
702 $AddedFiles{$2} = 1;
703 } elsif ($1 == 'D') {
704 $RemovedFiles{$2} = 1;
705 } elsif ($1 == 'M' || $1 == 'R' || $1 == 'C') {
706 $ModifiedFiles{$2} = 1;
707 } else {
708 print "UNMATCHABLE: $Lines[$i]\n";
709 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000710 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000711 }
Daniel Dunbaraffc0a52009-10-19 09:18:46 +0000712 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000713}#!NOCVSSTATS
714
715my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
716my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
717my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
718my $UserCommitList = join "\n", sort keys %UsersCommitted;
719my $UserUpdateList = join "\n", sort keys %UsersUpdated;
720
721##############################################################
722#
723# Build the entire tree, saving build messages to the build log
724#
725##############################################################
726if (!$NOCHECKOUT && !$NOBUILD) {
727 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000728 RunLoggedCommand("(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) ",
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000729 $BuildLog, "CONFIGURE");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000730 # Build the entire tree, capturing the output into $BuildLog
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000731 RunAppendingLoggedCommand("(time -p $NICE $MAKECMD clean)", $BuildLog, "BUILD CLEAN");
732 RunAppendingLoggedCommand("(time -p $NICE $MAKECMD $MAKEOPTS)", $BuildLog, "BUILD");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000733}
734
735##############################################################
736#
737# Get some statistics about the build...
738#
739##############################################################
740#this can de done on server
741#my @Linked = split '\n', `grep Linking $BuildLog`;
742#my $NumExecutables = scalar(grep(/executable/, @Linked));
743#my $NumLibraries = scalar(grep(!/executable/, @Linked));
744#my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
745
746# Get the number of lines of source code. Must be here after the build is done
747# because countloc.sh uses the llvm-config script which must be built.
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000748my $LOC = `utils/countloc.sh -topdir $LLVMSrcDir`;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000749
750# Get the time taken by the configure script
751my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
752my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
753my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
754my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
755
756$ConfigTime=-1 unless $ConfigTime;
757$ConfigWallTime=-1 unless $ConfigWallTime;
758
759my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
760my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
761my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
762my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
763
764$BuildTime=-1 unless $BuildTime;
765$BuildWallTime=-1 unless $BuildWallTime;
766
767my $BuildError = 0, $BuildStatus = "OK";
768if ($NOBUILD) {
769 $BuildStatus = "Skipped by user";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000770}
771elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
772 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
773 $BuildStatus = "Error: compilation aborted";
774 $BuildError = 1;
775 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
776}
777if ($BuildError) { $NODEJAGNU=1; }
778
779my $a_file_sizes="";
780my $o_file_sizes="";
781if (!$BuildError) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000782 print "Organizing size of .o and .a files\n"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000783 if ( $VERBOSE );
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000784 ChangeDir( "$LLVMObjDir", "Build Directory" );
Bob Wilson722d58b2009-06-19 17:19:38 +0000785
786 my @dirs = ('utils', 'lib', 'tools');
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000787 if($BUILDTYPE eq "release"){
Bob Wilson722d58b2009-06-19 17:19:38 +0000788 push @dirs, 'Release';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000789 } elsif($BUILDTYPE eq "release-asserts") {
Bob Wilson722d58b2009-06-19 17:19:38 +0000790 push @dirs, 'Release-Asserts';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000791 } else {
Bob Wilson722d58b2009-06-19 17:19:38 +0000792 push @dirs, 'Debug';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000793 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000794
Bob Wilson722d58b2009-06-19 17:19:38 +0000795 find(sub {
796 $a_file_sizes .= (-s $_)." $File::Find::name $BUILDTYPE\n" if /\.a$/i;
797 $o_file_sizes .= (-s $_)." $File::Find::name $BUILDTYPE\n" if /\.o$/i;
798 }, @dirs);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000799} else {
800 $a_file_sizes="No data due to a bad build.";
801 $o_file_sizes="No data due to a bad build.";
802}
803
804##############################################################
805#
806# Running dejagnu tests
807#
808##############################################################
809my $DejangnuTestResults=""; # String containing the results of the dejagnu
810my $dejagnu_output = "$DejagnuTestsLog";
811if (!$NODEJAGNU) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000812 #Run the feature and regression tests, results are put into testrun.sum
813 #Full log in testrun.log
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000814 RunLoggedCommand("(time -p $MAKECMD $MAKEOPTS check)", $dejagnu_output, "DEJAGNU");
Misha Brukmanafa1e862009-01-02 16:28:18 +0000815
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000816 #Copy the testrun.log and testrun.sum to our webdir
817 CopyFile("test/testrun.log", $DejagnuLog);
818 CopyFile("test/testrun.sum", $DejagnuSum);
819 #can be done on server
820 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
821 $unexpfail_tests = $DejagnuTestResults;
822}
823
824#Extract time of dejagnu tests
825my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
826my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
827$DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
Misha Brukmanafa1e862009-01-02 16:28:18 +0000828$DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
829$DejagnuTestResults =
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000830 "Dejagnu skipped by user choice." unless $DejagnuTestResults;
831$DejagnuTime = "0.0" unless $DejagnuTime;
832$DejagnuWallTime = "0.0" unless $DejagnuWallTime;
833
834##############################################################
835#
836# Get warnings from the build
837#
838##############################################################
839if (!$NODEJAGNU) {
840 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
841 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
842 my @Warnings;
843 my $CurDir = "";
844
845 foreach $Warning (@Warn) {
846 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
847 $CurDir = $1; # Keep track of directory warning is in...
848 # Remove buildir prefix if included
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000849 if ($CurDir =~ m#$LLVMSrcDir/(.*)#) { $CurDir = $1; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000850 } else {
851 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
852 }
853 }
854 my $WarningsFile = join "\n", @Warnings;
855 $WarningsFile =~ s/:[0-9]+:/::/g;
856
857 # Emit the warnings file, so we can diff...
858 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
859 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
860
861 # Output something to stdout if something has changed
862 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
863 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
864
865 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
866 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
867
868} #endif !NODEGAGNU
869
870##############################################################
871#
872# If we built the tree successfully, run the nightly programs tests...
873#
Misha Brukmanafa1e862009-01-02 16:28:18 +0000874# A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000875# "External")
876#
877##############################################################
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000878
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000879sub TestDirectory {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000880 my $SubDir = shift;
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000881 ChangeDir( "$LLVMTestDir/$SubDir",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000882 "Programs Test Subdirectory" ) || return ("", "");
Misha Brukmanafa1e862009-01-02 16:28:18 +0000883
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000884 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000885
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000886 # Run the programs tests... creating a report.nightly.csv file
887 if (!$NOTEST) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000888 if( $VERBOSE) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000889 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
Bill Wendling085ff3f2009-07-16 22:59:17 +0000890 "$TESTFLAGS TEST=nightly > $ProgramTestLog 2>&1\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000891 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000892 RunLoggedCommand("$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
Bill Wendling085ff3f2009-07-16 22:59:17 +0000893 "$TESTFLAGS TEST=nightly",
894 $ProgramTestLog, "TEST DIRECTORY $SubDir");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000895 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
Misha Brukmanafa1e862009-01-02 16:28:18 +0000896 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000897
898 my $ProgramsTable;
899 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
900 $TestError = 1;
901 $ProgramsTable="Error running test $SubDir\n";
902 print "ERROR TESTING\n";
903 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
904 $TestError = 1;
905 $ProgramsTable="Makefile error running tests $SubDir!\n";
906 print "ERROR TESTING\n";
907 } else {
908 $TestError = 0;
909 #
910 # Create a list of the tests which were run...
911 #
912 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
913 "| sort > $Prefix-$SubDir-Tests.txt";
914 }
915 $ProgramsTable = ReadFile "report.nightly.csv";
916
917 ChangeDir( "../../..", "Programs Test Parent Directory" );
918 return ($ProgramsTable, $llcbeta_options);
919} #end sub TestDirectory
920
921##############################################################
922#
923# Calling sub TestDirectory
924#
925##############################################################
926if (!$BuildError) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000927 ($SingleSourceProgramsTable, $llcbeta_options) =
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000928 TestDirectory("SingleSource");
929 WriteFile "$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000930 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
931 WriteFile "$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
932 if ( ! $NOEXTERNALS ) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000933 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
934 WriteFile "$Prefix-External-Performance.txt", $ExternalProgramsTable;
Misha Brukmanafa1e862009-01-02 16:28:18 +0000935 system "cat $Prefix-SingleSource-Tests.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000936 "$Prefix-MultiSource-Tests.txt ".
937 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000938 system "cat $Prefix-SingleSource-Performance.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000939 "$Prefix-MultiSource-Performance.txt ".
940 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
941 } else {
942 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
943 if ( $VERBOSE ) {
944 print "External TEST STAGE SKIPPED\n";
945 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000946 system "cat $Prefix-SingleSource-Tests.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000947 "$Prefix-MultiSource-Tests.txt ".
948 " | sort > $Prefix-Tests.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000949 system "cat $Prefix-SingleSource-Performance.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000950 "$Prefix-MultiSource-Performance.txt ".
951 " | sort > $Prefix-Performance.txt";
952 }
953
954 ##############################################################
955 #
Misha Brukmanafa1e862009-01-02 16:28:18 +0000956 #
957 # gathering tests added removed broken information here
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000958 #
959 #
960 ##############################################################
961 my $dejagnu_test_list = ReadFile "$Prefix-Tests.txt";
962 my @DEJAGNU = split "\n", $dejagnu_test_list;
963 my ($passes, $fails, $xfails) = "";
964
965 if(!$NODEJAGNU) {
966 for ($x=0; $x<@DEJAGNU; $x++) {
967 if ($DEJAGNU[$x] =~ m/^PASS:/) {
968 $passes.="$DEJAGNU[$x]\n";
969 }
970 elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
971 $fails.="$DEJAGNU[$x]\n";
972 }
973 elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
974 $xfails.="$DEJAGNU[$x]\n";
975 }
976 }
977 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000978
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000979} #end if !$BuildError
980
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000981##############################################################
982#
983# Getting end timestamp
984#
985##############################################################
986$endtime = `date "+20%y-%m-%d %H:%M:%S"`;
987
988
989##############################################################
990#
991# Place all the logs neatly into one humungous file
992#
993##############################################################
994if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
995
Misha Brukmanafa1e862009-01-02 16:28:18 +0000996$machine_data = "uname: ".`uname -a`.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000997 "hardware: ".`uname -m`.
998 "os: ".`uname -sr`.
999 "name: ".`uname -n`.
1000 "date: ".`date \"+20%y-%m-%d\"`.
Misha Brukmanafa1e862009-01-02 16:28:18 +00001001 "time: ".`date +\"%H:%M:%S\"`;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001002
1003my @CVS_DATA;
1004my $cvs_data;
1005@CVS_DATA = ReadFile "$COLog";
1006$cvs_data = join("\n", @CVS_DATA);
1007
1008my @BUILD_DATA;
1009my $build_data;
1010@BUILD_DATA = ReadFile "$BuildLog";
1011$build_data = join("\n", @BUILD_DATA);
1012
1013my (@DEJAGNU_LOG, @DEJAGNU_SUM, @DEJAGNULOG_FULL, @GCC_VERSION);
1014my ($dejagnutests_log ,$dejagnutests_sum, $dejagnulog_full) = "";
1015my ($gcc_version, $gcc_version_long) = "";
1016
1017$gcc_version_long="";
1018if ($GCCPATH ne "") {
1019 $gcc_version_long = `$GCCPATH/gcc --version`;
1020} elsif ($ENV{"CC"}) {
1021 $gcc_version_long = `$ENV{"CC"} --version`;
1022} else {
1023 $gcc_version_long = `gcc --version`;
1024}
1025@GCC_VERSION = split '\n', $gcc_version_long;
1026$gcc_version = $GCC_VERSION[0];
1027
1028$llvmgcc_version_long="";
1029if ($LLVMGCCPATH ne "") {
1030 $llvmgcc_version_long = `$LLVMGCCPATH/llvm-gcc -v 2>&1`;
1031} else {
1032 $llvmgcc_version_long = `llvm-gcc -v 2>&1`;
1033}
1034@LLVMGCC_VERSION = split '\n', $llvmgcc_version_long;
1035$llvmgcc_versionTarget = $LLVMGCC_VERSION[1];
1036$llvmgcc_versionTarget =~ /Target: (.+)/;
1037$targetTriple = $1;
1038
1039if(!$BuildError){
1040 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
1041 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
1042 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
1043 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
1044
1045 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
1046 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
1047}
1048
1049##############################################################
1050#
1051# Send data via a post request
1052#
1053##############################################################
1054
1055if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
1056
1057my %hash_of_data = (
1058 'machine_data' => $machine_data,
1059 'build_data' => $build_data,
1060 'gcc_version' => $gcc_version,
1061 'nickname' => $nickname,
1062 'dejagnutime_wall' => $DejagnuWallTime,
1063 'dejagnutime_cpu' => $DejagnuTime,
1064 'cvscheckouttime_wall' => $CheckoutTime_Wall,
1065 'cvscheckouttime_cpu' => $CheckoutTime_CPU,
1066 'configtime_wall' => $ConfigWallTime,
1067 'configtime_cpu'=> $ConfigTime,
1068 'buildtime_wall' => $BuildWallTime,
1069 'buildtime_cpu' => $BuildTime,
1070 'warnings' => $WarningsFile,
1071 'cvsusercommitlist' => $UserCommitList,
1072 'cvsuserupdatelist' => $UserUpdateList,
1073 'cvsaddedfiles' => $CVSAddedFiles,
1074 'cvsmodifiedfiles' => $CVSModifiedFiles,
1075 'cvsremovedfiles' => $CVSRemovedFiles,
1076 'lines_of_code' => $LOC,
1077 'cvs_file_count' => $NumFilesInCVS,
1078 'cvs_dir_count' => $NumDirsInCVS,
1079 'buildstatus' => $BuildStatus,
1080 'singlesource_programstable' => $SingleSourceProgramsTable,
1081 'multisource_programstable' => $MultiSourceProgramsTable,
1082 'externalsource_programstable' => $ExternalProgramsTable,
1083 'llcbeta_options' => $multisource_llcbeta_options,
1084 'warnings_removed' => $WarningsRemoved,
1085 'warnings_added' => $WarningsAdded,
1086 'passing_tests' => $passes,
1087 'expfail_tests' => $xfails,
1088 'unexpfail_tests' => $fails,
1089 'all_tests' => $dejagnu_test_list,
1090 'new_tests' => "",
1091 'removed_tests' => "",
1092 'dejagnutests_results' => $DejagnuTestResults,
1093 'dejagnutests_log' => $dejagnulog_full,
1094 'starttime' => $starttime,
1095 'endtime' => $endtime,
1096 'o_file_sizes' => $o_file_sizes,
1097 'a_file_sizes' => $a_file_sizes,
1098 'target_triple' => $targetTriple
1099);
1100
Daniel Dunbar3b377ef2009-06-26 22:33:28 +00001101if ($SUBMIT || !($SUBMITAUX eq "")) {
Tanya Lattner084a3ee2008-03-10 07:28:08 +00001102 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
1103 if( $VERBOSE) { print "============================\n$response"; }
1104} else {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001105 print "============================\n";
1106 foreach $x(keys %hash_of_data){
1107 print "$x => $hash_of_data{$x}\n";
1108 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001109}
1110
1111##############################################################
1112#
1113# Remove the cvs tree...
1114#
1115##############################################################
Misha Brukmanafa1e862009-01-02 16:28:18 +00001116system ( "$NICE rm -rf $BuildDir")
Daniel Dunbard3ecefe2009-07-13 22:17:49 +00001117 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVEATEND);
Misha Brukmanafa1e862009-01-02 16:28:18 +00001118system ( "$NICE rm -rf $WebDir")
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001119 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);