blob: c8be6ecf50f1632ab7c500fb1b767e2c68d146fe [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001#!/usr/bin/perl
2use POSIX qw(strftime);
3use File::Copy;
Bob Wilson722d58b2009-06-19 17:19:38 +00004use File::Find;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005use Socket;
6
7#
8# Program: NewNightlyTest.pl
9#
10# Synopsis: Perform a series of tests which are designed to be run nightly.
11# This is used to keep track of the status of the LLVM tree, tracking
Misha Brukmanafa1e862009-01-02 16:28:18 +000012# regressions and performance changes. Submits this information
Dan Gohmanf17a25c2007-07-18 16:29:46 +000013# to llvm.org where it is placed into the nightlytestresults database.
14#
Dan Gohmanf17a25c2007-07-18 16:29:46 +000015# Syntax: NightlyTest.pl [OPTIONS] [CVSROOT BUILDDIR WEBDIR]
16# where
17# OPTIONS may include one or more of the following:
Dan Gohmanf17a25c2007-07-18 16:29:46 +000018#
Daniel Dunbarae3faf12009-10-19 09:18:24 +000019# MAIN OPTIONS:
20# -config LLVMPATH If specified, use an existing LLVM build and only run and
21# report the test information. The LLVMCONFIG argument should
22# be the path to the llvm-config executable in the LLVM build.
23# This should be the first argument if given. NOT YET
24# IMPLEMENTED.
25# -nickname NAME The NAME argument specifieds the nickname this script
26# will submit to the nightlytest results repository.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000027# -submit-server Specifies a server to submit the test results too. If this
Misha Brukmanafa1e862009-01-02 16:28:18 +000028# option is not specified it defaults to
29# llvm.org. This is basically just the address of the
Dan Gohmanf17a25c2007-07-18 16:29:46 +000030# webserver
31# -submit-script Specifies which script to call on the submit server. If
32# this option is not specified it defaults to
Misha Brukmanafa1e862009-01-02 16:28:18 +000033# /nightlytest/NightlyTestAccept.php. This is basically
Dan Gohmanf17a25c2007-07-18 16:29:46 +000034# everything after the www.yourserver.org.
Daniel Dunbar016a4bb2009-05-18 23:24:26 +000035# -submit-aux If specified, an auxiliary script to run in addition to the
36# normal submit script. The script will be passed the path to
37# the "sentdata.txt" file as its sole argument.
Tanya Lattner084a3ee2008-03-10 07:28:08 +000038# -nosubmit Do not report the test results back to a submit server.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000039#
Daniel Dunbarae3faf12009-10-19 09:18:24 +000040#
41# BUILD OPTIONS (not used with -config):
42# -nocheckout Do not create, checkout, update, or configure
43# the source tree.
44# -noremove Do not remove the BUILDDIR after it has been built.
45# -noremoveresults Do not remove the WEBDIR after it has been built.
46# -nobuild Do not build llvm. If tests are enabled perform them
47# on the llvm build specified in the build directory
48# -release Build an LLVM Release version
49# -release-asserts Build an LLVM ReleaseAsserts version
50# -disable-bindings Disable building LLVM bindings.
Daniel Dunbarae3faf12009-10-19 09:18:24 +000051# -with-clang Checkout Clang source into tools/clang.
52# -compileflags Next argument specifies extra options passed to make when
53# building LLVM.
54# -use-gmake Use gmake instead of the default make command to build
55# llvm and run tests.
56#
57# TESTING OPTIONS:
58# -notest Do not even attempt to run the test programs.
59# -nodejagnu Do not run feature or regression tests
60# -enable-llcbeta Enable testing of beta features in llc.
61# -enable-lli Enable testing of lli (interpreter) features, default is off
62# -disable-pic Disable building with Position Independent Code.
63# -disable-llc Disable LLC tests in the nightly tester.
64# -disable-jit Disable JIT tests in the nightly tester.
65# -disable-cbe Disable C backend tests in the nightly tester.
66# -disable-lto Disable link time optimization.
67# -test-cflags Next argument specifies that C compilation options that
68# override the default when running the testsuite.
69# -test-cxxflags Next argument specifies that C++ compilation options that
70# override the default when running the testsuite.
71# -extraflags Next argument specifies extra options that are passed to
72# compile the tests.
73# -noexternals Do not run the external tests (for cases where povray
74# or SPEC are not installed)
75# -with-externals Specify a directory where the external tests are located.
76#
77# OTHER OPTIONS:
78# -parallel Run parallel jobs with GNU Make (see -parallel-jobs).
79# -parallel-jobs The number of parallel Make jobs to use (default is two).
80# -verbose Turn on some debug output
Daniel Dunbarae3faf12009-10-19 09:18:24 +000081# -nice Checkout/Configure/Build with "nice" to reduce impact
82# on busy servers.
83# -f2c Next argument specifies path to F2C utility
84# -gccpath Path to gcc/g++ used to build LLVM
85# -target Specify the target triplet
86# -cflags Next argument specifies that C compilation options that
87# override the default.
88# -cxxflags Next argument specifies that C++ compilation options that
89# override the default.
90# -ldflags Next argument specifies that linker options that override
91# the default.
92#
Daniel Dunbar414cffe2009-10-19 09:18:54 +000093# CVSROOT is ignored, it is passed for backwards compatibility.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000094# BUILDDIR is the directory where sources for this test run will be checked out
95# AND objects for this test run will be built. This directory MUST NOT
Daniel Dunbar414cffe2009-10-19 09:18:54 +000096# exist before the script is run; it will be created by the svn checkout
Dan Gohmanf17a25c2007-07-18 16:29:46 +000097# process and erased (unless -noremove is specified; see above.)
98# WEBDIR is the directory into which the test results web page will be written,
99# AND in which the "index.html" is assumed to be a symlink to the most recent
100# copy of the results. This directory will be created if it does not exist.
101# LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
102# to. This is the same as you would have for a normal LLVM build.
103#
104##############################################################
105#
106# Getting environment variables
107#
108##############################################################
109my $HOME = $ENV{'HOME'};
110my $SVNURL = $ENV{"SVNURL"};
Duncan Sands01388f92009-06-12 13:02:52 +0000111$SVNURL = 'http://llvm.org/svn/llvm-project' unless $SVNURL;
Evan Chengb6d7fc32009-06-18 21:39:50 +0000112my $TestSVNURL = $ENV{"TestSVNURL"};
Evan Chenge45329e2009-07-14 06:23:41 +0000113$TestSVNURL = 'http://llvm.org/svn/llvm-project' unless $TestSVNURL;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000114my $BuildDir = $ENV{'BUILDDIR'};
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000115my $WebDir = $ENV{'WEBDIR'};
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000116
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000117my $LLVMSrcDir = $ENV{'LLVMSRCDIR'};
118$LLVMSrcDir = "$BuildDir/llvm" unless $LLVMSrcDir;
119my $LLVMObjDir = $ENV{'LLVMOBJDIR'};
120$LLVMObjDir = "$BuildDir/llvm" unless $LLVMObjDir;
121my $LLVMTestDir = $ENV{'LLVMTESTDIR'};
122$LLVMTestDir = "$BuildDir/llvm/projects/llvm-test" unless $LLVMTestDir;
123
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000124##############################################################
125#
126# Calculate the date prefix...
127#
128##############################################################
129@TIME = localtime;
Daniel Dunbar93ad6a82009-07-01 14:52:59 +0000130my $DATE = sprintf "%4d-%02d-%02d_%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3], $TIME[1], $TIME[0];
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000131
132##############################################################
133#
134# Parse arguments...
135#
136##############################################################
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000137$CONFIG_PATH="";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000138$CONFIGUREARGS="";
139$nickname="";
140$NOTEST=0;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000141$MAKECMD="make";
142$SUBMITSERVER = "llvm.org";
143$SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
Daniel Dunbar016a4bb2009-05-18 23:24:26 +0000144$SUBMITAUX="";
Tanya Lattner084a3ee2008-03-10 07:28:08 +0000145$SUBMIT = 1;
Daniel Dunbarf8cdaec2009-05-28 22:45:24 +0000146$PARALLELJOBS = "2";
Bill Wendling085ff3f2009-07-16 22:59:17 +0000147my $TESTFLAGS="";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000148
149while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
150 shift;
151 last if /^--$/; # Stop processing arguments on --
152
153 # List command line options here...
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000154 if (/^-config$/) { $CONFIG_PATH = "$ARGV[0]"; shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000155 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000156 if (/^-noremove$/) { $NOREMOVE = 1; next; }
Daniel Dunbard3ecefe2009-07-13 22:17:49 +0000157 if (/^-noremoveatend$/) { $NOREMOVEATEND = 1; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000158 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
Daniel Dunbar2041d9a2009-06-02 21:14:15 +0000159 if (/^-notest$/) { $NOTEST = 1; next; }
160 if (/^-norunningtests$/) { next; } # Backward compatibility, ignored.
Daniel Dunbarf8cdaec2009-05-28 22:45:24 +0000161 if (/^-parallel-jobs$/) { $PARALLELJOBS = "$ARGV[0]"; shift; next;}
162 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j$PARALLELJOBS -l3.0"; next; }
Duncan Sands01388f92009-06-12 13:02:52 +0000163 if (/^-with-clang$/) { $WITHCLANG = 1; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000164 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
165 "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
166 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
Dan Gohmanbd399762008-10-30 01:08:03 +0000167 "DISABLE_ASSERTIONS=1 ".
Misha Brukmanafa1e862009-01-02 16:28:18 +0000168 "OPTIMIZE_OPTION=-O2";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000169 $BUILDTYPE="release-asserts"; next;}
170 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
Duncan Sands01388f92009-06-12 13:02:52 +0000171 if (/^-disable-pic$/) { $CONFIGUREARGS .= " --enable-pic=no"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000172 if (/^-enable-lli$/) { $PROGTESTOPTS .= " ENABLE_LLI=1";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000173 $CONFIGUREARGS .= " --enable-lli"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000174 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000175 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000176 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
177 $CONFIGUREARGS .= " --disable-jit"; next; }
Daniel Dunbar31a1f1c2009-03-10 19:33:13 +0000178 if (/^-disable-bindings$/) { $CONFIGUREARGS .= " --disable-bindings"; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000179 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
Evan Cheng32efae02008-01-12 04:27:18 +0000180 if (/^-disable-lto$/) { $PROGTESTOPTS .= " DISABLE_LTO=1"; next; }
Evan Cheng08206772008-01-14 17:58:03 +0000181 if (/^-test-opts$/) { $PROGTESTOPTS .= " $ARGV[0]"; shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000182 if (/^-verbose$/) { $VERBOSE = 1; next; }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000183 if (/^-teelogs$/) { $TEELOGS = 1; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000184 if (/^-nice$/) { $NICE = "nice "; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000185 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000186 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000187 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000188 shift; next; }
Daniel Dunbardd9c4aa2009-07-13 22:31:58 +0000189 if (/^-configure-args$/) { $CONFIGUREARGS .= " $ARGV[0]";
190 shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000191 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
192 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
Daniel Dunbar016a4bb2009-05-18 23:24:26 +0000193 if (/^-submit-aux/) { $SUBMITAUX = "$ARGV[0]"; shift; next; }
Tanya Lattner084a3ee2008-03-10 07:28:08 +0000194 if (/^-nosubmit$/) { $SUBMIT = 0; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000195 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
196 if (/^-gccpath/) { $CONFIGUREARGS .=
197 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000198 $GCCPATH=$ARGV[0]; shift; next; }
199 else { $GCCPATH=""; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000200 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000201 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000202 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000203 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000204 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000205 shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000206 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000207 shift; next; }
Bill Wendling085ff3f2009-07-16 22:59:17 +0000208 if (/^-test-cflags/) { $TESTFLAGS = "$TESTFLAGS CFLAGS=\'$ARGV[0]\'";
209 shift; next; }
210 if (/^-test-cxxflags/) { $TESTFLAGS = "$TESTFLAGS CXXFLAGS=\'$ARGV[0]\'";
211 shift; next; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000212 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
213 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000214 if (/^-extraflags/) { $CONFIGUREARGS .=
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000215 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
216 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
217 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
218 if (/^-nobuild$/) { $NOBUILD = 1; next; }
219 print "Unknown option: $_ : ignoring!\n";
220}
221
222if ($ENV{'LLVMGCCDIR'}) {
223 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
Bob Wilsonc6d296b2009-03-12 19:47:24 +0000224 $LLVMGCCPATH = $ENV{'LLVMGCCDIR'} . '/bin';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000225}
226else {
227 $LLVMGCCPATH = "";
228}
229
230if ($CONFIGUREARGS !~ /--disable-jit/) {
231 $CONFIGUREARGS .= " --enable-jit";
232}
233
Daniel Dunbardce5acc2009-10-19 09:19:19 +0000234if (@ARGV != 0 and @ARGV != 3) {
235 die "error: must specify 0 or 3 options!";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000236}
237
238if (@ARGV == 3) {
Daniel Dunbardce5acc2009-10-19 09:19:19 +0000239 if ($CONFIG_PATH ne "") {
240 die "error: arguments are unsupported in -config mode,";
241 }
242
Daniel Dunbar414cffe2009-10-19 09:18:54 +0000243 # ARGV[0] used to be the CVS root, ignored for backward compatibility.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000244 $BuildDir = $ARGV[1];
245 $WebDir = $ARGV[2];
246}
247
Daniel Dunbar414cffe2009-10-19 09:18:54 +0000248if ($BuildDir eq "" or
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000249 $WebDir eq "") {
Daniel Dunbar414cffe2009-10-19 09:18:54 +0000250 die("please specify a build directory, and a web directory");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000251 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000252
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000253if ($nickname eq "") {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000254 die ("Please invoke NewNightlyTest.pl with command line option " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000255 "\"-nickname <nickname>\"");
256}
257
258if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
259 $BUILDTYPE = "debug";
260}
261
Daniel Dunbardce5acc2009-10-19 09:19:19 +0000262if ($CONFIG_PATH ne "") {
263 die "error: -config mode is not yet implemented,";
264}
265
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000266##############################################################
267#
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000268# Define the file names we'll use
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000269#
270##############################################################
271my $Prefix = "$WebDir/$DATE";
272my $BuildLog = "$Prefix-Build-Log.txt";
273my $COLog = "$Prefix-CVS-Log.txt";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000274my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
275my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
276my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
277my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
278my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
279my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
280if (! -d $WebDir) {
Daniel Dunbar6981e022009-10-19 13:19:53 +0000281 mkdir $WebDir, 0777 or die "Unable to create web directory: '$WebDir'.";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000282 if($VERBOSE){
283 warn "$WebDir did not exist; creating it.\n";
284 }
285}
286
287if ($VERBOSE) {
288 print "INITIALIZED\n";
Daniel Dunbaraffc0a52009-10-19 09:18:46 +0000289 print "SVN URL = $SVNURL\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000290 print "COLog = $COLog\n";
291 print "BuildDir = $BuildDir\n";
292 print "WebDir = $WebDir\n";
293 print "Prefix = $Prefix\n";
294 print "BuildLog = $BuildLog\n";
295}
296
297##############################################################
298#
299# Helper functions
300#
301##############################################################
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000302
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000303sub GetDir {
304 my $Suffix = shift;
305 opendir DH, $WebDir;
306 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
307 closedir DH;
308 return @Result;
309}
310
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000311sub RunLoggedCommand {
312 my $Command = shift;
313 my $Log = shift;
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000314 my $Title = shift;
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000315 if ($TEELOGS) {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000316 if ($VERBOSE) {
317 print "$Title\n";
318 print "$Command 2>&1 | tee $Log\n";
319 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000320 system "$Command 2>&1 | tee $Log";
321 } else {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000322 if ($VERBOSE) {
323 print "$Title\n";
324 print "$Command 2>&1 > $Log\n";
325 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000326 system "$Command 2>&1 > $Log";
327 }
328}
329
330sub RunAppendingLoggedCommand {
331 my $Command = shift;
332 my $Log = shift;
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000333 my $Title = shift;
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000334 if ($TEELOGS) {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000335 if ($VERBOSE) {
336 print "$Title\n";
337 print "$Command 2>&1 | tee -a $Log\n";
338 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000339 system "$Command 2>&1 | tee -a $Log";
340 } else {
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000341 if ($VERBOSE) {
342 print "$Title\n";
343 print "$Command 2>&1 > $Log\n";
344 }
345 system "$Command 2>&1 >> $Log";
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000346 }
347}
348
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000349#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000350#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
351sub GetRegex { # (Regex with ()'s, value)
352 $_[1] =~ /$_[0]/m;
Misha Brukmanafa1e862009-01-02 16:28:18 +0000353 return $1
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000354 if (defined($1));
355 return "0";
356}
357
358#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
359#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
360sub GetRegexNum {
361 my ($Regex, $Num, $Regex2, $File) = @_;
362 my @Items = split "\n", `grep '$Regex' $File`;
363 return GetRegex $Regex2, $Items[$Num];
364}
365
366#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
367#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
368sub ChangeDir { # directory, logical name
369 my ($dir,$name) = @_;
370 chomp($dir);
371 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
372 $result = chdir($dir);
373 if (!$result) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000374 print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000375 return false;
376 }
377 return true;
378}
379
380#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
381#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
382sub ReadFile {
383 if (open (FILE, $_[0])) {
384 undef $/;
385 my $Ret = <FILE>;
386 close FILE;
387 $/ = '\n';
388 return $Ret;
389 } else {
390 print "Could not open file '$_[0]' for reading!\n";
391 return "";
392 }
393}
394
395#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
396#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
397sub WriteFile { # (filename, contents)
398 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
399 print FILE $_[1];
400 close FILE;
401}
402
403#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
404#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
405sub CopyFile { #filename, newfile
406 my ($file, $newfile) = @_;
407 chomp($file);
408 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
409 copy($file, $newfile);
410}
411
412#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
413#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
414sub AddRecord {
415 my ($Val, $Filename,$WebDir) = @_;
416 my @Records;
417 if (open FILE, "$WebDir/$Filename") {
418 @Records = grep !/$DATE/, split "\n", <FILE>;
419 close FILE;
420 }
421 push @Records, "$DATE: $Val";
422 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
423}
424
425#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
426#
427# FormatTime - Convert a time from 1m23.45 into 83.45
428#
429#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
430sub FormatTime {
431 my $Time = shift;
432 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
433 $Time = sprintf("%7.4f", $1*60.0+$2);
434 }
435 return $Time;
436}
437
438#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
439#
Misha Brukmanafa1e862009-01-02 16:28:18 +0000440# This function is meant to read in the dejagnu sum file and
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000441# return a string with only the results (i.e. PASS/FAIL/XPASS/
442# XFAIL).
443#
444#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
445sub GetDejagnuTestResults { # (filename, log)
446 my ($filename, $DejagnuLog) = @_;
447 my @lines;
448 $/ = "\n"; #Make sure we're going line at a time.
449
450 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
451
452 if (open SRCHFILE, $filename) {
453 # Process test results
454 while ( <SRCHFILE> ) {
455 if ( length($_) > 1 ) {
456 chomp($_);
457 if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\/test\/(.*)$/ ) {
458 push(@lines, "$1: test/$2");
459 }
460 }
461 }
462 }
463 close SRCHFILE;
464
465 my $content = join("\n", @lines);
466 return $content;
467}
468
469
470
471#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
472#
473# This function acts as a mini web browswer submitting data
474# to our central server via the post method
475#
476#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000477sub SendData {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000478 $host = $_[0];
479 $file = $_[1];
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000480 $variables = $_[2];
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000481
Daniel Dunbara2533002009-05-28 18:31:40 +0000482 # Write out the "...-sentdata.txt" file.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000483
Daniel Dunbara2533002009-05-28 18:31:40 +0000484 my $sentdata="";
485 foreach $x (keys (%$variables)){
486 $value = $variables->{$x};
487 $sentdata.= "$x => $value\n";
488 }
489 WriteFile "$Prefix-sentdata.txt", $sentdata;
490
491 if (!($SUBMITAUX eq "")) {
Daniel Dunbar3b377ef2009-06-26 22:33:28 +0000492 system "$SUBMITAUX \"$Prefix-sentdata.txt\"";
493 }
494
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000495 if (!$SUBMIT) {
Daniel Dunbar3b377ef2009-06-26 22:33:28 +0000496 return "Skipped standard submit.\n";
Daniel Dunbara2533002009-05-28 18:31:40 +0000497 }
498
499 # Create the content to send to the server.
500
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000501 my $content;
502 foreach $key (keys (%$variables)){
503 $value = $variables->{$key};
504 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
505 $content .= "$key=$value&";
506 }
507
Daniel Dunbara2533002009-05-28 18:31:40 +0000508 # Send the data to the server.
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000509 #
Daniel Dunbara2533002009-05-28 18:31:40 +0000510 # FIXME: This code should be more robust?
Daniel Dunbarae3faf12009-10-19 09:18:24 +0000511
Daniel Dunbara2533002009-05-28 18:31:40 +0000512 $port=80;
513 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
514 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
515 die "Bad socket\n";
516 connect SOCK, $socketaddr or die "Bad connection\n";
517 select((select(SOCK), $| = 1)[0]);
518
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000519 $length = length($content);
520
521 my $send= "POST $file HTTP/1.0\n";
522 $send.= "Host: $host\n";
523 $send.= "Content-Type: application/x-www-form-urlencoded\n";
524 $send.= "Content-length: $length\n\n";
525 $send.= "$content";
526
527 print SOCK $send;
528 my $result;
529 while(<SOCK>){
530 $result .= $_;
531 }
532 close(SOCK);
533
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000534 return $result;
535}
536
537##############################################################
538#
539# Getting Start timestamp
540#
541##############################################################
542$starttime = `date "+20%y-%m-%d %H:%M:%S"`;
543
544##############################################################
545#
Daniel Dunbar414cffe2009-10-19 09:18:54 +0000546# Create the source repository directory
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000547#
548##############################################################
549if (!$NOCHECKOUT) {
550 if (-d $BuildDir) {
551 if (!$NOREMOVE) {
552 if ( $VERBOSE ) {
553 print "Build directory exists! Removing it\n";
554 }
555 system "rm -rf $BuildDir";
556 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
557 } else {
558 if ( $VERBOSE ) {
559 print "Build directory exists!\n";
560 }
561 }
562 } else {
563 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
564 }
565}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000566
567
568##############################################################
569#
Daniel Dunbar414cffe2009-10-19 09:18:54 +0000570# Check out the llvm tree with SVN
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000571#
572##############################################################
573if (!$NOCHECKOUT) {
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000574 ChangeDir( $BuildDir, "checkout directory" );
Daniel Dunbaraffc0a52009-10-19 09:18:46 +0000575 my $SVNCMD = "$NICE svn co --non-interactive $SVNURL";
576 my $SVNCMD2 = "$NICE svn co --non-interactive $TestSVNURL";
577 RunLoggedCommand("( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
578 "$SVNCMD2/test-suite/trunk llvm-test )", $COLog,
579 "CHECKOUT LLVM");
580 if ($WITHCLANG) {
581 my $SVNCMD = "$NICE svn co --non-interactive $SVNURL/cfe/trunk";
582 RunLoggedCommand("( time -p cd llvm/tools ; $SVNCMD clang )", $COLog,
583 "CHECKOUT CLANG");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000584 }
585}
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000586ChangeDir( $LLVMSrcDir , "llvm source directory") ;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000587
588##############################################################
589#
Daniel Dunbar414cffe2009-10-19 09:18:54 +0000590# Get some static statistics about the current source code
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000591#
592# This can probably be put on the server side
593#
594##############################################################
595my $CheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $COLog`;
596my $CheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $COLog`;
597my $CheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $COLog`;
598my $CheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
599
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000600##############################################################
601#
602# Build the entire tree, saving build messages to the build log
603#
604##############################################################
605if (!$NOCHECKOUT && !$NOBUILD) {
606 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000607 RunLoggedCommand("(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) ",
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000608 $BuildLog, "CONFIGURE");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000609 # Build the entire tree, capturing the output into $BuildLog
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000610 RunAppendingLoggedCommand("(time -p $NICE $MAKECMD clean)", $BuildLog, "BUILD CLEAN");
611 RunAppendingLoggedCommand("(time -p $NICE $MAKECMD $MAKEOPTS)", $BuildLog, "BUILD");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000612}
613
614##############################################################
615#
616# Get some statistics about the build...
617#
618##############################################################
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000619
620# Get the time taken by the configure script
621my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
622my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
623my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
624my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
625
626$ConfigTime=-1 unless $ConfigTime;
627$ConfigWallTime=-1 unless $ConfigWallTime;
628
629my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
630my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
631my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
632my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
633
634$BuildTime=-1 unless $BuildTime;
635$BuildWallTime=-1 unless $BuildWallTime;
636
637my $BuildError = 0, $BuildStatus = "OK";
638if ($NOBUILD) {
639 $BuildStatus = "Skipped by user";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000640}
641elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
642 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
643 $BuildStatus = "Error: compilation aborted";
644 $BuildError = 1;
645 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
646}
647if ($BuildError) { $NODEJAGNU=1; }
648
649my $a_file_sizes="";
650my $o_file_sizes="";
651if (!$BuildError) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000652 print "Organizing size of .o and .a files\n"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000653 if ( $VERBOSE );
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000654 ChangeDir( "$LLVMObjDir", "Build Directory" );
Bob Wilson722d58b2009-06-19 17:19:38 +0000655
656 my @dirs = ('utils', 'lib', 'tools');
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000657 if($BUILDTYPE eq "release"){
Bob Wilson722d58b2009-06-19 17:19:38 +0000658 push @dirs, 'Release';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000659 } elsif($BUILDTYPE eq "release-asserts") {
Bob Wilson722d58b2009-06-19 17:19:38 +0000660 push @dirs, 'Release-Asserts';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000661 } else {
Bob Wilson722d58b2009-06-19 17:19:38 +0000662 push @dirs, 'Debug';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000663 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000664
Bob Wilson722d58b2009-06-19 17:19:38 +0000665 find(sub {
666 $a_file_sizes .= (-s $_)." $File::Find::name $BUILDTYPE\n" if /\.a$/i;
667 $o_file_sizes .= (-s $_)." $File::Find::name $BUILDTYPE\n" if /\.o$/i;
668 }, @dirs);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000669} else {
670 $a_file_sizes="No data due to a bad build.";
671 $o_file_sizes="No data due to a bad build.";
672}
673
674##############################################################
675#
676# Running dejagnu tests
677#
678##############################################################
679my $DejangnuTestResults=""; # String containing the results of the dejagnu
680my $dejagnu_output = "$DejagnuTestsLog";
681if (!$NODEJAGNU) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000682 #Run the feature and regression tests, results are put into testrun.sum
683 #Full log in testrun.log
Daniel Dunbare2d4fc52009-06-26 02:30:49 +0000684 RunLoggedCommand("(time -p $MAKECMD $MAKEOPTS check)", $dejagnu_output, "DEJAGNU");
Misha Brukmanafa1e862009-01-02 16:28:18 +0000685
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000686 #Copy the testrun.log and testrun.sum to our webdir
687 CopyFile("test/testrun.log", $DejagnuLog);
688 CopyFile("test/testrun.sum", $DejagnuSum);
689 #can be done on server
690 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
691 $unexpfail_tests = $DejagnuTestResults;
692}
693
694#Extract time of dejagnu tests
695my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
696my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
697$DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
Misha Brukmanafa1e862009-01-02 16:28:18 +0000698$DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
699$DejagnuTestResults =
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000700 "Dejagnu skipped by user choice." unless $DejagnuTestResults;
701$DejagnuTime = "0.0" unless $DejagnuTime;
702$DejagnuWallTime = "0.0" unless $DejagnuWallTime;
703
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000704if (!$NODEJAGNU) {
705 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000706} #endif !NODEGAGNU
707
708##############################################################
709#
710# If we built the tree successfully, run the nightly programs tests...
711#
Misha Brukmanafa1e862009-01-02 16:28:18 +0000712# A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000713# "External")
714#
715##############################################################
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000716
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000717sub TestDirectory {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000718 my $SubDir = shift;
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000719 ChangeDir( "$LLVMTestDir/$SubDir",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000720 "Programs Test Subdirectory" ) || return ("", "");
Misha Brukmanafa1e862009-01-02 16:28:18 +0000721
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000722 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000723
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000724 # Run the programs tests... creating a report.nightly.csv file
725 if (!$NOTEST) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000726 if( $VERBOSE) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000727 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
Bill Wendling085ff3f2009-07-16 22:59:17 +0000728 "$TESTFLAGS TEST=nightly > $ProgramTestLog 2>&1\n";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000729 }
Daniel Dunbar83968bb2009-06-26 01:53:05 +0000730 RunLoggedCommand("$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
Bill Wendling085ff3f2009-07-16 22:59:17 +0000731 "$TESTFLAGS TEST=nightly",
732 $ProgramTestLog, "TEST DIRECTORY $SubDir");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000733 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
Misha Brukmanafa1e862009-01-02 16:28:18 +0000734 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000735
736 my $ProgramsTable;
737 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
738 $TestError = 1;
739 $ProgramsTable="Error running test $SubDir\n";
740 print "ERROR TESTING\n";
741 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
742 $TestError = 1;
743 $ProgramsTable="Makefile error running tests $SubDir!\n";
744 print "ERROR TESTING\n";
745 } else {
746 $TestError = 0;
747 #
748 # Create a list of the tests which were run...
749 #
750 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
751 "| sort > $Prefix-$SubDir-Tests.txt";
752 }
753 $ProgramsTable = ReadFile "report.nightly.csv";
754
755 ChangeDir( "../../..", "Programs Test Parent Directory" );
756 return ($ProgramsTable, $llcbeta_options);
757} #end sub TestDirectory
758
759##############################################################
760#
761# Calling sub TestDirectory
762#
763##############################################################
764if (!$BuildError) {
Misha Brukmanafa1e862009-01-02 16:28:18 +0000765 ($SingleSourceProgramsTable, $llcbeta_options) =
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000766 TestDirectory("SingleSource");
767 WriteFile "$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000768 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
769 WriteFile "$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
770 if ( ! $NOEXTERNALS ) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000771 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
772 WriteFile "$Prefix-External-Performance.txt", $ExternalProgramsTable;
Misha Brukmanafa1e862009-01-02 16:28:18 +0000773 system "cat $Prefix-SingleSource-Tests.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000774 "$Prefix-MultiSource-Tests.txt ".
775 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000776 system "cat $Prefix-SingleSource-Performance.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000777 "$Prefix-MultiSource-Performance.txt ".
778 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
779 } else {
780 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
781 if ( $VERBOSE ) {
782 print "External TEST STAGE SKIPPED\n";
783 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000784 system "cat $Prefix-SingleSource-Tests.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000785 "$Prefix-MultiSource-Tests.txt ".
786 " | sort > $Prefix-Tests.txt";
Misha Brukmanafa1e862009-01-02 16:28:18 +0000787 system "cat $Prefix-SingleSource-Performance.txt " .
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000788 "$Prefix-MultiSource-Performance.txt ".
789 " | sort > $Prefix-Performance.txt";
790 }
791
792 ##############################################################
793 #
Misha Brukmanafa1e862009-01-02 16:28:18 +0000794 #
795 # gathering tests added removed broken information here
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000796 #
797 #
798 ##############################################################
799 my $dejagnu_test_list = ReadFile "$Prefix-Tests.txt";
800 my @DEJAGNU = split "\n", $dejagnu_test_list;
801 my ($passes, $fails, $xfails) = "";
802
803 if(!$NODEJAGNU) {
804 for ($x=0; $x<@DEJAGNU; $x++) {
805 if ($DEJAGNU[$x] =~ m/^PASS:/) {
806 $passes.="$DEJAGNU[$x]\n";
807 }
808 elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
809 $fails.="$DEJAGNU[$x]\n";
810 }
811 elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
812 $xfails.="$DEJAGNU[$x]\n";
813 }
814 }
815 }
Misha Brukmanafa1e862009-01-02 16:28:18 +0000816
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000817} #end if !$BuildError
818
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000819##############################################################
820#
821# Getting end timestamp
822#
823##############################################################
824$endtime = `date "+20%y-%m-%d %H:%M:%S"`;
825
826
827##############################################################
828#
829# Place all the logs neatly into one humungous file
830#
831##############################################################
832if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
833
Misha Brukmanafa1e862009-01-02 16:28:18 +0000834$machine_data = "uname: ".`uname -a`.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000835 "hardware: ".`uname -m`.
836 "os: ".`uname -sr`.
837 "name: ".`uname -n`.
838 "date: ".`date \"+20%y-%m-%d\"`.
Misha Brukmanafa1e862009-01-02 16:28:18 +0000839 "time: ".`date +\"%H:%M:%S\"`;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000840
841my @CVS_DATA;
842my $cvs_data;
843@CVS_DATA = ReadFile "$COLog";
844$cvs_data = join("\n", @CVS_DATA);
845
846my @BUILD_DATA;
847my $build_data;
848@BUILD_DATA = ReadFile "$BuildLog";
849$build_data = join("\n", @BUILD_DATA);
850
851my (@DEJAGNU_LOG, @DEJAGNU_SUM, @DEJAGNULOG_FULL, @GCC_VERSION);
852my ($dejagnutests_log ,$dejagnutests_sum, $dejagnulog_full) = "";
853my ($gcc_version, $gcc_version_long) = "";
854
855$gcc_version_long="";
856if ($GCCPATH ne "") {
857 $gcc_version_long = `$GCCPATH/gcc --version`;
858} elsif ($ENV{"CC"}) {
859 $gcc_version_long = `$ENV{"CC"} --version`;
860} else {
861 $gcc_version_long = `gcc --version`;
862}
863@GCC_VERSION = split '\n', $gcc_version_long;
864$gcc_version = $GCC_VERSION[0];
865
866$llvmgcc_version_long="";
867if ($LLVMGCCPATH ne "") {
868 $llvmgcc_version_long = `$LLVMGCCPATH/llvm-gcc -v 2>&1`;
869} else {
870 $llvmgcc_version_long = `llvm-gcc -v 2>&1`;
871}
872@LLVMGCC_VERSION = split '\n', $llvmgcc_version_long;
873$llvmgcc_versionTarget = $LLVMGCC_VERSION[1];
874$llvmgcc_versionTarget =~ /Target: (.+)/;
875$targetTriple = $1;
876
877if(!$BuildError){
878 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
879 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
880 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
881 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
882
883 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
884 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
885}
886
887##############################################################
888#
889# Send data via a post request
890#
891##############################################################
892
893if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
894
895my %hash_of_data = (
896 'machine_data' => $machine_data,
897 'build_data' => $build_data,
898 'gcc_version' => $gcc_version,
899 'nickname' => $nickname,
900 'dejagnutime_wall' => $DejagnuWallTime,
901 'dejagnutime_cpu' => $DejagnuTime,
902 'cvscheckouttime_wall' => $CheckoutTime_Wall,
903 'cvscheckouttime_cpu' => $CheckoutTime_CPU,
904 'configtime_wall' => $ConfigWallTime,
905 'configtime_cpu'=> $ConfigTime,
906 'buildtime_wall' => $BuildWallTime,
907 'buildtime_cpu' => $BuildTime,
Daniel Dunbar6981e022009-10-19 13:19:53 +0000908 'warnings' => "",
Daniel Dunbar9ec7b9e2009-10-19 09:19:09 +0000909 'cvsusercommitlist' => "",
910 'cvsuserupdatelist' => "",
911 'cvsaddedfiles' => "",
912 'cvsmodifiedfiles' => "",
913 'cvsremovedfiles' => "",
914 'lines_of_code' => "",
915 'cvs_file_count' => 0,
916 'cvs_dir_count' => 0,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000917 'buildstatus' => $BuildStatus,
918 'singlesource_programstable' => $SingleSourceProgramsTable,
919 'multisource_programstable' => $MultiSourceProgramsTable,
920 'externalsource_programstable' => $ExternalProgramsTable,
921 'llcbeta_options' => $multisource_llcbeta_options,
Daniel Dunbar6981e022009-10-19 13:19:53 +0000922 'warnings_removed' => "",
923 'warnings_added' => "",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000924 'passing_tests' => $passes,
925 'expfail_tests' => $xfails,
926 'unexpfail_tests' => $fails,
927 'all_tests' => $dejagnu_test_list,
928 'new_tests' => "",
929 'removed_tests' => "",
930 'dejagnutests_results' => $DejagnuTestResults,
931 'dejagnutests_log' => $dejagnulog_full,
932 'starttime' => $starttime,
933 'endtime' => $endtime,
934 'o_file_sizes' => $o_file_sizes,
935 'a_file_sizes' => $a_file_sizes,
936 'target_triple' => $targetTriple
937);
938
Daniel Dunbar3b377ef2009-06-26 22:33:28 +0000939if ($SUBMIT || !($SUBMITAUX eq "")) {
Tanya Lattner084a3ee2008-03-10 07:28:08 +0000940 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
941 if( $VERBOSE) { print "============================\n$response"; }
942} else {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000943 print "============================\n";
944 foreach $x(keys %hash_of_data){
945 print "$x => $hash_of_data{$x}\n";
946 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000947}
948
949##############################################################
950#
Daniel Dunbar414cffe2009-10-19 09:18:54 +0000951# Remove the source tree...
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000952#
953##############################################################
Misha Brukmanafa1e862009-01-02 16:28:18 +0000954system ( "$NICE rm -rf $BuildDir")
Daniel Dunbard3ecefe2009-07-13 22:17:49 +0000955 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVEATEND);
Misha Brukmanafa1e862009-01-02 16:28:18 +0000956system ( "$NICE rm -rf $WebDir")
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000957 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);