blob: 235ce8bfdf36489971d532f67533b488728e81cd [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;
4use Socket;
5
6#
7# Program: NewNightlyTest.pl
8#
9# Synopsis: Perform a series of tests which are designed to be run nightly.
10# This is used to keep track of the status of the LLVM tree, tracking
Misha Brukman12c8d1b2009-01-02 16:28:18 +000011# regressions and performance changes. Submits this information
Reid Spencerfa34d7b2006-08-13 09:53:02 +000012# to llvm.org where it is placed into the nightlytestresults database.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000013#
14# Modified heavily by Patrick Jenkins, July 2006
15#
16# Syntax: NightlyTest.pl [OPTIONS] [CVSROOT BUILDDIR WEBDIR]
17# where
18# OPTIONS may include one or more of the following:
19# -nocheckout Do not create, checkout, update, or configure
20# the source tree.
21# -noremove Do not remove the BUILDDIR after it has been built.
Patrick Jenkinsa5c04d62006-07-07 17:31:38 +000022# -noremoveresults Do not remove the WEBDIR after it has been built.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000023# -nobuild Do not build llvm. If tests are enabled perform them
24# on the llvm build specified in the build directory
25# -notest Do not even attempt to run the test programs. Implies
26# -norunningtests.
27# -norunningtests Do not run the Olden benchmark suite with
28# LARGE_PROBLEM_SIZE enabled.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000029# -nodejagnu Do not run feature or regression tests
30# -parallel Run two parallel jobs with GNU Make.
31# -release Build an LLVM Release version
Jim Laskey27b8ba02006-09-28 17:49:20 +000032# -release-asserts Build an LLVM ReleaseAsserts version
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000033# -enable-llcbeta Enable testing of beta features in llc.
Reid Spencer2bae1f52006-11-24 20:34:16 +000034# -enable-lli Enable testing of lli (interpreter) features, default is off
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000035# -disable-llc Disable LLC tests in the nightly tester.
36# -disable-jit Disable JIT tests in the nightly tester.
37# -disable-cbe Disable C backend tests in the nightly tester.
Evan Chenge04c90b2008-01-12 04:27:18 +000038# -disable-lto Disable link time optimization.
Daniel Dunbar111def82009-03-10 19:33:13 +000039# -disable-bindings Disable building LLVM bindings.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000040# -verbose Turn on some debug output
41# -debug Print information useful only to maintainers of this script.
42# -nice Checkout/Configure/Build with "nice" to reduce impact
43# on busy servers.
44# -f2c Next argument specifies path to F2C utility
45# -nickname The next argument specifieds the nickname this script
46# will submit to the nightlytest results repository.
47# -gccpath Path to gcc/g++ used to build LLVM
48# -cvstag Check out a specific CVS tag to build LLVM (useful for
49# testing release branches)
Reid Spencerece1f682007-07-02 06:19:57 +000050# -usecvs Check code out from the (old) CVS Repository instead of from
51# the standard Subversion repository.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000052# -target Specify the target triplet
53# -cflags Next argument specifies that C compilation options that
54# override the default.
55# -cxxflags Next argument specifies that C++ compilation options that
56# override the default.
57# -ldflags Next argument specifies that linker options that override
58# the default.
Patrick Jenkins215b48f2006-07-07 18:50:51 +000059# -compileflags Next argument specifies extra options passed to make when
60# building LLVM.
Patrick Jenkins0e9402f2006-08-11 23:02:09 +000061# -use-gmake Use gmake instead of the default make command to build
Patrick Jenkins1cd46912006-07-27 01:17:17 +000062# llvm and run tests.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000063#
64# ---------------- Options to configure llvm-test ----------------------------
Patrick Jenkins215b48f2006-07-07 18:50:51 +000065# -extraflags Next argument specifies extra options that are passed to
66# compile the tests.
67# -noexternals Do not run the external tests (for cases where povray
68# or SPEC are not installed)
69# -with-externals Specify a directory where the external tests are located.
Patrick Jenkins0e9402f2006-08-11 23:02:09 +000070# -submit-server Specifies a server to submit the test results too. If this
Misha Brukman12c8d1b2009-01-02 16:28:18 +000071# option is not specified it defaults to
72# llvm.org. This is basically just the address of the
Patrick Jenkins0e9402f2006-08-11 23:02:09 +000073# webserver
74# -submit-script Specifies which script to call on the submit server. If
75# this option is not specified it defaults to
Misha Brukman12c8d1b2009-01-02 16:28:18 +000076# /nightlytest/NightlyTestAccept.php. This is basically
Patrick Jenkins0e9402f2006-08-11 23:02:09 +000077# everything after the www.yourserver.org.
Tanya Lattnerc1611882008-03-10 07:28:08 +000078# -nosubmit Do not report the test results back to a submit server.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000079#
80# CVSROOT is the CVS repository from which the tree will be checked out,
81# specified either in the full :method:user@host:/dir syntax, or
82# just /dir if using a local repo.
83# BUILDDIR is the directory where sources for this test run will be checked out
84# AND objects for this test run will be built. This directory MUST NOT
85# exist before the script is run; it will be created by the cvs checkout
86# process and erased (unless -noremove is specified; see above.)
87# WEBDIR is the directory into which the test results web page will be written,
88# AND in which the "index.html" is assumed to be a symlink to the most recent
89# copy of the results. This directory will be created if it does not exist.
90# LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
91# to. This is the same as you would have for a normal LLVM build.
92#
93##############################################################
94#
95# Getting environment variables
96#
97##############################################################
Reid Spencerfa34d7b2006-08-13 09:53:02 +000098my $HOME = $ENV{'HOME'};
Reid Spencer99e865a2007-04-07 04:41:16 +000099my $SVNURL = $ENV{"SVNURL"};
Reid Spencerc9a15d52007-06-26 17:08:16 +0000100$SVNURL = 'https://llvm.org/svn/llvm-project' unless $SVNURL;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000101my $CVSRootDir = $ENV{'CVSROOT'};
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000102$CVSRootDir = "/home/vadve/shared/PublicCVS" unless $CVSRootDir;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000103my $BuildDir = $ENV{'BUILDDIR'};
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000104$BuildDir = "$HOME/buildtest" unless $BuildDir;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000105my $WebDir = $ENV{'WEBDIR'};
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000106$WebDir = "$HOME/cvs/testresults-X86" unless $WebDir;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000107
108##############################################################
109#
110# Calculate the date prefix...
111#
112##############################################################
113@TIME = localtime;
114my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
115my $DateString = strftime "%B %d, %Y", localtime;
116my $TestStartTime = gmtime() . "GMT<br>" . localtime() . " (local)";
117
118##############################################################
119#
120# Parse arguments...
121#
122##############################################################
123$CONFIGUREARGS="";
Patrick Jenkins49717a42006-07-21 01:39:42 +0000124$nickname="";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000125$NOTEST=0;
John Criswelleecd7112007-06-29 19:12:50 +0000126$USESVN=1;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000127$NORUNNINGTESTS=0;
Patrick Jenkins1cd46912006-07-27 01:17:17 +0000128$MAKECMD="make";
Patrick Jenkins0e9402f2006-08-11 23:02:09 +0000129$SUBMITSERVER = "llvm.org";
Jim Laskey6d8a1b72006-09-15 17:03:36 +0000130$SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
Tanya Lattnerc1611882008-03-10 07:28:08 +0000131$SUBMIT = 1;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000132
133while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000134 shift;
135 last if /^--$/; # Stop processing arguments on --
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000136
137 # List command line options here...
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000138 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
139 if (/^-nocvsstats$/) { $NOCVSSTATS = 1; next; }
140 if (/^-noremove$/) { $NOREMOVE = 1; next; }
141 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
142 if (/^-notest$/) { $NOTEST = 1; $NORUNNINGTESTS = 1; next; }
143 if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
144 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j2 -l3.0"; next; }
145 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
146 "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
Jim Laskey27b8ba02006-09-28 17:49:20 +0000147 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
Dan Gohmanc6e22412008-10-30 01:08:03 +0000148 "DISABLE_ASSERTIONS=1 ".
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000149 "OPTIMIZE_OPTION=-O2";
Reid Spencer93c456c2006-10-19 15:24:04 +0000150 $BUILDTYPE="release-asserts"; next;}
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000151 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
Reid Spencer2bae1f52006-11-24 20:34:16 +0000152 if (/^-enable-lli$/) { $PROGTESTOPTS .= " ENABLE_LLI=1";
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000153 $CONFIGUREARGS .= " --enable-lli"; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000154 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000155 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000156 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
157 $CONFIGUREARGS .= " --disable-jit"; next; }
Daniel Dunbar111def82009-03-10 19:33:13 +0000158 if (/^-disable-bindings$/) { $CONFIGUREARGS .= " --disable-bindings"; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000159 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
Evan Chenge04c90b2008-01-12 04:27:18 +0000160 if (/^-disable-lto$/) { $PROGTESTOPTS .= " DISABLE_LTO=1"; next; }
Evan Cheng3d64f1c2008-01-14 17:58:03 +0000161 if (/^-test-opts$/) { $PROGTESTOPTS .= " $ARGV[0]"; shift; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000162 if (/^-verbose$/) { $VERBOSE = 1; next; }
163 if (/^-debug$/) { $DEBUG = 1; next; }
164 if (/^-nice$/) { $NICE = "nice "; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000165 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000166 shift; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000167 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000168 shift; next; }
169 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
170 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
Tanya Lattnerc1611882008-03-10 07:28:08 +0000171 if (/^-nosubmit$/) { $SUBMIT = 0; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000172 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
173 if (/^-gccpath/) { $CONFIGUREARGS .=
174 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000175 $GCCPATH=$ARGV[0]; shift; next; }
176 else { $GCCPATH=""; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000177 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000178 else { $CVSCOOPT="";}
Reid Spencerece1f682007-07-02 06:19:57 +0000179 if (/^-usecvs/) { $USESVN = 0; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000180 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000181 shift; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000182 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000183 shift; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000184 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000185 shift; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000186 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000187 shift; next; }
188 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
189 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000190 if (/^-extraflags/) { $CONFIGUREARGS .=
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000191 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
192 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
193 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
194 if (/^-nobuild$/) { $NOBUILD = 1; next; }
195 print "Unknown option: $_ : ignoring!\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000196}
197
198if ($ENV{'LLVMGCCDIR'}) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000199 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
Bob Wilson85cdfad2009-03-12 19:47:24 +0000200 $LLVMGCCPATH = $ENV{'LLVMGCCDIR'} . '/bin';
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000201}
Tanya Lattner849c9a22007-04-13 04:36:48 +0000202else {
203 $LLVMGCCPATH = "";
204}
205
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000206if ($CONFIGUREARGS !~ /--disable-jit/) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000207 $CONFIGUREARGS .= " --enable-jit";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000208}
209
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000210if (@ARGV != 0 and @ARGV != 3 and $VERBOSE) {
211 foreach $x (@ARGV) {
212 print "$x\n";
213 }
214 print "Must specify 0 or 3 options!";
Patrick Jenkinsf58473f2006-07-27 01:03:46 +0000215}
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000216
217if (@ARGV == 3) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000218 $CVSRootDir = $ARGV[0];
219 $BuildDir = $ARGV[1];
220 $WebDir = $ARGV[2];
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000221}
222
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000223if ($CVSRootDir eq "" or
224 $BuildDir eq "" or
225 $WebDir eq "") {
226 die("please specify a cvs root directory, a build directory, and a ".
Patrick Jenkinsf58473f2006-07-27 01:03:46 +0000227 "web directory");
228 }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000229
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000230if ($nickname eq "") {
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000231 die ("Please invoke NewNightlyTest.pl with command line option " .
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000232 "\"-nickname <nickname>\"");
Patrick Jenkins514e2582006-07-20 22:28:43 +0000233}
Patrick Jenkins1cd46912006-07-27 01:17:17 +0000234
Jim Laskey27b8ba02006-09-28 17:49:20 +0000235if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000236 $BUILDTYPE = "debug";
Patrick Jenkins26ba6092006-07-23 22:57:28 +0000237}
Patrick Jenkins514e2582006-07-20 22:28:43 +0000238
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000239##############################################################
240#
241#define the file names we'll use
242#
243##############################################################
244my $Prefix = "$WebDir/$DATE";
245my $BuildLog = "$Prefix-Build-Log.txt";
Reid Spencer99e865a2007-04-07 04:41:16 +0000246my $COLog = "$Prefix-CVS-Log.txt";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000247my $OldenTestsLog = "$Prefix-Olden-tests.txt";
248my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
249my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
Patrick Jenkins26ba6092006-07-23 22:57:28 +0000250my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000251my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
252my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
253my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
254if (! -d $WebDir) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000255 mkdir $WebDir, 0777;
Patrick Jenkins03137752006-08-21 20:45:57 +0000256 if($VERBOSE){
257 warn "$WebDir did not exist; creating it.\n";
258 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000259}
260
261if ($VERBOSE) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000262 print "INITIALIZED\n";
Reid Spencer99e865a2007-04-07 04:41:16 +0000263 if ($USESVN) {
264 print "SVN URL = $SVNURL\n";
265 } else {
266 print "CVS Root = $CVSRootDir\n";
267 }
268 print "COLog = $COLog\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000269 print "BuildDir = $BuildDir\n";
270 print "WebDir = $WebDir\n";
271 print "Prefix = $Prefix\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000272 print "BuildLog = $BuildLog\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000273}
274
275##############################################################
276#
277# Helper functions
278#
279##############################################################
280sub GetDir {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000281 my $Suffix = shift;
282 opendir DH, $WebDir;
283 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
284 closedir DH;
285 return @Result;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000286}
287
288#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
289#
290# DiffFiles - Diff the current version of the file against the last version of
291# the file, reporting things added and removed. This is used to report, for
292# example, added and removed warnings. This returns a pair (added, removed)
293#
294#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
295sub DiffFiles {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000296 my $Suffix = shift;
297 my @Others = GetDir $Suffix;
298 if (@Others == 0) { # No other files? We added all entries...
299 return (`cat $WebDir/$DATE$Suffix`, "");
300 }
301# Diff the files now...
302 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
303 my $Added = join "\n", grep /^</, @Diffs;
304 my $Removed = join "\n", grep /^>/, @Diffs;
305 $Added =~ s/^< //gm;
306 $Removed =~ s/^> //gm;
307 return ($Added, $Removed);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000308}
309
310#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
311#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
312sub GetRegex { # (Regex with ()'s, value)
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000313 $_[1] =~ /$_[0]/m;
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000314 return $1
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000315 if (defined($1));
316 return "0";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000317}
318
319#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
320#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
321sub GetRegexNum {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000322 my ($Regex, $Num, $Regex2, $File) = @_;
323 my @Items = split "\n", `grep '$Regex' $File`;
324 return GetRegex $Regex2, $Items[$Num];
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000325}
326
327#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
328#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
329sub ChangeDir { # directory, logical name
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000330 my ($dir,$name) = @_;
331 chomp($dir);
332 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
333 $result = chdir($dir);
334 if (!$result) {
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000335 print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000336 return false;
337 }
338 return true;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000339}
340
341#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
342#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
343sub ReadFile {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000344 if (open (FILE, $_[0])) {
345 undef $/;
346 my $Ret = <FILE>;
347 close FILE;
348 $/ = '\n';
349 return $Ret;
350 } else {
351 print "Could not open file '$_[0]' for reading!\n";
352 return "";
353 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000354}
355
356#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
357#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
358sub WriteFile { # (filename, contents)
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000359 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
360 print FILE $_[1];
361 close FILE;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000362}
363
364#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
365#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
366sub CopyFile { #filename, newfile
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000367 my ($file, $newfile) = @_;
368 chomp($file);
369 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
370 copy($file, $newfile);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000371}
372
373#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
374#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
375sub AddRecord {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000376 my ($Val, $Filename,$WebDir) = @_;
377 my @Records;
378 if (open FILE, "$WebDir/$Filename") {
379 @Records = grep !/$DATE/, split "\n", <FILE>;
380 close FILE;
381 }
382 push @Records, "$DATE: $Val";
383 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000384}
385
386#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
387#
388# FormatTime - Convert a time from 1m23.45 into 83.45
389#
390#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
391sub FormatTime {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000392 my $Time = shift;
393 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
394 $Time = sprintf("%7.4f", $1*60.0+$2);
395 }
396 return $Time;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000397}
398
399#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000400#
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000401# This function is meant to read in the dejagnu sum file and
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000402# return a string with only the results (i.e. PASS/FAIL/XPASS/
403# XFAIL).
404#
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000405#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
406sub GetDejagnuTestResults { # (filename, log)
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000407 my ($filename, $DejagnuLog) = @_;
408 my @lines;
409 $/ = "\n"; #Make sure we're going line at a time.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000410
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000411 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000412
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000413 if (open SRCHFILE, $filename) {
414 # Process test results
415 while ( <SRCHFILE> ) {
416 if ( length($_) > 1 ) {
417 chomp($_);
Jim Laskey01d7bcf2006-09-20 09:20:22 +0000418 if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\/test\/(.*)$/ ) {
419 push(@lines, "$1: test/$2");
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000420 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000421 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000422 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000423 }
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000424 close SRCHFILE;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000425
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000426 my $content = join("\n", @lines);
427 return $content;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000428}
429
430
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000431
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000432#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
433#
434# This function acts as a mini web browswer submitting data
435# to our central server via the post method
436#
437#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
438sub SendData{
439 $host = $_[0];
440 $file = $_[1];
441 $variables=$_[2];
442
443 $port=80;
444 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000445 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000446 die "Bad socket\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000447 connect SOCK, $socketaddr or die "Bad connection\n";
448 select((select(SOCK), $| = 1)[0]);
449
450 #creating content here
451 my $content;
452 foreach $key (keys (%$variables)){
453 $value = $variables->{$key};
454 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
455 $content .= "$key=$value&";
456 }
457
458 $length = length($content);
459
460 my $send= "POST $file HTTP/1.0\n";
Lauro Ramos Venancio46040232007-05-03 14:05:07 +0000461 $send.= "Host: $host\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000462 $send.= "Content-Type: application/x-www-form-urlencoded\n";
463 $send.= "Content-length: $length\n\n";
464 $send.= "$content";
465
Patrick Jenkinse8501eb2006-08-07 01:54:37 +0000466 print SOCK $send;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000467 my $result;
468 while(<SOCK>){
469 $result .= $_;
470 }
471 close(SOCK);
472
473 my $sentdata="";
Patrick Jenkins4c4e3562006-07-07 21:40:34 +0000474 foreach $x (keys (%$variables)){
Patrick Jenkins7267bd62006-07-10 18:35:41 +0000475 $value = $variables->{$x};
476 $sentdata.= "$x => $value\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000477 }
478 WriteFile "$Prefix-sentdata.txt", $sentdata;
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000479
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000480
481 return $result;
482}
483
Patrick Jenkins215b48f2006-07-07 18:50:51 +0000484##############################################################
485#
486# Getting Start timestamp
487#
488##############################################################
Patrick Jenkinsb67e1182006-07-21 21:43:09 +0000489$starttime = `date "+20%y-%m-%d %H:%M:%S"`;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000490
491##############################################################
492#
493# Create the CVS repository directory
494#
495##############################################################
496if (!$NOCHECKOUT) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000497 if (-d $BuildDir) {
498 if (!$NOREMOVE) {
499 if ( $VERBOSE ) {
500 print "Build directory exists! Removing it\n";
501 }
502 system "rm -rf $BuildDir";
Reid Spencer99e865a2007-04-07 04:41:16 +0000503 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000504 } else {
Jim Laskey6d8a1b72006-09-15 17:03:36 +0000505 if ( $VERBOSE ) {
506 print "Build directory exists!\n";
507 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000508 }
Jim Laskey6d8a1b72006-09-15 17:03:36 +0000509 } else {
Reid Spencer99e865a2007-04-07 04:41:16 +0000510 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000511 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000512}
Reid Spencer99e865a2007-04-07 04:41:16 +0000513ChangeDir( $BuildDir, "checkout directory" );
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000514
515
516##############################################################
517#
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000518# Check out the llvm tree, using either SVN or CVS
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000519#
520##############################################################
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000521if (!$NOCHECKOUT) {
Reid Spencerceb9d782007-07-02 06:16:32 +0000522 if ( $VERBOSE ) { print "CHECKOUT STAGE:\n"; }
Reid Spencer99e865a2007-04-07 04:41:16 +0000523 if ($USESVN) {
524 my $SVNCMD = "$NICE svn co $SVNURL";
525 if ($VERBOSE) {
Reid Spencer1c01cf92007-06-29 03:12:42 +0000526 print "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
527 "$SVNCMD/test-suite/trunk llvm-test ) > $COLog 2>&1\n";
Reid Spencer99e865a2007-04-07 04:41:16 +0000528 }
Reid Spencerceb9d782007-07-02 06:16:32 +0000529 system "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
530 "$SVNCMD/test-suite/trunk llvm-test ) > $COLog 2>&1\n";
Reid Spencer99e865a2007-04-07 04:41:16 +0000531 } else {
532 my $CVSOPT = "";
533 $CVSOPT = "-z3" # Use compression if going over ssh.
534 if $CVSRootDir =~ /^:ext:/;
535 my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co -P $CVSCOOPT";
Reid Spencerceb9d782007-07-02 06:16:32 +0000536 if ($VERBOSE) {
537 print "( time -p $CVSCMD llvm; cd llvm/projects ; " .
538 "$CVSCMD llvm-test ) > $COLog 2>&1\n";
539 }
Reid Spencer99e865a2007-04-07 04:41:16 +0000540 system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
Reid Spencerb5fda752007-04-07 05:20:07 +0000541 "$CVSCMD llvm-test ) > $COLog 2>&1\n";
Reid Spencer99e865a2007-04-07 04:41:16 +0000542 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000543}
Reid Spencer99e865a2007-04-07 04:41:16 +0000544ChangeDir( $BuildDir , "Checkout directory") ;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000545ChangeDir( "llvm" , "llvm source directory") ;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000546
547##############################################################
548#
549# Get some static statistics about the current state of CVS
550#
551# This can probably be put on the server side
552#
553##############################################################
Reid Spencer99e865a2007-04-07 04:41:16 +0000554my $CheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $COLog`;
555my $CheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $COLog`;
556my $CheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $COLog`;
557my $CheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000558
Reid Spencer99e865a2007-04-07 04:41:16 +0000559my $NumFilesInCVS = 0;
560my $NumDirsInCVS = 0;
561if ($USESVN) {
562 $NumFilesInCVS = `egrep '^A' $COLog | wc -l` + 0;
Nick Lewyckyef7d2bb2008-06-05 12:54:44 +0000563 $NumDirsInCVS = `sed -e 's#/[^/]*\$##' $COLog | sort | uniq | wc -l` + 0;
Reid Spencer99e865a2007-04-07 04:41:16 +0000564} else {
565 $NumFilesInCVS = `egrep '^U' $COLog | wc -l` + 0;
566 $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $COLog | wc -l` + 0;
567}
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000568
569##############################################################
570#
571# Extract some information from the CVS history... use a hash so no duplicate
572# stuff is stored. This gets the history from the previous days worth
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000573# of cvs activity and parses it.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000574#
575##############################################################
576
Reid Spencer99e865a2007-04-07 04:41:16 +0000577# This just computes a reasonably accurate #of seconds since 2000. It doesn't
578# have to be perfect as its only used for comparing date ranges within a couple
579# of days.
580sub ConvertToSeconds {
581 my ($sec, $min, $hour, $day, $mon, $yr) = @_;
582 my $Result = ($yr - 2000) * 12;
583 $Result += $mon;
584 $Result *= 31;
585 $Result += $day;
586 $Result *= 24;
587 $Result += $hour;
588 $Result *= 60;
589 $Result += $min;
590 $Result *= 60;
591 $Result += $sec;
592 return $Result;
593}
594
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000595my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
596
Reid Spencer99e865a2007-04-07 04:41:16 +0000597if (!$NOCVSSTATS) {
598 if ($VERBOSE) { print "CHANGE HISTORY ANALYSIS STAGE\n"; }
Reid Spencer776964a2007-04-04 06:59:36 +0000599
Reid Spencer99e865a2007-04-07 04:41:16 +0000600 if ($USESVN) {
601 @SVNHistory = split /<logentry/, `svn log --xml --verbose -r{$DATE}:HEAD`;
602 # Skip very first entry because it is the XML header cruft
603 shift @SVNHistory;
604 my $Now = time();
605 foreach $Record (@SVNHistory) {
606 my @Lines = split "\n", $Record;
607 my ($Author, $Date, $Revision);
608 # Get the date and see if its one we want to process.
609 my ($Year, $Month, $Day, $Hour, $Min, $Sec);
610 if ($Lines[3] =~ /<date>(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/){
611 $Year = $1; $Month = $2; $Day = $3; $Hour = $4; $Min = $5; $Sec = $6;
612 }
613 my $Then = ConvertToSeconds($Sec, $Min, $Hour, $Day, $Month, $Year);
614 # Get the current date and compute when "yesterday" is.
615 my ($NSec, $NMin, $NHour, $NDay, $NMon, $NYear) = gmtime();
616 my $Now = ConvertToSeconds( $NSec, $NMin, $NHour, $NDay, $NMon, $NYear);
617 if (($Now - 24*60*60) > $Then) {
618 next;
619 }
620 if ($Lines[1] =~ / revision="([0-9]*)">/) {
621 $Revision = $1;
622 }
623 if ($Lines[2] =~ /<author>([^<]*)<\/author>/) {
624 $Author = $1;
625 }
626 $UsersCommitted{$Author} = 1;
627 $Date = $Year . "-" . $Month . "-" . $Day;
628 $Time = $Hour . ":" . $Min . ":" . $Sec;
629 print "Rev: $Revision, Author: $Author, Date: $Date, Time: $Time\n";
630 for ($i = 6; $i < $#Lines; $i += 2 ) {
631 if ($Lines[$i] =~ /^ action="(.)">([^<]*)</) {
632 if ($1 == "A") {
633 $AddedFiles{$2} = 1;
634 } elsif ($1 == 'D') {
635 $RemovedFiles{$2} = 1;
636 } elsif ($1 == 'M' || $1 == 'R' || $1 == 'C') {
637 $ModifiedFiles{$2} = 1;
638 } else {
639 print "UNMATCHABLE: $Lines[$i]\n";
640 }
641 }
642 }
643 }
644 } else {
645 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000646#print join "\n", @CVSHistory; print "\n";
647
Reid Spencer99e865a2007-04-07 04:41:16 +0000648 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000649
650# Loop over every record from the CVS history, filling in the hashes.
Reid Spencer99e865a2007-04-07 04:41:16 +0000651 foreach $File (@CVSHistory) {
652 my ($Type, $Date, $UID, $Rev, $Filename);
653 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
654 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
655 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
656 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
657 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
658 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
659 } else {
660 print "UNMATCHABLE: $File\n";
661 next;
662 }
663 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000664
Reid Spencer99e865a2007-04-07 04:41:16 +0000665 if ($Filename =~ /^llvm/) {
666 if ($Type eq 'M') { # Modified
667 $ModifiedFiles{$Filename} = 1;
668 $UsersCommitted{$UID} = 1;
669 } elsif ($Type eq 'A') { # Added
670 $AddedFiles{$Filename} = 1;
671 $UsersCommitted{$UID} = 1;
672 } elsif ($Type eq 'R') { # Removed
673 $RemovedFiles{$Filename} = 1;
674 $UsersCommitted{$UID} = 1;
675 } else {
676 $UsersUpdated{$UID} = 1;
677 }
678 }
679 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000680
Reid Spencer99e865a2007-04-07 04:41:16 +0000681 my $TestError = 1;
682 } #$USESVN
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000683}#!NOCVSSTATS
684
685my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
686my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
687my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
688my $UserCommitList = join "\n", sort keys %UsersCommitted;
689my $UserUpdateList = join "\n", sort keys %UsersUpdated;
690
691##############################################################
692#
693# Build the entire tree, saving build messages to the build log
694#
695##############################################################
696if (!$NOCHECKOUT && !$NOBUILD) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000697 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
698 if ( $VERBOSE ) {
699 print "CONFIGURE STAGE:\n";
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000700 print "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000701 "> $BuildLog 2>&1\n";
702 }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000703 system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) " .
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000704 "> $BuildLog 2>&1";
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000705 if ( $VERBOSE ) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000706 print "BUILD STAGE:\n";
707 print "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1\n";
708 }
709 # Build the entire tree, capturing the output into $BuildLog
710 system "(time -p $NICE $MAKECMD $MAKEOPTS) >> $BuildLog 2>&1";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000711}
712
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000713##############################################################
714#
715# Get some statistics about the build...
716#
717##############################################################
718#this can de done on server
719#my @Linked = split '\n', `grep Linking $BuildLog`;
720#my $NumExecutables = scalar(grep(/executable/, @Linked));
721#my $NumLibraries = scalar(grep(!/executable/, @Linked));
722#my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
723
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000724# Get the number of lines of source code. Must be here after the build is done
725# because countloc.sh uses the llvm-config script which must be built.
Patrick Jenkinsb993b0a2006-08-16 22:18:41 +0000726my $LOC = `utils/countloc.sh -topdir $BuildDir/llvm`;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000727
728# Get the time taken by the configure script
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000729my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
730my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
731my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
732my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
733
734$ConfigTime=-1 unless $ConfigTime;
735$ConfigWallTime=-1 unless $ConfigWallTime;
736
737my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
738my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
739my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
740my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
741
742$BuildTime=-1 unless $BuildTime;
743$BuildWallTime=-1 unless $BuildWallTime;
744
745my $BuildError = 0, $BuildStatus = "OK";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000746if ($NOBUILD) {
747 $BuildStatus = "Skipped by user";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000748}
Patrick Jenkinsf58473f2006-07-27 01:03:46 +0000749elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000750 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
751 $BuildStatus = "Error: compilation aborted";
752 $BuildError = 1;
753 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000754}
755if ($BuildError) { $NODEJAGNU=1; }
756
Patrick Jenkins169357e2006-07-23 21:38:07 +0000757my $a_file_sizes="";
758my $o_file_sizes="";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000759if (!$BuildError) {
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000760 print "Organizing size of .o and .a files\n"
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000761 if ( $VERBOSE );
762 ChangeDir( "$BuildDir/llvm", "Build Directory" );
763 $afiles.= `find utils/ -iname '*.a' -ls`;
764 $afiles.= `find lib/ -iname '*.a' -ls`;
765 $afiles.= `find tools/ -iname '*.a' -ls`;
766 if($BUILDTYPE eq "release"){
Jim Laskey7a8efce2006-09-29 17:31:45 +0000767 $afiles.= `find Release/ -iname '*.a' -ls`;
Jim Laskey27b8ba02006-09-28 17:49:20 +0000768 } elsif($BUILDTYPE eq "release-asserts") {
769 $afiles.= `find Release-Asserts/ -iname '*.a' -ls`;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000770 } else {
771 $afiles.= `find Debug/ -iname '*.a' -ls`;
772 }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000773
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000774 $ofiles.= `find utils/ -iname '*.o' -ls`;
775 $ofiles.= `find lib/ -iname '*.o' -ls`;
776 $ofiles.= `find tools/ -iname '*.o' -ls`;
777 if($BUILDTYPE eq "release"){
Jim Laskey7a8efce2006-09-29 17:31:45 +0000778 $ofiles.= `find Release/ -iname '*.o' -ls`;
Jim Laskey27b8ba02006-09-28 17:49:20 +0000779 } elsif($BUILDTYPE eq "release-asserts") {
780 $ofiles.= `find Release-Asserts/ -iname '*.o' -ls`;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000781 } else {
782 $ofiles.= `find Debug/ -iname '*.o' -ls`;
783 }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000784
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000785 @AFILES = split "\n", $afiles;
786 $a_file_sizes="";
787 foreach $x (@AFILES){
788 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
789 $a_file_sizes.="$1 $2 $BUILDTYPE\n";
790 }
791 @OFILES = split "\n", $ofiles;
792 $o_file_sizes="";
793 foreach $x (@OFILES){
794 $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
795 $o_file_sizes.="$1 $2 $BUILDTYPE\n";
796 }
797} else {
798 $a_file_sizes="No data due to a bad build.";
799 $o_file_sizes="No data due to a bad build.";
Patrick Jenkins169357e2006-07-23 21:38:07 +0000800}
Patrick Jenkins169357e2006-07-23 21:38:07 +0000801
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000802##############################################################
803#
804# Running dejagnu tests
805#
806##############################################################
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000807my $DejangnuTestResults=""; # String containing the results of the dejagnu
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000808my $dejagnu_output = "$DejagnuTestsLog";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000809if (!$NODEJAGNU) {
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000810 if($VERBOSE) {
811 print "DEJAGNU FEATURE/REGRESSION TEST STAGE:\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000812 print "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1\n";
813 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000814
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000815 #Run the feature and regression tests, results are put into testrun.sum
816 #Full log in testrun.log
817 system "(time -p $MAKECMD $MAKEOPTS check) > $dejagnu_output 2>&1";
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000818
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000819 #Copy the testrun.log and testrun.sum to our webdir
820 CopyFile("test/testrun.log", $DejagnuLog);
821 CopyFile("test/testrun.sum", $DejagnuSum);
822 #can be done on server
823 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
824 $unexpfail_tests = $DejagnuTestResults;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000825}
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000826
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000827#Extract time of dejagnu tests
828my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
829my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
830$DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000831$DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
832$DejagnuTestResults =
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000833 "Dejagnu skipped by user choice." unless $DejagnuTestResults;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000834$DejagnuTime = "0.0" unless $DejagnuTime;
835$DejagnuWallTime = "0.0" unless $DejagnuWallTime;
836
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000837##############################################################
838#
839# Get warnings from the build
840#
841##############################################################
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000842if (!$NODEJAGNU) {
843 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
844 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
845 my @Warnings;
846 my $CurDir = "";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000847
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000848 foreach $Warning (@Warn) {
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000849 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000850 $CurDir = $1; # Keep track of directory warning is in...
851 # Remove buildir prefix if included
852 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { $CurDir = $1; }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000853 } else {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000854 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000855 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000856 }
857 my $WarningsFile = join "\n", @Warnings;
858 $WarningsFile =~ s/:[0-9]+:/::/g;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000859
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000860 # Emit the warnings file, so we can diff...
861 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
862 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000863
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000864 # Output something to stdout if something has changed
865 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
866 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000867
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000868 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
869 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000870
871} #endif !NODEGAGNU
872
873##############################################################
874#
875# If we built the tree successfully, run the nightly programs tests...
876#
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000877# A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000878# "External")
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000879#
880##############################################################
881sub TestDirectory {
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000882 my $SubDir = shift;
883 ChangeDir( "$BuildDir/llvm/projects/llvm-test/$SubDir",
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000884 "Programs Test Subdirectory" ) || return ("", "");
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000885
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000886 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000887
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000888 # Run the programs tests... creating a report.nightly.csv file
889 if (!$NOTEST) {
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000890 if( $VERBOSE) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000891 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000892 "TEST=nightly > $ProgramTestLog 2>&1\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000893 }
894 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000895 "TEST=nightly > $ProgramTestLog 2>&1";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000896 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000897 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000898
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000899 my $ProgramsTable;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000900 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000901 $TestError = 1;
902 $ProgramsTable="Error running test $SubDir\n";
903 print "ERROR TESTING\n";
904 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
905 $TestError = 1;
906 $ProgramsTable="Makefile error running tests $SubDir!\n";
907 print "ERROR TESTING\n";
908 } else {
909 $TestError = 0;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000910 #
911 # Create a list of the tests which were run...
912 #
913 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000914 "| sort > $Prefix-$SubDir-Tests.txt";
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000915 }
916 $ProgramsTable = ReadFile "report.nightly.csv";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000917
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000918 ChangeDir( "../../..", "Programs Test Parent Directory" );
919 return ($ProgramsTable, $llcbeta_options);
Patrick Jenkins9e384ab2006-08-14 16:07:14 +0000920} #end sub TestDirectory
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000921
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000922##############################################################
923#
924# Calling sub TestDirectory
925#
926##############################################################
Patrick Jenkinsc281b0d2006-07-27 19:00:01 +0000927if (!$BuildError) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000928 if ( $VERBOSE ) {
Patrick Jenkinse631c4a2006-08-04 17:55:01 +0000929 print "SingleSource TEST STAGE\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000930 }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000931 ($SingleSourceProgramsTable, $llcbeta_options) =
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000932 TestDirectory("SingleSource");
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000933 WriteFile "$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
Patrick Jenkins4257ccb2006-08-08 02:03:53 +0000934 if ( $VERBOSE ) {
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000935 print "MultiSource TEST STAGE\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000936 }
937 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000938 WriteFile "$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000939 if ( ! $NOEXTERNALS ) {
940 if ( $VERBOSE ) {
941 print "External TEST STAGE\n";
942 }
943 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000944 WriteFile "$Prefix-External-Performance.txt", $ExternalProgramsTable;
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000945 system "cat $Prefix-SingleSource-Tests.txt " .
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000946 "$Prefix-MultiSource-Tests.txt ".
947 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000948 system "cat $Prefix-SingleSource-Performance.txt " .
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000949 "$Prefix-MultiSource-Performance.txt ".
950 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000951 } else {
952 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
953 if ( $VERBOSE ) {
954 print "External TEST STAGE SKIPPED\n";
955 }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000956 system "cat $Prefix-SingleSource-Tests.txt " .
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000957 "$Prefix-MultiSource-Tests.txt ".
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000958 " | sort > $Prefix-Tests.txt";
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000959 system "cat $Prefix-SingleSource-Performance.txt " .
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000960 "$Prefix-MultiSource-Performance.txt ".
961 " | sort > $Prefix-Performance.txt";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000962 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000963
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000964 ##############################################################
965 #
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000966 #
967 # gathering tests added removed broken information here
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000968 #
969 #
970 ##############################################################
971 my $dejagnu_test_list = ReadFile "$Prefix-Tests.txt";
972 my @DEJAGNU = split "\n", $dejagnu_test_list;
973 my ($passes, $fails, $xfails) = "";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000974
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000975 if(!$NODEJAGNU) {
976 for ($x=0; $x<@DEJAGNU; $x++) {
977 if ($DEJAGNU[$x] =~ m/^PASS:/) {
978 $passes.="$DEJAGNU[$x]\n";
979 }
980 elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
981 $fails.="$DEJAGNU[$x]\n";
982 }
983 elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
984 $xfails.="$DEJAGNU[$x]\n";
985 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000986 }
987 }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000988
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000989} #end if !$BuildError
990
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000991
992##############################################################
993#
994# If we built the tree successfully, runs of the Olden suite with
995# LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
996#
997##############################################################
998if (!$BuildError) {
Patrick Jenkinsd7210f92006-08-02 18:37:40 +0000999 if ( $VERBOSE ) { print "OLDEN TEST SUITE STAGE\n"; }
1000 my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
1001 $MachCodeSize) = ("","","","","","","");
1002 if (!$NORUNNINGTESTS) {
1003 ChangeDir( "$BuildDir/llvm/projects/llvm-test/MultiSource/Benchmarks/Olden",
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001004 "Olden Test Directory");
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001005
Patrick Jenkinsd7210f92006-08-02 18:37:40 +00001006 # Clean out previous results...
1007 system "$NICE $MAKECMD $MAKEOPTS clean > /dev/null 2>&1";
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001008
Patrick Jenkinsd7210f92006-08-02 18:37:40 +00001009 # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE and
1010 # GET_STABLE_NUMBERS enabled!
Misha Brukman12c8d1b2009-01-02 16:28:18 +00001011 if( $VERBOSE ) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001012 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
1013 "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
Misha Brukman12c8d1b2009-01-02 16:28:18 +00001014 "> /dev/null 2>&1\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001015 }
1016 system "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out " .
1017 "TEST=nightly LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 " .
1018 "> /dev/null 2>&1";
1019 system "cp report.nightly.csv $OldenTestsLog";
Misha Brukman12c8d1b2009-01-02 16:28:18 +00001020 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001021}
1022
Patrick Jenkins215b48f2006-07-07 18:50:51 +00001023##############################################################
1024#
1025# Getting end timestamp
1026#
1027##############################################################
Patrick Jenkinsb67e1182006-07-21 21:43:09 +00001028$endtime = `date "+20%y-%m-%d %H:%M:%S"`;
Patrick Jenkins215b48f2006-07-07 18:50:51 +00001029
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001030
1031##############################################################
1032#
1033# Place all the logs neatly into one humungous file
1034#
1035##############################################################
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001036if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
1037
Misha Brukman12c8d1b2009-01-02 16:28:18 +00001038$machine_data = "uname: ".`uname -a`.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001039 "hardware: ".`uname -m`.
1040 "os: ".`uname -sr`.
1041 "name: ".`uname -n`.
1042 "date: ".`date \"+20%y-%m-%d\"`.
Misha Brukman12c8d1b2009-01-02 16:28:18 +00001043 "time: ".`date +\"%H:%M:%S\"`;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001044
1045my @CVS_DATA;
1046my $cvs_data;
Reid Spencer99e865a2007-04-07 04:41:16 +00001047@CVS_DATA = ReadFile "$COLog";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001048$cvs_data = join("\n", @CVS_DATA);
1049
1050my @BUILD_DATA;
1051my $build_data;
1052@BUILD_DATA = ReadFile "$BuildLog";
1053$build_data = join("\n", @BUILD_DATA);
1054
Patrick Jenkins03137752006-08-21 20:45:57 +00001055my (@DEJAGNU_LOG, @DEJAGNU_SUM, @DEJAGNULOG_FULL, @GCC_VERSION);
1056my ($dejagnutests_log ,$dejagnutests_sum, $dejagnulog_full) = "";
1057my ($gcc_version, $gcc_version_long) = "";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001058
Patrick Jenkinsad6f7582006-08-22 18:11:19 +00001059$gcc_version_long="";
1060if ($GCCPATH ne "") {
1061 $gcc_version_long = `$GCCPATH/gcc --version`;
Jeff Cohen75454222007-04-10 19:13:43 +00001062} elsif ($ENV{"CC"}) {
1063 $gcc_version_long = `$ENV{"CC"} --version`;
Patrick Jenkinsad6f7582006-08-22 18:11:19 +00001064} else {
1065 $gcc_version_long = `gcc --version`;
1066}
1067@GCC_VERSION = split '\n', $gcc_version_long;
1068$gcc_version = $GCC_VERSION[0];
1069
Tanya Lattner849c9a22007-04-13 04:36:48 +00001070$llvmgcc_version_long="";
1071if ($LLVMGCCPATH ne "") {
1072 $llvmgcc_version_long = `$LLVMGCCPATH/llvm-gcc -v 2>&1`;
1073} else {
1074 $llvmgcc_version_long = `llvm-gcc -v 2>&1`;
1075}
1076@LLVMGCC_VERSION = split '\n', $llvmgcc_version_long;
1077$llvmgcc_versionTarget = $LLVMGCC_VERSION[1];
1078$llvmgcc_versionTarget =~ /Target: (.+)/;
1079$targetTriple = $1;
1080
Patrick Jenkins03137752006-08-21 20:45:57 +00001081if(!$BuildError){
1082 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
1083 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
1084 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
1085 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001086
Patrick Jenkins03137752006-08-21 20:45:57 +00001087 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
1088 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
Patrick Jenkins79fbf7f2006-07-14 20:44:09 +00001089}
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001090
1091##############################################################
1092#
1093# Send data via a post request
1094#
1095##############################################################
1096
1097if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
1098
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001099my %hash_of_data = (
1100 'machine_data' => $machine_data,
1101 'build_data' => $build_data,
1102 'gcc_version' => $gcc_version,
1103 'nickname' => $nickname,
1104 'dejagnutime_wall' => $DejagnuWallTime,
1105 'dejagnutime_cpu' => $DejagnuTime,
Reid Spencer99e865a2007-04-07 04:41:16 +00001106 'cvscheckouttime_wall' => $CheckoutTime_Wall,
1107 'cvscheckouttime_cpu' => $CheckoutTime_CPU,
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001108 'configtime_wall' => $ConfigWallTime,
1109 'configtime_cpu'=> $ConfigTime,
1110 'buildtime_wall' => $BuildWallTime,
1111 'buildtime_cpu' => $BuildTime,
1112 'warnings' => $WarningsFile,
1113 'cvsusercommitlist' => $UserCommitList,
1114 'cvsuserupdatelist' => $UserUpdateList,
1115 'cvsaddedfiles' => $CVSAddedFiles,
1116 'cvsmodifiedfiles' => $CVSModifiedFiles,
1117 'cvsremovedfiles' => $CVSRemovedFiles,
1118 'lines_of_code' => $LOC,
1119 'cvs_file_count' => $NumFilesInCVS,
1120 'cvs_dir_count' => $NumDirsInCVS,
1121 'buildstatus' => $BuildStatus,
1122 'singlesource_programstable' => $SingleSourceProgramsTable,
1123 'multisource_programstable' => $MultiSourceProgramsTable,
1124 'externalsource_programstable' => $ExternalProgramsTable,
1125 'llcbeta_options' => $multisource_llcbeta_options,
1126 'warnings_removed' => $WarningsRemoved,
1127 'warnings_added' => $WarningsAdded,
1128 'passing_tests' => $passes,
1129 'expfail_tests' => $xfails,
1130 'unexpfail_tests' => $fails,
1131 'all_tests' => $dejagnu_test_list,
1132 'new_tests' => "",
1133 'removed_tests' => "",
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +00001134 'dejagnutests_results' => $DejagnuTestResults,
1135 'dejagnutests_log' => $dejagnulog_full,
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001136 'starttime' => $starttime,
1137 'endtime' => $endtime,
1138 'o_file_sizes' => $o_file_sizes,
Tanya Lattner849c9a22007-04-13 04:36:48 +00001139 'a_file_sizes' => $a_file_sizes,
1140 'target_triple' => $targetTriple
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001141);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001142
Tanya Lattnerc1611882008-03-10 07:28:08 +00001143if ($SUBMIT) {
1144 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
1145 if( $VERBOSE) { print "============================\n$response"; }
1146} else {
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001147 print "============================\n";
1148 foreach $x(keys %hash_of_data){
1149 print "$x => $hash_of_data{$x}\n";
1150 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001151}
1152
1153##############################################################
1154#
1155# Remove the cvs tree...
1156#
1157##############################################################
Misha Brukman12c8d1b2009-01-02 16:28:18 +00001158system ( "$NICE rm -rf $BuildDir")
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001159 if (!$NOCHECKOUT and !$NOREMOVE);
Misha Brukman12c8d1b2009-01-02 16:28:18 +00001160system ( "$NICE rm -rf $WebDir")
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001161 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);