blob: f74711a44d0083e5c6fd7a029d48d46c5a47ad3d [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##############################################################
125@TIME = localtime;
Daniel Dunbar42cdc382009-07-01 14:52:59 +0000126my $DATE = sprintf "%4d-%02d-%02d_%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3], $TIME[1], $TIME[0];
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000127
128##############################################################
129#
130# Parse arguments...
131#
132##############################################################
Daniel Dunbar4628e5e2009-10-19 09:18:24 +0000133$CONFIG_PATH="";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000134$CONFIGUREARGS="";
Patrick Jenkins49717a42006-07-21 01:39:42 +0000135$nickname="";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000136$NOTEST=0;
Patrick Jenkins1cd46912006-07-27 01:17:17 +0000137$MAKECMD="make";
Patrick Jenkins0e9402f2006-08-11 23:02:09 +0000138$SUBMITSERVER = "llvm.org";
Jim Laskey6d8a1b72006-09-15 17:03:36 +0000139$SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
Daniel Dunbarcd3f9992009-05-18 23:24:26 +0000140$SUBMITAUX="";
Tanya Lattnerc1611882008-03-10 07:28:08 +0000141$SUBMIT = 1;
Daniel Dunbar056dbd02009-05-28 22:45:24 +0000142$PARALLELJOBS = "2";
Bill Wendling49e31822009-07-16 22:59:17 +0000143my $TESTFLAGS="";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000144
Daniel Dunbar2d7adb52009-11-06 04:11:29 +0000145if ($ENV{'LLVMGCCDIR'}) {
146 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
147 $LLVMGCCPATH = $ENV{'LLVMGCCDIR'} . '/bin';
148}
149else {
150 $LLVMGCCPATH = "";
151}
152
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000153while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000154 shift;
155 last if /^--$/; # Stop processing arguments on --
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000156
157 # List command line options here...
Daniel Dunbar4628e5e2009-10-19 09:18:24 +0000158 if (/^-config$/) { $CONFIG_PATH = "$ARGV[0]"; shift; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000159 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
Daniel Dunbarda420ee2009-11-06 04:12:07 +0000160 if (/^-noclean$/) { $NOCLEAN = 1; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000161 if (/^-noremove$/) { $NOREMOVE = 1; next; }
Daniel Dunbar0c39e382009-07-13 22:17:49 +0000162 if (/^-noremoveatend$/) { $NOREMOVEATEND = 1; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000163 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
Daniel Dunbarf5a59502009-06-02 21:14:15 +0000164 if (/^-notest$/) { $NOTEST = 1; next; }
165 if (/^-norunningtests$/) { next; } # Backward compatibility, ignored.
Daniel Dunbar056dbd02009-05-28 22:45:24 +0000166 if (/^-parallel-jobs$/) { $PARALLELJOBS = "$ARGV[0]"; shift; next;}
Daniel Dunbar2bb4c532009-10-19 13:20:50 +0000167 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j$PARALLELJOBS"; next; }
Daniel Dunbarddef0952009-10-19 13:20:56 +0000168 if (/^-parallel-test$/) { $PROGTESTOPTS .= " ENABLE_PARALLEL_REPORT=1"; next; }
Duncan Sands45db29c2009-06-12 13:02:52 +0000169 if (/^-with-clang$/) { $WITHCLANG = 1; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000170 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
Daniel Dunbarf2741382009-10-20 07:30:46 +0000171 "OPTIMIZE_OPTION=-O2"; next;}
Jim Laskey27b8ba02006-09-28 17:49:20 +0000172 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
Dan Gohmanc6e22412008-10-30 01:08:03 +0000173 "DISABLE_ASSERTIONS=1 ".
Daniel Dunbarf2741382009-10-20 07:30:46 +0000174 "OPTIMIZE_OPTION=-O2"; next;}
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000175 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
Duncan Sands45db29c2009-06-12 13:02:52 +0000176 if (/^-disable-pic$/) { $CONFIGUREARGS .= " --enable-pic=no"; next; }
Reid Spencer2bae1f52006-11-24 20:34:16 +0000177 if (/^-enable-lli$/) { $PROGTESTOPTS .= " ENABLE_LLI=1";
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000178 $CONFIGUREARGS .= " --enable-lli"; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000179 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000180 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000181 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
182 $CONFIGUREARGS .= " --disable-jit"; next; }
Daniel Dunbar111def82009-03-10 19:33:13 +0000183 if (/^-disable-bindings$/) { $CONFIGUREARGS .= " --disable-bindings"; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000184 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
Evan Chenge04c90b2008-01-12 04:27:18 +0000185 if (/^-disable-lto$/) { $PROGTESTOPTS .= " DISABLE_LTO=1"; next; }
Evan Cheng3d64f1c2008-01-14 17:58:03 +0000186 if (/^-test-opts$/) { $PROGTESTOPTS .= " $ARGV[0]"; shift; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000187 if (/^-verbose$/) { $VERBOSE = 1; next; }
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000188 if (/^-teelogs$/) { $TEELOGS = 1; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000189 if (/^-nice$/) { $NICE = "nice "; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000190 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000191 shift; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000192 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000193 shift; next; }
Daniel Dunbarff79ef42009-07-13 22:31:58 +0000194 if (/^-configure-args$/) { $CONFIGUREARGS .= " $ARGV[0]";
195 shift; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000196 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
197 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
Daniel Dunbarcd3f9992009-05-18 23:24:26 +0000198 if (/^-submit-aux/) { $SUBMITAUX = "$ARGV[0]"; shift; next; }
Tanya Lattnerc1611882008-03-10 07:28:08 +0000199 if (/^-nosubmit$/) { $SUBMIT = 0; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000200 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
201 if (/^-gccpath/) { $CONFIGUREARGS .=
202 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000203 $GCCPATH=$ARGV[0]; shift; next; }
204 else { $GCCPATH=""; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000205 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000206 shift; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000207 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000208 shift; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000209 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000210 shift; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000211 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000212 shift; next; }
Bill Wendling49e31822009-07-16 22:59:17 +0000213 if (/^-test-cflags/) { $TESTFLAGS = "$TESTFLAGS CFLAGS=\'$ARGV[0]\'";
214 shift; next; }
215 if (/^-test-cxxflags/) { $TESTFLAGS = "$TESTFLAGS CXXFLAGS=\'$ARGV[0]\'";
216 shift; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000217 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
Daniel Dunbar2d7adb52009-11-06 04:11:29 +0000218 if (/^-llvmgccdir/) { $CONFIGUREARGS .= " --with-llvmgccdir=\'$ARGV[0]\'";
219 $LLVMGCCPATH = $ARGV[0] . '/bin';
220 shift; next;}
221 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000222 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000223 if (/^-extraflags/) { $CONFIGUREARGS .=
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000224 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
225 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
226 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
227 if (/^-nobuild$/) { $NOBUILD = 1; next; }
228 print "Unknown option: $_ : ignoring!\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000229}
230
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000231if ($CONFIGUREARGS !~ /--disable-jit/) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000232 $CONFIGUREARGS .= " --enable-jit";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000233}
234
Daniel Dunbar0e9fe692009-10-19 09:19:19 +0000235if (@ARGV != 0 and @ARGV != 3) {
236 die "error: must specify 0 or 3 options!";
Patrick Jenkinsf58473f2006-07-27 01:03:46 +0000237}
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000238
239if (@ARGV == 3) {
Daniel Dunbar0e9fe692009-10-19 09:19:19 +0000240 if ($CONFIG_PATH ne "") {
241 die "error: arguments are unsupported in -config mode,";
242 }
243
Daniel Dunbar2e107942009-10-19 09:18:54 +0000244 # ARGV[0] used to be the CVS root, ignored for backward compatibility.
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000245 $BuildDir = $ARGV[1];
246 $WebDir = $ARGV[2];
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000247}
248
Daniel Dunbar80dd4532009-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 Brukman12c8d1b2009-01-02 16:28:18 +0000261
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000262if ($nickname eq "") {
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000263 die ("Please invoke NewNightlyTest.pl with command line option " .
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000264 "\"-nickname <nickname>\"");
Patrick Jenkins514e2582006-07-20 22:28:43 +0000265}
Patrick Jenkins1cd46912006-07-27 01:17:17 +0000266
Daniel Dunbarfe1974a2009-11-06 04:12:02 +0000267my $LLVMSrcDir = $ENV{'LLVMSRCDIR'};
268$LLVMSrcDir = "$BuildDir/llvm" unless $LLVMSrcDir;
269my $LLVMObjDir = $ENV{'LLVMOBJDIR'};
270$LLVMObjDir = "$BuildDir/llvm" unless $LLVMObjDir;
271my $LLVMTestDir = $ENV{'LLVMTESTDIR'};
272$LLVMTestDir = "$BuildDir/llvm/projects/llvm-test" unless $LLVMTestDir;
273
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000274##############################################################
275#
Daniel Dunbar4628e5e2009-10-19 09:18:24 +0000276# Define the file names we'll use
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000277#
278##############################################################
Daniel Dunbar80dd4532009-10-20 07:30:54 +0000279
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000280my $Prefix = "$WebDir/$DATE";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000281my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
282my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
Patrick Jenkins26ba6092006-07-23 22:57:28 +0000283my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000284
Daniel Dunbar80dd4532009-10-20 07:30:54 +0000285# These are only valid in non-config mode.
286my $ConfigureLog = "", $BuildLog = "", $COLog = "";
287my $DejagnuLog = "", $DejagnuSum = "", $DejagnuLog = "";
288
289# Are we in config mode?
290my $ConfigMode = 0;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000291
292##############################################################
293#
294# Helper functions
295#
296##############################################################
Daniel Dunbar4628e5e2009-10-19 09:18:24 +0000297
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000298sub GetDir {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000299 my $Suffix = shift;
300 opendir DH, $WebDir;
301 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
302 closedir DH;
303 return @Result;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000304}
305
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000306sub RunLoggedCommand {
307 my $Command = shift;
308 my $Log = shift;
Daniel Dunbarfc0fc3a2009-06-26 02:30:49 +0000309 my $Title = shift;
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000310 if ($TEELOGS) {
Daniel Dunbarfc0fc3a2009-06-26 02:30:49 +0000311 if ($VERBOSE) {
312 print "$Title\n";
313 print "$Command 2>&1 | tee $Log\n";
314 }
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000315 system "$Command 2>&1 | tee $Log";
316 } else {
Daniel Dunbarfc0fc3a2009-06-26 02:30:49 +0000317 if ($VERBOSE) {
318 print "$Title\n";
319 print "$Command 2>&1 > $Log\n";
320 }
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000321 system "$Command 2>&1 > $Log";
322 }
323}
324
325sub RunAppendingLoggedCommand {
326 my $Command = shift;
327 my $Log = shift;
Daniel Dunbarfc0fc3a2009-06-26 02:30:49 +0000328 my $Title = shift;
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000329 if ($TEELOGS) {
Daniel Dunbarfc0fc3a2009-06-26 02:30:49 +0000330 if ($VERBOSE) {
331 print "$Title\n";
332 print "$Command 2>&1 | tee -a $Log\n";
333 }
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000334 system "$Command 2>&1 | tee -a $Log";
335 } else {
Daniel Dunbarfc0fc3a2009-06-26 02:30:49 +0000336 if ($VERBOSE) {
337 print "$Title\n";
338 print "$Command 2>&1 > $Log\n";
339 }
340 system "$Command 2>&1 >> $Log";
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000341 }
342}
343
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000344sub GetRegex { # (Regex with ()'s, value)
Daniel Dunbar34311232009-10-19 13:20:19 +0000345 if ($_[1] =~ /$_[0]/m) {
346 return $1;
347 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000348 return "0";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000349}
350
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000351sub ChangeDir { # directory, logical name
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000352 my ($dir,$name) = @_;
353 chomp($dir);
354 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
355 $result = chdir($dir);
356 if (!$result) {
Daniel Dunbar2bb4c532009-10-19 13:20:50 +0000357 print "ERROR!!! Cannot change directory to: $name ($dir) because $!\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000358 return false;
359 }
360 return true;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000361}
362
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000363sub ReadFile {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000364 if (open (FILE, $_[0])) {
365 undef $/;
366 my $Ret = <FILE>;
367 close FILE;
368 $/ = '\n';
369 return $Ret;
370 } else {
371 print "Could not open file '$_[0]' for reading!\n";
372 return "";
373 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000374}
375
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000376sub WriteFile { # (filename, contents)
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000377 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
378 print FILE $_[1];
379 close FILE;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000380}
381
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000382sub CopyFile { #filename, newfile
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000383 my ($file, $newfile) = @_;
384 chomp($file);
385 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
386 copy($file, $newfile);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000387}
388
389#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000390#
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000391# This function is meant to read in the dejagnu sum file and
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000392# return a string with only the results (i.e. PASS/FAIL/XPASS/
393# XFAIL).
394#
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000395#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
396sub GetDejagnuTestResults { # (filename, log)
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000397 my ($filename, $DejagnuLog) = @_;
398 my @lines;
399 $/ = "\n"; #Make sure we're going line at a time.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000400
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000401 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000402
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000403 if (open SRCHFILE, $filename) {
404 # Process test results
405 while ( <SRCHFILE> ) {
406 if ( length($_) > 1 ) {
407 chomp($_);
Jim Laskey01d7bcf2006-09-20 09:20:22 +0000408 if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\/test\/(.*)$/ ) {
409 push(@lines, "$1: test/$2");
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000410 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000411 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000412 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000413 }
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000414 close SRCHFILE;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000415
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000416 my $content = join("\n", @lines);
417 return $content;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000418}
419
420
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000421
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000422#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
423#
424# This function acts as a mini web browswer submitting data
425# to our central server via the post method
426#
427#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Daniel Dunbar4628e5e2009-10-19 09:18:24 +0000428sub SendData {
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000429 $host = $_[0];
430 $file = $_[1];
Daniel Dunbar4628e5e2009-10-19 09:18:24 +0000431 $variables = $_[2];
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000432
Daniel Dunbar94a37a42009-05-28 18:31:40 +0000433 # Write out the "...-sentdata.txt" file.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000434
Daniel Dunbar94a37a42009-05-28 18:31:40 +0000435 my $sentdata="";
436 foreach $x (keys (%$variables)){
437 $value = $variables->{$x};
438 $sentdata.= "$x => $value\n";
439 }
440 WriteFile "$Prefix-sentdata.txt", $sentdata;
441
442 if (!($SUBMITAUX eq "")) {
Daniel Dunbarf7f02a92009-06-26 22:33:28 +0000443 system "$SUBMITAUX \"$Prefix-sentdata.txt\"";
444 }
445
Daniel Dunbar4628e5e2009-10-19 09:18:24 +0000446 if (!$SUBMIT) {
Daniel Dunbarf7f02a92009-06-26 22:33:28 +0000447 return "Skipped standard submit.\n";
Daniel Dunbar94a37a42009-05-28 18:31:40 +0000448 }
449
450 # Create the content to send to the server.
451
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000452 my $content;
453 foreach $key (keys (%$variables)){
454 $value = $variables->{$key};
455 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
456 $content .= "$key=$value&";
457 }
458
Daniel Dunbar94a37a42009-05-28 18:31:40 +0000459 # Send the data to the server.
Daniel Dunbar4628e5e2009-10-19 09:18:24 +0000460 #
Daniel Dunbar94a37a42009-05-28 18:31:40 +0000461 # FIXME: This code should be more robust?
Daniel Dunbar4628e5e2009-10-19 09:18:24 +0000462
Daniel Dunbar94a37a42009-05-28 18:31:40 +0000463 $port=80;
464 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
465 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
466 die "Bad socket\n";
467 connect SOCK, $socketaddr or die "Bad connection\n";
468 select((select(SOCK), $| = 1)[0]);
469
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000470 $length = length($content);
471
472 my $send= "POST $file HTTP/1.0\n";
Lauro Ramos Venancio46040232007-05-03 14:05:07 +0000473 $send.= "Host: $host\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000474 $send.= "Content-Type: application/x-www-form-urlencoded\n";
475 $send.= "Content-length: $length\n\n";
476 $send.= "$content";
477
Patrick Jenkinse8501eb2006-08-07 01:54:37 +0000478 print SOCK $send;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000479 my $result;
480 while(<SOCK>){
481 $result .= $_;
482 }
483 close(SOCK);
484
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000485 return $result;
486}
487
Patrick Jenkins215b48f2006-07-07 18:50:51 +0000488##############################################################
489#
Daniel Dunbar5381eb72009-10-19 13:20:31 +0000490# Individual Build & Test Functions
Patrick Jenkins215b48f2006-07-07 18:50:51 +0000491#
492##############################################################
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000493
Daniel Dunbar5381eb72009-10-19 13:20:31 +0000494# Create the source repository directory.
Daniel Dunbar8df92e82009-10-19 13:20:06 +0000495sub CheckoutSource {
Daniel Dunbar80dd4532009-10-20 07:30:54 +0000496 die "Invalid call!" unless $ConfigMode == 0;
Daniel Dunbar1409c132009-10-19 13:20:38 +0000497 if (-d $BuildDir) {
498 if (!$NOREMOVE) {
499 if ( $VERBOSE ) {
500 print "Build directory exists! Removing it\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000501 }
Daniel Dunbar1409c132009-10-19 13:20:38 +0000502 system "rm -rf $BuildDir";
Daniel Dunbar8df92e82009-10-19 13:20:06 +0000503 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
Daniel Dunbar1409c132009-10-19 13:20:38 +0000504 } else {
505 if ( $VERBOSE ) {
506 print "Build directory exists!\n";
507 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000508 }
Daniel Dunbar1409c132009-10-19 13:20:38 +0000509 } else {
510 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
511 }
Daniel Dunbar8df92e82009-10-19 13:20:06 +0000512
Daniel Dunbar1409c132009-10-19 13:20:38 +0000513 ChangeDir( $BuildDir, "checkout directory" );
514 my $SVNCMD = "$NICE svn co --non-interactive";
515 RunLoggedCommand("( time -p $SVNCMD $SVNURL/llvm/trunk llvm; cd llvm/projects ; " .
516 " $SVNCMD $TestSVNURL/test-suite/trunk llvm-test )", $COLog,
517 "CHECKOUT LLVM");
518 if ($WITHCLANG) {
519 RunLoggedCommand("( cd llvm/tools ; " .
520 " $SVNCMD $SVNURL/cfe/trunk clang )", $COLog,
521 "CHECKOUT CLANG");
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000522 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000523}
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000524
Daniel Dunbar1409c132009-10-19 13:20:38 +0000525# Build the entire tree, saving build messages to the build log. Returns false
526# on build failure.
Daniel Dunbar439801e2009-10-19 13:20:13 +0000527sub BuildLLVM {
Daniel Dunbar80dd4532009-10-20 07:30:54 +0000528 die "Invalid call!" unless $ConfigMode == 0;
Daniel Dunbar1409c132009-10-19 13:20:38 +0000529 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
530 RunLoggedCommand("(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) ",
531 $ConfigureLog, "CONFIGURE");
532 # Build the entire tree, capturing the output into $BuildLog
Daniel Dunbarda420ee2009-11-06 04:12:07 +0000533 if (!$NOCLEAN) {
534 RunAppendingLoggedCommand("($NICE $MAKECMD $MAKEOPTS clean)", $BuildLog, "BUILD CLEAN");
535 }
Daniel Dunbar1409c132009-10-19 13:20:38 +0000536 RunAppendingLoggedCommand("(time -p $NICE $MAKECMD $MAKEOPTS)", $BuildLog, "BUILD");
537
538 if (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
539 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l` + 0) {
540 return 0;
Daniel Dunbar439801e2009-10-19 13:20:13 +0000541 }
542
Daniel Dunbar1409c132009-10-19 13:20:38 +0000543 return 1;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000544}
545
Daniel Dunbar5381eb72009-10-19 13:20:31 +0000546# Running dejagnu tests and save results to log.
547sub RunDejaGNUTests {
Daniel Dunbar80dd4532009-10-20 07:30:54 +0000548 die "Invalid call!" unless $ConfigMode == 0;
Daniel Dunbar1409c132009-10-19 13:20:38 +0000549 # Run the feature and regression tests, results are put into testrun.sum and
550 # the full log in testrun.log.
Daniel Dunbar2bb4c532009-10-19 13:20:50 +0000551 system "rm -f test/testrun.log test/testrun.sum";
Daniel Dunbar1409c132009-10-19 13:20:38 +0000552 RunLoggedCommand("(time -p $MAKECMD $MAKEOPTS check)", $DejagnuLog, "DEJAGNU");
Daniel Dunbar5381eb72009-10-19 13:20:31 +0000553
Daniel Dunbar1409c132009-10-19 13:20:38 +0000554 # Copy the testrun.log and testrun.sum to our webdir.
555 CopyFile("test/testrun.log", $DejagnuLog);
556 CopyFile("test/testrun.sum", $DejagnuSum);
Daniel Dunbar5381eb72009-10-19 13:20:31 +0000557
Daniel Dunbar1409c132009-10-19 13:20:38 +0000558 return GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000559}
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000560
Daniel Dunbar5381eb72009-10-19 13:20:31 +0000561# Run the named tests (i.e. "SingleSource" "MultiSource" "External")
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000562sub TestDirectory {
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000563 my $SubDir = shift;
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000564 ChangeDir( "$LLVMTestDir/$SubDir",
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000565 "Programs Test Subdirectory" ) || return ("", "");
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000566
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000567 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000568
Daniel Dunbarda420ee2009-11-06 04:12:07 +0000569 # Make sure to clean the test results.
570 RunLoggedCommand("$MAKECMD -k $MAKEOPTS $PROGTESTOPTS clean $TESTFLAGS",
571 $ProgramTestLog, "TEST DIRECTORY $SubDir");
Daniel Dunbar80dd4532009-10-20 07:30:54 +0000572
Daniel Dunbar1409c132009-10-19 13:20:38 +0000573 # Run the programs tests... creating a report.nightly.csv file.
Daniel Dunbar34311232009-10-19 13:20:19 +0000574 my $LLCBetaOpts = "";
Daniel Dunbar1409c132009-10-19 13:20:38 +0000575 RunLoggedCommand("$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
576 "$TESTFLAGS TEST=nightly",
577 $ProgramTestLog, "TEST DIRECTORY $SubDir");
578 $LLCBetaOpts = `$MAKECMD print-llcbeta-option`;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000579
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000580 my $ProgramsTable;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000581 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000582 $ProgramsTable="Error running test $SubDir\n";
583 print "ERROR TESTING\n";
584 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000585 $ProgramsTable="Makefile error running tests $SubDir!\n";
586 print "ERROR TESTING\n";
587 } else {
Daniel Dunbar1409c132009-10-19 13:20:38 +0000588 # Create a list of the tests which were run...
589 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
590 "| sort > $Prefix-$SubDir-Tests.txt";
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000591 }
592 $ProgramsTable = ReadFile "report.nightly.csv";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000593
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000594 ChangeDir( "../../..", "Programs Test Parent Directory" );
Daniel Dunbar34311232009-10-19 13:20:19 +0000595 return ($ProgramsTable, $LLCBetaOpts);
596}
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000597
Daniel Dunbarac0c0642009-10-19 13:20:44 +0000598# Run all the nightly tests and return the program tables and the list of tests,
Daniel Dunbar5381eb72009-10-19 13:20:31 +0000599# passes, fails, and xfails.
Daniel Dunbar4a338bf2009-10-19 13:20:25 +0000600sub RunNightlyTest() {
Daniel Dunbar1409c132009-10-19 13:20:38 +0000601 ($SSProgs, $llcbeta_options) = TestDirectory("SingleSource");
602 WriteFile "$Prefix-SingleSource-Performance.txt", $SSProgs;
603 ($MSProgs, $llcbeta_options) = TestDirectory("MultiSource");
604 WriteFile "$Prefix-MultiSource-Performance.txt", $MSProgs;
605 if ( ! $NOEXTERNALS ) {
606 ($ExtProgs, $llcbeta_options) = TestDirectory("External");
607 WriteFile "$Prefix-External-Performance.txt", $ExtProgs;
608 system "cat $Prefix-SingleSource-Tests.txt " .
609 "$Prefix-MultiSource-Tests.txt ".
610 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
611 system "cat $Prefix-SingleSource-Performance.txt " .
612 "$Prefix-MultiSource-Performance.txt ".
613 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
614 } else {
615 $ExtProgs = "External TEST STAGE SKIPPED\n";
616 if ( $VERBOSE ) {
617 print "External TEST STAGE SKIPPED\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000618 }
Daniel Dunbar1409c132009-10-19 13:20:38 +0000619 system "cat $Prefix-SingleSource-Tests.txt " .
620 "$Prefix-MultiSource-Tests.txt ".
621 " | sort > $Prefix-Tests.txt";
622 system "cat $Prefix-SingleSource-Performance.txt " .
623 "$Prefix-MultiSource-Performance.txt ".
624 " | sort > $Prefix-Performance.txt";
625 }
Daniel Dunbar4a338bf2009-10-19 13:20:25 +0000626
Daniel Dunbar1409c132009-10-19 13:20:38 +0000627 # Compile passes, fails, xfails.
Daniel Dunbarac0c0642009-10-19 13:20:44 +0000628 my $All = (ReadFile "$Prefix-Tests.txt");
629 my @TestSuiteResultLines = split "\n", $All;
Daniel Dunbar1409c132009-10-19 13:20:38 +0000630 my ($Passes, $Fails, $XFails) = "";
Daniel Dunbar4a338bf2009-10-19 13:20:25 +0000631
Daniel Dunbar1409c132009-10-19 13:20:38 +0000632 for ($x=0; $x < @TestSuiteResultLines; $x++) {
633 if (@TestSuiteResultLines[$x] =~ m/^PASS:/) {
634 $Passes .= "$TestSuiteResultLines[$x]\n";
635 }
636 elsif (@TestSuiteResultLines[$x] =~ m/^FAIL:/) {
637 $Fails .= "$TestSuiteResultLines[$x]\n";
638 }
639 elsif (@TestSuiteResultLines[$x] =~ m/^XFAIL:/) {
640 $XFails .= "$TestSuiteResultLines[$x]\n";
Daniel Dunbar4a338bf2009-10-19 13:20:25 +0000641 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000642 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000643
Daniel Dunbarac0c0642009-10-19 13:20:44 +0000644 return ($SSProgs, $MSProgs, $ExtProgs, $All, $Passes, $Fails, $XFails);
Daniel Dunbar34311232009-10-19 13:20:19 +0000645}
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000646
Daniel Dunbar5381eb72009-10-19 13:20:31 +0000647##############################################################
648#
Daniel Dunbar80dd4532009-10-20 07:30:54 +0000649# Initialize filenames
650#
651##############################################################
652
653if (! -d $WebDir) {
654 mkdir $WebDir, 0777 or die "Unable to create web directory: '$WebDir'.";
655 if($VERBOSE){
656 warn "$WebDir did not exist; creating it.\n";
657 }
658}
659
660if ($CONFIG_PATH ne "") {
661 $ConfigMode = 1;
662 $LLVMSrcDir = GetRegex "^(.*)\\s+", `$CONFIG_PATH --src-root`;
663 $LLVMObjDir = GetRegex "^(.*)\\s+", `$CONFIG_PATH --obj-root`;
664 # FIXME: Add llvm-config hook for this?
665 $LLVMTestDir = $LLVMObjDir . "/projects/test-suite";
666} else {
667 $ConfigureLog = "$Prefix-Configure-Log.txt";
668 $BuildLog = "$Prefix-Build-Log.txt";
669 $COLog = "$Prefix-CVS-Log.txt";
670 $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
671 $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
672 $DejagnuLog = "$Prefix-DejagnuTests-Log.txt";
673}
674
675if ($VERBOSE) {
676 if ($CONFIG_PATH ne "") {
677 print "INITIALIZED (config mode)\n";
678 print "WebDir = $WebDir\n";
679 print "Prefix = $Prefix\n";
680 print "LLVM Src = $LLVMSrcDir\n";
681 print "LLVM Obj = $LLVMObjDir\n";
682 print "LLVM Test = $LLVMTestDir\n";
683 } else {
684 print "INITIALIZED\n";
685 print "SVN URL = $SVNURL\n";
686 print "COLog = $COLog\n";
687 print "BuildDir = $BuildDir\n";
688 print "WebDir = $WebDir\n";
689 print "Prefix = $Prefix\n";
690 print "BuildLog = $BuildLog\n";
691 }
692}
693
694##############################################################
695#
Daniel Dunbar5381eb72009-10-19 13:20:31 +0000696# The actual NewNightlyTest logic.
697#
698##############################################################
699
700$starttime = `date "+20%y-%m-%d %H:%M:%S"`;
701
Daniel Dunbar1409c132009-10-19 13:20:38 +0000702my $BuildError = 0, $BuildStatus = "OK";
Daniel Dunbar1409c132009-10-19 13:20:38 +0000703my $DejagnuTestResults = "Dejagnu skipped by user choice.";
Daniel Dunbar80dd4532009-10-20 07:30:54 +0000704if ($ConfigMode == 0) {
705 if (!$NOCHECKOUT) {
706 CheckoutSource();
707 }
708
709 # Build LLVM.
710 ChangeDir( $LLVMSrcDir , "llvm source directory") ;
711 if ($NOCHECKOUT || $NOBUILD) {
712 $BuildStatus = "Skipped by user";
713 } else {
714 if (!BuildLLVM()) {
715 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
716 $BuildError = 1;
717 $BuildStatus = "Error: compilation aborted";
718 $NODEJAGNU=1;
719 }
720 }
721
722 # Run DejaGNU.
723 if (!$NODEJAGNU && !$BuildError) {
724 $DejagnuTestResults = RunDejaGNUTests();
725 }
Daniel Dunbar1409c132009-10-19 13:20:38 +0000726}
727
728# Run the llvm-test tests.
Daniel Dunbar4a338bf2009-10-19 13:20:25 +0000729my ($SingleSourceProgramsTable, $MultiSourceProgramsTable, $ExternalProgramsTable,
Daniel Dunbarac0c0642009-10-19 13:20:44 +0000730 $all_tests, $passes, $fails, $xfails) = "";
Daniel Dunbar1409c132009-10-19 13:20:38 +0000731if (!$NOTEST && !$BuildError) {
732 ($SingleSourceProgramsTable, $MultiSourceProgramsTable, $ExternalProgramsTable,
Daniel Dunbarac0c0642009-10-19 13:20:44 +0000733 $all_tests, $passes, $fails, $xfails) = RunNightlyTest();
Daniel Dunbar1409c132009-10-19 13:20:38 +0000734}
Daniel Dunbar4a338bf2009-10-19 13:20:25 +0000735
Patrick Jenkinsb67e1182006-07-21 21:43:09 +0000736$endtime = `date "+20%y-%m-%d %H:%M:%S"`;
Patrick Jenkins215b48f2006-07-07 18:50:51 +0000737
Daniel Dunbar2bb4c532009-10-19 13:20:50 +0000738# The last bit of logic is to remove the build and web dirs, after sending data
739# to the server.
740
Daniel Dunbar5381eb72009-10-19 13:20:31 +0000741##############################################################
742#
743# Accumulate the information to send to the server.
744#
745##############################################################
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000746
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000747if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
748
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000749$machine_data = "uname: ".`uname -a`.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000750 "hardware: ".`uname -m`.
751 "os: ".`uname -sr`.
752 "name: ".`uname -n`.
753 "date: ".`date \"+20%y-%m-%d\"`.
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000754 "time: ".`date +\"%H:%M:%S\"`;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000755
Daniel Dunbar5381eb72009-10-19 13:20:31 +0000756# Get gcc version.
Daniel Dunbar34311232009-10-19 13:20:19 +0000757my $gcc_version_long = "";
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000758if ($GCCPATH ne "") {
Daniel Dunbar34311232009-10-19 13:20:19 +0000759 $gcc_version_long = `$GCCPATH/gcc --version`;
Jeff Cohen75454222007-04-10 19:13:43 +0000760} elsif ($ENV{"CC"}) {
Daniel Dunbar34311232009-10-19 13:20:19 +0000761 $gcc_version_long = `$ENV{"CC"} --version`;
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000762} else {
Daniel Dunbar34311232009-10-19 13:20:19 +0000763 $gcc_version_long = `gcc --version`;
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000764}
Daniel Dunbar34311232009-10-19 13:20:19 +0000765my $gcc_version = (split '\n', $gcc_version_long)[0];
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000766
Daniel Dunbar5381eb72009-10-19 13:20:31 +0000767# Get llvm-gcc target triple.
Daniel Dunbar2d7adb52009-11-06 04:11:29 +0000768#
769# FIXME: This shouldn't be hardwired to llvm-gcc.
Daniel Dunbar34311232009-10-19 13:20:19 +0000770my $llvmgcc_version_long = "";
Tanya Lattner849c9a22007-04-13 04:36:48 +0000771if ($LLVMGCCPATH ne "") {
772 $llvmgcc_version_long = `$LLVMGCCPATH/llvm-gcc -v 2>&1`;
773} else {
774 $llvmgcc_version_long = `llvm-gcc -v 2>&1`;
775}
Daniel Dunbar34311232009-10-19 13:20:19 +0000776(split '\n', $llvmgcc_version_long)[1] =~ /Target: (.+)/;
777my $targetTriple = $1;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000778
Daniel Dunbar34311232009-10-19 13:20:19 +0000779# Logs.
Daniel Dunbar80dd4532009-10-20 07:30:54 +0000780my ($ConfigureLogData, $BuildLogData, $DejagnuLogData, $CheckoutLogData) = "";
781if ($ConfigMode == 0) {
782 $ConfigureLogData = ReadFile $ConfigureLog;
783 $BuildLogData = ReadFile $BuildLog;
784 $DejagnuLogData = ReadFile $DejagnuLog;
785 $CheckoutLogData = ReadFile $COLog;
786}
Daniel Dunbar34311232009-10-19 13:20:19 +0000787
Daniel Dunbar439801e2009-10-19 13:20:13 +0000788# Checkout info.
Daniel Dunbar34311232009-10-19 13:20:19 +0000789my $CheckoutTime_Wall = GetRegex "^real ([0-9.]+)", $CheckoutLogData;
790my $CheckoutTime_User = GetRegex "^user ([0-9.]+)", $CheckoutLogData;
791my $CheckoutTime_Sys = GetRegex "^sys ([0-9.]+)", $CheckoutLogData;
Daniel Dunbar8df92e82009-10-19 13:20:06 +0000792my $CheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
793
Daniel Dunbar439801e2009-10-19 13:20:13 +0000794# Configure info.
Daniel Dunbar34311232009-10-19 13:20:19 +0000795my $ConfigTimeU = GetRegex "^user ([0-9.]+)", $ConfigureLogData;
796my $ConfigTimeS = GetRegex "^sys ([0-9.]+)", $ConfigureLogData;
Daniel Dunbar439801e2009-10-19 13:20:13 +0000797my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
Daniel Dunbar34311232009-10-19 13:20:19 +0000798my $ConfigWallTime = GetRegex "^real ([0-9.]+)",$ConfigureLogData;
Daniel Dunbar439801e2009-10-19 13:20:13 +0000799$ConfigTime=-1 unless $ConfigTime;
800$ConfigWallTime=-1 unless $ConfigWallTime;
801
802# Build info.
Daniel Dunbar34311232009-10-19 13:20:19 +0000803my $BuildTimeU = GetRegex "^user ([0-9.]+)", $BuildLogData;
804my $BuildTimeS = GetRegex "^sys ([0-9.]+)", $BuildLogData;
Daniel Dunbar439801e2009-10-19 13:20:13 +0000805my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
Daniel Dunbar34311232009-10-19 13:20:19 +0000806my $BuildWallTime = GetRegex "^real ([0-9.]+)", $BuildLogData;
Daniel Dunbar439801e2009-10-19 13:20:13 +0000807$BuildTime=-1 unless $BuildTime;
808$BuildWallTime=-1 unless $BuildWallTime;
809
Daniel Dunbar34311232009-10-19 13:20:19 +0000810# DejaGNU info.
811my $DejagnuTimeU = GetRegex "^user ([0-9.]+)", $DejagnuLogData;
812my $DejagnuTimeS = GetRegex "^sys ([0-9.]+)", $DejagnuLogData;
813$DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
814$DejagnuWallTime = GetRegex "^real ([0-9.]+)", $DejagnuLogData;
815$DejagnuTime = "0.0" unless $DejagnuTime;
816$DejagnuWallTime = "0.0" unless $DejagnuWallTime;
Daniel Dunbar439801e2009-10-19 13:20:13 +0000817
Daniel Dunbar2bb4c532009-10-19 13:20:50 +0000818if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
819
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000820my %hash_of_data = (
821 'machine_data' => $machine_data,
Daniel Dunbar34311232009-10-19 13:20:19 +0000822 'build_data' => $ConfigureLogData . $BuildLogData,
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000823 'gcc_version' => $gcc_version,
824 'nickname' => $nickname,
825 'dejagnutime_wall' => $DejagnuWallTime,
826 'dejagnutime_cpu' => $DejagnuTime,
Reid Spencer99e865a2007-04-07 04:41:16 +0000827 'cvscheckouttime_wall' => $CheckoutTime_Wall,
828 'cvscheckouttime_cpu' => $CheckoutTime_CPU,
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000829 'configtime_wall' => $ConfigWallTime,
830 'configtime_cpu'=> $ConfigTime,
831 'buildtime_wall' => $BuildWallTime,
832 'buildtime_cpu' => $BuildTime,
Daniel Dunbar2bb4c532009-10-19 13:20:50 +0000833 'buildstatus' => $BuildStatus,
834 'singlesource_programstable' => $SingleSourceProgramsTable,
835 'multisource_programstable' => $MultiSourceProgramsTable,
836 'externalsource_programstable' => $ExternalProgramsTable,
837 'llcbeta_options' => $llcbeta_options,
838 'passing_tests' => $passes,
839 'expfail_tests' => $xfails,
840 'unexpfail_tests' => $fails,
841 'all_tests' => $all_tests,
842 'dejagnutests_results' => $DejagnuTestResults,
843 'dejagnutests_log' => $DejagnuLogData,
844 'starttime' => $starttime,
845 'endtime' => $endtime,
846 'target_triple' => $targetTriple,
847
848 # Unused, but left around for backwards compatability.
Daniel Dunbar7a1e60a2009-10-19 13:19:53 +0000849 'warnings' => "",
Daniel Dunbar7c9eb9e2009-10-19 09:19:09 +0000850 'cvsusercommitlist' => "",
851 'cvsuserupdatelist' => "",
852 'cvsaddedfiles' => "",
853 'cvsmodifiedfiles' => "",
854 'cvsremovedfiles' => "",
855 'lines_of_code' => "",
856 'cvs_file_count' => 0,
857 'cvs_dir_count' => 0,
Daniel Dunbar7a1e60a2009-10-19 13:19:53 +0000858 'warnings_removed' => "",
859 'warnings_added' => "",
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000860 'new_tests' => "",
861 'removed_tests' => "",
Daniel Dunbar7f0e81f2009-10-19 13:20:00 +0000862 'o_file_sizes' => "",
Daniel Dunbar2bb4c532009-10-19 13:20:50 +0000863 'a_file_sizes' => ""
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000864);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000865
Daniel Dunbarf7f02a92009-06-26 22:33:28 +0000866if ($SUBMIT || !($SUBMITAUX eq "")) {
Tanya Lattnerc1611882008-03-10 07:28:08 +0000867 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
868 if( $VERBOSE) { print "============================\n$response"; }
869} else {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000870 print "============================\n";
871 foreach $x(keys %hash_of_data){
872 print "$x => $hash_of_data{$x}\n";
873 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000874}
875
876##############################################################
877#
Daniel Dunbar2e107942009-10-19 09:18:54 +0000878# Remove the source tree...
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000879#
880##############################################################
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000881system ( "$NICE rm -rf $BuildDir")
Daniel Dunbar0c39e382009-07-13 22:17:49 +0000882 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVEATEND);
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000883system ( "$NICE rm -rf $WebDir")
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000884 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);