blob: 1b48168262a5f3354628b900b4b0ce76a1bb3bcb [file] [log] [blame]
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001#!/usr/bin/perl
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00002use POSIX qw(strftime);
3use File::Copy;
Bob Wilson6dc11b42009-06-19 17:19:38 +00004use File::Find;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +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 Brukman12c8d1b2009-01-02 16:28:18 +000012# regressions and performance changes. Submits this information
Reid Spencerfa34d7b2006-08-13 09:53:02 +000013# to llvm.org where it is placed into the nightlytestresults database.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000014#
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000015# Syntax: NightlyTest.pl [OPTIONS] [CVSROOT BUILDDIR WEBDIR]
16# where
17# OPTIONS may include one or more of the following:
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000018#
Daniel Dunbar4628e5e2009-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.
Daniel Dunbarc6139692010-03-16 15:53:02 +000027# -nouname Don't include uname data (machine will be identified by nickname only).
Patrick Jenkins0e9402f2006-08-11 23:02:09 +000028# -submit-server Specifies a server to submit the test results too. If this
Misha Brukman12c8d1b2009-01-02 16:28:18 +000029# option is not specified it defaults to
30# llvm.org. This is basically just the address of the
Patrick Jenkins0e9402f2006-08-11 23:02:09 +000031# webserver
32# -submit-script Specifies which script to call on the submit server. If
33# this option is not specified it defaults to
Misha Brukman12c8d1b2009-01-02 16:28:18 +000034# /nightlytest/NightlyTestAccept.php. This is basically
Patrick Jenkins0e9402f2006-08-11 23:02:09 +000035# everything after the www.yourserver.org.
Daniel Dunbarcd3f9992009-05-18 23:24:26 +000036# -submit-aux If specified, an auxiliary script to run in addition to the
37# normal submit script. The script will be passed the path to
38# the "sentdata.txt" file as its sole argument.
Tanya Lattnerc1611882008-03-10 07:28:08 +000039# -nosubmit Do not report the test results back to a submit server.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000040#
Daniel Dunbar4628e5e2009-10-19 09:18:24 +000041#
42# BUILD OPTIONS (not used with -config):
43# -nocheckout Do not create, checkout, update, or configure
44# the source tree.
45# -noremove Do not remove the BUILDDIR after it has been built.
46# -noremoveresults Do not remove the WEBDIR after it has been built.
Daniel Dunbarda420ee2009-11-06 04:12:07 +000047# -noclean Do not run 'make clean' before building.
Daniel Dunbar4628e5e2009-10-19 09:18:24 +000048# -nobuild Do not build llvm. If tests are enabled perform them
49# on the llvm build specified in the build directory
Duncan Sands8246adc2010-07-07 07:48:00 +000050# -release Build an LLVM Release+Asserts version
51# -release-asserts Build an LLVM Release version
Daniel Dunbar4628e5e2009-10-19 09:18:24 +000052# -disable-bindings Disable building LLVM bindings.
Daniel Dunbar4628e5e2009-10-19 09:18:24 +000053# -with-clang Checkout Clang source into tools/clang.
54# -compileflags Next argument specifies extra options passed to make when
55# building LLVM.
56# -use-gmake Use gmake instead of the default make command to build
57# llvm and run tests.
Daniel Dunbar2d7adb52009-11-06 04:11:29 +000058# -llvmgccdir Next argument specifies the llvm-gcc install prefix.
Daniel Dunbar4628e5e2009-10-19 09:18:24 +000059#
60# TESTING OPTIONS:
61# -notest Do not even attempt to run the test programs.
62# -nodejagnu Do not run feature or regression tests
63# -enable-llcbeta Enable testing of beta features in llc.
64# -enable-lli Enable testing of lli (interpreter) features, default is off
65# -disable-pic Disable building with Position Independent Code.
66# -disable-llc Disable LLC tests in the nightly tester.
67# -disable-jit Disable JIT tests in the nightly tester.
68# -disable-cbe Disable C backend tests in the nightly tester.
69# -disable-lto Disable link time optimization.
70# -test-cflags Next argument specifies that C compilation options that
71# override the default when running the testsuite.
72# -test-cxxflags Next argument specifies that C++ compilation options that
73# override the default when running the testsuite.
74# -extraflags Next argument specifies extra options that are passed to
75# compile the tests.
76# -noexternals Do not run the external tests (for cases where povray
77# or SPEC are not installed)
78# -with-externals Specify a directory where the external tests are located.
79#
80# OTHER OPTIONS:
81# -parallel Run parallel jobs with GNU Make (see -parallel-jobs).
82# -parallel-jobs The number of parallel Make jobs to use (default is two).
Daniel Dunbarddef0952009-10-19 13:20:56 +000083# -parallel-test Allow parallel execution of llvm-test
Daniel Dunbar4628e5e2009-10-19 09:18:24 +000084# -verbose Turn on some debug output
Daniel Dunbar4628e5e2009-10-19 09:18:24 +000085# -nice Checkout/Configure/Build with "nice" to reduce impact
86# on busy servers.
87# -f2c Next argument specifies path to F2C utility
88# -gccpath Path to gcc/g++ used to build LLVM
89# -target Specify the target triplet
90# -cflags Next argument specifies that C compilation options that
91# override the default.
92# -cxxflags Next argument specifies that C++ compilation options that
93# override the default.
94# -ldflags Next argument specifies that linker options that override
95# the default.
96#
Daniel Dunbar2e107942009-10-19 09:18:54 +000097# CVSROOT is ignored, it is passed for backwards compatibility.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000098# BUILDDIR is the directory where sources for this test run will be checked out
99# AND objects for this test run will be built. This directory MUST NOT
Daniel Dunbar2e107942009-10-19 09:18:54 +0000100# exist before the script is run; it will be created by the svn checkout
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000101# process and erased (unless -noremove is specified; see above.)
102# WEBDIR is the directory into which the test results web page will be written,
103# AND in which the "index.html" is assumed to be a symlink to the most recent
104# copy of the results. This directory will be created if it does not exist.
105# LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
106# to. This is the same as you would have for a normal LLVM build.
107#
108##############################################################
109#
110# Getting environment variables
111#
112##############################################################
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000113my $HOME = $ENV{'HOME'};
Reid Spencer99e865a2007-04-07 04:41:16 +0000114my $SVNURL = $ENV{"SVNURL"};
Duncan Sands45db29c2009-06-12 13:02:52 +0000115$SVNURL = 'http://llvm.org/svn/llvm-project' unless $SVNURL;
Evan Cheng53df0a22009-06-18 21:39:50 +0000116my $TestSVNURL = $ENV{"TestSVNURL"};
Evan Chenge11c4db2009-07-14 06:23:41 +0000117$TestSVNURL = 'http://llvm.org/svn/llvm-project' unless $TestSVNURL;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000118my $BuildDir = $ENV{'BUILDDIR'};
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000119my $WebDir = $ENV{'WEBDIR'};
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000120
121##############################################################
122#
123# Calculate the date prefix...
124#
125##############################################################
Daniel Dunbar6580da42009-11-06 04:12:13 +0000126use POSIX;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000127@TIME = localtime;
Daniel Dunbar6580da42009-11-06 04:12:13 +0000128my $DATE = strftime("%Y-%m-%d_%H-%M-%S", localtime());
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000129
130##############################################################
131#
132# Parse arguments...
133#
134##############################################################
Daniel Dunbar4628e5e2009-10-19 09:18:24 +0000135$CONFIG_PATH="";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000136$CONFIGUREARGS="";
Patrick Jenkins49717a42006-07-21 01:39:42 +0000137$nickname="";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000138$NOTEST=0;
Patrick Jenkins1cd46912006-07-27 01:17:17 +0000139$MAKECMD="make";
Patrick Jenkins0e9402f2006-08-11 23:02:09 +0000140$SUBMITSERVER = "llvm.org";
Jim Laskey6d8a1b72006-09-15 17:03:36 +0000141$SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
Daniel Dunbarcd3f9992009-05-18 23:24:26 +0000142$SUBMITAUX="";
Tanya Lattnerc1611882008-03-10 07:28:08 +0000143$SUBMIT = 1;
Daniel Dunbar056dbd02009-05-28 22:45:24 +0000144$PARALLELJOBS = "2";
Bill Wendling49e31822009-07-16 22:59:17 +0000145my $TESTFLAGS="";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000146
Daniel Dunbar2d7adb52009-11-06 04:11:29 +0000147if ($ENV{'LLVMGCCDIR'}) {
148 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
149 $LLVMGCCPATH = $ENV{'LLVMGCCDIR'} . '/bin';
150}
151else {
152 $LLVMGCCPATH = "";
153}
154
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000155while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000156 shift;
157 last if /^--$/; # Stop processing arguments on --
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000158
159 # List command line options here...
Daniel Dunbar4628e5e2009-10-19 09:18:24 +0000160 if (/^-config$/) { $CONFIG_PATH = "$ARGV[0]"; shift; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000161 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
Daniel Dunbarda420ee2009-11-06 04:12:07 +0000162 if (/^-noclean$/) { $NOCLEAN = 1; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000163 if (/^-noremove$/) { $NOREMOVE = 1; next; }
Daniel Dunbar0c39e382009-07-13 22:17:49 +0000164 if (/^-noremoveatend$/) { $NOREMOVEATEND = 1; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000165 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
Daniel Dunbarf5a59502009-06-02 21:14:15 +0000166 if (/^-notest$/) { $NOTEST = 1; next; }
167 if (/^-norunningtests$/) { next; } # Backward compatibility, ignored.
Daniel Dunbar056dbd02009-05-28 22:45:24 +0000168 if (/^-parallel-jobs$/) { $PARALLELJOBS = "$ARGV[0]"; shift; next;}
Daniel Dunbar2bb4c532009-10-19 13:20:50 +0000169 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j$PARALLELJOBS"; next; }
Daniel Dunbarddef0952009-10-19 13:20:56 +0000170 if (/^-parallel-test$/) { $PROGTESTOPTS .= " ENABLE_PARALLEL_REPORT=1"; next; }
Duncan Sands45db29c2009-06-12 13:02:52 +0000171 if (/^-with-clang$/) { $WITHCLANG = 1; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000172 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
Daniel Dunbarf2741382009-10-20 07:30:46 +0000173 "OPTIMIZE_OPTION=-O2"; next;}
Jim Laskey27b8ba02006-09-28 17:49:20 +0000174 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
Dan Gohmanc6e22412008-10-30 01:08:03 +0000175 "DISABLE_ASSERTIONS=1 ".
Daniel Dunbarf2741382009-10-20 07:30:46 +0000176 "OPTIMIZE_OPTION=-O2"; next;}
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000177 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
Duncan Sands45db29c2009-06-12 13:02:52 +0000178 if (/^-disable-pic$/) { $CONFIGUREARGS .= " --enable-pic=no"; next; }
Reid Spencer2bae1f52006-11-24 20:34:16 +0000179 if (/^-enable-lli$/) { $PROGTESTOPTS .= " ENABLE_LLI=1";
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000180 $CONFIGUREARGS .= " --enable-lli"; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000181 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000182 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000183 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
184 $CONFIGUREARGS .= " --disable-jit"; next; }
Daniel Dunbar111def82009-03-10 19:33:13 +0000185 if (/^-disable-bindings$/) { $CONFIGUREARGS .= " --disable-bindings"; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000186 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
Evan Chenge04c90b2008-01-12 04:27:18 +0000187 if (/^-disable-lto$/) { $PROGTESTOPTS .= " DISABLE_LTO=1"; next; }
Evan Cheng3d64f1c2008-01-14 17:58:03 +0000188 if (/^-test-opts$/) { $PROGTESTOPTS .= " $ARGV[0]"; shift; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000189 if (/^-verbose$/) { $VERBOSE = 1; next; }
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000190 if (/^-teelogs$/) { $TEELOGS = 1; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000191 if (/^-nice$/) { $NICE = "nice "; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000192 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000193 shift; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000194 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000195 shift; next; }
Daniel Dunbarff79ef42009-07-13 22:31:58 +0000196 if (/^-configure-args$/) { $CONFIGUREARGS .= " $ARGV[0]";
197 shift; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000198 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
199 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
Daniel Dunbarcd3f9992009-05-18 23:24:26 +0000200 if (/^-submit-aux/) { $SUBMITAUX = "$ARGV[0]"; shift; next; }
Tanya Lattnerc1611882008-03-10 07:28:08 +0000201 if (/^-nosubmit$/) { $SUBMIT = 0; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000202 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
203 if (/^-gccpath/) { $CONFIGUREARGS .=
204 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000205 $GCCPATH=$ARGV[0]; shift; next; }
206 else { $GCCPATH=""; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000207 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000208 shift; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000209 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000210 shift; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000211 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000212 shift; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000213 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000214 shift; next; }
Bill Wendling49e31822009-07-16 22:59:17 +0000215 if (/^-test-cflags/) { $TESTFLAGS = "$TESTFLAGS CFLAGS=\'$ARGV[0]\'";
216 shift; next; }
217 if (/^-test-cxxflags/) { $TESTFLAGS = "$TESTFLAGS CXXFLAGS=\'$ARGV[0]\'";
218 shift; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000219 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
Daniel Dunbar2d7adb52009-11-06 04:11:29 +0000220 if (/^-llvmgccdir/) { $CONFIGUREARGS .= " --with-llvmgccdir=\'$ARGV[0]\'";
221 $LLVMGCCPATH = $ARGV[0] . '/bin';
222 shift; next;}
223 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
Daniel Dunbarc6139692010-03-16 15:53:02 +0000224 if (/^-nouname$/) { $NOUNAME = 1; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000225 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000226 if (/^-extraflags/) { $CONFIGUREARGS .=
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000227 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
228 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
Daniel Dunbar539e1872009-11-08 09:34:14 +0000229 if (/^-nodejagnu$/) { next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000230 if (/^-nobuild$/) { $NOBUILD = 1; next; }
231 print "Unknown option: $_ : ignoring!\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000232}
233
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000234if ($CONFIGUREARGS !~ /--disable-jit/) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000235 $CONFIGUREARGS .= " --enable-jit";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000236}
237
Daniel Dunbar0e9fe692009-10-19 09:19:19 +0000238if (@ARGV != 0 and @ARGV != 3) {
239 die "error: must specify 0 or 3 options!";
Patrick Jenkinsf58473f2006-07-27 01:03:46 +0000240}
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000241
242if (@ARGV == 3) {
Daniel Dunbar0e9fe692009-10-19 09:19:19 +0000243 if ($CONFIG_PATH ne "") {
244 die "error: arguments are unsupported in -config mode,";
245 }
246
Daniel Dunbar2e107942009-10-19 09:18:54 +0000247 # ARGV[0] used to be the CVS root, ignored for backward compatibility.
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000248 $BuildDir = $ARGV[1];
249 $WebDir = $ARGV[2];
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000250}
251
Daniel Dunbar80dd4532009-10-20 07:30:54 +0000252if ($CONFIG_PATH ne "") {
253 $BuildDir = "";
254 $SVNURL = $TestSVNURL = "";
255 if ($WebDir eq "") {
256 die("please specify a web directory");
257 }
258} else {
259 if ($BuildDir eq "" or
260 $WebDir eq "") {
261 die("please specify a build directory, and a web directory");
262 }
263}
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000264
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000265if ($nickname eq "") {
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000266 die ("Please invoke NewNightlyTest.pl with command line option " .
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000267 "\"-nickname <nickname>\"");
Patrick Jenkins514e2582006-07-20 22:28:43 +0000268}
Patrick Jenkins1cd46912006-07-27 01:17:17 +0000269
Daniel Dunbarfe1974a2009-11-06 04:12:02 +0000270my $LLVMSrcDir = $ENV{'LLVMSRCDIR'};
271$LLVMSrcDir = "$BuildDir/llvm" unless $LLVMSrcDir;
272my $LLVMObjDir = $ENV{'LLVMOBJDIR'};
273$LLVMObjDir = "$BuildDir/llvm" unless $LLVMObjDir;
274my $LLVMTestDir = $ENV{'LLVMTESTDIR'};
275$LLVMTestDir = "$BuildDir/llvm/projects/llvm-test" unless $LLVMTestDir;
276
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000277##############################################################
278#
Daniel Dunbar4628e5e2009-10-19 09:18:24 +0000279# Define the file names we'll use
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000280#
281##############################################################
Daniel Dunbar80dd4532009-10-20 07:30:54 +0000282
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000283my $Prefix = "$WebDir/$DATE";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000284my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
285my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
Patrick Jenkins26ba6092006-07-23 22:57:28 +0000286my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000287
Daniel Dunbar80dd4532009-10-20 07:30:54 +0000288# These are only valid in non-config mode.
289my $ConfigureLog = "", $BuildLog = "", $COLog = "";
290my $DejagnuLog = "", $DejagnuSum = "", $DejagnuLog = "";
291
292# Are we in config mode?
293my $ConfigMode = 0;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000294
295##############################################################
296#
297# Helper functions
298#
299##############################################################
Daniel Dunbar4628e5e2009-10-19 09:18:24 +0000300
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000301sub GetDir {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000302 my $Suffix = shift;
303 opendir DH, $WebDir;
304 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
305 closedir DH;
306 return @Result;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000307}
308
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000309sub RunLoggedCommand {
310 my $Command = shift;
311 my $Log = shift;
Daniel Dunbarfc0fc3a2009-06-26 02:30:49 +0000312 my $Title = shift;
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000313 if ($TEELOGS) {
Daniel Dunbarfc0fc3a2009-06-26 02:30:49 +0000314 if ($VERBOSE) {
315 print "$Title\n";
316 print "$Command 2>&1 | tee $Log\n";
317 }
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000318 system "$Command 2>&1 | tee $Log";
319 } else {
Daniel Dunbarfc0fc3a2009-06-26 02:30:49 +0000320 if ($VERBOSE) {
321 print "$Title\n";
Daniel Dunbar96820432009-12-15 00:41:47 +0000322 print "$Command > $Log 2>&1\n";
Daniel Dunbarfc0fc3a2009-06-26 02:30:49 +0000323 }
Daniel Dunbar96820432009-12-15 00:41:47 +0000324 system "$Command > $Log 2>&1";
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000325 }
326}
327
328sub RunAppendingLoggedCommand {
329 my $Command = shift;
330 my $Log = shift;
Daniel Dunbarfc0fc3a2009-06-26 02:30:49 +0000331 my $Title = shift;
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000332 if ($TEELOGS) {
Daniel Dunbarfc0fc3a2009-06-26 02:30:49 +0000333 if ($VERBOSE) {
334 print "$Title\n";
335 print "$Command 2>&1 | tee -a $Log\n";
336 }
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000337 system "$Command 2>&1 | tee -a $Log";
338 } else {
Daniel Dunbarfc0fc3a2009-06-26 02:30:49 +0000339 if ($VERBOSE) {
340 print "$Title\n";
Daniel Dunbar96820432009-12-15 00:41:47 +0000341 print "$Command >> $Log 2>&1\n";
Daniel Dunbarfc0fc3a2009-06-26 02:30:49 +0000342 }
Daniel Dunbar96820432009-12-15 00:41:47 +0000343 system "$Command >> $Log 2>&1";
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000344 }
345}
346
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000347sub GetRegex { # (Regex with ()'s, value)
Daniel Dunbar34311232009-10-19 13:20:19 +0000348 if ($_[1] =~ /$_[0]/m) {
349 return $1;
350 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000351 return "0";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000352}
353
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000354sub ChangeDir { # directory, logical name
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000355 my ($dir,$name) = @_;
356 chomp($dir);
357 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
358 $result = chdir($dir);
359 if (!$result) {
Daniel Dunbar2bb4c532009-10-19 13:20:50 +0000360 print "ERROR!!! Cannot change directory to: $name ($dir) because $!\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000361 return false;
362 }
363 return true;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000364}
365
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000366sub ReadFile {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000367 if (open (FILE, $_[0])) {
368 undef $/;
369 my $Ret = <FILE>;
370 close FILE;
371 $/ = '\n';
372 return $Ret;
373 } else {
374 print "Could not open file '$_[0]' for reading!\n";
375 return "";
376 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000377}
378
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000379sub WriteFile { # (filename, contents)
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000380 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
381 print FILE $_[1];
382 close FILE;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000383}
384
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000385sub CopyFile { #filename, newfile
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000386 my ($file, $newfile) = @_;
387 chomp($file);
388 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
389 copy($file, $newfile);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000390}
391
392#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000393#
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000394# This function acts as a mini web browswer submitting data
395# to our central server via the post method
396#
397#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Daniel Dunbar1b54d422009-12-14 17:58:27 +0000398sub WriteSentData {
399 $variables = $_[0];
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000400
Daniel Dunbar94a37a42009-05-28 18:31:40 +0000401 # Write out the "...-sentdata.txt" file.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000402
Daniel Dunbar94a37a42009-05-28 18:31:40 +0000403 my $sentdata="";
404 foreach $x (keys (%$variables)){
405 $value = $variables->{$x};
406 $sentdata.= "$x => $value\n";
407 }
408 WriteFile "$Prefix-sentdata.txt", $sentdata;
Daniel Dunbar1b54d422009-12-14 17:58:27 +0000409}
410
411sub SendData {
412 $host = $_[0];
413 $file = $_[1];
414 $variables = $_[2];
Daniel Dunbar94a37a42009-05-28 18:31:40 +0000415
416 if (!($SUBMITAUX eq "")) {
Daniel Dunbarf7f02a92009-06-26 22:33:28 +0000417 system "$SUBMITAUX \"$Prefix-sentdata.txt\"";
418 }
419
Daniel Dunbar4628e5e2009-10-19 09:18:24 +0000420 if (!$SUBMIT) {
Daniel Dunbarf7f02a92009-06-26 22:33:28 +0000421 return "Skipped standard submit.\n";
Daniel Dunbar94a37a42009-05-28 18:31:40 +0000422 }
423
424 # Create the content to send to the server.
425
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000426 my $content;
427 foreach $key (keys (%$variables)){
428 $value = $variables->{$key};
429 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
430 $content .= "$key=$value&";
431 }
432
Daniel Dunbar94a37a42009-05-28 18:31:40 +0000433 # Send the data to the server.
Daniel Dunbar4628e5e2009-10-19 09:18:24 +0000434 #
Daniel Dunbar94a37a42009-05-28 18:31:40 +0000435 # FIXME: This code should be more robust?
Daniel Dunbar4628e5e2009-10-19 09:18:24 +0000436
Daniel Dunbar94a37a42009-05-28 18:31:40 +0000437 $port=80;
438 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
439 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
440 die "Bad socket\n";
441 connect SOCK, $socketaddr or die "Bad connection\n";
442 select((select(SOCK), $| = 1)[0]);
443
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000444 $length = length($content);
445
446 my $send= "POST $file HTTP/1.0\n";
Lauro Ramos Venancio46040232007-05-03 14:05:07 +0000447 $send.= "Host: $host\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000448 $send.= "Content-Type: application/x-www-form-urlencoded\n";
449 $send.= "Content-length: $length\n\n";
450 $send.= "$content";
451
Patrick Jenkinse8501eb2006-08-07 01:54:37 +0000452 print SOCK $send;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000453 my $result;
454 while(<SOCK>){
455 $result .= $_;
456 }
457 close(SOCK);
458
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000459 return $result;
460}
461
Patrick Jenkins215b48f2006-07-07 18:50:51 +0000462##############################################################
463#
Daniel Dunbar5381eb72009-10-19 13:20:31 +0000464# Individual Build & Test Functions
Patrick Jenkins215b48f2006-07-07 18:50:51 +0000465#
466##############################################################
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000467
Daniel Dunbar5381eb72009-10-19 13:20:31 +0000468# Create the source repository directory.
Daniel Dunbar8df92e82009-10-19 13:20:06 +0000469sub CheckoutSource {
Daniel Dunbar80dd4532009-10-20 07:30:54 +0000470 die "Invalid call!" unless $ConfigMode == 0;
Daniel Dunbar1409c132009-10-19 13:20:38 +0000471 if (-d $BuildDir) {
472 if (!$NOREMOVE) {
473 if ( $VERBOSE ) {
474 print "Build directory exists! Removing it\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000475 }
Daniel Dunbar1409c132009-10-19 13:20:38 +0000476 system "rm -rf $BuildDir";
Daniel Dunbar8df92e82009-10-19 13:20:06 +0000477 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
Daniel Dunbar1409c132009-10-19 13:20:38 +0000478 } else {
479 if ( $VERBOSE ) {
480 print "Build directory exists!\n";
481 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000482 }
Daniel Dunbar1409c132009-10-19 13:20:38 +0000483 } else {
484 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
485 }
Daniel Dunbar8df92e82009-10-19 13:20:06 +0000486
Daniel Dunbar1409c132009-10-19 13:20:38 +0000487 ChangeDir( $BuildDir, "checkout directory" );
488 my $SVNCMD = "$NICE svn co --non-interactive";
489 RunLoggedCommand("( time -p $SVNCMD $SVNURL/llvm/trunk llvm; cd llvm/projects ; " .
490 " $SVNCMD $TestSVNURL/test-suite/trunk llvm-test )", $COLog,
491 "CHECKOUT LLVM");
492 if ($WITHCLANG) {
493 RunLoggedCommand("( cd llvm/tools ; " .
494 " $SVNCMD $SVNURL/cfe/trunk clang )", $COLog,
495 "CHECKOUT CLANG");
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000496 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000497}
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000498
Daniel Dunbar1409c132009-10-19 13:20:38 +0000499# Build the entire tree, saving build messages to the build log. Returns false
500# on build failure.
Daniel Dunbar439801e2009-10-19 13:20:13 +0000501sub BuildLLVM {
Daniel Dunbar80dd4532009-10-20 07:30:54 +0000502 die "Invalid call!" unless $ConfigMode == 0;
Daniel Dunbar1409c132009-10-19 13:20:38 +0000503 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
504 RunLoggedCommand("(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) ",
505 $ConfigureLog, "CONFIGURE");
506 # Build the entire tree, capturing the output into $BuildLog
Daniel Dunbarda420ee2009-11-06 04:12:07 +0000507 if (!$NOCLEAN) {
508 RunAppendingLoggedCommand("($NICE $MAKECMD $MAKEOPTS clean)", $BuildLog, "BUILD CLEAN");
509 }
Daniel Dunbar1409c132009-10-19 13:20:38 +0000510 RunAppendingLoggedCommand("(time -p $NICE $MAKECMD $MAKEOPTS)", $BuildLog, "BUILD");
511
Daniel Dunbar252a0df2009-12-14 17:58:33 +0000512 if (`grep -a '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
513 `grep -a '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l` + 0) {
Daniel Dunbar1409c132009-10-19 13:20:38 +0000514 return 0;
Daniel Dunbar439801e2009-10-19 13:20:13 +0000515 }
516
Daniel Dunbar1409c132009-10-19 13:20:38 +0000517 return 1;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000518}
519
Daniel Dunbar5381eb72009-10-19 13:20:31 +0000520# Run the named tests (i.e. "SingleSource" "MultiSource" "External")
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000521sub TestDirectory {
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000522 my $SubDir = shift;
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000523 ChangeDir( "$LLVMTestDir/$SubDir",
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000524 "Programs Test Subdirectory" ) || return ("", "");
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000525
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000526 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000527
Daniel Dunbarda420ee2009-11-06 04:12:07 +0000528 # Make sure to clean the test results.
529 RunLoggedCommand("$MAKECMD -k $MAKEOPTS $PROGTESTOPTS clean $TESTFLAGS",
530 $ProgramTestLog, "TEST DIRECTORY $SubDir");
Daniel Dunbar80dd4532009-10-20 07:30:54 +0000531
Daniel Dunbar1409c132009-10-19 13:20:38 +0000532 # Run the programs tests... creating a report.nightly.csv file.
Daniel Dunbar34311232009-10-19 13:20:19 +0000533 my $LLCBetaOpts = "";
Daniel Dunbar1409c132009-10-19 13:20:38 +0000534 RunLoggedCommand("$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
535 "$TESTFLAGS TEST=nightly",
536 $ProgramTestLog, "TEST DIRECTORY $SubDir");
537 $LLCBetaOpts = `$MAKECMD print-llcbeta-option`;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000538
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000539 my $ProgramsTable;
Daniel Dunbar252a0df2009-12-14 17:58:33 +0000540 if (`grep -a '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000541 $ProgramsTable="Error running test $SubDir\n";
542 print "ERROR TESTING\n";
Daniel Dunbar252a0df2009-12-14 17:58:33 +0000543 } elsif (`grep -a '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000544 $ProgramsTable="Makefile error running tests $SubDir!\n";
545 print "ERROR TESTING\n";
546 } else {
Daniel Dunbar1409c132009-10-19 13:20:38 +0000547 # Create a list of the tests which were run...
Daniel Dunbar252a0df2009-12-14 17:58:33 +0000548 system "egrep -a 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
Daniel Dunbar1409c132009-10-19 13:20:38 +0000549 "| sort > $Prefix-$SubDir-Tests.txt";
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000550 }
551 $ProgramsTable = ReadFile "report.nightly.csv";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000552
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000553 ChangeDir( "../../..", "Programs Test Parent Directory" );
Daniel Dunbar34311232009-10-19 13:20:19 +0000554 return ($ProgramsTable, $LLCBetaOpts);
555}
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000556
Daniel Dunbarac0c0642009-10-19 13:20:44 +0000557# Run all the nightly tests and return the program tables and the list of tests,
Daniel Dunbar5381eb72009-10-19 13:20:31 +0000558# passes, fails, and xfails.
Daniel Dunbar4a338bf2009-10-19 13:20:25 +0000559sub RunNightlyTest() {
Daniel Dunbar1409c132009-10-19 13:20:38 +0000560 ($SSProgs, $llcbeta_options) = TestDirectory("SingleSource");
561 WriteFile "$Prefix-SingleSource-Performance.txt", $SSProgs;
562 ($MSProgs, $llcbeta_options) = TestDirectory("MultiSource");
563 WriteFile "$Prefix-MultiSource-Performance.txt", $MSProgs;
564 if ( ! $NOEXTERNALS ) {
565 ($ExtProgs, $llcbeta_options) = TestDirectory("External");
566 WriteFile "$Prefix-External-Performance.txt", $ExtProgs;
567 system "cat $Prefix-SingleSource-Tests.txt " .
568 "$Prefix-MultiSource-Tests.txt ".
569 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
570 system "cat $Prefix-SingleSource-Performance.txt " .
571 "$Prefix-MultiSource-Performance.txt ".
572 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
573 } else {
574 $ExtProgs = "External TEST STAGE SKIPPED\n";
575 if ( $VERBOSE ) {
576 print "External TEST STAGE SKIPPED\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000577 }
Daniel Dunbar1409c132009-10-19 13:20:38 +0000578 system "cat $Prefix-SingleSource-Tests.txt " .
579 "$Prefix-MultiSource-Tests.txt ".
580 " | sort > $Prefix-Tests.txt";
581 system "cat $Prefix-SingleSource-Performance.txt " .
582 "$Prefix-MultiSource-Performance.txt ".
583 " | sort > $Prefix-Performance.txt";
584 }
Daniel Dunbar4a338bf2009-10-19 13:20:25 +0000585
Daniel Dunbar1409c132009-10-19 13:20:38 +0000586 # Compile passes, fails, xfails.
Daniel Dunbarac0c0642009-10-19 13:20:44 +0000587 my $All = (ReadFile "$Prefix-Tests.txt");
588 my @TestSuiteResultLines = split "\n", $All;
Daniel Dunbar1409c132009-10-19 13:20:38 +0000589 my ($Passes, $Fails, $XFails) = "";
Daniel Dunbar4a338bf2009-10-19 13:20:25 +0000590
Daniel Dunbar1409c132009-10-19 13:20:38 +0000591 for ($x=0; $x < @TestSuiteResultLines; $x++) {
592 if (@TestSuiteResultLines[$x] =~ m/^PASS:/) {
593 $Passes .= "$TestSuiteResultLines[$x]\n";
594 }
595 elsif (@TestSuiteResultLines[$x] =~ m/^FAIL:/) {
596 $Fails .= "$TestSuiteResultLines[$x]\n";
597 }
598 elsif (@TestSuiteResultLines[$x] =~ m/^XFAIL:/) {
599 $XFails .= "$TestSuiteResultLines[$x]\n";
Daniel Dunbar4a338bf2009-10-19 13:20:25 +0000600 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000601 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000602
Daniel Dunbarac0c0642009-10-19 13:20:44 +0000603 return ($SSProgs, $MSProgs, $ExtProgs, $All, $Passes, $Fails, $XFails);
Daniel Dunbar34311232009-10-19 13:20:19 +0000604}
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000605
Daniel Dunbar5381eb72009-10-19 13:20:31 +0000606##############################################################
607#
Daniel Dunbar80dd4532009-10-20 07:30:54 +0000608# Initialize filenames
609#
610##############################################################
611
612if (! -d $WebDir) {
613 mkdir $WebDir, 0777 or die "Unable to create web directory: '$WebDir'.";
614 if($VERBOSE){
615 warn "$WebDir did not exist; creating it.\n";
616 }
617}
618
619if ($CONFIG_PATH ne "") {
620 $ConfigMode = 1;
621 $LLVMSrcDir = GetRegex "^(.*)\\s+", `$CONFIG_PATH --src-root`;
622 $LLVMObjDir = GetRegex "^(.*)\\s+", `$CONFIG_PATH --obj-root`;
623 # FIXME: Add llvm-config hook for this?
624 $LLVMTestDir = $LLVMObjDir . "/projects/test-suite";
625} else {
626 $ConfigureLog = "$Prefix-Configure-Log.txt";
627 $BuildLog = "$Prefix-Build-Log.txt";
628 $COLog = "$Prefix-CVS-Log.txt";
Daniel Dunbar80dd4532009-10-20 07:30:54 +0000629}
630
631if ($VERBOSE) {
632 if ($CONFIG_PATH ne "") {
633 print "INITIALIZED (config mode)\n";
634 print "WebDir = $WebDir\n";
635 print "Prefix = $Prefix\n";
636 print "LLVM Src = $LLVMSrcDir\n";
637 print "LLVM Obj = $LLVMObjDir\n";
638 print "LLVM Test = $LLVMTestDir\n";
639 } else {
640 print "INITIALIZED\n";
641 print "SVN URL = $SVNURL\n";
642 print "COLog = $COLog\n";
643 print "BuildDir = $BuildDir\n";
644 print "WebDir = $WebDir\n";
645 print "Prefix = $Prefix\n";
646 print "BuildLog = $BuildLog\n";
647 }
648}
649
650##############################################################
651#
Daniel Dunbar5381eb72009-10-19 13:20:31 +0000652# The actual NewNightlyTest logic.
653#
654##############################################################
655
656$starttime = `date "+20%y-%m-%d %H:%M:%S"`;
657
Daniel Dunbar1409c132009-10-19 13:20:38 +0000658my $BuildError = 0, $BuildStatus = "OK";
Daniel Dunbar80dd4532009-10-20 07:30:54 +0000659if ($ConfigMode == 0) {
660 if (!$NOCHECKOUT) {
661 CheckoutSource();
662 }
663
664 # Build LLVM.
665 ChangeDir( $LLVMSrcDir , "llvm source directory") ;
666 if ($NOCHECKOUT || $NOBUILD) {
667 $BuildStatus = "Skipped by user";
668 } else {
669 if (!BuildLLVM()) {
670 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
671 $BuildError = 1;
672 $BuildStatus = "Error: compilation aborted";
Daniel Dunbar80dd4532009-10-20 07:30:54 +0000673 }
674 }
Daniel Dunbar1409c132009-10-19 13:20:38 +0000675}
676
677# Run the llvm-test tests.
Daniel Dunbar4a338bf2009-10-19 13:20:25 +0000678my ($SingleSourceProgramsTable, $MultiSourceProgramsTable, $ExternalProgramsTable,
Daniel Dunbarac0c0642009-10-19 13:20:44 +0000679 $all_tests, $passes, $fails, $xfails) = "";
Daniel Dunbar1409c132009-10-19 13:20:38 +0000680if (!$NOTEST && !$BuildError) {
681 ($SingleSourceProgramsTable, $MultiSourceProgramsTable, $ExternalProgramsTable,
Daniel Dunbarac0c0642009-10-19 13:20:44 +0000682 $all_tests, $passes, $fails, $xfails) = RunNightlyTest();
Daniel Dunbar1409c132009-10-19 13:20:38 +0000683}
Daniel Dunbar4a338bf2009-10-19 13:20:25 +0000684
Patrick Jenkinsb67e1182006-07-21 21:43:09 +0000685$endtime = `date "+20%y-%m-%d %H:%M:%S"`;
Patrick Jenkins215b48f2006-07-07 18:50:51 +0000686
Daniel Dunbar2bb4c532009-10-19 13:20:50 +0000687# The last bit of logic is to remove the build and web dirs, after sending data
688# to the server.
689
Daniel Dunbar5381eb72009-10-19 13:20:31 +0000690##############################################################
691#
692# Accumulate the information to send to the server.
693#
694##############################################################
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000695
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000696if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
697
Daniel Dunbarc6139692010-03-16 15:53:02 +0000698if ( ! $NOUNAME ) {
699 $machine_data = "uname: ".`uname -a`.
700 "hardware: ".`uname -m`.
701 "os: ".`uname -sr`.
702 "name: ".`uname -n`.
703 "date: ".`date \"+20%y-%m-%d\"`.
704 "time: ".`date +\"%H:%M:%S\"`;
705} else {
706 $machine_data = "uname: (excluded)\n".
707 "hardware: ".`uname -m`.
708 "os: ".`uname -sr`.
709 "name: $nickname\n".
710 "date: ".`date \"+20%y-%m-%d\"`.
711 "time: ".`date +\"%H:%M:%S\"`;
712}
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000713
Daniel Dunbar5381eb72009-10-19 13:20:31 +0000714# Get gcc version.
Daniel Dunbar34311232009-10-19 13:20:19 +0000715my $gcc_version_long = "";
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000716if ($GCCPATH ne "") {
Daniel Dunbar34311232009-10-19 13:20:19 +0000717 $gcc_version_long = `$GCCPATH/gcc --version`;
Jeff Cohen75454222007-04-10 19:13:43 +0000718} elsif ($ENV{"CC"}) {
Daniel Dunbar34311232009-10-19 13:20:19 +0000719 $gcc_version_long = `$ENV{"CC"} --version`;
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000720} else {
Daniel Dunbar34311232009-10-19 13:20:19 +0000721 $gcc_version_long = `gcc --version`;
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000722}
Daniel Dunbar34311232009-10-19 13:20:19 +0000723my $gcc_version = (split '\n', $gcc_version_long)[0];
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000724
Daniel Dunbar5381eb72009-10-19 13:20:31 +0000725# Get llvm-gcc target triple.
Daniel Dunbar2d7adb52009-11-06 04:11:29 +0000726#
727# FIXME: This shouldn't be hardwired to llvm-gcc.
Daniel Dunbar34311232009-10-19 13:20:19 +0000728my $llvmgcc_version_long = "";
Tanya Lattner849c9a22007-04-13 04:36:48 +0000729if ($LLVMGCCPATH ne "") {
730 $llvmgcc_version_long = `$LLVMGCCPATH/llvm-gcc -v 2>&1`;
731} else {
732 $llvmgcc_version_long = `llvm-gcc -v 2>&1`;
733}
Daniel Dunbar34311232009-10-19 13:20:19 +0000734(split '\n', $llvmgcc_version_long)[1] =~ /Target: (.+)/;
735my $targetTriple = $1;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000736
Daniel Dunbar34311232009-10-19 13:20:19 +0000737# Logs.
Daniel Dunbar539e1872009-11-08 09:34:14 +0000738my ($ConfigureLogData, $BuildLogData, $CheckoutLogData) = "";
Daniel Dunbar80dd4532009-10-20 07:30:54 +0000739if ($ConfigMode == 0) {
740 $ConfigureLogData = ReadFile $ConfigureLog;
741 $BuildLogData = ReadFile $BuildLog;
Daniel Dunbar80dd4532009-10-20 07:30:54 +0000742 $CheckoutLogData = ReadFile $COLog;
743}
Daniel Dunbar34311232009-10-19 13:20:19 +0000744
Daniel Dunbar439801e2009-10-19 13:20:13 +0000745# Checkout info.
Daniel Dunbar34311232009-10-19 13:20:19 +0000746my $CheckoutTime_Wall = GetRegex "^real ([0-9.]+)", $CheckoutLogData;
747my $CheckoutTime_User = GetRegex "^user ([0-9.]+)", $CheckoutLogData;
748my $CheckoutTime_Sys = GetRegex "^sys ([0-9.]+)", $CheckoutLogData;
Daniel Dunbar8df92e82009-10-19 13:20:06 +0000749my $CheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
750
Daniel Dunbar439801e2009-10-19 13:20:13 +0000751# Configure info.
Daniel Dunbar34311232009-10-19 13:20:19 +0000752my $ConfigTimeU = GetRegex "^user ([0-9.]+)", $ConfigureLogData;
753my $ConfigTimeS = GetRegex "^sys ([0-9.]+)", $ConfigureLogData;
Daniel Dunbar439801e2009-10-19 13:20:13 +0000754my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
Daniel Dunbar34311232009-10-19 13:20:19 +0000755my $ConfigWallTime = GetRegex "^real ([0-9.]+)",$ConfigureLogData;
Daniel Dunbar439801e2009-10-19 13:20:13 +0000756$ConfigTime=-1 unless $ConfigTime;
757$ConfigWallTime=-1 unless $ConfigWallTime;
758
759# Build info.
Daniel Dunbar34311232009-10-19 13:20:19 +0000760my $BuildTimeU = GetRegex "^user ([0-9.]+)", $BuildLogData;
761my $BuildTimeS = GetRegex "^sys ([0-9.]+)", $BuildLogData;
Daniel Dunbar439801e2009-10-19 13:20:13 +0000762my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
Daniel Dunbar34311232009-10-19 13:20:19 +0000763my $BuildWallTime = GetRegex "^real ([0-9.]+)", $BuildLogData;
Daniel Dunbar439801e2009-10-19 13:20:13 +0000764$BuildTime=-1 unless $BuildTime;
765$BuildWallTime=-1 unless $BuildWallTime;
766
Daniel Dunbar2bb4c532009-10-19 13:20:50 +0000767if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
768
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000769my %hash_of_data = (
770 'machine_data' => $machine_data,
Daniel Dunbar34311232009-10-19 13:20:19 +0000771 'build_data' => $ConfigureLogData . $BuildLogData,
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000772 'gcc_version' => $gcc_version,
773 'nickname' => $nickname,
Daniel Dunbar539e1872009-11-08 09:34:14 +0000774 'dejagnutime_wall' => "0.0",
775 'dejagnutime_cpu' => "0.0",
Reid Spencer99e865a2007-04-07 04:41:16 +0000776 'cvscheckouttime_wall' => $CheckoutTime_Wall,
777 'cvscheckouttime_cpu' => $CheckoutTime_CPU,
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000778 'configtime_wall' => $ConfigWallTime,
779 'configtime_cpu'=> $ConfigTime,
780 'buildtime_wall' => $BuildWallTime,
781 'buildtime_cpu' => $BuildTime,
Daniel Dunbar2bb4c532009-10-19 13:20:50 +0000782 'buildstatus' => $BuildStatus,
783 'singlesource_programstable' => $SingleSourceProgramsTable,
784 'multisource_programstable' => $MultiSourceProgramsTable,
785 'externalsource_programstable' => $ExternalProgramsTable,
786 'llcbeta_options' => $llcbeta_options,
787 'passing_tests' => $passes,
788 'expfail_tests' => $xfails,
789 'unexpfail_tests' => $fails,
790 'all_tests' => $all_tests,
Daniel Dunbar539e1872009-11-08 09:34:14 +0000791 'dejagnutests_results' => "Dejagnu skipped by user choice.",
792 'dejagnutests_log' => "",
Daniel Dunbar2bb4c532009-10-19 13:20:50 +0000793 'starttime' => $starttime,
794 'endtime' => $endtime,
795 'target_triple' => $targetTriple,
796
797 # Unused, but left around for backwards compatability.
Daniel Dunbar7a1e60a2009-10-19 13:19:53 +0000798 'warnings' => "",
Daniel Dunbar7c9eb9e2009-10-19 09:19:09 +0000799 'cvsusercommitlist' => "",
800 'cvsuserupdatelist' => "",
801 'cvsaddedfiles' => "",
802 'cvsmodifiedfiles' => "",
803 'cvsremovedfiles' => "",
804 'lines_of_code' => "",
805 'cvs_file_count' => 0,
806 'cvs_dir_count' => 0,
Daniel Dunbar7a1e60a2009-10-19 13:19:53 +0000807 'warnings_removed' => "",
808 'warnings_added' => "",
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000809 'new_tests' => "",
810 'removed_tests' => "",
Daniel Dunbar7f0e81f2009-10-19 13:20:00 +0000811 'o_file_sizes' => "",
Daniel Dunbar2bb4c532009-10-19 13:20:50 +0000812 'a_file_sizes' => ""
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000813);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000814
Daniel Dunbar1b54d422009-12-14 17:58:27 +0000815# Write out the "...-sentdata.txt" file.
816WriteSentData \%hash_of_data;
817
Daniel Dunbarf7f02a92009-06-26 22:33:28 +0000818if ($SUBMIT || !($SUBMITAUX eq "")) {
Tanya Lattnerc1611882008-03-10 07:28:08 +0000819 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
820 if( $VERBOSE) { print "============================\n$response"; }
821} else {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000822 print "============================\n";
823 foreach $x(keys %hash_of_data){
824 print "$x => $hash_of_data{$x}\n";
825 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000826}
827
828##############################################################
829#
Daniel Dunbar2e107942009-10-19 09:18:54 +0000830# Remove the source tree...
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000831#
832##############################################################
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000833system ( "$NICE rm -rf $BuildDir")
Daniel Dunbar0c39e382009-07-13 22:17:49 +0000834 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVEATEND);
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000835system ( "$NICE rm -rf $WebDir")
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000836 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);