blob: 7453caf27f2732e10a128db3f7960ee8f6d58f4a [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; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000158 if (/^-noremove$/) { $NOREMOVE = 1; next; }
Daniel Dunbard3ecefe2009-07-13 22:17:49 +0000159 if (/^-noremoveatend$/) { $NOREMOVEATEND = 1; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000160 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
Daniel Dunbar2041d9a2009-06-02 21:14:15 +0000161 if (/^-notest$/) { $NOTEST = 1; next; }
162 if (/^-norunningtests$/) { next; } # Backward compatibility, ignored.
Daniel Dunbarf8cdaec2009-05-28 22:45:24 +0000163 if (/^-parallel-jobs$/) { $PARALLELJOBS = "$ARGV[0]"; shift; next;}
164 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j$PARALLELJOBS -l3.0"; next; }
Duncan Sands01388f92009-06-12 13:02:52 +0000165 if (/^-with-clang$/) { $WITHCLANG = 1; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000166 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
167 "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
168 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
Dan Gohmanbd399762008-10-30 01:08:03 +0000169 "DISABLE_ASSERTIONS=1 ".
Misha Brukmanafa1e862009-01-02 16:28:18 +0000170 "OPTIMIZE_OPTION=-O2";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000171 $BUILDTYPE="release-asserts"; next;}
172 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
Duncan Sands01388f92009-06-12 13:02:52 +0000173 if (/^-disable-pic$/) { $CONFIGUREARGS .= " --enable-pic=no"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000174 if (/^-enable-lli$/) { $PROGTESTOPTS .= " ENABLE_LLI=1";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000175 $CONFIGUREARGS .= " --enable-lli"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000176 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000177 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000178 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
179 $CONFIGUREARGS .= " --disable-jit"; next; }
Daniel Dunbar31a1f1c2009-03-10 19:33:13 +0000180 if (/^-disable-bindings$/) { $CONFIGUREARGS .= " --disable-bindings"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000181 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
Evan Cheng32efae02008-01-12 04:27:18 +0000182 if (/^-disable-lto$/) { $PROGTESTOPTS .= " DISABLE_LTO=1"; next; }
Evan Cheng08206772008-01-14 17:58:03 +0000183 if (/^-test-opts$/) { $PROGTESTOPTS .= " $ARGV[0]"; shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000184 if (/^-verbose$/) { $VERBOSE = 1; next; }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000185 if (/^-teelogs$/) { $TEELOGS = 1; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000186 if (/^-nice$/) { $NICE = "nice "; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000187 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000188 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000189 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000190 shift; next; }
Daniel Dunbardd9c4aa2009-07-13 22:31:58 +0000191 if (/^-configure-args$/) { $CONFIGUREARGS .= " $ARGV[0]";
192 shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000193 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
194 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
Daniel Dunbar016a4bb2009-05-18 23:24:26 +0000195 if (/^-submit-aux/) { $SUBMITAUX = "$ARGV[0]"; shift; next; }
Tanya Lattner084a3ee2008-03-10 07:28:08 +0000196 if (/^-nosubmit$/) { $SUBMIT = 0; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000197 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
198 if (/^-gccpath/) { $CONFIGUREARGS .=
199 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000200 $GCCPATH=$ARGV[0]; shift; next; }
201 else { $GCCPATH=""; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000202 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000203 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000204 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000205 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000206 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000207 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000208 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000209 shift; next; }
Bill Wendling085ff3f2009-07-16 22:59:17 +0000210 if (/^-test-cflags/) { $TESTFLAGS = "$TESTFLAGS CFLAGS=\'$ARGV[0]\'";
211 shift; next; }
212 if (/^-test-cxxflags/) { $TESTFLAGS = "$TESTFLAGS CXXFLAGS=\'$ARGV[0]\'";
213 shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000214 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
215 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000216 if (/^-extraflags/) { $CONFIGUREARGS .=
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000217 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
218 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
219 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
220 if (/^-nobuild$/) { $NOBUILD = 1; next; }
221 print "Unknown option: $_ : ignoring!\n";
222}
223
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000224if (!($CONFIG_PATH eq "")) {
225 die "error: -config mode is not yet implemented,";
226}
227
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000228if ($ENV{'LLVMGCCDIR'}) {
229 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
Bob Wilsonc6d296b2009-03-12 19:47:24 +0000230 $LLVMGCCPATH = $ENV{'LLVMGCCDIR'} . '/bin';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000231}
232else {
233 $LLVMGCCPATH = "";
234}
235
236if ($CONFIGUREARGS !~ /--disable-jit/) {
237 $CONFIGUREARGS .= " --enable-jit";
238}
239
240if (@ARGV != 0 and @ARGV != 3 and $VERBOSE) {
241 foreach $x (@ARGV) {
242 print "$x\n";
243 }
244 print "Must specify 0 or 3 options!";
245}
246
247if (@ARGV == 3) {
Daniel Dunbar414cffe2009-10-19 09:18:54 +0000248 # ARGV[0] used to be the CVS root, ignored for backward compatibility.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000249 $BuildDir = $ARGV[1];
250 $WebDir = $ARGV[2];
251}
252
Daniel Dunbar414cffe2009-10-19 09:18:54 +0000253if ($BuildDir eq "" or
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000254 $WebDir eq "") {
Daniel Dunbar414cffe2009-10-19 09:18:54 +0000255 die("please specify a build directory, and a web directory");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000256 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000257
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000258if ($nickname eq "") {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000259 die ("Please invoke NewNightlyTest.pl with command line option " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000260 "\"-nickname <nickname>\"");
261}
262
263if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
264 $BUILDTYPE = "debug";
265}
266
267##############################################################
268#
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000269# Define the file names we'll use
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000270#
271##############################################################
272my $Prefix = "$WebDir/$DATE";
273my $BuildLog = "$Prefix-Build-Log.txt";
274my $COLog = "$Prefix-CVS-Log.txt";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000275my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
276my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
277my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
278my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
279my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
280my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
281if (! -d $WebDir) {
282 mkdir $WebDir, 0777;
283 if($VERBOSE){
284 warn "$WebDir did not exist; creating it.\n";
285 }
286}
287
288if ($VERBOSE) {
289 print "INITIALIZED\n";
Daniel Dunbaraffc0a52009-10-19 09:18:46 +0000290 print "SVN URL = $SVNURL\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000291 print "COLog = $COLog\n";
292 print "BuildDir = $BuildDir\n";
293 print "WebDir = $WebDir\n";
294 print "Prefix = $Prefix\n";
295 print "BuildLog = $BuildLog\n";
296}
297
298##############################################################
299#
300# Helper functions
301#
302##############################################################
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000303
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000304sub GetDir {
305 my $Suffix = shift;
306 opendir DH, $WebDir;
307 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
308 closedir DH;
309 return @Result;
310}
311
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000312sub RunLoggedCommand {
313 my $Command = shift;
314 my $Log = shift;
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000315 my $Title = shift;
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000316 if ($TEELOGS) {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000317 if ($VERBOSE) {
318 print "$Title\n";
319 print "$Command 2>&1 | tee $Log\n";
320 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000321 system "$Command 2>&1 | tee $Log";
322 } else {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000323 if ($VERBOSE) {
324 print "$Title\n";
325 print "$Command 2>&1 > $Log\n";
326 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000327 system "$Command 2>&1 > $Log";
328 }
329}
330
331sub RunAppendingLoggedCommand {
332 my $Command = shift;
333 my $Log = shift;
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000334 my $Title = shift;
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000335 if ($TEELOGS) {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000336 if ($VERBOSE) {
337 print "$Title\n";
338 print "$Command 2>&1 | tee -a $Log\n";
339 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000340 system "$Command 2>&1 | tee -a $Log";
341 } else {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000342 if ($VERBOSE) {
343 print "$Title\n";
344 print "$Command 2>&1 > $Log\n";
345 }
346 system "$Command 2>&1 >> $Log";
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000347 }
348}
349
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000350#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
351#
352# DiffFiles - Diff the current version of the file against the last version of
353# the file, reporting things added and removed. This is used to report, for
354# example, added and removed warnings. This returns a pair (added, removed)
355#
356#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
357sub DiffFiles {
358 my $Suffix = shift;
359 my @Others = GetDir $Suffix;
360 if (@Others == 0) { # No other files? We added all entries...
361 return (`cat $WebDir/$DATE$Suffix`, "");
362 }
363# Diff the files now...
364 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
365 my $Added = join "\n", grep /^</, @Diffs;
366 my $Removed = join "\n", grep /^>/, @Diffs;
367 $Added =~ s/^< //gm;
368 $Removed =~ s/^> //gm;
369 return ($Added, $Removed);
370}
371
372#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
373#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
374sub GetRegex { # (Regex with ()'s, value)
375 $_[1] =~ /$_[0]/m;
Misha Brukmanafa1e862009-01-02 16:28:18 +0000376 return $1
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000377 if (defined($1));
378 return "0";
379}
380
381#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
382#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
383sub GetRegexNum {
384 my ($Regex, $Num, $Regex2, $File) = @_;
385 my @Items = split "\n", `grep '$Regex' $File`;
386 return GetRegex $Regex2, $Items[$Num];
387}
388
389#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
390#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
391sub ChangeDir { # directory, logical name
392 my ($dir,$name) = @_;
393 chomp($dir);
394 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
395 $result = chdir($dir);
396 if (!$result) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000397 print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000398 return false;
399 }
400 return true;
401}
402
403#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
404#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
405sub ReadFile {
406 if (open (FILE, $_[0])) {
407 undef $/;
408 my $Ret = <FILE>;
409 close FILE;
410 $/ = '\n';
411 return $Ret;
412 } else {
413 print "Could not open file '$_[0]' for reading!\n";
414 return "";
415 }
416}
417
418#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
419#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
420sub WriteFile { # (filename, contents)
421 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
422 print FILE $_[1];
423 close FILE;
424}
425
426#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
427#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
428sub CopyFile { #filename, newfile
429 my ($file, $newfile) = @_;
430 chomp($file);
431 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
432 copy($file, $newfile);
433}
434
435#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
436#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
437sub AddRecord {
438 my ($Val, $Filename,$WebDir) = @_;
439 my @Records;
440 if (open FILE, "$WebDir/$Filename") {
441 @Records = grep !/$DATE/, split "\n", <FILE>;
442 close FILE;
443 }
444 push @Records, "$DATE: $Val";
445 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
446}
447
448#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
449#
450# FormatTime - Convert a time from 1m23.45 into 83.45
451#
452#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
453sub FormatTime {
454 my $Time = shift;
455 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
456 $Time = sprintf("%7.4f", $1*60.0+$2);
457 }
458 return $Time;
459}
460
461#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
462#
Misha Brukmanafa1e862009-01-02 16:28:18 +0000463# This function is meant to read in the dejagnu sum file and
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000464# return a string with only the results (i.e. PASS/FAIL/XPASS/
465# XFAIL).
466#
467#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
468sub GetDejagnuTestResults { # (filename, log)
469 my ($filename, $DejagnuLog) = @_;
470 my @lines;
471 $/ = "\n"; #Make sure we're going line at a time.
472
473 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
474
475 if (open SRCHFILE, $filename) {
476 # Process test results
477 while ( <SRCHFILE> ) {
478 if ( length($_) > 1 ) {
479 chomp($_);
480 if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\/test\/(.*)$/ ) {
481 push(@lines, "$1: test/$2");
482 }
483 }
484 }
485 }
486 close SRCHFILE;
487
488 my $content = join("\n", @lines);
489 return $content;
490}
491
492
493
494#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
495#
496# This function acts as a mini web browswer submitting data
497# to our central server via the post method
498#
499#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000500sub SendData {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000501 $host = $_[0];
502 $file = $_[1];
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000503 $variables = $_[2];
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000504
Daniel Dunbara2533002009-05-28 18:31:40 +0000505 # Write out the "...-sentdata.txt" file.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000506
Daniel Dunbara2533002009-05-28 18:31:40 +0000507 my $sentdata="";
508 foreach $x (keys (%$variables)){
509 $value = $variables->{$x};
510 $sentdata.= "$x => $value\n";
511 }
512 WriteFile "$Prefix-sentdata.txt", $sentdata;
513
514 if (!($SUBMITAUX eq "")) {
Daniel Dunbar3b377ef2009-06-26 22:33:28 +0000515 system "$SUBMITAUX \"$Prefix-sentdata.txt\"";
516 }
517
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000518 if (!$SUBMIT) {
Daniel Dunbar3b377ef2009-06-26 22:33:28 +0000519 return "Skipped standard submit.\n";
Daniel Dunbara2533002009-05-28 18:31:40 +0000520 }
521
522 # Create the content to send to the server.
523
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000524 my $content;
525 foreach $key (keys (%$variables)){
526 $value = $variables->{$key};
527 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
528 $content .= "$key=$value&";
529 }
530
Daniel Dunbara2533002009-05-28 18:31:40 +0000531 # Send the data to the server.
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000532 #
Daniel Dunbara2533002009-05-28 18:31:40 +0000533 # FIXME: This code should be more robust?
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000534
Daniel Dunbara2533002009-05-28 18:31:40 +0000535 $port=80;
536 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
537 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
538 die "Bad socket\n";
539 connect SOCK, $socketaddr or die "Bad connection\n";
540 select((select(SOCK), $| = 1)[0]);
541
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000542 $length = length($content);
543
544 my $send= "POST $file HTTP/1.0\n";
545 $send.= "Host: $host\n";
546 $send.= "Content-Type: application/x-www-form-urlencoded\n";
547 $send.= "Content-length: $length\n\n";
548 $send.= "$content";
549
550 print SOCK $send;
551 my $result;
552 while(<SOCK>){
553 $result .= $_;
554 }
555 close(SOCK);
556
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000557 return $result;
558}
559
560##############################################################
561#
562# Getting Start timestamp
563#
564##############################################################
565$starttime = `date "+20%y-%m-%d %H:%M:%S"`;
566
567##############################################################
568#
Daniel Dunbar414cffe2009-10-19 09:18:54 +0000569# Create the source repository directory
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000570#
571##############################################################
572if (!$NOCHECKOUT) {
573 if (-d $BuildDir) {
574 if (!$NOREMOVE) {
575 if ( $VERBOSE ) {
576 print "Build directory exists! Removing it\n";
577 }
578 system "rm -rf $BuildDir";
579 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
580 } else {
581 if ( $VERBOSE ) {
582 print "Build directory exists!\n";
583 }
584 }
585 } else {
586 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
587 }
588}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000589
590
591##############################################################
592#
Daniel Dunbar414cffe2009-10-19 09:18:54 +0000593# Check out the llvm tree with SVN
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000594#
595##############################################################
596if (!$NOCHECKOUT) {
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000597 ChangeDir( $BuildDir, "checkout directory" );
Daniel Dunbaraffc0a52009-10-19 09:18:46 +0000598 my $SVNCMD = "$NICE svn co --non-interactive $SVNURL";
599 my $SVNCMD2 = "$NICE svn co --non-interactive $TestSVNURL";
600 RunLoggedCommand("( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
601 "$SVNCMD2/test-suite/trunk llvm-test )", $COLog,
602 "CHECKOUT LLVM");
603 if ($WITHCLANG) {
604 my $SVNCMD = "$NICE svn co --non-interactive $SVNURL/cfe/trunk";
605 RunLoggedCommand("( time -p cd llvm/tools ; $SVNCMD clang )", $COLog,
606 "CHECKOUT CLANG");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000607 }
608}
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000609ChangeDir( $LLVMSrcDir , "llvm source directory") ;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000610
611##############################################################
612#
Daniel Dunbar414cffe2009-10-19 09:18:54 +0000613# Get some static statistics about the current source code
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000614#
615# This can probably be put on the server side
616#
617##############################################################
618my $CheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $COLog`;
619my $CheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $COLog`;
620my $CheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $COLog`;
621my $CheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
622
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000623##############################################################
624#
625# Build the entire tree, saving build messages to the build log
626#
627##############################################################
628if (!$NOCHECKOUT && !$NOBUILD) {
629 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000630 RunLoggedCommand("(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) ",
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000631 $BuildLog, "CONFIGURE");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000632 # Build the entire tree, capturing the output into $BuildLog
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000633 RunAppendingLoggedCommand("(time -p $NICE $MAKECMD clean)", $BuildLog, "BUILD CLEAN");
634 RunAppendingLoggedCommand("(time -p $NICE $MAKECMD $MAKEOPTS)", $BuildLog, "BUILD");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000635}
636
637##############################################################
638#
639# Get some statistics about the build...
640#
641##############################################################
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000642
643# Get the time taken by the configure script
644my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
645my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
646my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
647my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
648
649$ConfigTime=-1 unless $ConfigTime;
650$ConfigWallTime=-1 unless $ConfigWallTime;
651
652my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
653my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
654my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
655my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
656
657$BuildTime=-1 unless $BuildTime;
658$BuildWallTime=-1 unless $BuildWallTime;
659
660my $BuildError = 0, $BuildStatus = "OK";
661if ($NOBUILD) {
662 $BuildStatus = "Skipped by user";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000663}
664elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
665 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
666 $BuildStatus = "Error: compilation aborted";
667 $BuildError = 1;
668 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
669}
670if ($BuildError) { $NODEJAGNU=1; }
671
672my $a_file_sizes="";
673my $o_file_sizes="";
674if (!$BuildError) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000675 print "Organizing size of .o and .a files\n"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000676 if ( $VERBOSE );
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000677 ChangeDir( "$LLVMObjDir", "Build Directory" );
Bob Wilson722d58b2009-06-19 17:19:38 +0000678
679 my @dirs = ('utils', 'lib', 'tools');
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000680 if($BUILDTYPE eq "release"){
Bob Wilson722d58b2009-06-19 17:19:38 +0000681 push @dirs, 'Release';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000682 } elsif($BUILDTYPE eq "release-asserts") {
Bob Wilson722d58b2009-06-19 17:19:38 +0000683 push @dirs, 'Release-Asserts';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000684 } else {
Bob Wilson722d58b2009-06-19 17:19:38 +0000685 push @dirs, 'Debug';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000686 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000687
Bob Wilson722d58b2009-06-19 17:19:38 +0000688 find(sub {
689 $a_file_sizes .= (-s $_)." $File::Find::name $BUILDTYPE\n" if /\.a$/i;
690 $o_file_sizes .= (-s $_)." $File::Find::name $BUILDTYPE\n" if /\.o$/i;
691 }, @dirs);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000692} else {
693 $a_file_sizes="No data due to a bad build.";
694 $o_file_sizes="No data due to a bad build.";
695}
696
697##############################################################
698#
699# Running dejagnu tests
700#
701##############################################################
702my $DejangnuTestResults=""; # String containing the results of the dejagnu
703my $dejagnu_output = "$DejagnuTestsLog";
704if (!$NODEJAGNU) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000705 #Run the feature and regression tests, results are put into testrun.sum
706 #Full log in testrun.log
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000707 RunLoggedCommand("(time -p $MAKECMD $MAKEOPTS check)", $dejagnu_output, "DEJAGNU");
Misha Brukmanafa1e862009-01-02 16:28:18 +0000708
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000709 #Copy the testrun.log and testrun.sum to our webdir
710 CopyFile("test/testrun.log", $DejagnuLog);
711 CopyFile("test/testrun.sum", $DejagnuSum);
712 #can be done on server
713 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
714 $unexpfail_tests = $DejagnuTestResults;
715}
716
717#Extract time of dejagnu tests
718my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
719my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
720$DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
Misha Brukmanafa1e862009-01-02 16:28:18 +0000721$DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
722$DejagnuTestResults =
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000723 "Dejagnu skipped by user choice." unless $DejagnuTestResults;
724$DejagnuTime = "0.0" unless $DejagnuTime;
725$DejagnuWallTime = "0.0" unless $DejagnuWallTime;
726
727##############################################################
728#
729# Get warnings from the build
730#
731##############################################################
732if (!$NODEJAGNU) {
733 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
734 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
735 my @Warnings;
736 my $CurDir = "";
737
738 foreach $Warning (@Warn) {
739 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
740 $CurDir = $1; # Keep track of directory warning is in...
741 # Remove buildir prefix if included
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000742 if ($CurDir =~ m#$LLVMSrcDir/(.*)#) { $CurDir = $1; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000743 } else {
744 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
745 }
746 }
747 my $WarningsFile = join "\n", @Warnings;
748 $WarningsFile =~ s/:[0-9]+:/::/g;
749
750 # Emit the warnings file, so we can diff...
751 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
752 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
753
754 # Output something to stdout if something has changed
755 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
756 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
757
758 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
759 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
760
761} #endif !NODEGAGNU
762
763##############################################################
764#
765# If we built the tree successfully, run the nightly programs tests...
766#
Misha Brukmanafa1e862009-01-02 16:28:18 +0000767# A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000768# "External")
769#
770##############################################################
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000771
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000772sub TestDirectory {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000773 my $SubDir = shift;
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000774 ChangeDir( "$LLVMTestDir/$SubDir",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000775 "Programs Test Subdirectory" ) || return ("", "");
Misha Brukmanafa1e862009-01-02 16:28:18 +0000776
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000777 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000778
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000779 # Run the programs tests... creating a report.nightly.csv file
780 if (!$NOTEST) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000781 if( $VERBOSE) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000782 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
Bill Wendling085ff3f2009-07-16 22:59:17 +0000783 "$TESTFLAGS TEST=nightly > $ProgramTestLog 2>&1\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000784 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000785 RunLoggedCommand("$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
Bill Wendling085ff3f2009-07-16 22:59:17 +0000786 "$TESTFLAGS TEST=nightly",
787 $ProgramTestLog, "TEST DIRECTORY $SubDir");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000788 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
Misha Brukmanafa1e862009-01-02 16:28:18 +0000789 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000790
791 my $ProgramsTable;
792 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
793 $TestError = 1;
794 $ProgramsTable="Error running test $SubDir\n";
795 print "ERROR TESTING\n";
796 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
797 $TestError = 1;
798 $ProgramsTable="Makefile error running tests $SubDir!\n";
799 print "ERROR TESTING\n";
800 } else {
801 $TestError = 0;
802 #
803 # Create a list of the tests which were run...
804 #
805 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
806 "| sort > $Prefix-$SubDir-Tests.txt";
807 }
808 $ProgramsTable = ReadFile "report.nightly.csv";
809
810 ChangeDir( "../../..", "Programs Test Parent Directory" );
811 return ($ProgramsTable, $llcbeta_options);
812} #end sub TestDirectory
813
814##############################################################
815#
816# Calling sub TestDirectory
817#
818##############################################################
819if (!$BuildError) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000820 ($SingleSourceProgramsTable, $llcbeta_options) =
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000821 TestDirectory("SingleSource");
822 WriteFile "$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000823 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
824 WriteFile "$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
825 if ( ! $NOEXTERNALS ) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000826 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
827 WriteFile "$Prefix-External-Performance.txt", $ExternalProgramsTable;
Misha Brukmanafa1e862009-01-02 16:28:18 +0000828 system "cat $Prefix-SingleSource-Tests.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000829 "$Prefix-MultiSource-Tests.txt ".
830 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000831 system "cat $Prefix-SingleSource-Performance.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000832 "$Prefix-MultiSource-Performance.txt ".
833 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
834 } else {
835 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
836 if ( $VERBOSE ) {
837 print "External TEST STAGE SKIPPED\n";
838 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000839 system "cat $Prefix-SingleSource-Tests.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000840 "$Prefix-MultiSource-Tests.txt ".
841 " | sort > $Prefix-Tests.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000842 system "cat $Prefix-SingleSource-Performance.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000843 "$Prefix-MultiSource-Performance.txt ".
844 " | sort > $Prefix-Performance.txt";
845 }
846
847 ##############################################################
848 #
Misha Brukmanafa1e862009-01-02 16:28:18 +0000849 #
850 # gathering tests added removed broken information here
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000851 #
852 #
853 ##############################################################
854 my $dejagnu_test_list = ReadFile "$Prefix-Tests.txt";
855 my @DEJAGNU = split "\n", $dejagnu_test_list;
856 my ($passes, $fails, $xfails) = "";
857
858 if(!$NODEJAGNU) {
859 for ($x=0; $x<@DEJAGNU; $x++) {
860 if ($DEJAGNU[$x] =~ m/^PASS:/) {
861 $passes.="$DEJAGNU[$x]\n";
862 }
863 elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
864 $fails.="$DEJAGNU[$x]\n";
865 }
866 elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
867 $xfails.="$DEJAGNU[$x]\n";
868 }
869 }
870 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000871
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000872} #end if !$BuildError
873
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000874##############################################################
875#
876# Getting end timestamp
877#
878##############################################################
879$endtime = `date "+20%y-%m-%d %H:%M:%S"`;
880
881
882##############################################################
883#
884# Place all the logs neatly into one humungous file
885#
886##############################################################
887if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
888
Misha Brukmanafa1e862009-01-02 16:28:18 +0000889$machine_data = "uname: ".`uname -a`.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000890 "hardware: ".`uname -m`.
891 "os: ".`uname -sr`.
892 "name: ".`uname -n`.
893 "date: ".`date \"+20%y-%m-%d\"`.
Misha Brukmanafa1e862009-01-02 16:28:18 +0000894 "time: ".`date +\"%H:%M:%S\"`;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000895
896my @CVS_DATA;
897my $cvs_data;
898@CVS_DATA = ReadFile "$COLog";
899$cvs_data = join("\n", @CVS_DATA);
900
901my @BUILD_DATA;
902my $build_data;
903@BUILD_DATA = ReadFile "$BuildLog";
904$build_data = join("\n", @BUILD_DATA);
905
906my (@DEJAGNU_LOG, @DEJAGNU_SUM, @DEJAGNULOG_FULL, @GCC_VERSION);
907my ($dejagnutests_log ,$dejagnutests_sum, $dejagnulog_full) = "";
908my ($gcc_version, $gcc_version_long) = "";
909
910$gcc_version_long="";
911if ($GCCPATH ne "") {
912 $gcc_version_long = `$GCCPATH/gcc --version`;
913} elsif ($ENV{"CC"}) {
914 $gcc_version_long = `$ENV{"CC"} --version`;
915} else {
916 $gcc_version_long = `gcc --version`;
917}
918@GCC_VERSION = split '\n', $gcc_version_long;
919$gcc_version = $GCC_VERSION[0];
920
921$llvmgcc_version_long="";
922if ($LLVMGCCPATH ne "") {
923 $llvmgcc_version_long = `$LLVMGCCPATH/llvm-gcc -v 2>&1`;
924} else {
925 $llvmgcc_version_long = `llvm-gcc -v 2>&1`;
926}
927@LLVMGCC_VERSION = split '\n', $llvmgcc_version_long;
928$llvmgcc_versionTarget = $LLVMGCC_VERSION[1];
929$llvmgcc_versionTarget =~ /Target: (.+)/;
930$targetTriple = $1;
931
932if(!$BuildError){
933 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
934 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
935 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
936 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
937
938 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
939 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
940}
941
942##############################################################
943#
944# Send data via a post request
945#
946##############################################################
947
948if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
949
950my %hash_of_data = (
951 'machine_data' => $machine_data,
952 'build_data' => $build_data,
953 'gcc_version' => $gcc_version,
954 'nickname' => $nickname,
955 'dejagnutime_wall' => $DejagnuWallTime,
956 'dejagnutime_cpu' => $DejagnuTime,
957 'cvscheckouttime_wall' => $CheckoutTime_Wall,
958 'cvscheckouttime_cpu' => $CheckoutTime_CPU,
959 'configtime_wall' => $ConfigWallTime,
960 'configtime_cpu'=> $ConfigTime,
961 'buildtime_wall' => $BuildWallTime,
962 'buildtime_cpu' => $BuildTime,
963 'warnings' => $WarningsFile,
Daniel Dunbar9ec7b9e2009-10-19 09:19:09 +0000964 'cvsusercommitlist' => "",
965 'cvsuserupdatelist' => "",
966 'cvsaddedfiles' => "",
967 'cvsmodifiedfiles' => "",
968 'cvsremovedfiles' => "",
969 'lines_of_code' => "",
970 'cvs_file_count' => 0,
971 'cvs_dir_count' => 0,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000972 'buildstatus' => $BuildStatus,
973 'singlesource_programstable' => $SingleSourceProgramsTable,
974 'multisource_programstable' => $MultiSourceProgramsTable,
975 'externalsource_programstable' => $ExternalProgramsTable,
976 'llcbeta_options' => $multisource_llcbeta_options,
977 'warnings_removed' => $WarningsRemoved,
978 'warnings_added' => $WarningsAdded,
979 'passing_tests' => $passes,
980 'expfail_tests' => $xfails,
981 'unexpfail_tests' => $fails,
982 'all_tests' => $dejagnu_test_list,
983 'new_tests' => "",
984 'removed_tests' => "",
985 'dejagnutests_results' => $DejagnuTestResults,
986 'dejagnutests_log' => $dejagnulog_full,
987 'starttime' => $starttime,
988 'endtime' => $endtime,
989 'o_file_sizes' => $o_file_sizes,
990 'a_file_sizes' => $a_file_sizes,
991 'target_triple' => $targetTriple
992);
993
Daniel Dunbar3b377ef2009-06-26 22:33:28 +0000994if ($SUBMIT || !($SUBMITAUX eq "")) {
Tanya Lattner084a3ee2008-03-10 07:28:08 +0000995 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
996 if( $VERBOSE) { print "============================\n$response"; }
997} else {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000998 print "============================\n";
999 foreach $x(keys %hash_of_data){
1000 print "$x => $hash_of_data{$x}\n";
1001 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001002}
1003
1004##############################################################
1005#
Daniel Dunbar414cffe2009-10-19 09:18:54 +00001006# Remove the source tree...
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001007#
1008##############################################################
Misha Brukmanafa1e862009-01-02 16:28:18 +00001009system ( "$NICE rm -rf $BuildDir")
Daniel Dunbard3ecefe2009-07-13 22:17:49 +00001010 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVEATEND);
Misha Brukmanafa1e862009-01-02 16:28:18 +00001011system ( "$NICE rm -rf $WebDir")
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001012 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);