blob: ed22b77f9989b3429a289efe07540975659225e0 [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).
Daniel Dunbarc5382fb2009-10-19 13:20:56 +000080# -parallel-test Allow parallel execution of llvm-test
Daniel Dunbarae3faf12009-10-19 09:18:24 +000081# -verbose Turn on some debug output
Daniel Dunbarae3faf12009-10-19 09:18:24 +000082# -nice Checkout/Configure/Build with "nice" to reduce impact
83# on busy servers.
84# -f2c Next argument specifies path to F2C utility
85# -gccpath Path to gcc/g++ used to build LLVM
86# -target Specify the target triplet
87# -cflags Next argument specifies that C compilation options that
88# override the default.
89# -cxxflags Next argument specifies that C++ compilation options that
90# override the default.
91# -ldflags Next argument specifies that linker options that override
92# the default.
93#
Daniel Dunbar414cffe2009-10-19 09:18:54 +000094# CVSROOT is ignored, it is passed for backwards compatibility.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000095# BUILDDIR is the directory where sources for this test run will be checked out
96# AND objects for this test run will be built. This directory MUST NOT
Daniel Dunbar414cffe2009-10-19 09:18:54 +000097# exist before the script is run; it will be created by the svn checkout
Dan Gohmanf17a25c2007-07-18 16:29:46 +000098# process and erased (unless -noremove is specified; see above.)
99# WEBDIR is the directory into which the test results web page will be written,
100# AND in which the "index.html" is assumed to be a symlink to the most recent
101# copy of the results. This directory will be created if it does not exist.
102# LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
103# to. This is the same as you would have for a normal LLVM build.
104#
105##############################################################
106#
107# Getting environment variables
108#
109##############################################################
110my $HOME = $ENV{'HOME'};
111my $SVNURL = $ENV{"SVNURL"};
Duncan Sands01388f92009-06-12 13:02:52 +0000112$SVNURL = 'http://llvm.org/svn/llvm-project' unless $SVNURL;
Evan Chengb6d7fc32009-06-18 21:39:50 +0000113my $TestSVNURL = $ENV{"TestSVNURL"};
Evan Chenge45329e2009-07-14 06:23:41 +0000114$TestSVNURL = 'http://llvm.org/svn/llvm-project' unless $TestSVNURL;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000115my $BuildDir = $ENV{'BUILDDIR'};
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000116my $WebDir = $ENV{'WEBDIR'};
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000117
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000118my $LLVMSrcDir = $ENV{'LLVMSRCDIR'};
119$LLVMSrcDir = "$BuildDir/llvm" unless $LLVMSrcDir;
120my $LLVMObjDir = $ENV{'LLVMOBJDIR'};
121$LLVMObjDir = "$BuildDir/llvm" unless $LLVMObjDir;
122my $LLVMTestDir = $ENV{'LLVMTESTDIR'};
123$LLVMTestDir = "$BuildDir/llvm/projects/llvm-test" unless $LLVMTestDir;
124
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000125##############################################################
126#
127# Calculate the date prefix...
128#
129##############################################################
130@TIME = localtime;
Daniel Dunbar93ad6a82009-07-01 14:52:59 +0000131my $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 +0000132
133##############################################################
134#
135# Parse arguments...
136#
137##############################################################
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000138$CONFIG_PATH="";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000139$CONFIGUREARGS="";
140$nickname="";
141$NOTEST=0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000142$MAKECMD="make";
143$SUBMITSERVER = "llvm.org";
144$SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
Daniel Dunbar016a4bb2009-05-18 23:24:26 +0000145$SUBMITAUX="";
Tanya Lattner084a3ee2008-03-10 07:28:08 +0000146$SUBMIT = 1;
Daniel Dunbarf8cdaec2009-05-28 22:45:24 +0000147$PARALLELJOBS = "2";
Bill Wendling085ff3f2009-07-16 22:59:17 +0000148my $TESTFLAGS="";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000149
150while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
151 shift;
152 last if /^--$/; # Stop processing arguments on --
153
154 # List command line options here...
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000155 if (/^-config$/) { $CONFIG_PATH = "$ARGV[0]"; shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000156 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000157 if (/^-noremove$/) { $NOREMOVE = 1; next; }
Daniel Dunbard3ecefe2009-07-13 22:17:49 +0000158 if (/^-noremoveatend$/) { $NOREMOVEATEND = 1; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000159 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
Daniel Dunbar2041d9a2009-06-02 21:14:15 +0000160 if (/^-notest$/) { $NOTEST = 1; next; }
161 if (/^-norunningtests$/) { next; } # Backward compatibility, ignored.
Daniel Dunbarf8cdaec2009-05-28 22:45:24 +0000162 if (/^-parallel-jobs$/) { $PARALLELJOBS = "$ARGV[0]"; shift; next;}
Daniel Dunbar96aab412009-10-19 13:20:50 +0000163 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j$PARALLELJOBS"; next; }
Daniel Dunbarc5382fb2009-10-19 13:20:56 +0000164 if (/^-parallel-test$/) { $PROGTESTOPTS .= " ENABLE_PARALLEL_REPORT=1"; 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 ".
Daniel Dunbar955b7392009-10-20 07:30:46 +0000167 "OPTIMIZE_OPTION=-O2"; next;}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000168 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
Dan Gohmanbd399762008-10-30 01:08:03 +0000169 "DISABLE_ASSERTIONS=1 ".
Daniel Dunbar955b7392009-10-20 07:30:46 +0000170 "OPTIMIZE_OPTION=-O2"; next;}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000171 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
Duncan Sands01388f92009-06-12 13:02:52 +0000172 if (/^-disable-pic$/) { $CONFIGUREARGS .= " --enable-pic=no"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000173 if (/^-enable-lli$/) { $PROGTESTOPTS .= " ENABLE_LLI=1";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000174 $CONFIGUREARGS .= " --enable-lli"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000175 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000176 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000177 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
178 $CONFIGUREARGS .= " --disable-jit"; next; }
Daniel Dunbar31a1f1c2009-03-10 19:33:13 +0000179 if (/^-disable-bindings$/) { $CONFIGUREARGS .= " --disable-bindings"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000180 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
Evan Cheng32efae02008-01-12 04:27:18 +0000181 if (/^-disable-lto$/) { $PROGTESTOPTS .= " DISABLE_LTO=1"; next; }
Evan Cheng08206772008-01-14 17:58:03 +0000182 if (/^-test-opts$/) { $PROGTESTOPTS .= " $ARGV[0]"; shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000183 if (/^-verbose$/) { $VERBOSE = 1; next; }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000184 if (/^-teelogs$/) { $TEELOGS = 1; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000185 if (/^-nice$/) { $NICE = "nice "; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000186 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000187 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000188 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000189 shift; next; }
Daniel Dunbardd9c4aa2009-07-13 22:31:58 +0000190 if (/^-configure-args$/) { $CONFIGUREARGS .= " $ARGV[0]";
191 shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000192 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
193 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
Daniel Dunbar016a4bb2009-05-18 23:24:26 +0000194 if (/^-submit-aux/) { $SUBMITAUX = "$ARGV[0]"; shift; next; }
Tanya Lattner084a3ee2008-03-10 07:28:08 +0000195 if (/^-nosubmit$/) { $SUBMIT = 0; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000196 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
197 if (/^-gccpath/) { $CONFIGUREARGS .=
198 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000199 $GCCPATH=$ARGV[0]; shift; next; }
200 else { $GCCPATH=""; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000201 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000202 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000203 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000204 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000205 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000206 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000207 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000208 shift; next; }
Bill Wendling085ff3f2009-07-16 22:59:17 +0000209 if (/^-test-cflags/) { $TESTFLAGS = "$TESTFLAGS CFLAGS=\'$ARGV[0]\'";
210 shift; next; }
211 if (/^-test-cxxflags/) { $TESTFLAGS = "$TESTFLAGS CXXFLAGS=\'$ARGV[0]\'";
212 shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000213 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
214 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000215 if (/^-extraflags/) { $CONFIGUREARGS .=
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000216 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
217 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
218 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
219 if (/^-nobuild$/) { $NOBUILD = 1; next; }
220 print "Unknown option: $_ : ignoring!\n";
221}
222
223if ($ENV{'LLVMGCCDIR'}) {
224 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
Bob Wilsonc6d296b2009-03-12 19:47:24 +0000225 $LLVMGCCPATH = $ENV{'LLVMGCCDIR'} . '/bin';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000226}
227else {
228 $LLVMGCCPATH = "";
229}
230
231if ($CONFIGUREARGS !~ /--disable-jit/) {
232 $CONFIGUREARGS .= " --enable-jit";
233}
234
Daniel Dunbardce5acc2009-10-19 09:19:19 +0000235if (@ARGV != 0 and @ARGV != 3) {
236 die "error: must specify 0 or 3 options!";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000237}
238
239if (@ARGV == 3) {
Daniel Dunbardce5acc2009-10-19 09:19:19 +0000240 if ($CONFIG_PATH ne "") {
241 die "error: arguments are unsupported in -config mode,";
242 }
243
Daniel Dunbar414cffe2009-10-19 09:18:54 +0000244 # ARGV[0] used to be the CVS root, ignored for backward compatibility.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000245 $BuildDir = $ARGV[1];
246 $WebDir = $ARGV[2];
247}
248
Daniel Dunbar4736b502009-10-20 07:30:54 +0000249if ($CONFIG_PATH ne "") {
250 $BuildDir = "";
251 $SVNURL = $TestSVNURL = "";
252 if ($WebDir eq "") {
253 die("please specify a web directory");
254 }
255} else {
256 if ($BuildDir eq "" or
257 $WebDir eq "") {
258 die("please specify a build directory, and a web directory");
259 }
260}
Misha Brukmanafa1e862009-01-02 16:28:18 +0000261
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000262if ($nickname eq "") {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000263 die ("Please invoke NewNightlyTest.pl with command line option " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000264 "\"-nickname <nickname>\"");
265}
266
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000267##############################################################
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##############################################################
Daniel Dunbar4736b502009-10-20 07:30:54 +0000272
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000273my $Prefix = "$WebDir/$DATE";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000274my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
275my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
276my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000277
Daniel Dunbar4736b502009-10-20 07:30:54 +0000278# These are only valid in non-config mode.
279my $ConfigureLog = "", $BuildLog = "", $COLog = "";
280my $DejagnuLog = "", $DejagnuSum = "", $DejagnuLog = "";
281
282# Are we in config mode?
283my $ConfigMode = 0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000284
285##############################################################
286#
287# Helper functions
288#
289##############################################################
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000290
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000291sub GetDir {
292 my $Suffix = shift;
293 opendir DH, $WebDir;
294 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
295 closedir DH;
296 return @Result;
297}
298
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000299sub RunLoggedCommand {
300 my $Command = shift;
301 my $Log = shift;
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000302 my $Title = shift;
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000303 if ($TEELOGS) {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000304 if ($VERBOSE) {
305 print "$Title\n";
306 print "$Command 2>&1 | tee $Log\n";
307 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000308 system "$Command 2>&1 | tee $Log";
309 } else {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000310 if ($VERBOSE) {
311 print "$Title\n";
312 print "$Command 2>&1 > $Log\n";
313 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000314 system "$Command 2>&1 > $Log";
315 }
316}
317
318sub RunAppendingLoggedCommand {
319 my $Command = shift;
320 my $Log = shift;
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000321 my $Title = shift;
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000322 if ($TEELOGS) {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000323 if ($VERBOSE) {
324 print "$Title\n";
325 print "$Command 2>&1 | tee -a $Log\n";
326 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000327 system "$Command 2>&1 | tee -a $Log";
328 } else {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000329 if ($VERBOSE) {
330 print "$Title\n";
331 print "$Command 2>&1 > $Log\n";
332 }
333 system "$Command 2>&1 >> $Log";
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000334 }
335}
336
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000337sub GetRegex { # (Regex with ()'s, value)
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000338 if ($_[1] =~ /$_[0]/m) {
339 return $1;
340 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000341 return "0";
342}
343
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000344sub ChangeDir { # directory, logical name
345 my ($dir,$name) = @_;
346 chomp($dir);
347 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
348 $result = chdir($dir);
349 if (!$result) {
Daniel Dunbar96aab412009-10-19 13:20:50 +0000350 print "ERROR!!! Cannot change directory to: $name ($dir) because $!\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000351 return false;
352 }
353 return true;
354}
355
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000356sub ReadFile {
357 if (open (FILE, $_[0])) {
358 undef $/;
359 my $Ret = <FILE>;
360 close FILE;
361 $/ = '\n';
362 return $Ret;
363 } else {
364 print "Could not open file '$_[0]' for reading!\n";
365 return "";
366 }
367}
368
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000369sub WriteFile { # (filename, contents)
370 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
371 print FILE $_[1];
372 close FILE;
373}
374
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000375sub CopyFile { #filename, newfile
376 my ($file, $newfile) = @_;
377 chomp($file);
378 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
379 copy($file, $newfile);
380}
381
382#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000383#
Misha Brukmanafa1e862009-01-02 16:28:18 +0000384# This function is meant to read in the dejagnu sum file and
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000385# return a string with only the results (i.e. PASS/FAIL/XPASS/
386# XFAIL).
387#
388#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
389sub GetDejagnuTestResults { # (filename, log)
390 my ($filename, $DejagnuLog) = @_;
391 my @lines;
392 $/ = "\n"; #Make sure we're going line at a time.
393
394 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
395
396 if (open SRCHFILE, $filename) {
397 # Process test results
398 while ( <SRCHFILE> ) {
399 if ( length($_) > 1 ) {
400 chomp($_);
401 if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\/test\/(.*)$/ ) {
402 push(@lines, "$1: test/$2");
403 }
404 }
405 }
406 }
407 close SRCHFILE;
408
409 my $content = join("\n", @lines);
410 return $content;
411}
412
413
414
415#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
416#
417# This function acts as a mini web browswer submitting data
418# to our central server via the post method
419#
420#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000421sub SendData {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000422 $host = $_[0];
423 $file = $_[1];
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000424 $variables = $_[2];
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000425
Daniel Dunbara2533002009-05-28 18:31:40 +0000426 # Write out the "...-sentdata.txt" file.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000427
Daniel Dunbara2533002009-05-28 18:31:40 +0000428 my $sentdata="";
429 foreach $x (keys (%$variables)){
430 $value = $variables->{$x};
431 $sentdata.= "$x => $value\n";
432 }
433 WriteFile "$Prefix-sentdata.txt", $sentdata;
434
435 if (!($SUBMITAUX eq "")) {
Daniel Dunbar3b377ef2009-06-26 22:33:28 +0000436 system "$SUBMITAUX \"$Prefix-sentdata.txt\"";
437 }
438
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000439 if (!$SUBMIT) {
Daniel Dunbar3b377ef2009-06-26 22:33:28 +0000440 return "Skipped standard submit.\n";
Daniel Dunbara2533002009-05-28 18:31:40 +0000441 }
442
443 # Create the content to send to the server.
444
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000445 my $content;
446 foreach $key (keys (%$variables)){
447 $value = $variables->{$key};
448 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
449 $content .= "$key=$value&";
450 }
451
Daniel Dunbara2533002009-05-28 18:31:40 +0000452 # Send the data to the server.
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000453 #
Daniel Dunbara2533002009-05-28 18:31:40 +0000454 # FIXME: This code should be more robust?
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000455
Daniel Dunbara2533002009-05-28 18:31:40 +0000456 $port=80;
457 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
458 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
459 die "Bad socket\n";
460 connect SOCK, $socketaddr or die "Bad connection\n";
461 select((select(SOCK), $| = 1)[0]);
462
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000463 $length = length($content);
464
465 my $send= "POST $file HTTP/1.0\n";
466 $send.= "Host: $host\n";
467 $send.= "Content-Type: application/x-www-form-urlencoded\n";
468 $send.= "Content-length: $length\n\n";
469 $send.= "$content";
470
471 print SOCK $send;
472 my $result;
473 while(<SOCK>){
474 $result .= $_;
475 }
476 close(SOCK);
477
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000478 return $result;
479}
480
481##############################################################
482#
Daniel Dunbar2b9446e2009-10-19 13:20:31 +0000483# Individual Build & Test Functions
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000484#
485##############################################################
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000486
Daniel Dunbar2b9446e2009-10-19 13:20:31 +0000487# Create the source repository directory.
Daniel Dunbar4493e942009-10-19 13:20:06 +0000488sub CheckoutSource {
Daniel Dunbar4736b502009-10-20 07:30:54 +0000489 die "Invalid call!" unless $ConfigMode == 0;
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000490 if (-d $BuildDir) {
491 if (!$NOREMOVE) {
492 if ( $VERBOSE ) {
493 print "Build directory exists! Removing it\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000494 }
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000495 system "rm -rf $BuildDir";
Daniel Dunbar4493e942009-10-19 13:20:06 +0000496 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000497 } else {
498 if ( $VERBOSE ) {
499 print "Build directory exists!\n";
500 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000501 }
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000502 } else {
503 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
504 }
Daniel Dunbar4493e942009-10-19 13:20:06 +0000505
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000506 ChangeDir( $BuildDir, "checkout directory" );
507 my $SVNCMD = "$NICE svn co --non-interactive";
508 RunLoggedCommand("( time -p $SVNCMD $SVNURL/llvm/trunk llvm; cd llvm/projects ; " .
509 " $SVNCMD $TestSVNURL/test-suite/trunk llvm-test )", $COLog,
510 "CHECKOUT LLVM");
511 if ($WITHCLANG) {
512 RunLoggedCommand("( cd llvm/tools ; " .
513 " $SVNCMD $SVNURL/cfe/trunk clang )", $COLog,
514 "CHECKOUT CLANG");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000515 }
516}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000517
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000518# Build the entire tree, saving build messages to the build log. Returns false
519# on build failure.
Daniel Dunbarf2ec0092009-10-19 13:20:13 +0000520sub BuildLLVM {
Daniel Dunbar4736b502009-10-20 07:30:54 +0000521 die "Invalid call!" unless $ConfigMode == 0;
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000522 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
523 RunLoggedCommand("(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) ",
524 $ConfigureLog, "CONFIGURE");
525 # Build the entire tree, capturing the output into $BuildLog
Daniel Dunbar96aab412009-10-19 13:20:50 +0000526 RunAppendingLoggedCommand("($NICE $MAKECMD $MAKEOPTS clean)", $BuildLog, "BUILD CLEAN");
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000527 RunAppendingLoggedCommand("(time -p $NICE $MAKECMD $MAKEOPTS)", $BuildLog, "BUILD");
528
529 if (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
530 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l` + 0) {
531 return 0;
Daniel Dunbarf2ec0092009-10-19 13:20:13 +0000532 }
533
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000534 return 1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000535}
536
Daniel Dunbar2b9446e2009-10-19 13:20:31 +0000537# Running dejagnu tests and save results to log.
538sub RunDejaGNUTests {
Daniel Dunbar4736b502009-10-20 07:30:54 +0000539 die "Invalid call!" unless $ConfigMode == 0;
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000540 # Run the feature and regression tests, results are put into testrun.sum and
541 # the full log in testrun.log.
Daniel Dunbar96aab412009-10-19 13:20:50 +0000542 system "rm -f test/testrun.log test/testrun.sum";
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000543 RunLoggedCommand("(time -p $MAKECMD $MAKEOPTS check)", $DejagnuLog, "DEJAGNU");
Daniel Dunbar2b9446e2009-10-19 13:20:31 +0000544
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000545 # Copy the testrun.log and testrun.sum to our webdir.
546 CopyFile("test/testrun.log", $DejagnuLog);
547 CopyFile("test/testrun.sum", $DejagnuSum);
Daniel Dunbar2b9446e2009-10-19 13:20:31 +0000548
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000549 return GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000550}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000551
Daniel Dunbar2b9446e2009-10-19 13:20:31 +0000552# Run the named tests (i.e. "SingleSource" "MultiSource" "External")
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000553sub TestDirectory {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000554 my $SubDir = shift;
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000555 ChangeDir( "$LLVMTestDir/$SubDir",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000556 "Programs Test Subdirectory" ) || return ("", "");
Misha Brukmanafa1e862009-01-02 16:28:18 +0000557
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000558 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000559
Daniel Dunbar4736b502009-10-20 07:30:54 +0000560 # Make sure to clean things if in non-config mode.
561 if ($ConfigMode == 1) {
562 RunLoggedCommand("$MAKECMD -k $MAKEOPTS $PROGTESTOPTS clean $TESTFLAGS",
563 $ProgramTestLog, "TEST DIRECTORY $SubDir");
564 }
565
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000566 # Run the programs tests... creating a report.nightly.csv file.
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000567 my $LLCBetaOpts = "";
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000568 RunLoggedCommand("$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
569 "$TESTFLAGS TEST=nightly",
570 $ProgramTestLog, "TEST DIRECTORY $SubDir");
571 $LLCBetaOpts = `$MAKECMD print-llcbeta-option`;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000572
573 my $ProgramsTable;
574 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000575 $ProgramsTable="Error running test $SubDir\n";
576 print "ERROR TESTING\n";
577 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000578 $ProgramsTable="Makefile error running tests $SubDir!\n";
579 print "ERROR TESTING\n";
580 } else {
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000581 # Create a list of the tests which were run...
582 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
583 "| sort > $Prefix-$SubDir-Tests.txt";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000584 }
585 $ProgramsTable = ReadFile "report.nightly.csv";
586
587 ChangeDir( "../../..", "Programs Test Parent Directory" );
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000588 return ($ProgramsTable, $LLCBetaOpts);
589}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000590
Daniel Dunbarf4192812009-10-19 13:20:44 +0000591# Run all the nightly tests and return the program tables and the list of tests,
Daniel Dunbar2b9446e2009-10-19 13:20:31 +0000592# passes, fails, and xfails.
Daniel Dunbar2942b022009-10-19 13:20:25 +0000593sub RunNightlyTest() {
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000594 ($SSProgs, $llcbeta_options) = TestDirectory("SingleSource");
595 WriteFile "$Prefix-SingleSource-Performance.txt", $SSProgs;
596 ($MSProgs, $llcbeta_options) = TestDirectory("MultiSource");
597 WriteFile "$Prefix-MultiSource-Performance.txt", $MSProgs;
598 if ( ! $NOEXTERNALS ) {
599 ($ExtProgs, $llcbeta_options) = TestDirectory("External");
600 WriteFile "$Prefix-External-Performance.txt", $ExtProgs;
601 system "cat $Prefix-SingleSource-Tests.txt " .
602 "$Prefix-MultiSource-Tests.txt ".
603 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
604 system "cat $Prefix-SingleSource-Performance.txt " .
605 "$Prefix-MultiSource-Performance.txt ".
606 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
607 } else {
608 $ExtProgs = "External TEST STAGE SKIPPED\n";
609 if ( $VERBOSE ) {
610 print "External TEST STAGE SKIPPED\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000611 }
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000612 system "cat $Prefix-SingleSource-Tests.txt " .
613 "$Prefix-MultiSource-Tests.txt ".
614 " | sort > $Prefix-Tests.txt";
615 system "cat $Prefix-SingleSource-Performance.txt " .
616 "$Prefix-MultiSource-Performance.txt ".
617 " | sort > $Prefix-Performance.txt";
618 }
Daniel Dunbar2942b022009-10-19 13:20:25 +0000619
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000620 # Compile passes, fails, xfails.
Daniel Dunbarf4192812009-10-19 13:20:44 +0000621 my $All = (ReadFile "$Prefix-Tests.txt");
622 my @TestSuiteResultLines = split "\n", $All;
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000623 my ($Passes, $Fails, $XFails) = "";
Daniel Dunbar2942b022009-10-19 13:20:25 +0000624
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000625 for ($x=0; $x < @TestSuiteResultLines; $x++) {
626 if (@TestSuiteResultLines[$x] =~ m/^PASS:/) {
627 $Passes .= "$TestSuiteResultLines[$x]\n";
628 }
629 elsif (@TestSuiteResultLines[$x] =~ m/^FAIL:/) {
630 $Fails .= "$TestSuiteResultLines[$x]\n";
631 }
632 elsif (@TestSuiteResultLines[$x] =~ m/^XFAIL:/) {
633 $XFails .= "$TestSuiteResultLines[$x]\n";
Daniel Dunbar2942b022009-10-19 13:20:25 +0000634 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000635 }
636
Daniel Dunbarf4192812009-10-19 13:20:44 +0000637 return ($SSProgs, $MSProgs, $ExtProgs, $All, $Passes, $Fails, $XFails);
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000638}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000639
Daniel Dunbar2b9446e2009-10-19 13:20:31 +0000640##############################################################
641#
Daniel Dunbar4736b502009-10-20 07:30:54 +0000642# Initialize filenames
643#
644##############################################################
645
646if (! -d $WebDir) {
647 mkdir $WebDir, 0777 or die "Unable to create web directory: '$WebDir'.";
648 if($VERBOSE){
649 warn "$WebDir did not exist; creating it.\n";
650 }
651}
652
653if ($CONFIG_PATH ne "") {
654 $ConfigMode = 1;
655 $LLVMSrcDir = GetRegex "^(.*)\\s+", `$CONFIG_PATH --src-root`;
656 $LLVMObjDir = GetRegex "^(.*)\\s+", `$CONFIG_PATH --obj-root`;
657 # FIXME: Add llvm-config hook for this?
658 $LLVMTestDir = $LLVMObjDir . "/projects/test-suite";
659} else {
660 $ConfigureLog = "$Prefix-Configure-Log.txt";
661 $BuildLog = "$Prefix-Build-Log.txt";
662 $COLog = "$Prefix-CVS-Log.txt";
663 $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
664 $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
665 $DejagnuLog = "$Prefix-DejagnuTests-Log.txt";
666}
667
668if ($VERBOSE) {
669 if ($CONFIG_PATH ne "") {
670 print "INITIALIZED (config mode)\n";
671 print "WebDir = $WebDir\n";
672 print "Prefix = $Prefix\n";
673 print "LLVM Src = $LLVMSrcDir\n";
674 print "LLVM Obj = $LLVMObjDir\n";
675 print "LLVM Test = $LLVMTestDir\n";
676 } else {
677 print "INITIALIZED\n";
678 print "SVN URL = $SVNURL\n";
679 print "COLog = $COLog\n";
680 print "BuildDir = $BuildDir\n";
681 print "WebDir = $WebDir\n";
682 print "Prefix = $Prefix\n";
683 print "BuildLog = $BuildLog\n";
684 }
685}
686
687##############################################################
688#
Daniel Dunbar2b9446e2009-10-19 13:20:31 +0000689# The actual NewNightlyTest logic.
690#
691##############################################################
692
693$starttime = `date "+20%y-%m-%d %H:%M:%S"`;
694
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000695my $BuildError = 0, $BuildStatus = "OK";
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000696my $DejagnuTestResults = "Dejagnu skipped by user choice.";
Daniel Dunbar4736b502009-10-20 07:30:54 +0000697if ($ConfigMode == 0) {
698 if (!$NOCHECKOUT) {
699 CheckoutSource();
700 }
701
702 # Build LLVM.
703 ChangeDir( $LLVMSrcDir , "llvm source directory") ;
704 if ($NOCHECKOUT || $NOBUILD) {
705 $BuildStatus = "Skipped by user";
706 } else {
707 if (!BuildLLVM()) {
708 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
709 $BuildError = 1;
710 $BuildStatus = "Error: compilation aborted";
711 $NODEJAGNU=1;
712 }
713 }
714
715 # Run DejaGNU.
716 if (!$NODEJAGNU && !$BuildError) {
717 $DejagnuTestResults = RunDejaGNUTests();
718 }
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000719}
720
721# Run the llvm-test tests.
Daniel Dunbar2942b022009-10-19 13:20:25 +0000722my ($SingleSourceProgramsTable, $MultiSourceProgramsTable, $ExternalProgramsTable,
Daniel Dunbarf4192812009-10-19 13:20:44 +0000723 $all_tests, $passes, $fails, $xfails) = "";
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000724if (!$NOTEST && !$BuildError) {
725 ($SingleSourceProgramsTable, $MultiSourceProgramsTable, $ExternalProgramsTable,
Daniel Dunbarf4192812009-10-19 13:20:44 +0000726 $all_tests, $passes, $fails, $xfails) = RunNightlyTest();
Daniel Dunbara2b34e32009-10-19 13:20:38 +0000727}
Daniel Dunbar2942b022009-10-19 13:20:25 +0000728
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000729$endtime = `date "+20%y-%m-%d %H:%M:%S"`;
730
Daniel Dunbar96aab412009-10-19 13:20:50 +0000731# The last bit of logic is to remove the build and web dirs, after sending data
732# to the server.
733
Daniel Dunbar2b9446e2009-10-19 13:20:31 +0000734##############################################################
735#
736# Accumulate the information to send to the server.
737#
738##############################################################
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000739
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000740if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
741
Misha Brukmanafa1e862009-01-02 16:28:18 +0000742$machine_data = "uname: ".`uname -a`.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000743 "hardware: ".`uname -m`.
744 "os: ".`uname -sr`.
745 "name: ".`uname -n`.
746 "date: ".`date \"+20%y-%m-%d\"`.
Misha Brukmanafa1e862009-01-02 16:28:18 +0000747 "time: ".`date +\"%H:%M:%S\"`;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000748
Daniel Dunbar2b9446e2009-10-19 13:20:31 +0000749# Get gcc version.
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000750my $gcc_version_long = "";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000751if ($GCCPATH ne "") {
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000752 $gcc_version_long = `$GCCPATH/gcc --version`;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000753} elsif ($ENV{"CC"}) {
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000754 $gcc_version_long = `$ENV{"CC"} --version`;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000755} else {
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000756 $gcc_version_long = `gcc --version`;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000757}
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000758my $gcc_version = (split '\n', $gcc_version_long)[0];
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000759
Daniel Dunbar2b9446e2009-10-19 13:20:31 +0000760# Get llvm-gcc target triple.
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000761my $llvmgcc_version_long = "";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000762if ($LLVMGCCPATH ne "") {
763 $llvmgcc_version_long = `$LLVMGCCPATH/llvm-gcc -v 2>&1`;
764} else {
765 $llvmgcc_version_long = `llvm-gcc -v 2>&1`;
766}
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000767(split '\n', $llvmgcc_version_long)[1] =~ /Target: (.+)/;
768my $targetTriple = $1;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000769
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000770# Logs.
Daniel Dunbar4736b502009-10-20 07:30:54 +0000771my ($ConfigureLogData, $BuildLogData, $DejagnuLogData, $CheckoutLogData) = "";
772if ($ConfigMode == 0) {
773 $ConfigureLogData = ReadFile $ConfigureLog;
774 $BuildLogData = ReadFile $BuildLog;
775 $DejagnuLogData = ReadFile $DejagnuLog;
776 $CheckoutLogData = ReadFile $COLog;
777}
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000778
Daniel Dunbarf2ec0092009-10-19 13:20:13 +0000779# Checkout info.
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000780my $CheckoutTime_Wall = GetRegex "^real ([0-9.]+)", $CheckoutLogData;
781my $CheckoutTime_User = GetRegex "^user ([0-9.]+)", $CheckoutLogData;
782my $CheckoutTime_Sys = GetRegex "^sys ([0-9.]+)", $CheckoutLogData;
Daniel Dunbar4493e942009-10-19 13:20:06 +0000783my $CheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
784
Daniel Dunbarf2ec0092009-10-19 13:20:13 +0000785# Configure info.
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000786my $ConfigTimeU = GetRegex "^user ([0-9.]+)", $ConfigureLogData;
787my $ConfigTimeS = GetRegex "^sys ([0-9.]+)", $ConfigureLogData;
Daniel Dunbarf2ec0092009-10-19 13:20:13 +0000788my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000789my $ConfigWallTime = GetRegex "^real ([0-9.]+)",$ConfigureLogData;
Daniel Dunbarf2ec0092009-10-19 13:20:13 +0000790$ConfigTime=-1 unless $ConfigTime;
791$ConfigWallTime=-1 unless $ConfigWallTime;
792
793# Build info.
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000794my $BuildTimeU = GetRegex "^user ([0-9.]+)", $BuildLogData;
795my $BuildTimeS = GetRegex "^sys ([0-9.]+)", $BuildLogData;
Daniel Dunbarf2ec0092009-10-19 13:20:13 +0000796my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000797my $BuildWallTime = GetRegex "^real ([0-9.]+)", $BuildLogData;
Daniel Dunbarf2ec0092009-10-19 13:20:13 +0000798$BuildTime=-1 unless $BuildTime;
799$BuildWallTime=-1 unless $BuildWallTime;
800
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000801# DejaGNU info.
802my $DejagnuTimeU = GetRegex "^user ([0-9.]+)", $DejagnuLogData;
803my $DejagnuTimeS = GetRegex "^sys ([0-9.]+)", $DejagnuLogData;
804$DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
805$DejagnuWallTime = GetRegex "^real ([0-9.]+)", $DejagnuLogData;
806$DejagnuTime = "0.0" unless $DejagnuTime;
807$DejagnuWallTime = "0.0" unless $DejagnuWallTime;
Daniel Dunbarf2ec0092009-10-19 13:20:13 +0000808
Daniel Dunbar96aab412009-10-19 13:20:50 +0000809if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
810
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000811my %hash_of_data = (
812 'machine_data' => $machine_data,
Daniel Dunbarce25daf2009-10-19 13:20:19 +0000813 'build_data' => $ConfigureLogData . $BuildLogData,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000814 'gcc_version' => $gcc_version,
815 'nickname' => $nickname,
816 'dejagnutime_wall' => $DejagnuWallTime,
817 'dejagnutime_cpu' => $DejagnuTime,
818 'cvscheckouttime_wall' => $CheckoutTime_Wall,
819 'cvscheckouttime_cpu' => $CheckoutTime_CPU,
820 'configtime_wall' => $ConfigWallTime,
821 'configtime_cpu'=> $ConfigTime,
822 'buildtime_wall' => $BuildWallTime,
823 'buildtime_cpu' => $BuildTime,
Daniel Dunbar96aab412009-10-19 13:20:50 +0000824 'buildstatus' => $BuildStatus,
825 'singlesource_programstable' => $SingleSourceProgramsTable,
826 'multisource_programstable' => $MultiSourceProgramsTable,
827 'externalsource_programstable' => $ExternalProgramsTable,
828 'llcbeta_options' => $llcbeta_options,
829 'passing_tests' => $passes,
830 'expfail_tests' => $xfails,
831 'unexpfail_tests' => $fails,
832 'all_tests' => $all_tests,
833 'dejagnutests_results' => $DejagnuTestResults,
834 'dejagnutests_log' => $DejagnuLogData,
835 'starttime' => $starttime,
836 'endtime' => $endtime,
837 'target_triple' => $targetTriple,
838
839 # Unused, but left around for backwards compatability.
Daniel Dunbar6981e022009-10-19 13:19:53 +0000840 'warnings' => "",
Daniel Dunbar9ec7b9e2009-10-19 09:19:09 +0000841 'cvsusercommitlist' => "",
842 'cvsuserupdatelist' => "",
843 'cvsaddedfiles' => "",
844 'cvsmodifiedfiles' => "",
845 'cvsremovedfiles' => "",
846 'lines_of_code' => "",
847 'cvs_file_count' => 0,
848 'cvs_dir_count' => 0,
Daniel Dunbar6981e022009-10-19 13:19:53 +0000849 'warnings_removed' => "",
850 'warnings_added' => "",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000851 'new_tests' => "",
852 'removed_tests' => "",
Daniel Dunbar3c52ad12009-10-19 13:20:00 +0000853 'o_file_sizes' => "",
Daniel Dunbar96aab412009-10-19 13:20:50 +0000854 'a_file_sizes' => ""
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000855);
856
Daniel Dunbar3b377ef2009-06-26 22:33:28 +0000857if ($SUBMIT || !($SUBMITAUX eq "")) {
Tanya Lattner084a3ee2008-03-10 07:28:08 +0000858 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
859 if( $VERBOSE) { print "============================\n$response"; }
860} else {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000861 print "============================\n";
862 foreach $x(keys %hash_of_data){
863 print "$x => $hash_of_data{$x}\n";
864 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000865}
866
867##############################################################
868#
Daniel Dunbar414cffe2009-10-19 09:18:54 +0000869# Remove the source tree...
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000870#
871##############################################################
Misha Brukmanafa1e862009-01-02 16:28:18 +0000872system ( "$NICE rm -rf $BuildDir")
Daniel Dunbard3ecefe2009-07-13 22:17:49 +0000873 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVEATEND);
Misha Brukmanafa1e862009-01-02 16:28:18 +0000874system ( "$NICE rm -rf $WebDir")
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000875 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);