blob: 51f90184eb393b5e0533d0739f0eaafbf0632ce0 [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.
Patrick Jenkins0e9402f2006-08-11 23:02:09 +000027# -submit-server Specifies a server to submit the test results too. If this
Misha Brukman12c8d1b2009-01-02 16:28:18 +000028# option is not specified it defaults to
29# llvm.org. This is basically just the address of the
Patrick Jenkins0e9402f2006-08-11 23:02:09 +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 Brukman12c8d1b2009-01-02 16:28:18 +000033# /nightlytest/NightlyTestAccept.php. This is basically
Patrick Jenkins0e9402f2006-08-11 23:02:09 +000034# everything after the www.yourserver.org.
Daniel Dunbarcd3f9992009-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 Lattnerc1611882008-03-10 07:28:08 +000038# -nosubmit Do not report the test results back to a submit server.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000039#
Daniel Dunbar4628e5e2009-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 Dunbarda420ee2009-11-06 04:12:07 +000046# -noclean Do not run 'make clean' before building.
Daniel Dunbar4628e5e2009-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 Dunbar4628e5e2009-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 Dunbar2d7adb52009-11-06 04:11:29 +000057# -llvmgccdir Next argument specifies the llvm-gcc install prefix.
Daniel Dunbar4628e5e2009-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 Dunbarddef0952009-10-19 13:20:56 +000082# -parallel-test Allow parallel execution of llvm-test
Daniel Dunbar4628e5e2009-10-19 09:18:24 +000083# -verbose Turn on some debug output
Daniel Dunbar4628e5e2009-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 Dunbar2e107942009-10-19 09:18:54 +000096# CVSROOT is ignored, it is passed for backwards compatibility.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +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 Dunbar2e107942009-10-19 09:18:54 +000099# exist before the script is run; it will be created by the svn checkout
Patrick Jenkinsfe030d72006-07-06 21:19:32 +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##############################################################
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000112my $HOME = $ENV{'HOME'};
Reid Spencer99e865a2007-04-07 04:41:16 +0000113my $SVNURL = $ENV{"SVNURL"};
Duncan Sands45db29c2009-06-12 13:02:52 +0000114$SVNURL = 'http://llvm.org/svn/llvm-project' unless $SVNURL;
Evan Cheng53df0a22009-06-18 21:39:50 +0000115my $TestSVNURL = $ENV{"TestSVNURL"};
Evan Chenge11c4db2009-07-14 06:23:41 +0000116$TestSVNURL = 'http://llvm.org/svn/llvm-project' unless $TestSVNURL;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000117my $BuildDir = $ENV{'BUILDDIR'};
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000118my $WebDir = $ENV{'WEBDIR'};
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000119
120##############################################################
121#
122# Calculate the date prefix...
123#
124##############################################################
Daniel Dunbar6580da42009-11-06 04:12:13 +0000125use POSIX;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000126@TIME = localtime;
Daniel Dunbar6580da42009-11-06 04:12:13 +0000127my $DATE = strftime("%Y-%m-%d_%H-%M-%S", localtime());
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000128
129##############################################################
130#
131# Parse arguments...
132#
133##############################################################
Daniel Dunbar4628e5e2009-10-19 09:18:24 +0000134$CONFIG_PATH="";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000135$CONFIGUREARGS="";
Patrick Jenkins49717a42006-07-21 01:39:42 +0000136$nickname="";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000137$NOTEST=0;
Patrick Jenkins1cd46912006-07-27 01:17:17 +0000138$MAKECMD="make";
Patrick Jenkins0e9402f2006-08-11 23:02:09 +0000139$SUBMITSERVER = "llvm.org";
Jim Laskey6d8a1b72006-09-15 17:03:36 +0000140$SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
Daniel Dunbarcd3f9992009-05-18 23:24:26 +0000141$SUBMITAUX="";
Tanya Lattnerc1611882008-03-10 07:28:08 +0000142$SUBMIT = 1;
Daniel Dunbar056dbd02009-05-28 22:45:24 +0000143$PARALLELJOBS = "2";
Bill Wendling49e31822009-07-16 22:59:17 +0000144my $TESTFLAGS="";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000145
Daniel Dunbar2d7adb52009-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
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000154while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000155 shift;
156 last if /^--$/; # Stop processing arguments on --
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000157
158 # List command line options here...
Daniel Dunbar4628e5e2009-10-19 09:18:24 +0000159 if (/^-config$/) { $CONFIG_PATH = "$ARGV[0]"; shift; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000160 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
Daniel Dunbarda420ee2009-11-06 04:12:07 +0000161 if (/^-noclean$/) { $NOCLEAN = 1; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000162 if (/^-noremove$/) { $NOREMOVE = 1; next; }
Daniel Dunbar0c39e382009-07-13 22:17:49 +0000163 if (/^-noremoveatend$/) { $NOREMOVEATEND = 1; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000164 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
Daniel Dunbarf5a59502009-06-02 21:14:15 +0000165 if (/^-notest$/) { $NOTEST = 1; next; }
166 if (/^-norunningtests$/) { next; } # Backward compatibility, ignored.
Daniel Dunbar056dbd02009-05-28 22:45:24 +0000167 if (/^-parallel-jobs$/) { $PARALLELJOBS = "$ARGV[0]"; shift; next;}
Daniel Dunbar2bb4c532009-10-19 13:20:50 +0000168 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j$PARALLELJOBS"; next; }
Daniel Dunbarddef0952009-10-19 13:20:56 +0000169 if (/^-parallel-test$/) { $PROGTESTOPTS .= " ENABLE_PARALLEL_REPORT=1"; next; }
Duncan Sands45db29c2009-06-12 13:02:52 +0000170 if (/^-with-clang$/) { $WITHCLANG = 1; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000171 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
Daniel Dunbarf2741382009-10-20 07:30:46 +0000172 "OPTIMIZE_OPTION=-O2"; next;}
Jim Laskey27b8ba02006-09-28 17:49:20 +0000173 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
Dan Gohmanc6e22412008-10-30 01:08:03 +0000174 "DISABLE_ASSERTIONS=1 ".
Daniel Dunbarf2741382009-10-20 07:30:46 +0000175 "OPTIMIZE_OPTION=-O2"; next;}
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000176 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
Duncan Sands45db29c2009-06-12 13:02:52 +0000177 if (/^-disable-pic$/) { $CONFIGUREARGS .= " --enable-pic=no"; next; }
Reid Spencer2bae1f52006-11-24 20:34:16 +0000178 if (/^-enable-lli$/) { $PROGTESTOPTS .= " ENABLE_LLI=1";
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000179 $CONFIGUREARGS .= " --enable-lli"; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000180 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000181 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000182 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
183 $CONFIGUREARGS .= " --disable-jit"; next; }
Daniel Dunbar111def82009-03-10 19:33:13 +0000184 if (/^-disable-bindings$/) { $CONFIGUREARGS .= " --disable-bindings"; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000185 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
Evan Chenge04c90b2008-01-12 04:27:18 +0000186 if (/^-disable-lto$/) { $PROGTESTOPTS .= " DISABLE_LTO=1"; next; }
Evan Cheng3d64f1c2008-01-14 17:58:03 +0000187 if (/^-test-opts$/) { $PROGTESTOPTS .= " $ARGV[0]"; shift; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000188 if (/^-verbose$/) { $VERBOSE = 1; next; }
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000189 if (/^-teelogs$/) { $TEELOGS = 1; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000190 if (/^-nice$/) { $NICE = "nice "; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000191 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000192 shift; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000193 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000194 shift; next; }
Daniel Dunbarff79ef42009-07-13 22:31:58 +0000195 if (/^-configure-args$/) { $CONFIGUREARGS .= " $ARGV[0]";
196 shift; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000197 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
198 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
Daniel Dunbarcd3f9992009-05-18 23:24:26 +0000199 if (/^-submit-aux/) { $SUBMITAUX = "$ARGV[0]"; shift; next; }
Tanya Lattnerc1611882008-03-10 07:28:08 +0000200 if (/^-nosubmit$/) { $SUBMIT = 0; next; }
Misha Brukman12c8d1b2009-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++";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000204 $GCCPATH=$ARGV[0]; shift; next; }
205 else { $GCCPATH=""; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000206 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000207 shift; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000208 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000209 shift; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000210 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000211 shift; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000212 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000213 shift; next; }
Bill Wendling49e31822009-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; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000218 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
Daniel Dunbar2d7adb52009-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; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000223 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000224 if (/^-extraflags/) { $CONFIGUREARGS .=
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000225 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
226 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
Daniel Dunbar539e1872009-11-08 09:34:14 +0000227 if (/^-nodejagnu$/) { next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000228 if (/^-nobuild$/) { $NOBUILD = 1; next; }
229 print "Unknown option: $_ : ignoring!\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000230}
231
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000232if ($CONFIGUREARGS !~ /--disable-jit/) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000233 $CONFIGUREARGS .= " --enable-jit";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000234}
235
Daniel Dunbar0e9fe692009-10-19 09:19:19 +0000236if (@ARGV != 0 and @ARGV != 3) {
237 die "error: must specify 0 or 3 options!";
Patrick Jenkinsf58473f2006-07-27 01:03:46 +0000238}
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000239
240if (@ARGV == 3) {
Daniel Dunbar0e9fe692009-10-19 09:19:19 +0000241 if ($CONFIG_PATH ne "") {
242 die "error: arguments are unsupported in -config mode,";
243 }
244
Daniel Dunbar2e107942009-10-19 09:18:54 +0000245 # ARGV[0] used to be the CVS root, ignored for backward compatibility.
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000246 $BuildDir = $ARGV[1];
247 $WebDir = $ARGV[2];
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000248}
249
Daniel Dunbar80dd4532009-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 Brukman12c8d1b2009-01-02 16:28:18 +0000262
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000263if ($nickname eq "") {
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000264 die ("Please invoke NewNightlyTest.pl with command line option " .
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000265 "\"-nickname <nickname>\"");
Patrick Jenkins514e2582006-07-20 22:28:43 +0000266}
Patrick Jenkins1cd46912006-07-27 01:17:17 +0000267
Daniel Dunbarfe1974a2009-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
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000275##############################################################
276#
Daniel Dunbar4628e5e2009-10-19 09:18:24 +0000277# Define the file names we'll use
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000278#
279##############################################################
Daniel Dunbar80dd4532009-10-20 07:30:54 +0000280
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000281my $Prefix = "$WebDir/$DATE";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000282my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
283my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
Patrick Jenkins26ba6092006-07-23 22:57:28 +0000284my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000285
Daniel Dunbar80dd4532009-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;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000292
293##############################################################
294#
295# Helper functions
296#
297##############################################################
Daniel Dunbar4628e5e2009-10-19 09:18:24 +0000298
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000299sub GetDir {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000300 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;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000305}
306
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000307sub RunLoggedCommand {
308 my $Command = shift;
309 my $Log = shift;
Daniel Dunbarfc0fc3a2009-06-26 02:30:49 +0000310 my $Title = shift;
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000311 if ($TEELOGS) {
Daniel Dunbarfc0fc3a2009-06-26 02:30:49 +0000312 if ($VERBOSE) {
313 print "$Title\n";
314 print "$Command 2>&1 | tee $Log\n";
315 }
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000316 system "$Command 2>&1 | tee $Log";
317 } else {
Daniel Dunbarfc0fc3a2009-06-26 02:30:49 +0000318 if ($VERBOSE) {
319 print "$Title\n";
320 print "$Command 2>&1 > $Log\n";
321 }
Daniel Dunbar2f90daf2009-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 Dunbarfc0fc3a2009-06-26 02:30:49 +0000329 my $Title = shift;
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000330 if ($TEELOGS) {
Daniel Dunbarfc0fc3a2009-06-26 02:30:49 +0000331 if ($VERBOSE) {
332 print "$Title\n";
333 print "$Command 2>&1 | tee -a $Log\n";
334 }
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000335 system "$Command 2>&1 | tee -a $Log";
336 } else {
Daniel Dunbarfc0fc3a2009-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 Dunbar2f90daf2009-06-26 01:53:05 +0000342 }
343}
344
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000345sub GetRegex { # (Regex with ()'s, value)
Daniel Dunbar34311232009-10-19 13:20:19 +0000346 if ($_[1] =~ /$_[0]/m) {
347 return $1;
348 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000349 return "0";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000350}
351
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000352sub ChangeDir { # directory, logical name
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000353 my ($dir,$name) = @_;
354 chomp($dir);
355 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
356 $result = chdir($dir);
357 if (!$result) {
Daniel Dunbar2bb4c532009-10-19 13:20:50 +0000358 print "ERROR!!! Cannot change directory to: $name ($dir) because $!\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000359 return false;
360 }
361 return true;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000362}
363
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000364sub ReadFile {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000365 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 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000375}
376
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000377sub WriteFile { # (filename, contents)
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000378 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
379 print FILE $_[1];
380 close FILE;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000381}
382
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000383sub CopyFile { #filename, newfile
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000384 my ($file, $newfile) = @_;
385 chomp($file);
386 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
387 copy($file, $newfile);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000388}
389
390#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000391#
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000392# This function acts as a mini web browswer submitting data
393# to our central server via the post method
394#
395#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Daniel Dunbar1b54d422009-12-14 17:58:27 +0000396sub WriteSentData {
397 $variables = $_[0];
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000398
Daniel Dunbar94a37a42009-05-28 18:31:40 +0000399 # Write out the "...-sentdata.txt" file.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000400
Daniel Dunbar94a37a42009-05-28 18:31:40 +0000401 my $sentdata="";
402 foreach $x (keys (%$variables)){
403 $value = $variables->{$x};
404 $sentdata.= "$x => $value\n";
405 }
406 WriteFile "$Prefix-sentdata.txt", $sentdata;
Daniel Dunbar1b54d422009-12-14 17:58:27 +0000407}
408
409sub SendData {
410 $host = $_[0];
411 $file = $_[1];
412 $variables = $_[2];
Daniel Dunbar94a37a42009-05-28 18:31:40 +0000413
414 if (!($SUBMITAUX eq "")) {
Daniel Dunbarf7f02a92009-06-26 22:33:28 +0000415 system "$SUBMITAUX \"$Prefix-sentdata.txt\"";
416 }
417
Daniel Dunbar4628e5e2009-10-19 09:18:24 +0000418 if (!$SUBMIT) {
Daniel Dunbarf7f02a92009-06-26 22:33:28 +0000419 return "Skipped standard submit.\n";
Daniel Dunbar94a37a42009-05-28 18:31:40 +0000420 }
421
422 # Create the content to send to the server.
423
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000424 my $content;
425 foreach $key (keys (%$variables)){
426 $value = $variables->{$key};
427 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
428 $content .= "$key=$value&";
429 }
430
Daniel Dunbar94a37a42009-05-28 18:31:40 +0000431 # Send the data to the server.
Daniel Dunbar4628e5e2009-10-19 09:18:24 +0000432 #
Daniel Dunbar94a37a42009-05-28 18:31:40 +0000433 # FIXME: This code should be more robust?
Daniel Dunbar4628e5e2009-10-19 09:18:24 +0000434
Daniel Dunbar94a37a42009-05-28 18:31:40 +0000435 $port=80;
436 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
437 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
438 die "Bad socket\n";
439 connect SOCK, $socketaddr or die "Bad connection\n";
440 select((select(SOCK), $| = 1)[0]);
441
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000442 $length = length($content);
443
444 my $send= "POST $file HTTP/1.0\n";
Lauro Ramos Venancio46040232007-05-03 14:05:07 +0000445 $send.= "Host: $host\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000446 $send.= "Content-Type: application/x-www-form-urlencoded\n";
447 $send.= "Content-length: $length\n\n";
448 $send.= "$content";
449
Patrick Jenkinse8501eb2006-08-07 01:54:37 +0000450 print SOCK $send;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000451 my $result;
452 while(<SOCK>){
453 $result .= $_;
454 }
455 close(SOCK);
456
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000457 return $result;
458}
459
Patrick Jenkins215b48f2006-07-07 18:50:51 +0000460##############################################################
461#
Daniel Dunbar5381eb72009-10-19 13:20:31 +0000462# Individual Build & Test Functions
Patrick Jenkins215b48f2006-07-07 18:50:51 +0000463#
464##############################################################
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000465
Daniel Dunbar5381eb72009-10-19 13:20:31 +0000466# Create the source repository directory.
Daniel Dunbar8df92e82009-10-19 13:20:06 +0000467sub CheckoutSource {
Daniel Dunbar80dd4532009-10-20 07:30:54 +0000468 die "Invalid call!" unless $ConfigMode == 0;
Daniel Dunbar1409c132009-10-19 13:20:38 +0000469 if (-d $BuildDir) {
470 if (!$NOREMOVE) {
471 if ( $VERBOSE ) {
472 print "Build directory exists! Removing it\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000473 }
Daniel Dunbar1409c132009-10-19 13:20:38 +0000474 system "rm -rf $BuildDir";
Daniel Dunbar8df92e82009-10-19 13:20:06 +0000475 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
Daniel Dunbar1409c132009-10-19 13:20:38 +0000476 } else {
477 if ( $VERBOSE ) {
478 print "Build directory exists!\n";
479 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000480 }
Daniel Dunbar1409c132009-10-19 13:20:38 +0000481 } else {
482 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
483 }
Daniel Dunbar8df92e82009-10-19 13:20:06 +0000484
Daniel Dunbar1409c132009-10-19 13:20:38 +0000485 ChangeDir( $BuildDir, "checkout directory" );
486 my $SVNCMD = "$NICE svn co --non-interactive";
487 RunLoggedCommand("( time -p $SVNCMD $SVNURL/llvm/trunk llvm; cd llvm/projects ; " .
488 " $SVNCMD $TestSVNURL/test-suite/trunk llvm-test )", $COLog,
489 "CHECKOUT LLVM");
490 if ($WITHCLANG) {
491 RunLoggedCommand("( cd llvm/tools ; " .
492 " $SVNCMD $SVNURL/cfe/trunk clang )", $COLog,
493 "CHECKOUT CLANG");
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000494 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000495}
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000496
Daniel Dunbar1409c132009-10-19 13:20:38 +0000497# Build the entire tree, saving build messages to the build log. Returns false
498# on build failure.
Daniel Dunbar439801e2009-10-19 13:20:13 +0000499sub BuildLLVM {
Daniel Dunbar80dd4532009-10-20 07:30:54 +0000500 die "Invalid call!" unless $ConfigMode == 0;
Daniel Dunbar1409c132009-10-19 13:20:38 +0000501 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
502 RunLoggedCommand("(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) ",
503 $ConfigureLog, "CONFIGURE");
504 # Build the entire tree, capturing the output into $BuildLog
Daniel Dunbarda420ee2009-11-06 04:12:07 +0000505 if (!$NOCLEAN) {
506 RunAppendingLoggedCommand("($NICE $MAKECMD $MAKEOPTS clean)", $BuildLog, "BUILD CLEAN");
507 }
Daniel Dunbar1409c132009-10-19 13:20:38 +0000508 RunAppendingLoggedCommand("(time -p $NICE $MAKECMD $MAKEOPTS)", $BuildLog, "BUILD");
509
Daniel Dunbar252a0df2009-12-14 17:58:33 +0000510 if (`grep -a '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
511 `grep -a '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l` + 0) {
Daniel Dunbar1409c132009-10-19 13:20:38 +0000512 return 0;
Daniel Dunbar439801e2009-10-19 13:20:13 +0000513 }
514
Daniel Dunbar1409c132009-10-19 13:20:38 +0000515 return 1;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000516}
517
Daniel Dunbar5381eb72009-10-19 13:20:31 +0000518# Run the named tests (i.e. "SingleSource" "MultiSource" "External")
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000519sub TestDirectory {
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000520 my $SubDir = shift;
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000521 ChangeDir( "$LLVMTestDir/$SubDir",
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000522 "Programs Test Subdirectory" ) || return ("", "");
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000523
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000524 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000525
Daniel Dunbarda420ee2009-11-06 04:12:07 +0000526 # Make sure to clean the test results.
527 RunLoggedCommand("$MAKECMD -k $MAKEOPTS $PROGTESTOPTS clean $TESTFLAGS",
528 $ProgramTestLog, "TEST DIRECTORY $SubDir");
Daniel Dunbar80dd4532009-10-20 07:30:54 +0000529
Daniel Dunbar1409c132009-10-19 13:20:38 +0000530 # Run the programs tests... creating a report.nightly.csv file.
Daniel Dunbar34311232009-10-19 13:20:19 +0000531 my $LLCBetaOpts = "";
Daniel Dunbar1409c132009-10-19 13:20:38 +0000532 RunLoggedCommand("$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
533 "$TESTFLAGS TEST=nightly",
534 $ProgramTestLog, "TEST DIRECTORY $SubDir");
535 $LLCBetaOpts = `$MAKECMD print-llcbeta-option`;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000536
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000537 my $ProgramsTable;
Daniel Dunbar252a0df2009-12-14 17:58:33 +0000538 if (`grep -a '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000539 $ProgramsTable="Error running test $SubDir\n";
540 print "ERROR TESTING\n";
Daniel Dunbar252a0df2009-12-14 17:58:33 +0000541 } elsif (`grep -a '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000542 $ProgramsTable="Makefile error running tests $SubDir!\n";
543 print "ERROR TESTING\n";
544 } else {
Daniel Dunbar1409c132009-10-19 13:20:38 +0000545 # Create a list of the tests which were run...
Daniel Dunbar252a0df2009-12-14 17:58:33 +0000546 system "egrep -a 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
Daniel Dunbar1409c132009-10-19 13:20:38 +0000547 "| sort > $Prefix-$SubDir-Tests.txt";
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000548 }
549 $ProgramsTable = ReadFile "report.nightly.csv";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000550
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000551 ChangeDir( "../../..", "Programs Test Parent Directory" );
Daniel Dunbar34311232009-10-19 13:20:19 +0000552 return ($ProgramsTable, $LLCBetaOpts);
553}
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000554
Daniel Dunbarac0c0642009-10-19 13:20:44 +0000555# Run all the nightly tests and return the program tables and the list of tests,
Daniel Dunbar5381eb72009-10-19 13:20:31 +0000556# passes, fails, and xfails.
Daniel Dunbar4a338bf2009-10-19 13:20:25 +0000557sub RunNightlyTest() {
Daniel Dunbar1409c132009-10-19 13:20:38 +0000558 ($SSProgs, $llcbeta_options) = TestDirectory("SingleSource");
559 WriteFile "$Prefix-SingleSource-Performance.txt", $SSProgs;
560 ($MSProgs, $llcbeta_options) = TestDirectory("MultiSource");
561 WriteFile "$Prefix-MultiSource-Performance.txt", $MSProgs;
562 if ( ! $NOEXTERNALS ) {
563 ($ExtProgs, $llcbeta_options) = TestDirectory("External");
564 WriteFile "$Prefix-External-Performance.txt", $ExtProgs;
565 system "cat $Prefix-SingleSource-Tests.txt " .
566 "$Prefix-MultiSource-Tests.txt ".
567 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
568 system "cat $Prefix-SingleSource-Performance.txt " .
569 "$Prefix-MultiSource-Performance.txt ".
570 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
571 } else {
572 $ExtProgs = "External TEST STAGE SKIPPED\n";
573 if ( $VERBOSE ) {
574 print "External TEST STAGE SKIPPED\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000575 }
Daniel Dunbar1409c132009-10-19 13:20:38 +0000576 system "cat $Prefix-SingleSource-Tests.txt " .
577 "$Prefix-MultiSource-Tests.txt ".
578 " | sort > $Prefix-Tests.txt";
579 system "cat $Prefix-SingleSource-Performance.txt " .
580 "$Prefix-MultiSource-Performance.txt ".
581 " | sort > $Prefix-Performance.txt";
582 }
Daniel Dunbar4a338bf2009-10-19 13:20:25 +0000583
Daniel Dunbar1409c132009-10-19 13:20:38 +0000584 # Compile passes, fails, xfails.
Daniel Dunbarac0c0642009-10-19 13:20:44 +0000585 my $All = (ReadFile "$Prefix-Tests.txt");
586 my @TestSuiteResultLines = split "\n", $All;
Daniel Dunbar1409c132009-10-19 13:20:38 +0000587 my ($Passes, $Fails, $XFails) = "";
Daniel Dunbar4a338bf2009-10-19 13:20:25 +0000588
Daniel Dunbar1409c132009-10-19 13:20:38 +0000589 for ($x=0; $x < @TestSuiteResultLines; $x++) {
590 if (@TestSuiteResultLines[$x] =~ m/^PASS:/) {
591 $Passes .= "$TestSuiteResultLines[$x]\n";
592 }
593 elsif (@TestSuiteResultLines[$x] =~ m/^FAIL:/) {
594 $Fails .= "$TestSuiteResultLines[$x]\n";
595 }
596 elsif (@TestSuiteResultLines[$x] =~ m/^XFAIL:/) {
597 $XFails .= "$TestSuiteResultLines[$x]\n";
Daniel Dunbar4a338bf2009-10-19 13:20:25 +0000598 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000599 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000600
Daniel Dunbarac0c0642009-10-19 13:20:44 +0000601 return ($SSProgs, $MSProgs, $ExtProgs, $All, $Passes, $Fails, $XFails);
Daniel Dunbar34311232009-10-19 13:20:19 +0000602}
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000603
Daniel Dunbar5381eb72009-10-19 13:20:31 +0000604##############################################################
605#
Daniel Dunbar80dd4532009-10-20 07:30:54 +0000606# Initialize filenames
607#
608##############################################################
609
610if (! -d $WebDir) {
611 mkdir $WebDir, 0777 or die "Unable to create web directory: '$WebDir'.";
612 if($VERBOSE){
613 warn "$WebDir did not exist; creating it.\n";
614 }
615}
616
617if ($CONFIG_PATH ne "") {
618 $ConfigMode = 1;
619 $LLVMSrcDir = GetRegex "^(.*)\\s+", `$CONFIG_PATH --src-root`;
620 $LLVMObjDir = GetRegex "^(.*)\\s+", `$CONFIG_PATH --obj-root`;
621 # FIXME: Add llvm-config hook for this?
622 $LLVMTestDir = $LLVMObjDir . "/projects/test-suite";
623} else {
624 $ConfigureLog = "$Prefix-Configure-Log.txt";
625 $BuildLog = "$Prefix-Build-Log.txt";
626 $COLog = "$Prefix-CVS-Log.txt";
Daniel Dunbar80dd4532009-10-20 07:30:54 +0000627}
628
629if ($VERBOSE) {
630 if ($CONFIG_PATH ne "") {
631 print "INITIALIZED (config mode)\n";
632 print "WebDir = $WebDir\n";
633 print "Prefix = $Prefix\n";
634 print "LLVM Src = $LLVMSrcDir\n";
635 print "LLVM Obj = $LLVMObjDir\n";
636 print "LLVM Test = $LLVMTestDir\n";
637 } else {
638 print "INITIALIZED\n";
639 print "SVN URL = $SVNURL\n";
640 print "COLog = $COLog\n";
641 print "BuildDir = $BuildDir\n";
642 print "WebDir = $WebDir\n";
643 print "Prefix = $Prefix\n";
644 print "BuildLog = $BuildLog\n";
645 }
646}
647
648##############################################################
649#
Daniel Dunbar5381eb72009-10-19 13:20:31 +0000650# The actual NewNightlyTest logic.
651#
652##############################################################
653
654$starttime = `date "+20%y-%m-%d %H:%M:%S"`;
655
Daniel Dunbar1409c132009-10-19 13:20:38 +0000656my $BuildError = 0, $BuildStatus = "OK";
Daniel Dunbar80dd4532009-10-20 07:30:54 +0000657if ($ConfigMode == 0) {
658 if (!$NOCHECKOUT) {
659 CheckoutSource();
660 }
661
662 # Build LLVM.
663 ChangeDir( $LLVMSrcDir , "llvm source directory") ;
664 if ($NOCHECKOUT || $NOBUILD) {
665 $BuildStatus = "Skipped by user";
666 } else {
667 if (!BuildLLVM()) {
668 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
669 $BuildError = 1;
670 $BuildStatus = "Error: compilation aborted";
Daniel Dunbar80dd4532009-10-20 07:30:54 +0000671 }
672 }
Daniel Dunbar1409c132009-10-19 13:20:38 +0000673}
674
675# Run the llvm-test tests.
Daniel Dunbar4a338bf2009-10-19 13:20:25 +0000676my ($SingleSourceProgramsTable, $MultiSourceProgramsTable, $ExternalProgramsTable,
Daniel Dunbarac0c0642009-10-19 13:20:44 +0000677 $all_tests, $passes, $fails, $xfails) = "";
Daniel Dunbar1409c132009-10-19 13:20:38 +0000678if (!$NOTEST && !$BuildError) {
679 ($SingleSourceProgramsTable, $MultiSourceProgramsTable, $ExternalProgramsTable,
Daniel Dunbarac0c0642009-10-19 13:20:44 +0000680 $all_tests, $passes, $fails, $xfails) = RunNightlyTest();
Daniel Dunbar1409c132009-10-19 13:20:38 +0000681}
Daniel Dunbar4a338bf2009-10-19 13:20:25 +0000682
Patrick Jenkinsb67e1182006-07-21 21:43:09 +0000683$endtime = `date "+20%y-%m-%d %H:%M:%S"`;
Patrick Jenkins215b48f2006-07-07 18:50:51 +0000684
Daniel Dunbar2bb4c532009-10-19 13:20:50 +0000685# The last bit of logic is to remove the build and web dirs, after sending data
686# to the server.
687
Daniel Dunbar5381eb72009-10-19 13:20:31 +0000688##############################################################
689#
690# Accumulate the information to send to the server.
691#
692##############################################################
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000693
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000694if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
695
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000696$machine_data = "uname: ".`uname -a`.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000697 "hardware: ".`uname -m`.
698 "os: ".`uname -sr`.
699 "name: ".`uname -n`.
700 "date: ".`date \"+20%y-%m-%d\"`.
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000701 "time: ".`date +\"%H:%M:%S\"`;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000702
Daniel Dunbar5381eb72009-10-19 13:20:31 +0000703# Get gcc version.
Daniel Dunbar34311232009-10-19 13:20:19 +0000704my $gcc_version_long = "";
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000705if ($GCCPATH ne "") {
Daniel Dunbar34311232009-10-19 13:20:19 +0000706 $gcc_version_long = `$GCCPATH/gcc --version`;
Jeff Cohen75454222007-04-10 19:13:43 +0000707} elsif ($ENV{"CC"}) {
Daniel Dunbar34311232009-10-19 13:20:19 +0000708 $gcc_version_long = `$ENV{"CC"} --version`;
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000709} else {
Daniel Dunbar34311232009-10-19 13:20:19 +0000710 $gcc_version_long = `gcc --version`;
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000711}
Daniel Dunbar34311232009-10-19 13:20:19 +0000712my $gcc_version = (split '\n', $gcc_version_long)[0];
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000713
Daniel Dunbar5381eb72009-10-19 13:20:31 +0000714# Get llvm-gcc target triple.
Daniel Dunbar2d7adb52009-11-06 04:11:29 +0000715#
716# FIXME: This shouldn't be hardwired to llvm-gcc.
Daniel Dunbar34311232009-10-19 13:20:19 +0000717my $llvmgcc_version_long = "";
Tanya Lattner849c9a22007-04-13 04:36:48 +0000718if ($LLVMGCCPATH ne "") {
719 $llvmgcc_version_long = `$LLVMGCCPATH/llvm-gcc -v 2>&1`;
720} else {
721 $llvmgcc_version_long = `llvm-gcc -v 2>&1`;
722}
Daniel Dunbar34311232009-10-19 13:20:19 +0000723(split '\n', $llvmgcc_version_long)[1] =~ /Target: (.+)/;
724my $targetTriple = $1;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000725
Daniel Dunbar34311232009-10-19 13:20:19 +0000726# Logs.
Daniel Dunbar539e1872009-11-08 09:34:14 +0000727my ($ConfigureLogData, $BuildLogData, $CheckoutLogData) = "";
Daniel Dunbar80dd4532009-10-20 07:30:54 +0000728if ($ConfigMode == 0) {
729 $ConfigureLogData = ReadFile $ConfigureLog;
730 $BuildLogData = ReadFile $BuildLog;
Daniel Dunbar80dd4532009-10-20 07:30:54 +0000731 $CheckoutLogData = ReadFile $COLog;
732}
Daniel Dunbar34311232009-10-19 13:20:19 +0000733
Daniel Dunbar439801e2009-10-19 13:20:13 +0000734# Checkout info.
Daniel Dunbar34311232009-10-19 13:20:19 +0000735my $CheckoutTime_Wall = GetRegex "^real ([0-9.]+)", $CheckoutLogData;
736my $CheckoutTime_User = GetRegex "^user ([0-9.]+)", $CheckoutLogData;
737my $CheckoutTime_Sys = GetRegex "^sys ([0-9.]+)", $CheckoutLogData;
Daniel Dunbar8df92e82009-10-19 13:20:06 +0000738my $CheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
739
Daniel Dunbar439801e2009-10-19 13:20:13 +0000740# Configure info.
Daniel Dunbar34311232009-10-19 13:20:19 +0000741my $ConfigTimeU = GetRegex "^user ([0-9.]+)", $ConfigureLogData;
742my $ConfigTimeS = GetRegex "^sys ([0-9.]+)", $ConfigureLogData;
Daniel Dunbar439801e2009-10-19 13:20:13 +0000743my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
Daniel Dunbar34311232009-10-19 13:20:19 +0000744my $ConfigWallTime = GetRegex "^real ([0-9.]+)",$ConfigureLogData;
Daniel Dunbar439801e2009-10-19 13:20:13 +0000745$ConfigTime=-1 unless $ConfigTime;
746$ConfigWallTime=-1 unless $ConfigWallTime;
747
748# Build info.
Daniel Dunbar34311232009-10-19 13:20:19 +0000749my $BuildTimeU = GetRegex "^user ([0-9.]+)", $BuildLogData;
750my $BuildTimeS = GetRegex "^sys ([0-9.]+)", $BuildLogData;
Daniel Dunbar439801e2009-10-19 13:20:13 +0000751my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
Daniel Dunbar34311232009-10-19 13:20:19 +0000752my $BuildWallTime = GetRegex "^real ([0-9.]+)", $BuildLogData;
Daniel Dunbar439801e2009-10-19 13:20:13 +0000753$BuildTime=-1 unless $BuildTime;
754$BuildWallTime=-1 unless $BuildWallTime;
755
Daniel Dunbar2bb4c532009-10-19 13:20:50 +0000756if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
757
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000758my %hash_of_data = (
759 'machine_data' => $machine_data,
Daniel Dunbar34311232009-10-19 13:20:19 +0000760 'build_data' => $ConfigureLogData . $BuildLogData,
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000761 'gcc_version' => $gcc_version,
762 'nickname' => $nickname,
Daniel Dunbar539e1872009-11-08 09:34:14 +0000763 'dejagnutime_wall' => "0.0",
764 'dejagnutime_cpu' => "0.0",
Reid Spencer99e865a2007-04-07 04:41:16 +0000765 'cvscheckouttime_wall' => $CheckoutTime_Wall,
766 'cvscheckouttime_cpu' => $CheckoutTime_CPU,
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000767 'configtime_wall' => $ConfigWallTime,
768 'configtime_cpu'=> $ConfigTime,
769 'buildtime_wall' => $BuildWallTime,
770 'buildtime_cpu' => $BuildTime,
Daniel Dunbar2bb4c532009-10-19 13:20:50 +0000771 'buildstatus' => $BuildStatus,
772 'singlesource_programstable' => $SingleSourceProgramsTable,
773 'multisource_programstable' => $MultiSourceProgramsTable,
774 'externalsource_programstable' => $ExternalProgramsTable,
775 'llcbeta_options' => $llcbeta_options,
776 'passing_tests' => $passes,
777 'expfail_tests' => $xfails,
778 'unexpfail_tests' => $fails,
779 'all_tests' => $all_tests,
Daniel Dunbar539e1872009-11-08 09:34:14 +0000780 'dejagnutests_results' => "Dejagnu skipped by user choice.",
781 'dejagnutests_log' => "",
Daniel Dunbar2bb4c532009-10-19 13:20:50 +0000782 'starttime' => $starttime,
783 'endtime' => $endtime,
784 'target_triple' => $targetTriple,
785
786 # Unused, but left around for backwards compatability.
Daniel Dunbar7a1e60a2009-10-19 13:19:53 +0000787 'warnings' => "",
Daniel Dunbar7c9eb9e2009-10-19 09:19:09 +0000788 'cvsusercommitlist' => "",
789 'cvsuserupdatelist' => "",
790 'cvsaddedfiles' => "",
791 'cvsmodifiedfiles' => "",
792 'cvsremovedfiles' => "",
793 'lines_of_code' => "",
794 'cvs_file_count' => 0,
795 'cvs_dir_count' => 0,
Daniel Dunbar7a1e60a2009-10-19 13:19:53 +0000796 'warnings_removed' => "",
797 'warnings_added' => "",
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000798 'new_tests' => "",
799 'removed_tests' => "",
Daniel Dunbar7f0e81f2009-10-19 13:20:00 +0000800 'o_file_sizes' => "",
Daniel Dunbar2bb4c532009-10-19 13:20:50 +0000801 'a_file_sizes' => ""
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000802);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000803
Daniel Dunbar1b54d422009-12-14 17:58:27 +0000804# Write out the "...-sentdata.txt" file.
805WriteSentData \%hash_of_data;
806
Daniel Dunbarf7f02a92009-06-26 22:33:28 +0000807if ($SUBMIT || !($SUBMITAUX eq "")) {
Tanya Lattnerc1611882008-03-10 07:28:08 +0000808 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
809 if( $VERBOSE) { print "============================\n$response"; }
810} else {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000811 print "============================\n";
812 foreach $x(keys %hash_of_data){
813 print "$x => $hash_of_data{$x}\n";
814 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000815}
816
817##############################################################
818#
Daniel Dunbar2e107942009-10-19 09:18:54 +0000819# Remove the source tree...
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000820#
821##############################################################
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000822system ( "$NICE rm -rf $BuildDir")
Daniel Dunbar0c39e382009-07-13 22:17:49 +0000823 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVEATEND);
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000824system ( "$NICE rm -rf $WebDir")
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000825 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);