blob: 62054edf87917bb0f6d8259486f7ba2b7dde8187 [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.
Daniel Dunbar0fa6ca52009-11-06 04:12:07 +000046# -noclean Do not run 'make clean' before building.
Daniel Dunbarae3faf12009-10-19 09:18:24 +000047# -nobuild Do not build llvm. If tests are enabled perform them
48# on the llvm build specified in the build directory
49# -release Build an LLVM Release version
50# -release-asserts Build an LLVM ReleaseAsserts version
51# -disable-bindings Disable building LLVM bindings.
Daniel Dunbarae3faf12009-10-19 09:18:24 +000052# -with-clang Checkout Clang source into tools/clang.
53# -compileflags Next argument specifies extra options passed to make when
54# building LLVM.
55# -use-gmake Use gmake instead of the default make command to build
56# llvm and run tests.
Daniel Dunbar4c419e72009-11-06 04:11:29 +000057# -llvmgccdir Next argument specifies the llvm-gcc install prefix.
Daniel Dunbarae3faf12009-10-19 09:18:24 +000058#
59# TESTING OPTIONS:
60# -notest Do not even attempt to run the test programs.
61# -nodejagnu Do not run feature or regression tests
62# -enable-llcbeta Enable testing of beta features in llc.
63# -enable-lli Enable testing of lli (interpreter) features, default is off
64# -disable-pic Disable building with Position Independent Code.
65# -disable-llc Disable LLC tests in the nightly tester.
66# -disable-jit Disable JIT tests in the nightly tester.
67# -disable-cbe Disable C backend tests in the nightly tester.
68# -disable-lto Disable link time optimization.
69# -test-cflags Next argument specifies that C compilation options that
70# override the default when running the testsuite.
71# -test-cxxflags Next argument specifies that C++ compilation options that
72# override the default when running the testsuite.
73# -extraflags Next argument specifies extra options that are passed to
74# compile the tests.
75# -noexternals Do not run the external tests (for cases where povray
76# or SPEC are not installed)
77# -with-externals Specify a directory where the external tests are located.
78#
79# OTHER OPTIONS:
80# -parallel Run parallel jobs with GNU Make (see -parallel-jobs).
81# -parallel-jobs The number of parallel Make jobs to use (default is two).
Daniel Dunbarc5382fb2009-10-19 13:20:56 +000082# -parallel-test Allow parallel execution of llvm-test
Daniel Dunbarae3faf12009-10-19 09:18:24 +000083# -verbose Turn on some debug output
Daniel Dunbarae3faf12009-10-19 09:18:24 +000084# -nice Checkout/Configure/Build with "nice" to reduce impact
85# on busy servers.
86# -f2c Next argument specifies path to F2C utility
87# -gccpath Path to gcc/g++ used to build LLVM
88# -target Specify the target triplet
89# -cflags Next argument specifies that C compilation options that
90# override the default.
91# -cxxflags Next argument specifies that C++ compilation options that
92# override the default.
93# -ldflags Next argument specifies that linker options that override
94# the default.
95#
Daniel Dunbar414cffe2009-10-19 09:18:54 +000096# CVSROOT is ignored, it is passed for backwards compatibility.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000097# BUILDDIR is the directory where sources for this test run will be checked out
98# AND objects for this test run will be built. This directory MUST NOT
Daniel Dunbar414cffe2009-10-19 09:18:54 +000099# exist before the script is run; it will be created by the svn checkout
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000100# process and erased (unless -noremove is specified; see above.)
101# WEBDIR is the directory into which the test results web page will be written,
102# AND in which the "index.html" is assumed to be a symlink to the most recent
103# copy of the results. This directory will be created if it does not exist.
104# LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
105# to. This is the same as you would have for a normal LLVM build.
106#
107##############################################################
108#
109# Getting environment variables
110#
111##############################################################
112my $HOME = $ENV{'HOME'};
113my $SVNURL = $ENV{"SVNURL"};
Duncan Sands01388f92009-06-12 13:02:52 +0000114$SVNURL = 'http://llvm.org/svn/llvm-project' unless $SVNURL;
Evan Chengb6d7fc32009-06-18 21:39:50 +0000115my $TestSVNURL = $ENV{"TestSVNURL"};
Evan Chenge45329e2009-07-14 06:23:41 +0000116$TestSVNURL = 'http://llvm.org/svn/llvm-project' unless $TestSVNURL;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000117my $BuildDir = $ENV{'BUILDDIR'};
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000118my $WebDir = $ENV{'WEBDIR'};
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000119
120##############################################################
121#
122# Calculate the date prefix...
123#
124##############################################################
Daniel Dunbar3209d112009-11-06 04:12:13 +0000125use POSIX;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000126@TIME = localtime;
Daniel Dunbar3209d112009-11-06 04:12:13 +0000127my $DATE = strftime("%Y-%m-%d_%H-%M-%S", localtime());
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000128
129##############################################################
130#
131# Parse arguments...
132#
133##############################################################
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000134$CONFIG_PATH="";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000135$CONFIGUREARGS="";
136$nickname="";
137$NOTEST=0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000138$MAKECMD="make";
139$SUBMITSERVER = "llvm.org";
140$SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
Daniel Dunbar016a4bb2009-05-18 23:24:26 +0000141$SUBMITAUX="";
Tanya Lattner084a3ee2008-03-10 07:28:08 +0000142$SUBMIT = 1;
Daniel Dunbarf8cdaec2009-05-28 22:45:24 +0000143$PARALLELJOBS = "2";
Bill Wendling085ff3f2009-07-16 22:59:17 +0000144my $TESTFLAGS="";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000145
Daniel Dunbar4c419e72009-11-06 04:11:29 +0000146if ($ENV{'LLVMGCCDIR'}) {
147 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
148 $LLVMGCCPATH = $ENV{'LLVMGCCDIR'} . '/bin';
149}
150else {
151 $LLVMGCCPATH = "";
152}
153
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000154while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
155 shift;
156 last if /^--$/; # Stop processing arguments on --
157
158 # List command line options here...
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000159 if (/^-config$/) { $CONFIG_PATH = "$ARGV[0]"; shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000160 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
Daniel Dunbar0fa6ca52009-11-06 04:12:07 +0000161 if (/^-noclean$/) { $NOCLEAN = 1; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000162 if (/^-noremove$/) { $NOREMOVE = 1; next; }
Daniel Dunbard3ecefe2009-07-13 22:17:49 +0000163 if (/^-noremoveatend$/) { $NOREMOVEATEND = 1; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000164 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
Daniel Dunbar2041d9a2009-06-02 21:14:15 +0000165 if (/^-notest$/) { $NOTEST = 1; next; }
166 if (/^-norunningtests$/) { next; } # Backward compatibility, ignored.
Daniel Dunbarf8cdaec2009-05-28 22:45:24 +0000167 if (/^-parallel-jobs$/) { $PARALLELJOBS = "$ARGV[0]"; shift; next;}
Daniel Dunbar96aab412009-10-19 13:20:50 +0000168 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j$PARALLELJOBS"; next; }
Daniel Dunbarc5382fb2009-10-19 13:20:56 +0000169 if (/^-parallel-test$/) { $PROGTESTOPTS .= " ENABLE_PARALLEL_REPORT=1"; next; }
Duncan Sands01388f92009-06-12 13:02:52 +0000170 if (/^-with-clang$/) { $WITHCLANG = 1; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000171 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
Daniel Dunbar955b7392009-10-20 07:30:46 +0000172 "OPTIMIZE_OPTION=-O2"; next;}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000173 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
Dan Gohmanbd399762008-10-30 01:08:03 +0000174 "DISABLE_ASSERTIONS=1 ".
Daniel Dunbar955b7392009-10-20 07:30:46 +0000175 "OPTIMIZE_OPTION=-O2"; next;}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000176 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
Duncan Sands01388f92009-06-12 13:02:52 +0000177 if (/^-disable-pic$/) { $CONFIGUREARGS .= " --enable-pic=no"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000178 if (/^-enable-lli$/) { $PROGTESTOPTS .= " ENABLE_LLI=1";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000179 $CONFIGUREARGS .= " --enable-lli"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000180 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000181 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000182 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
183 $CONFIGUREARGS .= " --disable-jit"; next; }
Daniel Dunbar31a1f1c2009-03-10 19:33:13 +0000184 if (/^-disable-bindings$/) { $CONFIGUREARGS .= " --disable-bindings"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000185 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
Evan Cheng32efae02008-01-12 04:27:18 +0000186 if (/^-disable-lto$/) { $PROGTESTOPTS .= " DISABLE_LTO=1"; next; }
Evan Cheng08206772008-01-14 17:58:03 +0000187 if (/^-test-opts$/) { $PROGTESTOPTS .= " $ARGV[0]"; shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000188 if (/^-verbose$/) { $VERBOSE = 1; next; }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000189 if (/^-teelogs$/) { $TEELOGS = 1; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000190 if (/^-nice$/) { $NICE = "nice "; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000191 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000192 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000193 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000194 shift; next; }
Daniel Dunbardd9c4aa2009-07-13 22:31:58 +0000195 if (/^-configure-args$/) { $CONFIGUREARGS .= " $ARGV[0]";
196 shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000197 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
198 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
Daniel Dunbar016a4bb2009-05-18 23:24:26 +0000199 if (/^-submit-aux/) { $SUBMITAUX = "$ARGV[0]"; shift; next; }
Tanya Lattner084a3ee2008-03-10 07:28:08 +0000200 if (/^-nosubmit$/) { $SUBMIT = 0; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000201 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
202 if (/^-gccpath/) { $CONFIGUREARGS .=
203 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000204 $GCCPATH=$ARGV[0]; shift; next; }
205 else { $GCCPATH=""; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000206 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000207 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000208 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000209 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000210 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000211 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000212 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000213 shift; next; }
Bill Wendling085ff3f2009-07-16 22:59:17 +0000214 if (/^-test-cflags/) { $TESTFLAGS = "$TESTFLAGS CFLAGS=\'$ARGV[0]\'";
215 shift; next; }
216 if (/^-test-cxxflags/) { $TESTFLAGS = "$TESTFLAGS CXXFLAGS=\'$ARGV[0]\'";
217 shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000218 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
Daniel Dunbar4c419e72009-11-06 04:11:29 +0000219 if (/^-llvmgccdir/) { $CONFIGUREARGS .= " --with-llvmgccdir=\'$ARGV[0]\'";
220 $LLVMGCCPATH = $ARGV[0] . '/bin';
221 shift; next;}
222 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000223 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000224 if (/^-extraflags/) { $CONFIGUREARGS .=
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000225 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
226 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
227 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
228 if (/^-nobuild$/) { $NOBUILD = 1; next; }
229 print "Unknown option: $_ : ignoring!\n";
230}
231
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000232if ($CONFIGUREARGS !~ /--disable-jit/) {
233 $CONFIGUREARGS .= " --enable-jit";
234}
235
Daniel Dunbardce5acc2009-10-19 09:19:19 +0000236if (@ARGV != 0 and @ARGV != 3) {
237 die "error: must specify 0 or 3 options!";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000238}
239
240if (@ARGV == 3) {
Daniel Dunbardce5acc2009-10-19 09:19:19 +0000241 if ($CONFIG_PATH ne "") {
242 die "error: arguments are unsupported in -config mode,";
243 }
244
Daniel Dunbar414cffe2009-10-19 09:18:54 +0000245 # ARGV[0] used to be the CVS root, ignored for backward compatibility.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000246 $BuildDir = $ARGV[1];
247 $WebDir = $ARGV[2];
248}
249
Daniel Dunbar4736b502009-10-20 07:30:54 +0000250if ($CONFIG_PATH ne "") {
251 $BuildDir = "";
252 $SVNURL = $TestSVNURL = "";
253 if ($WebDir eq "") {
254 die("please specify a web directory");
255 }
256} else {
257 if ($BuildDir eq "" or
258 $WebDir eq "") {
259 die("please specify a build directory, and a web directory");
260 }
261}
Misha Brukmanafa1e862009-01-02 16:28:18 +0000262
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000263if ($nickname eq "") {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000264 die ("Please invoke NewNightlyTest.pl with command line option " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000265 "\"-nickname <nickname>\"");
266}
267
Daniel Dunbar59db3022009-11-06 04:12:02 +0000268my $LLVMSrcDir = $ENV{'LLVMSRCDIR'};
269$LLVMSrcDir = "$BuildDir/llvm" unless $LLVMSrcDir;
270my $LLVMObjDir = $ENV{'LLVMOBJDIR'};
271$LLVMObjDir = "$BuildDir/llvm" unless $LLVMObjDir;
272my $LLVMTestDir = $ENV{'LLVMTESTDIR'};
273$LLVMTestDir = "$BuildDir/llvm/projects/llvm-test" unless $LLVMTestDir;
274
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000275##############################################################
276#
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000277# Define the file names we'll use
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000278#
279##############################################################
Daniel Dunbar4736b502009-10-20 07:30:54 +0000280
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000281my $Prefix = "$WebDir/$DATE";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000282my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
283my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
284my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000285
Daniel Dunbar4736b502009-10-20 07:30:54 +0000286# These are only valid in non-config mode.
287my $ConfigureLog = "", $BuildLog = "", $COLog = "";
288my $DejagnuLog = "", $DejagnuSum = "", $DejagnuLog = "";
289
290# Are we in config mode?
291my $ConfigMode = 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000292
293##############################################################
294#
295# Helper functions
296#
297##############################################################
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000298
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000299sub GetDir {
300 my $Suffix = shift;
301 opendir DH, $WebDir;
302 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
303 closedir DH;
304 return @Result;
305}
306
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000307sub RunLoggedCommand {
308 my $Command = shift;
309 my $Log = shift;
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000310 my $Title = shift;
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000311 if ($TEELOGS) {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000312 if ($VERBOSE) {
313 print "$Title\n";
314 print "$Command 2>&1 | tee $Log\n";
315 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000316 system "$Command 2>&1 | tee $Log";
317 } else {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000318 if ($VERBOSE) {
319 print "$Title\n";
320 print "$Command 2>&1 > $Log\n";
321 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000322 system "$Command 2>&1 > $Log";
323 }
324}
325
326sub RunAppendingLoggedCommand {
327 my $Command = shift;
328 my $Log = shift;
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000329 my $Title = shift;
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000330 if ($TEELOGS) {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000331 if ($VERBOSE) {
332 print "$Title\n";
333 print "$Command 2>&1 | tee -a $Log\n";
334 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000335 system "$Command 2>&1 | tee -a $Log";
336 } else {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000337 if ($VERBOSE) {
338 print "$Title\n";
339 print "$Command 2>&1 > $Log\n";
340 }
341 system "$Command 2>&1 >> $Log";
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000342 }
343}
344
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000345sub GetRegex { # (Regex with ()'s, value)
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000346 if ($_[1] =~ /$_[0]/m) {
347 return $1;
348 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000349 return "0";
350}
351
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000352sub ChangeDir { # directory, logical name
353 my ($dir,$name) = @_;
354 chomp($dir);
355 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
356 $result = chdir($dir);
357 if (!$result) {
Daniel Dunbar96aab412009-10-19 13:20:50 +0000358 print "ERROR!!! Cannot change directory to: $name ($dir) because $!\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000359 return false;
360 }
361 return true;
362}
363
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000364sub ReadFile {
365 if (open (FILE, $_[0])) {
366 undef $/;
367 my $Ret = <FILE>;
368 close FILE;
369 $/ = '\n';
370 return $Ret;
371 } else {
372 print "Could not open file '$_[0]' for reading!\n";
373 return "";
374 }
375}
376
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000377sub WriteFile { # (filename, contents)
378 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
379 print FILE $_[1];
380 close FILE;
381}
382
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000383sub CopyFile { #filename, newfile
384 my ($file, $newfile) = @_;
385 chomp($file);
386 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
387 copy($file, $newfile);
388}
389
390#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000391#
Misha Brukmanafa1e862009-01-02 16:28:18 +0000392# This function is meant to read in the dejagnu sum file and
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000393# return a string with only the results (i.e. PASS/FAIL/XPASS/
394# XFAIL).
395#
396#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
397sub GetDejagnuTestResults { # (filename, log)
398 my ($filename, $DejagnuLog) = @_;
399 my @lines;
400 $/ = "\n"; #Make sure we're going line at a time.
401
402 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
403
404 if (open SRCHFILE, $filename) {
405 # Process test results
406 while ( <SRCHFILE> ) {
407 if ( length($_) > 1 ) {
408 chomp($_);
409 if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\/test\/(.*)$/ ) {
410 push(@lines, "$1: test/$2");
411 }
412 }
413 }
414 }
415 close SRCHFILE;
416
417 my $content = join("\n", @lines);
418 return $content;
419}
420
421
422
423#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
424#
425# This function acts as a mini web browswer submitting data
426# to our central server via the post method
427#
428#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000429sub SendData {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000430 $host = $_[0];
431 $file = $_[1];
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000432 $variables = $_[2];
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000433
Daniel Dunbara2533002009-05-28 18:31:40 +0000434 # Write out the "...-sentdata.txt" file.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000435
Daniel Dunbara2533002009-05-28 18:31:40 +0000436 my $sentdata="";
437 foreach $x (keys (%$variables)){
438 $value = $variables->{$x};
439 $sentdata.= "$x => $value\n";
440 }
441 WriteFile "$Prefix-sentdata.txt", $sentdata;
442
443 if (!($SUBMITAUX eq "")) {
Daniel Dunbar3b377ef2009-06-26 22:33:28 +0000444 system "$SUBMITAUX \"$Prefix-sentdata.txt\"";
445 }
446
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000447 if (!$SUBMIT) {
Daniel Dunbar3b377ef2009-06-26 22:33:28 +0000448 return "Skipped standard submit.\n";
Daniel Dunbara2533002009-05-28 18:31:40 +0000449 }
450
451 # Create the content to send to the server.
452
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000453 my $content;
454 foreach $key (keys (%$variables)){
455 $value = $variables->{$key};
456 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
457 $content .= "$key=$value&";
458 }
459
Daniel Dunbara2533002009-05-28 18:31:40 +0000460 # Send the data to the server.
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000461 #
Daniel Dunbara2533002009-05-28 18:31:40 +0000462 # FIXME: This code should be more robust?
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000463
Daniel Dunbara2533002009-05-28 18:31:40 +0000464 $port=80;
465 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
466 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
467 die "Bad socket\n";
468 connect SOCK, $socketaddr or die "Bad connection\n";
469 select((select(SOCK), $| = 1)[0]);
470
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000471 $length = length($content);
472
473 my $send= "POST $file HTTP/1.0\n";
474 $send.= "Host: $host\n";
475 $send.= "Content-Type: application/x-www-form-urlencoded\n";
476 $send.= "Content-length: $length\n\n";
477 $send.= "$content";
478
479 print SOCK $send;
480 my $result;
481 while(<SOCK>){
482 $result .= $_;
483 }
484 close(SOCK);
485
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000486 return $result;
487}
488
489##############################################################
490#
Daniel Dunbar2b9446e2009-10-19 13:20:31 +0000491# Individual Build & Test Functions
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000492#
493##############################################################
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000494
Daniel Dunbar2b9446e2009-10-19 13:20:31 +0000495# Create the source repository directory.
Daniel Dunbar4493e942009-10-19 13:20:06 +0000496sub CheckoutSource {
Daniel Dunbar4736b502009-10-20 07:30:54 +0000497 die "Invalid call!" unless $ConfigMode == 0;
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000498 if (-d $BuildDir) {
499 if (!$NOREMOVE) {
500 if ( $VERBOSE ) {
501 print "Build directory exists! Removing it\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000502 }
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000503 system "rm -rf $BuildDir";
Daniel Dunbar4493e942009-10-19 13:20:06 +0000504 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000505 } else {
506 if ( $VERBOSE ) {
507 print "Build directory exists!\n";
508 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000509 }
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000510 } else {
511 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
512 }
Daniel Dunbar4493e942009-10-19 13:20:06 +0000513
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000514 ChangeDir( $BuildDir, "checkout directory" );
515 my $SVNCMD = "$NICE svn co --non-interactive";
516 RunLoggedCommand("( time -p $SVNCMD $SVNURL/llvm/trunk llvm; cd llvm/projects ; " .
517 " $SVNCMD $TestSVNURL/test-suite/trunk llvm-test )", $COLog,
518 "CHECKOUT LLVM");
519 if ($WITHCLANG) {
520 RunLoggedCommand("( cd llvm/tools ; " .
521 " $SVNCMD $SVNURL/cfe/trunk clang )", $COLog,
522 "CHECKOUT CLANG");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000523 }
524}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000525
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000526# Build the entire tree, saving build messages to the build log. Returns false
527# on build failure.
Daniel Dunbarf2ec0092009-10-19 13:20:13 +0000528sub BuildLLVM {
Daniel Dunbar4736b502009-10-20 07:30:54 +0000529 die "Invalid call!" unless $ConfigMode == 0;
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000530 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
531 RunLoggedCommand("(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) ",
532 $ConfigureLog, "CONFIGURE");
533 # Build the entire tree, capturing the output into $BuildLog
Daniel Dunbar0fa6ca52009-11-06 04:12:07 +0000534 if (!$NOCLEAN) {
535 RunAppendingLoggedCommand("($NICE $MAKECMD $MAKEOPTS clean)", $BuildLog, "BUILD CLEAN");
536 }
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000537 RunAppendingLoggedCommand("(time -p $NICE $MAKECMD $MAKEOPTS)", $BuildLog, "BUILD");
538
539 if (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
540 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l` + 0) {
541 return 0;
Daniel Dunbarf2ec0092009-10-19 13:20:13 +0000542 }
543
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000544 return 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000545}
546
Daniel Dunbar2b9446e2009-10-19 13:20:31 +0000547# Running dejagnu tests and save results to log.
548sub RunDejaGNUTests {
Daniel Dunbar4736b502009-10-20 07:30:54 +0000549 die "Invalid call!" unless $ConfigMode == 0;
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000550 # Run the feature and regression tests, results are put into testrun.sum and
551 # the full log in testrun.log.
Daniel Dunbar96aab412009-10-19 13:20:50 +0000552 system "rm -f test/testrun.log test/testrun.sum";
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000553 RunLoggedCommand("(time -p $MAKECMD $MAKEOPTS check)", $DejagnuLog, "DEJAGNU");
Daniel Dunbar2b9446e2009-10-19 13:20:31 +0000554
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000555 # Copy the testrun.log and testrun.sum to our webdir.
556 CopyFile("test/testrun.log", $DejagnuLog);
557 CopyFile("test/testrun.sum", $DejagnuSum);
Daniel Dunbar2b9446e2009-10-19 13:20:31 +0000558
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000559 return GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000560}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000561
Daniel Dunbar2b9446e2009-10-19 13:20:31 +0000562# Run the named tests (i.e. "SingleSource" "MultiSource" "External")
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000563sub TestDirectory {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000564 my $SubDir = shift;
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000565 ChangeDir( "$LLVMTestDir/$SubDir",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000566 "Programs Test Subdirectory" ) || return ("", "");
Misha Brukmanafa1e862009-01-02 16:28:18 +0000567
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000568 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000569
Daniel Dunbar0fa6ca52009-11-06 04:12:07 +0000570 # Make sure to clean the test results.
571 RunLoggedCommand("$MAKECMD -k $MAKEOPTS $PROGTESTOPTS clean $TESTFLAGS",
572 $ProgramTestLog, "TEST DIRECTORY $SubDir");
Daniel Dunbar4736b502009-10-20 07:30:54 +0000573
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000574 # Run the programs tests... creating a report.nightly.csv file.
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000575 my $LLCBetaOpts = "";
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000576 RunLoggedCommand("$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
577 "$TESTFLAGS TEST=nightly",
578 $ProgramTestLog, "TEST DIRECTORY $SubDir");
579 $LLCBetaOpts = `$MAKECMD print-llcbeta-option`;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000580
581 my $ProgramsTable;
582 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000583 $ProgramsTable="Error running test $SubDir\n";
584 print "ERROR TESTING\n";
585 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000586 $ProgramsTable="Makefile error running tests $SubDir!\n";
587 print "ERROR TESTING\n";
588 } else {
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000589 # Create a list of the tests which were run...
590 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
591 "| sort > $Prefix-$SubDir-Tests.txt";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000592 }
593 $ProgramsTable = ReadFile "report.nightly.csv";
594
595 ChangeDir( "../../..", "Programs Test Parent Directory" );
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000596 return ($ProgramsTable, $LLCBetaOpts);
597}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000598
Daniel Dunbarf4192812009-10-19 13:20:44 +0000599# Run all the nightly tests and return the program tables and the list of tests,
Daniel Dunbar2b9446e2009-10-19 13:20:31 +0000600# passes, fails, and xfails.
Daniel Dunbar2942b022009-10-19 13:20:25 +0000601sub RunNightlyTest() {
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000602 ($SSProgs, $llcbeta_options) = TestDirectory("SingleSource");
603 WriteFile "$Prefix-SingleSource-Performance.txt", $SSProgs;
604 ($MSProgs, $llcbeta_options) = TestDirectory("MultiSource");
605 WriteFile "$Prefix-MultiSource-Performance.txt", $MSProgs;
606 if ( ! $NOEXTERNALS ) {
607 ($ExtProgs, $llcbeta_options) = TestDirectory("External");
608 WriteFile "$Prefix-External-Performance.txt", $ExtProgs;
609 system "cat $Prefix-SingleSource-Tests.txt " .
610 "$Prefix-MultiSource-Tests.txt ".
611 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
612 system "cat $Prefix-SingleSource-Performance.txt " .
613 "$Prefix-MultiSource-Performance.txt ".
614 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
615 } else {
616 $ExtProgs = "External TEST STAGE SKIPPED\n";
617 if ( $VERBOSE ) {
618 print "External TEST STAGE SKIPPED\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000619 }
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000620 system "cat $Prefix-SingleSource-Tests.txt " .
621 "$Prefix-MultiSource-Tests.txt ".
622 " | sort > $Prefix-Tests.txt";
623 system "cat $Prefix-SingleSource-Performance.txt " .
624 "$Prefix-MultiSource-Performance.txt ".
625 " | sort > $Prefix-Performance.txt";
626 }
Daniel Dunbar2942b022009-10-19 13:20:25 +0000627
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000628 # Compile passes, fails, xfails.
Daniel Dunbarf4192812009-10-19 13:20:44 +0000629 my $All = (ReadFile "$Prefix-Tests.txt");
630 my @TestSuiteResultLines = split "\n", $All;
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000631 my ($Passes, $Fails, $XFails) = "";
Daniel Dunbar2942b022009-10-19 13:20:25 +0000632
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000633 for ($x=0; $x < @TestSuiteResultLines; $x++) {
634 if (@TestSuiteResultLines[$x] =~ m/^PASS:/) {
635 $Passes .= "$TestSuiteResultLines[$x]\n";
636 }
637 elsif (@TestSuiteResultLines[$x] =~ m/^FAIL:/) {
638 $Fails .= "$TestSuiteResultLines[$x]\n";
639 }
640 elsif (@TestSuiteResultLines[$x] =~ m/^XFAIL:/) {
641 $XFails .= "$TestSuiteResultLines[$x]\n";
Daniel Dunbar2942b022009-10-19 13:20:25 +0000642 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000643 }
644
Daniel Dunbarf4192812009-10-19 13:20:44 +0000645 return ($SSProgs, $MSProgs, $ExtProgs, $All, $Passes, $Fails, $XFails);
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000646}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000647
Daniel Dunbar2b9446e2009-10-19 13:20:31 +0000648##############################################################
649#
Daniel Dunbar4736b502009-10-20 07:30:54 +0000650# Initialize filenames
651#
652##############################################################
653
654if (! -d $WebDir) {
655 mkdir $WebDir, 0777 or die "Unable to create web directory: '$WebDir'.";
656 if($VERBOSE){
657 warn "$WebDir did not exist; creating it.\n";
658 }
659}
660
661if ($CONFIG_PATH ne "") {
662 $ConfigMode = 1;
663 $LLVMSrcDir = GetRegex "^(.*)\\s+", `$CONFIG_PATH --src-root`;
664 $LLVMObjDir = GetRegex "^(.*)\\s+", `$CONFIG_PATH --obj-root`;
665 # FIXME: Add llvm-config hook for this?
666 $LLVMTestDir = $LLVMObjDir . "/projects/test-suite";
667} else {
668 $ConfigureLog = "$Prefix-Configure-Log.txt";
669 $BuildLog = "$Prefix-Build-Log.txt";
670 $COLog = "$Prefix-CVS-Log.txt";
671 $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
672 $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
673 $DejagnuLog = "$Prefix-DejagnuTests-Log.txt";
674}
675
676if ($VERBOSE) {
677 if ($CONFIG_PATH ne "") {
678 print "INITIALIZED (config mode)\n";
679 print "WebDir = $WebDir\n";
680 print "Prefix = $Prefix\n";
681 print "LLVM Src = $LLVMSrcDir\n";
682 print "LLVM Obj = $LLVMObjDir\n";
683 print "LLVM Test = $LLVMTestDir\n";
684 } else {
685 print "INITIALIZED\n";
686 print "SVN URL = $SVNURL\n";
687 print "COLog = $COLog\n";
688 print "BuildDir = $BuildDir\n";
689 print "WebDir = $WebDir\n";
690 print "Prefix = $Prefix\n";
691 print "BuildLog = $BuildLog\n";
692 }
693}
694
695##############################################################
696#
Daniel Dunbar2b9446e2009-10-19 13:20:31 +0000697# The actual NewNightlyTest logic.
698#
699##############################################################
700
701$starttime = `date "+20%y-%m-%d %H:%M:%S"`;
702
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000703my $BuildError = 0, $BuildStatus = "OK";
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000704my $DejagnuTestResults = "Dejagnu skipped by user choice.";
Daniel Dunbar4736b502009-10-20 07:30:54 +0000705if ($ConfigMode == 0) {
706 if (!$NOCHECKOUT) {
707 CheckoutSource();
708 }
709
710 # Build LLVM.
711 ChangeDir( $LLVMSrcDir , "llvm source directory") ;
712 if ($NOCHECKOUT || $NOBUILD) {
713 $BuildStatus = "Skipped by user";
714 } else {
715 if (!BuildLLVM()) {
716 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
717 $BuildError = 1;
718 $BuildStatus = "Error: compilation aborted";
719 $NODEJAGNU=1;
720 }
721 }
722
723 # Run DejaGNU.
724 if (!$NODEJAGNU && !$BuildError) {
725 $DejagnuTestResults = RunDejaGNUTests();
726 }
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000727}
728
729# Run the llvm-test tests.
Daniel Dunbar2942b022009-10-19 13:20:25 +0000730my ($SingleSourceProgramsTable, $MultiSourceProgramsTable, $ExternalProgramsTable,
Daniel Dunbarf4192812009-10-19 13:20:44 +0000731 $all_tests, $passes, $fails, $xfails) = "";
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000732if (!$NOTEST && !$BuildError) {
733 ($SingleSourceProgramsTable, $MultiSourceProgramsTable, $ExternalProgramsTable,
Daniel Dunbarf4192812009-10-19 13:20:44 +0000734 $all_tests, $passes, $fails, $xfails) = RunNightlyTest();
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000735}
Daniel Dunbar2942b022009-10-19 13:20:25 +0000736
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000737$endtime = `date "+20%y-%m-%d %H:%M:%S"`;
738
Daniel Dunbar96aab412009-10-19 13:20:50 +0000739# The last bit of logic is to remove the build and web dirs, after sending data
740# to the server.
741
Daniel Dunbar2b9446e2009-10-19 13:20:31 +0000742##############################################################
743#
744# Accumulate the information to send to the server.
745#
746##############################################################
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000747
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000748if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
749
Misha Brukmanafa1e862009-01-02 16:28:18 +0000750$machine_data = "uname: ".`uname -a`.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000751 "hardware: ".`uname -m`.
752 "os: ".`uname -sr`.
753 "name: ".`uname -n`.
754 "date: ".`date \"+20%y-%m-%d\"`.
Misha Brukmanafa1e862009-01-02 16:28:18 +0000755 "time: ".`date +\"%H:%M:%S\"`;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000756
Daniel Dunbar2b9446e2009-10-19 13:20:31 +0000757# Get gcc version.
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000758my $gcc_version_long = "";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000759if ($GCCPATH ne "") {
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000760 $gcc_version_long = `$GCCPATH/gcc --version`;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000761} elsif ($ENV{"CC"}) {
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000762 $gcc_version_long = `$ENV{"CC"} --version`;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000763} else {
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000764 $gcc_version_long = `gcc --version`;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000765}
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000766my $gcc_version = (split '\n', $gcc_version_long)[0];
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000767
Daniel Dunbar2b9446e2009-10-19 13:20:31 +0000768# Get llvm-gcc target triple.
Daniel Dunbar4c419e72009-11-06 04:11:29 +0000769#
770# FIXME: This shouldn't be hardwired to llvm-gcc.
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000771my $llvmgcc_version_long = "";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000772if ($LLVMGCCPATH ne "") {
773 $llvmgcc_version_long = `$LLVMGCCPATH/llvm-gcc -v 2>&1`;
774} else {
775 $llvmgcc_version_long = `llvm-gcc -v 2>&1`;
776}
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000777(split '\n', $llvmgcc_version_long)[1] =~ /Target: (.+)/;
778my $targetTriple = $1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000779
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000780# Logs.
Daniel Dunbar4736b502009-10-20 07:30:54 +0000781my ($ConfigureLogData, $BuildLogData, $DejagnuLogData, $CheckoutLogData) = "";
782if ($ConfigMode == 0) {
783 $ConfigureLogData = ReadFile $ConfigureLog;
784 $BuildLogData = ReadFile $BuildLog;
785 $DejagnuLogData = ReadFile $DejagnuLog;
786 $CheckoutLogData = ReadFile $COLog;
787}
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000788
Daniel Dunbarf2ec0092009-10-19 13:20:13 +0000789# Checkout info.
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000790my $CheckoutTime_Wall = GetRegex "^real ([0-9.]+)", $CheckoutLogData;
791my $CheckoutTime_User = GetRegex "^user ([0-9.]+)", $CheckoutLogData;
792my $CheckoutTime_Sys = GetRegex "^sys ([0-9.]+)", $CheckoutLogData;
Daniel Dunbar4493e942009-10-19 13:20:06 +0000793my $CheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
794
Daniel Dunbarf2ec0092009-10-19 13:20:13 +0000795# Configure info.
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000796my $ConfigTimeU = GetRegex "^user ([0-9.]+)", $ConfigureLogData;
797my $ConfigTimeS = GetRegex "^sys ([0-9.]+)", $ConfigureLogData;
Daniel Dunbarf2ec0092009-10-19 13:20:13 +0000798my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000799my $ConfigWallTime = GetRegex "^real ([0-9.]+)",$ConfigureLogData;
Daniel Dunbarf2ec0092009-10-19 13:20:13 +0000800$ConfigTime=-1 unless $ConfigTime;
801$ConfigWallTime=-1 unless $ConfigWallTime;
802
803# Build info.
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000804my $BuildTimeU = GetRegex "^user ([0-9.]+)", $BuildLogData;
805my $BuildTimeS = GetRegex "^sys ([0-9.]+)", $BuildLogData;
Daniel Dunbarf2ec0092009-10-19 13:20:13 +0000806my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000807my $BuildWallTime = GetRegex "^real ([0-9.]+)", $BuildLogData;
Daniel Dunbarf2ec0092009-10-19 13:20:13 +0000808$BuildTime=-1 unless $BuildTime;
809$BuildWallTime=-1 unless $BuildWallTime;
810
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000811# DejaGNU info.
812my $DejagnuTimeU = GetRegex "^user ([0-9.]+)", $DejagnuLogData;
813my $DejagnuTimeS = GetRegex "^sys ([0-9.]+)", $DejagnuLogData;
814$DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
815$DejagnuWallTime = GetRegex "^real ([0-9.]+)", $DejagnuLogData;
816$DejagnuTime = "0.0" unless $DejagnuTime;
817$DejagnuWallTime = "0.0" unless $DejagnuWallTime;
Daniel Dunbarf2ec0092009-10-19 13:20:13 +0000818
Daniel Dunbar96aab412009-10-19 13:20:50 +0000819if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
820
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000821my %hash_of_data = (
822 'machine_data' => $machine_data,
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000823 'build_data' => $ConfigureLogData . $BuildLogData,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000824 'gcc_version' => $gcc_version,
825 'nickname' => $nickname,
826 'dejagnutime_wall' => $DejagnuWallTime,
827 'dejagnutime_cpu' => $DejagnuTime,
828 'cvscheckouttime_wall' => $CheckoutTime_Wall,
829 'cvscheckouttime_cpu' => $CheckoutTime_CPU,
830 'configtime_wall' => $ConfigWallTime,
831 'configtime_cpu'=> $ConfigTime,
832 'buildtime_wall' => $BuildWallTime,
833 'buildtime_cpu' => $BuildTime,
Daniel Dunbar96aab412009-10-19 13:20:50 +0000834 'buildstatus' => $BuildStatus,
835 'singlesource_programstable' => $SingleSourceProgramsTable,
836 'multisource_programstable' => $MultiSourceProgramsTable,
837 'externalsource_programstable' => $ExternalProgramsTable,
838 'llcbeta_options' => $llcbeta_options,
839 'passing_tests' => $passes,
840 'expfail_tests' => $xfails,
841 'unexpfail_tests' => $fails,
842 'all_tests' => $all_tests,
843 'dejagnutests_results' => $DejagnuTestResults,
844 'dejagnutests_log' => $DejagnuLogData,
845 'starttime' => $starttime,
846 'endtime' => $endtime,
847 'target_triple' => $targetTriple,
848
849 # Unused, but left around for backwards compatability.
Daniel Dunbar6981e022009-10-19 13:19:53 +0000850 'warnings' => "",
Daniel Dunbar9ec7b9e2009-10-19 09:19:09 +0000851 'cvsusercommitlist' => "",
852 'cvsuserupdatelist' => "",
853 'cvsaddedfiles' => "",
854 'cvsmodifiedfiles' => "",
855 'cvsremovedfiles' => "",
856 'lines_of_code' => "",
857 'cvs_file_count' => 0,
858 'cvs_dir_count' => 0,
Daniel Dunbar6981e022009-10-19 13:19:53 +0000859 'warnings_removed' => "",
860 'warnings_added' => "",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000861 'new_tests' => "",
862 'removed_tests' => "",
Daniel Dunbar3c52ad12009-10-19 13:20:00 +0000863 'o_file_sizes' => "",
Daniel Dunbar96aab412009-10-19 13:20:50 +0000864 'a_file_sizes' => ""
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000865);
866
Daniel Dunbar3b377ef2009-06-26 22:33:28 +0000867if ($SUBMIT || !($SUBMITAUX eq "")) {
Tanya Lattner084a3ee2008-03-10 07:28:08 +0000868 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
869 if( $VERBOSE) { print "============================\n$response"; }
870} else {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000871 print "============================\n";
872 foreach $x(keys %hash_of_data){
873 print "$x => $hash_of_data{$x}\n";
874 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000875}
876
877##############################################################
878#
Daniel Dunbar414cffe2009-10-19 09:18:54 +0000879# Remove the source tree...
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000880#
881##############################################################
Misha Brukmanafa1e862009-01-02 16:28:18 +0000882system ( "$NICE rm -rf $BuildDir")
Daniel Dunbard3ecefe2009-07-13 22:17:49 +0000883 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVEATEND);
Misha Brukmanafa1e862009-01-02 16:28:18 +0000884system ( "$NICE rm -rf $WebDir")
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000885 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);