blob: 37e22d9b6d8f3a86131bd4b51c6aafb6917964aa [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.
Daniel Dunbarae3faf12009-10-19 09:18:24 +000051# -with-clang Checkout Clang source into tools/clang.
52# -compileflags Next argument specifies extra options passed to make when
53# building LLVM.
54# -use-gmake Use gmake instead of the default make command to build
55# llvm and run tests.
56#
57# TESTING OPTIONS:
58# -notest Do not even attempt to run the test programs.
59# -nodejagnu Do not run feature or regression tests
60# -enable-llcbeta Enable testing of beta features in llc.
61# -enable-lli Enable testing of lli (interpreter) features, default is off
62# -disable-pic Disable building with Position Independent Code.
63# -disable-llc Disable LLC tests in the nightly tester.
64# -disable-jit Disable JIT tests in the nightly tester.
65# -disable-cbe Disable C backend tests in the nightly tester.
66# -disable-lto Disable link time optimization.
67# -test-cflags Next argument specifies that C compilation options that
68# override the default when running the testsuite.
69# -test-cxxflags Next argument specifies that C++ compilation options that
70# override the default when running the testsuite.
71# -extraflags Next argument specifies extra options that are passed to
72# compile the tests.
73# -noexternals Do not run the external tests (for cases where povray
74# or SPEC are not installed)
75# -with-externals Specify a directory where the external tests are located.
76#
77# OTHER OPTIONS:
78# -parallel Run parallel jobs with GNU Make (see -parallel-jobs).
79# -parallel-jobs The number of parallel Make jobs to use (default is two).
80# -verbose Turn on some debug output
Daniel Dunbarae3faf12009-10-19 09:18:24 +000081# -nice Checkout/Configure/Build with "nice" to reduce impact
82# on busy servers.
83# -f2c Next argument specifies path to F2C utility
84# -gccpath Path to gcc/g++ used to build LLVM
85# -target Specify the target triplet
86# -cflags Next argument specifies that C compilation options that
87# override the default.
88# -cxxflags Next argument specifies that C++ compilation options that
89# override the default.
90# -ldflags Next argument specifies that linker options that override
91# the default.
92#
Daniel Dunbar414cffe2009-10-19 09:18:54 +000093# CVSROOT is ignored, it is passed for backwards compatibility.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000094# BUILDDIR is the directory where sources for this test run will be checked out
95# AND objects for this test run will be built. This directory MUST NOT
Daniel Dunbar414cffe2009-10-19 09:18:54 +000096# exist before the script is run; it will be created by the svn checkout
Dan Gohmanf17a25c2007-07-18 16:29:46 +000097# process and erased (unless -noremove is specified; see above.)
98# WEBDIR is the directory into which the test results web page will be written,
99# AND in which the "index.html" is assumed to be a symlink to the most recent
100# copy of the results. This directory will be created if it does not exist.
101# LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
102# to. This is the same as you would have for a normal LLVM build.
103#
104##############################################################
105#
106# Getting environment variables
107#
108##############################################################
109my $HOME = $ENV{'HOME'};
110my $SVNURL = $ENV{"SVNURL"};
Duncan Sands01388f92009-06-12 13:02:52 +0000111$SVNURL = 'http://llvm.org/svn/llvm-project' unless $SVNURL;
Evan Chengb6d7fc32009-06-18 21:39:50 +0000112my $TestSVNURL = $ENV{"TestSVNURL"};
Evan Chenge45329e2009-07-14 06:23:41 +0000113$TestSVNURL = 'http://llvm.org/svn/llvm-project' unless $TestSVNURL;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000114my $BuildDir = $ENV{'BUILDDIR'};
115$BuildDir = "$HOME/buildtest" unless $BuildDir;
116my $WebDir = $ENV{'WEBDIR'};
117$WebDir = "$HOME/cvs/testresults-X86" unless $WebDir;
118
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000119my $LLVMSrcDir = $ENV{'LLVMSRCDIR'};
120$LLVMSrcDir = "$BuildDir/llvm" unless $LLVMSrcDir;
121my $LLVMObjDir = $ENV{'LLVMOBJDIR'};
122$LLVMObjDir = "$BuildDir/llvm" unless $LLVMObjDir;
123my $LLVMTestDir = $ENV{'LLVMTESTDIR'};
124$LLVMTestDir = "$BuildDir/llvm/projects/llvm-test" unless $LLVMTestDir;
125
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000126##############################################################
127#
128# Calculate the date prefix...
129#
130##############################################################
131@TIME = localtime;
Daniel Dunbar93ad6a82009-07-01 14:52:59 +0000132my $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 +0000133
134##############################################################
135#
136# Parse arguments...
137#
138##############################################################
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000139$CONFIG_PATH="";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000140$CONFIGUREARGS="";
141$nickname="";
142$NOTEST=0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000143$MAKECMD="make";
144$SUBMITSERVER = "llvm.org";
145$SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
Daniel Dunbar016a4bb2009-05-18 23:24:26 +0000146$SUBMITAUX="";
Tanya Lattner084a3ee2008-03-10 07:28:08 +0000147$SUBMIT = 1;
Daniel Dunbarf8cdaec2009-05-28 22:45:24 +0000148$PARALLELJOBS = "2";
Bill Wendling085ff3f2009-07-16 22:59:17 +0000149my $TESTFLAGS="";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000150
151while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
152 shift;
153 last if /^--$/; # Stop processing arguments on --
154
155 # List command line options here...
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000156 if (/^-config$/) { $CONFIG_PATH = "$ARGV[0]"; shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000157 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
158 if (/^-nocvsstats$/) { $NOCVSSTATS = 1; next; }
159 if (/^-noremove$/) { $NOREMOVE = 1; next; }
Daniel Dunbard3ecefe2009-07-13 22:17:49 +0000160 if (/^-noremoveatend$/) { $NOREMOVEATEND = 1; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000161 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
Daniel Dunbar2041d9a2009-06-02 21:14:15 +0000162 if (/^-notest$/) { $NOTEST = 1; next; }
163 if (/^-norunningtests$/) { next; } # Backward compatibility, ignored.
Daniel Dunbarf8cdaec2009-05-28 22:45:24 +0000164 if (/^-parallel-jobs$/) { $PARALLELJOBS = "$ARGV[0]"; shift; next;}
165 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j$PARALLELJOBS -l3.0"; next; }
Duncan Sands01388f92009-06-12 13:02:52 +0000166 if (/^-with-clang$/) { $WITHCLANG = 1; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000167 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
168 "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
169 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
Dan Gohmanbd399762008-10-30 01:08:03 +0000170 "DISABLE_ASSERTIONS=1 ".
Misha Brukmanafa1e862009-01-02 16:28:18 +0000171 "OPTIMIZE_OPTION=-O2";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000172 $BUILDTYPE="release-asserts"; next;}
173 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
Duncan Sands01388f92009-06-12 13:02:52 +0000174 if (/^-disable-pic$/) { $CONFIGUREARGS .= " --enable-pic=no"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000175 if (/^-enable-lli$/) { $PROGTESTOPTS .= " ENABLE_LLI=1";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000176 $CONFIGUREARGS .= " --enable-lli"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000177 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000178 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000179 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
180 $CONFIGUREARGS .= " --disable-jit"; next; }
Daniel Dunbar31a1f1c2009-03-10 19:33:13 +0000181 if (/^-disable-bindings$/) { $CONFIGUREARGS .= " --disable-bindings"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000182 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
Evan Cheng32efae02008-01-12 04:27:18 +0000183 if (/^-disable-lto$/) { $PROGTESTOPTS .= " DISABLE_LTO=1"; next; }
Evan Cheng08206772008-01-14 17:58:03 +0000184 if (/^-test-opts$/) { $PROGTESTOPTS .= " $ARGV[0]"; shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000185 if (/^-verbose$/) { $VERBOSE = 1; next; }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000186 if (/^-teelogs$/) { $TEELOGS = 1; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000187 if (/^-nice$/) { $NICE = "nice "; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000188 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000189 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000190 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000191 shift; next; }
Daniel Dunbardd9c4aa2009-07-13 22:31:58 +0000192 if (/^-configure-args$/) { $CONFIGUREARGS .= " $ARGV[0]";
193 shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000194 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
195 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
Daniel Dunbar016a4bb2009-05-18 23:24:26 +0000196 if (/^-submit-aux/) { $SUBMITAUX = "$ARGV[0]"; shift; next; }
Tanya Lattner084a3ee2008-03-10 07:28:08 +0000197 if (/^-nosubmit$/) { $SUBMIT = 0; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000198 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
199 if (/^-gccpath/) { $CONFIGUREARGS .=
200 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000201 $GCCPATH=$ARGV[0]; shift; next; }
202 else { $GCCPATH=""; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000203 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000204 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000205 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000206 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000207 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000208 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000209 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000210 shift; next; }
Bill Wendling085ff3f2009-07-16 22:59:17 +0000211 if (/^-test-cflags/) { $TESTFLAGS = "$TESTFLAGS CFLAGS=\'$ARGV[0]\'";
212 shift; next; }
213 if (/^-test-cxxflags/) { $TESTFLAGS = "$TESTFLAGS CXXFLAGS=\'$ARGV[0]\'";
214 shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000215 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
216 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000217 if (/^-extraflags/) { $CONFIGUREARGS .=
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000218 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
219 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
220 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
221 if (/^-nobuild$/) { $NOBUILD = 1; next; }
222 print "Unknown option: $_ : ignoring!\n";
223}
224
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000225if (!($CONFIG_PATH eq "")) {
226 die "error: -config mode is not yet implemented,";
227}
228
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000229if ($ENV{'LLVMGCCDIR'}) {
230 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
Bob Wilsonc6d296b2009-03-12 19:47:24 +0000231 $LLVMGCCPATH = $ENV{'LLVMGCCDIR'} . '/bin';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000232}
233else {
234 $LLVMGCCPATH = "";
235}
236
237if ($CONFIGUREARGS !~ /--disable-jit/) {
238 $CONFIGUREARGS .= " --enable-jit";
239}
240
241if (@ARGV != 0 and @ARGV != 3 and $VERBOSE) {
242 foreach $x (@ARGV) {
243 print "$x\n";
244 }
245 print "Must specify 0 or 3 options!";
246}
247
248if (@ARGV == 3) {
Daniel Dunbar414cffe2009-10-19 09:18:54 +0000249 # ARGV[0] used to be the CVS root, ignored for backward compatibility.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000250 $BuildDir = $ARGV[1];
251 $WebDir = $ARGV[2];
252}
253
Daniel Dunbar414cffe2009-10-19 09:18:54 +0000254if ($BuildDir eq "" or
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000255 $WebDir eq "") {
Daniel Dunbar414cffe2009-10-19 09:18:54 +0000256 die("please specify a build directory, and a web directory");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000257 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000258
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000259if ($nickname eq "") {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000260 die ("Please invoke NewNightlyTest.pl with command line option " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000261 "\"-nickname <nickname>\"");
262}
263
264if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
265 $BUILDTYPE = "debug";
266}
267
268##############################################################
269#
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000270# Define the file names we'll use
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000271#
272##############################################################
273my $Prefix = "$WebDir/$DATE";
274my $BuildLog = "$Prefix-Build-Log.txt";
275my $COLog = "$Prefix-CVS-Log.txt";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000276my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
277my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
278my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
279my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
280my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
281my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
282if (! -d $WebDir) {
283 mkdir $WebDir, 0777;
284 if($VERBOSE){
285 warn "$WebDir did not exist; creating it.\n";
286 }
287}
288
289if ($VERBOSE) {
290 print "INITIALIZED\n";
Daniel Dunbaraffc0a52009-10-19 09:18:46 +0000291 print "SVN URL = $SVNURL\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000292 print "COLog = $COLog\n";
293 print "BuildDir = $BuildDir\n";
294 print "WebDir = $WebDir\n";
295 print "Prefix = $Prefix\n";
296 print "BuildLog = $BuildLog\n";
297}
298
299##############################################################
300#
301# Helper functions
302#
303##############################################################
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000304
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000305sub GetDir {
306 my $Suffix = shift;
307 opendir DH, $WebDir;
308 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
309 closedir DH;
310 return @Result;
311}
312
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000313sub RunLoggedCommand {
314 my $Command = shift;
315 my $Log = shift;
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000316 my $Title = shift;
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000317 if ($TEELOGS) {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000318 if ($VERBOSE) {
319 print "$Title\n";
320 print "$Command 2>&1 | tee $Log\n";
321 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000322 system "$Command 2>&1 | tee $Log";
323 } else {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000324 if ($VERBOSE) {
325 print "$Title\n";
326 print "$Command 2>&1 > $Log\n";
327 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000328 system "$Command 2>&1 > $Log";
329 }
330}
331
332sub RunAppendingLoggedCommand {
333 my $Command = shift;
334 my $Log = shift;
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000335 my $Title = shift;
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000336 if ($TEELOGS) {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000337 if ($VERBOSE) {
338 print "$Title\n";
339 print "$Command 2>&1 | tee -a $Log\n";
340 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000341 system "$Command 2>&1 | tee -a $Log";
342 } else {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000343 if ($VERBOSE) {
344 print "$Title\n";
345 print "$Command 2>&1 > $Log\n";
346 }
347 system "$Command 2>&1 >> $Log";
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000348 }
349}
350
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000351#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
352#
353# DiffFiles - Diff the current version of the file against the last version of
354# the file, reporting things added and removed. This is used to report, for
355# example, added and removed warnings. This returns a pair (added, removed)
356#
357#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
358sub DiffFiles {
359 my $Suffix = shift;
360 my @Others = GetDir $Suffix;
361 if (@Others == 0) { # No other files? We added all entries...
362 return (`cat $WebDir/$DATE$Suffix`, "");
363 }
364# Diff the files now...
365 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
366 my $Added = join "\n", grep /^</, @Diffs;
367 my $Removed = join "\n", grep /^>/, @Diffs;
368 $Added =~ s/^< //gm;
369 $Removed =~ s/^> //gm;
370 return ($Added, $Removed);
371}
372
373#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
374#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
375sub GetRegex { # (Regex with ()'s, value)
376 $_[1] =~ /$_[0]/m;
Misha Brukmanafa1e862009-01-02 16:28:18 +0000377 return $1
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000378 if (defined($1));
379 return "0";
380}
381
382#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
383#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
384sub GetRegexNum {
385 my ($Regex, $Num, $Regex2, $File) = @_;
386 my @Items = split "\n", `grep '$Regex' $File`;
387 return GetRegex $Regex2, $Items[$Num];
388}
389
390#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
391#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
392sub ChangeDir { # directory, logical name
393 my ($dir,$name) = @_;
394 chomp($dir);
395 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
396 $result = chdir($dir);
397 if (!$result) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000398 print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000399 return false;
400 }
401 return true;
402}
403
404#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
405#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
406sub ReadFile {
407 if (open (FILE, $_[0])) {
408 undef $/;
409 my $Ret = <FILE>;
410 close FILE;
411 $/ = '\n';
412 return $Ret;
413 } else {
414 print "Could not open file '$_[0]' for reading!\n";
415 return "";
416 }
417}
418
419#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
420#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
421sub WriteFile { # (filename, contents)
422 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
423 print FILE $_[1];
424 close FILE;
425}
426
427#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
428#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
429sub CopyFile { #filename, newfile
430 my ($file, $newfile) = @_;
431 chomp($file);
432 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
433 copy($file, $newfile);
434}
435
436#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
437#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
438sub AddRecord {
439 my ($Val, $Filename,$WebDir) = @_;
440 my @Records;
441 if (open FILE, "$WebDir/$Filename") {
442 @Records = grep !/$DATE/, split "\n", <FILE>;
443 close FILE;
444 }
445 push @Records, "$DATE: $Val";
446 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
447}
448
449#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
450#
451# FormatTime - Convert a time from 1m23.45 into 83.45
452#
453#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
454sub FormatTime {
455 my $Time = shift;
456 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
457 $Time = sprintf("%7.4f", $1*60.0+$2);
458 }
459 return $Time;
460}
461
462#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
463#
Misha Brukmanafa1e862009-01-02 16:28:18 +0000464# This function is meant to read in the dejagnu sum file and
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000465# return a string with only the results (i.e. PASS/FAIL/XPASS/
466# XFAIL).
467#
468#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
469sub GetDejagnuTestResults { # (filename, log)
470 my ($filename, $DejagnuLog) = @_;
471 my @lines;
472 $/ = "\n"; #Make sure we're going line at a time.
473
474 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
475
476 if (open SRCHFILE, $filename) {
477 # Process test results
478 while ( <SRCHFILE> ) {
479 if ( length($_) > 1 ) {
480 chomp($_);
481 if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\/test\/(.*)$/ ) {
482 push(@lines, "$1: test/$2");
483 }
484 }
485 }
486 }
487 close SRCHFILE;
488
489 my $content = join("\n", @lines);
490 return $content;
491}
492
493
494
495#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
496#
497# This function acts as a mini web browswer submitting data
498# to our central server via the post method
499#
500#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000501sub SendData {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000502 $host = $_[0];
503 $file = $_[1];
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000504 $variables = $_[2];
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000505
Daniel Dunbara2533002009-05-28 18:31:40 +0000506 # Write out the "...-sentdata.txt" file.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000507
Daniel Dunbara2533002009-05-28 18:31:40 +0000508 my $sentdata="";
509 foreach $x (keys (%$variables)){
510 $value = $variables->{$x};
511 $sentdata.= "$x => $value\n";
512 }
513 WriteFile "$Prefix-sentdata.txt", $sentdata;
514
515 if (!($SUBMITAUX eq "")) {
Daniel Dunbar3b377ef2009-06-26 22:33:28 +0000516 system "$SUBMITAUX \"$Prefix-sentdata.txt\"";
517 }
518
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000519 if (!$SUBMIT) {
Daniel Dunbar3b377ef2009-06-26 22:33:28 +0000520 return "Skipped standard submit.\n";
Daniel Dunbara2533002009-05-28 18:31:40 +0000521 }
522
523 # Create the content to send to the server.
524
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000525 my $content;
526 foreach $key (keys (%$variables)){
527 $value = $variables->{$key};
528 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
529 $content .= "$key=$value&";
530 }
531
Daniel Dunbara2533002009-05-28 18:31:40 +0000532 # Send the data to the server.
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000533 #
Daniel Dunbara2533002009-05-28 18:31:40 +0000534 # FIXME: This code should be more robust?
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000535
Daniel Dunbara2533002009-05-28 18:31:40 +0000536 $port=80;
537 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
538 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
539 die "Bad socket\n";
540 connect SOCK, $socketaddr or die "Bad connection\n";
541 select((select(SOCK), $| = 1)[0]);
542
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000543 $length = length($content);
544
545 my $send= "POST $file HTTP/1.0\n";
546 $send.= "Host: $host\n";
547 $send.= "Content-Type: application/x-www-form-urlencoded\n";
548 $send.= "Content-length: $length\n\n";
549 $send.= "$content";
550
551 print SOCK $send;
552 my $result;
553 while(<SOCK>){
554 $result .= $_;
555 }
556 close(SOCK);
557
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000558 return $result;
559}
560
561##############################################################
562#
563# Getting Start timestamp
564#
565##############################################################
566$starttime = `date "+20%y-%m-%d %H:%M:%S"`;
567
568##############################################################
569#
Daniel Dunbar414cffe2009-10-19 09:18:54 +0000570# Create the source repository directory
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000571#
572##############################################################
573if (!$NOCHECKOUT) {
574 if (-d $BuildDir) {
575 if (!$NOREMOVE) {
576 if ( $VERBOSE ) {
577 print "Build directory exists! Removing it\n";
578 }
579 system "rm -rf $BuildDir";
580 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
581 } else {
582 if ( $VERBOSE ) {
583 print "Build directory exists!\n";
584 }
585 }
586 } else {
587 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
588 }
589}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000590
591
592##############################################################
593#
Daniel Dunbar414cffe2009-10-19 09:18:54 +0000594# Check out the llvm tree with SVN
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000595#
596##############################################################
597if (!$NOCHECKOUT) {
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000598 ChangeDir( $BuildDir, "checkout directory" );
Daniel Dunbaraffc0a52009-10-19 09:18:46 +0000599 my $SVNCMD = "$NICE svn co --non-interactive $SVNURL";
600 my $SVNCMD2 = "$NICE svn co --non-interactive $TestSVNURL";
601 RunLoggedCommand("( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
602 "$SVNCMD2/test-suite/trunk llvm-test )", $COLog,
603 "CHECKOUT LLVM");
604 if ($WITHCLANG) {
605 my $SVNCMD = "$NICE svn co --non-interactive $SVNURL/cfe/trunk";
606 RunLoggedCommand("( time -p cd llvm/tools ; $SVNCMD clang )", $COLog,
607 "CHECKOUT CLANG");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000608 }
609}
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000610ChangeDir( $LLVMSrcDir , "llvm source directory") ;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000611
612##############################################################
613#
Daniel Dunbar414cffe2009-10-19 09:18:54 +0000614# Get some static statistics about the current source code
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000615#
616# This can probably be put on the server side
617#
618##############################################################
619my $CheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $COLog`;
620my $CheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $COLog`;
621my $CheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $COLog`;
622my $CheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
623
624my $NumFilesInCVS = 0;
625my $NumDirsInCVS = 0;
Daniel Dunbaraffc0a52009-10-19 09:18:46 +0000626$NumFilesInCVS = `egrep '^A' $COLog | wc -l` + 0;
627$NumDirsInCVS = `sed -e 's#/[^/]*\$##' $COLog | sort | uniq | wc -l` + 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000628
629##############################################################
630#
631# Extract some information from the CVS history... use a hash so no duplicate
632# stuff is stored. This gets the history from the previous days worth
633# of cvs activity and parses it.
634#
635##############################################################
636
637# This just computes a reasonably accurate #of seconds since 2000. It doesn't
638# have to be perfect as its only used for comparing date ranges within a couple
639# of days.
640sub ConvertToSeconds {
641 my ($sec, $min, $hour, $day, $mon, $yr) = @_;
642 my $Result = ($yr - 2000) * 12;
643 $Result += $mon;
644 $Result *= 31;
645 $Result += $day;
646 $Result *= 24;
647 $Result += $hour;
648 $Result *= 60;
649 $Result += $min;
650 $Result *= 60;
651 $Result += $sec;
652 return $Result;
653}
654
655my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
656
657if (!$NOCVSSTATS) {
658 if ($VERBOSE) { print "CHANGE HISTORY ANALYSIS STAGE\n"; }
659
Daniel Dunbaraffc0a52009-10-19 09:18:46 +0000660 @SVNHistory = split /<logentry/, `svn log --non-interactive --xml --verbose -r{$DATE}:HEAD`;
661 # Skip very first entry because it is the XML header cruft
662 shift @SVNHistory;
663 my $Now = time();
664 foreach $Record (@SVNHistory) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000665 my @Lines = split "\n", $Record;
666 my ($Author, $Date, $Revision);
667 # Get the date and see if its one we want to process.
668 my ($Year, $Month, $Day, $Hour, $Min, $Sec);
669 if ($Lines[3] =~ /<date>(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/){
Daniel Dunbaraffc0a52009-10-19 09:18:46 +0000670 $Year = $1; $Month = $2; $Day = $3; $Hour = $4; $Min = $5; $Sec = $6;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000671 }
672 my $Then = ConvertToSeconds($Sec, $Min, $Hour, $Day, $Month, $Year);
673 # Get the current date and compute when "yesterday" is.
674 my ($NSec, $NMin, $NHour, $NDay, $NMon, $NYear) = gmtime();
675 my $Now = ConvertToSeconds( $NSec, $NMin, $NHour, $NDay, $NMon, $NYear);
676 if (($Now - 24*60*60) > $Then) {
Daniel Dunbaraffc0a52009-10-19 09:18:46 +0000677 next;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000678 }
679 if ($Lines[1] =~ / revision="([0-9]*)">/) {
Daniel Dunbaraffc0a52009-10-19 09:18:46 +0000680 $Revision = $1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000681 }
682 if ($Lines[2] =~ /<author>([^<]*)<\/author>/) {
Daniel Dunbaraffc0a52009-10-19 09:18:46 +0000683 $Author = $1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000684 }
685 $UsersCommitted{$Author} = 1;
686 $Date = $Year . "-" . $Month . "-" . $Day;
687 $Time = $Hour . ":" . $Min . ":" . $Sec;
688 print "Rev: $Revision, Author: $Author, Date: $Date, Time: $Time\n";
689 for ($i = 6; $i < $#Lines; $i += 2 ) {
Daniel Dunbaraffc0a52009-10-19 09:18:46 +0000690 if ($Lines[$i] =~ /^ action="(.)">([^<]*)</) {
691 if ($1 == "A") {
692 $AddedFiles{$2} = 1;
693 } elsif ($1 == 'D') {
694 $RemovedFiles{$2} = 1;
695 } elsif ($1 == 'M' || $1 == 'R' || $1 == 'C') {
696 $ModifiedFiles{$2} = 1;
697 } else {
698 print "UNMATCHABLE: $Lines[$i]\n";
699 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000700 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000701 }
Daniel Dunbaraffc0a52009-10-19 09:18:46 +0000702 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000703}#!NOCVSSTATS
704
705my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
706my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
707my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
708my $UserCommitList = join "\n", sort keys %UsersCommitted;
709my $UserUpdateList = join "\n", sort keys %UsersUpdated;
710
711##############################################################
712#
713# Build the entire tree, saving build messages to the build log
714#
715##############################################################
716if (!$NOCHECKOUT && !$NOBUILD) {
717 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000718 RunLoggedCommand("(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) ",
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000719 $BuildLog, "CONFIGURE");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000720 # Build the entire tree, capturing the output into $BuildLog
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000721 RunAppendingLoggedCommand("(time -p $NICE $MAKECMD clean)", $BuildLog, "BUILD CLEAN");
722 RunAppendingLoggedCommand("(time -p $NICE $MAKECMD $MAKEOPTS)", $BuildLog, "BUILD");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000723}
724
725##############################################################
726#
727# Get some statistics about the build...
728#
729##############################################################
730#this can de done on server
731#my @Linked = split '\n', `grep Linking $BuildLog`;
732#my $NumExecutables = scalar(grep(/executable/, @Linked));
733#my $NumLibraries = scalar(grep(!/executable/, @Linked));
734#my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
735
736# Get the number of lines of source code. Must be here after the build is done
737# because countloc.sh uses the llvm-config script which must be built.
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000738my $LOC = `utils/countloc.sh -topdir $LLVMSrcDir`;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000739
740# Get the time taken by the configure script
741my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
742my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
743my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
744my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
745
746$ConfigTime=-1 unless $ConfigTime;
747$ConfigWallTime=-1 unless $ConfigWallTime;
748
749my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
750my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
751my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
752my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
753
754$BuildTime=-1 unless $BuildTime;
755$BuildWallTime=-1 unless $BuildWallTime;
756
757my $BuildError = 0, $BuildStatus = "OK";
758if ($NOBUILD) {
759 $BuildStatus = "Skipped by user";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000760}
761elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
762 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
763 $BuildStatus = "Error: compilation aborted";
764 $BuildError = 1;
765 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
766}
767if ($BuildError) { $NODEJAGNU=1; }
768
769my $a_file_sizes="";
770my $o_file_sizes="";
771if (!$BuildError) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000772 print "Organizing size of .o and .a files\n"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000773 if ( $VERBOSE );
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000774 ChangeDir( "$LLVMObjDir", "Build Directory" );
Bob Wilson722d58b2009-06-19 17:19:38 +0000775
776 my @dirs = ('utils', 'lib', 'tools');
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000777 if($BUILDTYPE eq "release"){
Bob Wilson722d58b2009-06-19 17:19:38 +0000778 push @dirs, 'Release';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000779 } elsif($BUILDTYPE eq "release-asserts") {
Bob Wilson722d58b2009-06-19 17:19:38 +0000780 push @dirs, 'Release-Asserts';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000781 } else {
Bob Wilson722d58b2009-06-19 17:19:38 +0000782 push @dirs, 'Debug';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000783 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000784
Bob Wilson722d58b2009-06-19 17:19:38 +0000785 find(sub {
786 $a_file_sizes .= (-s $_)." $File::Find::name $BUILDTYPE\n" if /\.a$/i;
787 $o_file_sizes .= (-s $_)." $File::Find::name $BUILDTYPE\n" if /\.o$/i;
788 }, @dirs);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000789} else {
790 $a_file_sizes="No data due to a bad build.";
791 $o_file_sizes="No data due to a bad build.";
792}
793
794##############################################################
795#
796# Running dejagnu tests
797#
798##############################################################
799my $DejangnuTestResults=""; # String containing the results of the dejagnu
800my $dejagnu_output = "$DejagnuTestsLog";
801if (!$NODEJAGNU) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000802 #Run the feature and regression tests, results are put into testrun.sum
803 #Full log in testrun.log
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000804 RunLoggedCommand("(time -p $MAKECMD $MAKEOPTS check)", $dejagnu_output, "DEJAGNU");
Misha Brukmanafa1e862009-01-02 16:28:18 +0000805
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000806 #Copy the testrun.log and testrun.sum to our webdir
807 CopyFile("test/testrun.log", $DejagnuLog);
808 CopyFile("test/testrun.sum", $DejagnuSum);
809 #can be done on server
810 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
811 $unexpfail_tests = $DejagnuTestResults;
812}
813
814#Extract time of dejagnu tests
815my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
816my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
817$DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
Misha Brukmanafa1e862009-01-02 16:28:18 +0000818$DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
819$DejagnuTestResults =
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000820 "Dejagnu skipped by user choice." unless $DejagnuTestResults;
821$DejagnuTime = "0.0" unless $DejagnuTime;
822$DejagnuWallTime = "0.0" unless $DejagnuWallTime;
823
824##############################################################
825#
826# Get warnings from the build
827#
828##############################################################
829if (!$NODEJAGNU) {
830 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
831 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
832 my @Warnings;
833 my $CurDir = "";
834
835 foreach $Warning (@Warn) {
836 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
837 $CurDir = $1; # Keep track of directory warning is in...
838 # Remove buildir prefix if included
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000839 if ($CurDir =~ m#$LLVMSrcDir/(.*)#) { $CurDir = $1; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000840 } else {
841 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
842 }
843 }
844 my $WarningsFile = join "\n", @Warnings;
845 $WarningsFile =~ s/:[0-9]+:/::/g;
846
847 # Emit the warnings file, so we can diff...
848 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
849 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
850
851 # Output something to stdout if something has changed
852 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
853 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
854
855 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
856 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
857
858} #endif !NODEGAGNU
859
860##############################################################
861#
862# If we built the tree successfully, run the nightly programs tests...
863#
Misha Brukmanafa1e862009-01-02 16:28:18 +0000864# A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000865# "External")
866#
867##############################################################
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000868
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000869sub TestDirectory {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000870 my $SubDir = shift;
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000871 ChangeDir( "$LLVMTestDir/$SubDir",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000872 "Programs Test Subdirectory" ) || return ("", "");
Misha Brukmanafa1e862009-01-02 16:28:18 +0000873
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000874 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000875
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000876 # Run the programs tests... creating a report.nightly.csv file
877 if (!$NOTEST) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000878 if( $VERBOSE) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000879 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
Bill Wendling085ff3f2009-07-16 22:59:17 +0000880 "$TESTFLAGS TEST=nightly > $ProgramTestLog 2>&1\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000881 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000882 RunLoggedCommand("$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
Bill Wendling085ff3f2009-07-16 22:59:17 +0000883 "$TESTFLAGS TEST=nightly",
884 $ProgramTestLog, "TEST DIRECTORY $SubDir");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000885 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
Misha Brukmanafa1e862009-01-02 16:28:18 +0000886 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000887
888 my $ProgramsTable;
889 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
890 $TestError = 1;
891 $ProgramsTable="Error running test $SubDir\n";
892 print "ERROR TESTING\n";
893 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
894 $TestError = 1;
895 $ProgramsTable="Makefile error running tests $SubDir!\n";
896 print "ERROR TESTING\n";
897 } else {
898 $TestError = 0;
899 #
900 # Create a list of the tests which were run...
901 #
902 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
903 "| sort > $Prefix-$SubDir-Tests.txt";
904 }
905 $ProgramsTable = ReadFile "report.nightly.csv";
906
907 ChangeDir( "../../..", "Programs Test Parent Directory" );
908 return ($ProgramsTable, $llcbeta_options);
909} #end sub TestDirectory
910
911##############################################################
912#
913# Calling sub TestDirectory
914#
915##############################################################
916if (!$BuildError) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000917 ($SingleSourceProgramsTable, $llcbeta_options) =
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000918 TestDirectory("SingleSource");
919 WriteFile "$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000920 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
921 WriteFile "$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
922 if ( ! $NOEXTERNALS ) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000923 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
924 WriteFile "$Prefix-External-Performance.txt", $ExternalProgramsTable;
Misha Brukmanafa1e862009-01-02 16:28:18 +0000925 system "cat $Prefix-SingleSource-Tests.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000926 "$Prefix-MultiSource-Tests.txt ".
927 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000928 system "cat $Prefix-SingleSource-Performance.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000929 "$Prefix-MultiSource-Performance.txt ".
930 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
931 } else {
932 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
933 if ( $VERBOSE ) {
934 print "External TEST STAGE SKIPPED\n";
935 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000936 system "cat $Prefix-SingleSource-Tests.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000937 "$Prefix-MultiSource-Tests.txt ".
938 " | sort > $Prefix-Tests.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000939 system "cat $Prefix-SingleSource-Performance.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000940 "$Prefix-MultiSource-Performance.txt ".
941 " | sort > $Prefix-Performance.txt";
942 }
943
944 ##############################################################
945 #
Misha Brukmanafa1e862009-01-02 16:28:18 +0000946 #
947 # gathering tests added removed broken information here
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000948 #
949 #
950 ##############################################################
951 my $dejagnu_test_list = ReadFile "$Prefix-Tests.txt";
952 my @DEJAGNU = split "\n", $dejagnu_test_list;
953 my ($passes, $fails, $xfails) = "";
954
955 if(!$NODEJAGNU) {
956 for ($x=0; $x<@DEJAGNU; $x++) {
957 if ($DEJAGNU[$x] =~ m/^PASS:/) {
958 $passes.="$DEJAGNU[$x]\n";
959 }
960 elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
961 $fails.="$DEJAGNU[$x]\n";
962 }
963 elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
964 $xfails.="$DEJAGNU[$x]\n";
965 }
966 }
967 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000968
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000969} #end if !$BuildError
970
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000971##############################################################
972#
973# Getting end timestamp
974#
975##############################################################
976$endtime = `date "+20%y-%m-%d %H:%M:%S"`;
977
978
979##############################################################
980#
981# Place all the logs neatly into one humungous file
982#
983##############################################################
984if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
985
Misha Brukmanafa1e862009-01-02 16:28:18 +0000986$machine_data = "uname: ".`uname -a`.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000987 "hardware: ".`uname -m`.
988 "os: ".`uname -sr`.
989 "name: ".`uname -n`.
990 "date: ".`date \"+20%y-%m-%d\"`.
Misha Brukmanafa1e862009-01-02 16:28:18 +0000991 "time: ".`date +\"%H:%M:%S\"`;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000992
993my @CVS_DATA;
994my $cvs_data;
995@CVS_DATA = ReadFile "$COLog";
996$cvs_data = join("\n", @CVS_DATA);
997
998my @BUILD_DATA;
999my $build_data;
1000@BUILD_DATA = ReadFile "$BuildLog";
1001$build_data = join("\n", @BUILD_DATA);
1002
1003my (@DEJAGNU_LOG, @DEJAGNU_SUM, @DEJAGNULOG_FULL, @GCC_VERSION);
1004my ($dejagnutests_log ,$dejagnutests_sum, $dejagnulog_full) = "";
1005my ($gcc_version, $gcc_version_long) = "";
1006
1007$gcc_version_long="";
1008if ($GCCPATH ne "") {
1009 $gcc_version_long = `$GCCPATH/gcc --version`;
1010} elsif ($ENV{"CC"}) {
1011 $gcc_version_long = `$ENV{"CC"} --version`;
1012} else {
1013 $gcc_version_long = `gcc --version`;
1014}
1015@GCC_VERSION = split '\n', $gcc_version_long;
1016$gcc_version = $GCC_VERSION[0];
1017
1018$llvmgcc_version_long="";
1019if ($LLVMGCCPATH ne "") {
1020 $llvmgcc_version_long = `$LLVMGCCPATH/llvm-gcc -v 2>&1`;
1021} else {
1022 $llvmgcc_version_long = `llvm-gcc -v 2>&1`;
1023}
1024@LLVMGCC_VERSION = split '\n', $llvmgcc_version_long;
1025$llvmgcc_versionTarget = $LLVMGCC_VERSION[1];
1026$llvmgcc_versionTarget =~ /Target: (.+)/;
1027$targetTriple = $1;
1028
1029if(!$BuildError){
1030 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
1031 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
1032 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
1033 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
1034
1035 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
1036 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
1037}
1038
1039##############################################################
1040#
1041# Send data via a post request
1042#
1043##############################################################
1044
1045if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
1046
1047my %hash_of_data = (
1048 'machine_data' => $machine_data,
1049 'build_data' => $build_data,
1050 'gcc_version' => $gcc_version,
1051 'nickname' => $nickname,
1052 'dejagnutime_wall' => $DejagnuWallTime,
1053 'dejagnutime_cpu' => $DejagnuTime,
1054 'cvscheckouttime_wall' => $CheckoutTime_Wall,
1055 'cvscheckouttime_cpu' => $CheckoutTime_CPU,
1056 'configtime_wall' => $ConfigWallTime,
1057 'configtime_cpu'=> $ConfigTime,
1058 'buildtime_wall' => $BuildWallTime,
1059 'buildtime_cpu' => $BuildTime,
1060 'warnings' => $WarningsFile,
1061 'cvsusercommitlist' => $UserCommitList,
1062 'cvsuserupdatelist' => $UserUpdateList,
1063 'cvsaddedfiles' => $CVSAddedFiles,
1064 'cvsmodifiedfiles' => $CVSModifiedFiles,
1065 'cvsremovedfiles' => $CVSRemovedFiles,
1066 'lines_of_code' => $LOC,
1067 'cvs_file_count' => $NumFilesInCVS,
1068 'cvs_dir_count' => $NumDirsInCVS,
1069 'buildstatus' => $BuildStatus,
1070 'singlesource_programstable' => $SingleSourceProgramsTable,
1071 'multisource_programstable' => $MultiSourceProgramsTable,
1072 'externalsource_programstable' => $ExternalProgramsTable,
1073 'llcbeta_options' => $multisource_llcbeta_options,
1074 'warnings_removed' => $WarningsRemoved,
1075 'warnings_added' => $WarningsAdded,
1076 'passing_tests' => $passes,
1077 'expfail_tests' => $xfails,
1078 'unexpfail_tests' => $fails,
1079 'all_tests' => $dejagnu_test_list,
1080 'new_tests' => "",
1081 'removed_tests' => "",
1082 'dejagnutests_results' => $DejagnuTestResults,
1083 'dejagnutests_log' => $dejagnulog_full,
1084 'starttime' => $starttime,
1085 'endtime' => $endtime,
1086 'o_file_sizes' => $o_file_sizes,
1087 'a_file_sizes' => $a_file_sizes,
1088 'target_triple' => $targetTriple
1089);
1090
Daniel Dunbar3b377ef2009-06-26 22:33:28 +00001091if ($SUBMIT || !($SUBMITAUX eq "")) {
Tanya Lattner084a3ee2008-03-10 07:28:08 +00001092 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
1093 if( $VERBOSE) { print "============================\n$response"; }
1094} else {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001095 print "============================\n";
1096 foreach $x(keys %hash_of_data){
1097 print "$x => $hash_of_data{$x}\n";
1098 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001099}
1100
1101##############################################################
1102#
Daniel Dunbar414cffe2009-10-19 09:18:54 +00001103# Remove the source tree...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001104#
1105##############################################################
Misha Brukmanafa1e862009-01-02 16:28:18 +00001106system ( "$NICE rm -rf $BuildDir")
Daniel Dunbard3ecefe2009-07-13 22:17:49 +00001107 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVEATEND);
Misha Brukmanafa1e862009-01-02 16:28:18 +00001108system ( "$NICE rm -rf $WebDir")
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001109 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);