blob: 23982f176902dcfd1f5be5bbfa5c1494a05df70a [file] [log] [blame]
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001#!/usr/bin/perl
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00002use POSIX qw(strftime);
3use File::Copy;
Bob Wilson6dc11b42009-06-19 17:19:38 +00004use File::Find;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00005use Socket;
6
7#
8# Program: NewNightlyTest.pl
9#
10# Synopsis: Perform a series of tests which are designed to be run nightly.
11# This is used to keep track of the status of the LLVM tree, tracking
Misha Brukman12c8d1b2009-01-02 16:28:18 +000012# regressions and performance changes. Submits this information
Reid Spencerfa34d7b2006-08-13 09:53:02 +000013# to llvm.org where it is placed into the nightlytestresults database.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000014#
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000015# Syntax: NightlyTest.pl [OPTIONS] [CVSROOT BUILDDIR WEBDIR]
16# where
17# OPTIONS may include one or more of the following:
18# -nocheckout Do not create, checkout, update, or configure
19# the source tree.
20# -noremove Do not remove the BUILDDIR after it has been built.
Patrick Jenkinsa5c04d62006-07-07 17:31:38 +000021# -noremoveresults Do not remove the WEBDIR after it has been built.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000022# -nobuild Do not build llvm. If tests are enabled perform them
23# on the llvm build specified in the build directory
Daniel Dunbarf5a59502009-06-02 21:14:15 +000024# -notest Do not even attempt to run the test programs.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000025# -nodejagnu Do not run feature or regression tests
Daniel Dunbar056dbd02009-05-28 22:45:24 +000026# -parallel Run parallel jobs with GNU Make (see -parallel-jobs).
27# -parallel-jobs The number of parallel Make jobs to use (default is two).
Duncan Sands45db29c2009-06-12 13:02:52 +000028# -with-clang Checkout Clang source into tools/clang.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000029# -release Build an LLVM Release version
Jim Laskey27b8ba02006-09-28 17:49:20 +000030# -release-asserts Build an LLVM ReleaseAsserts version
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000031# -enable-llcbeta Enable testing of beta features in llc.
Reid Spencer2bae1f52006-11-24 20:34:16 +000032# -enable-lli Enable testing of lli (interpreter) features, default is off
Duncan Sands45db29c2009-06-12 13:02:52 +000033# -disable-pic Disable building with Position Independent Code.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000034# -disable-llc Disable LLC tests in the nightly tester.
35# -disable-jit Disable JIT tests in the nightly tester.
36# -disable-cbe Disable C backend tests in the nightly tester.
Evan Chenge04c90b2008-01-12 04:27:18 +000037# -disable-lto Disable link time optimization.
Daniel Dunbar111def82009-03-10 19:33:13 +000038# -disable-bindings Disable building LLVM bindings.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000039# -verbose Turn on some debug output
40# -debug Print information useful only to maintainers of this script.
41# -nice Checkout/Configure/Build with "nice" to reduce impact
42# on busy servers.
43# -f2c Next argument specifies path to F2C utility
44# -nickname The next argument specifieds the nickname this script
45# will submit to the nightlytest results repository.
46# -gccpath Path to gcc/g++ used to build LLVM
47# -cvstag Check out a specific CVS tag to build LLVM (useful for
48# testing release branches)
Reid Spencerece1f682007-07-02 06:19:57 +000049# -usecvs Check code out from the (old) CVS Repository instead of from
50# the standard Subversion repository.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000051# -target Specify the target triplet
52# -cflags Next argument specifies that C compilation options that
53# override the default.
54# -cxxflags Next argument specifies that C++ compilation options that
55# override the default.
56# -ldflags Next argument specifies that linker options that override
57# the default.
Patrick Jenkins215b48f2006-07-07 18:50:51 +000058# -compileflags Next argument specifies extra options passed to make when
59# building LLVM.
Patrick Jenkins0e9402f2006-08-11 23:02:09 +000060# -use-gmake Use gmake instead of the default make command to build
Patrick Jenkins1cd46912006-07-27 01:17:17 +000061# llvm and run tests.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000062#
63# ---------------- Options to configure llvm-test ----------------------------
Patrick Jenkins215b48f2006-07-07 18:50:51 +000064# -extraflags Next argument specifies extra options that are passed to
65# compile the tests.
66# -noexternals Do not run the external tests (for cases where povray
67# or SPEC are not installed)
68# -with-externals Specify a directory where the external tests are located.
Patrick Jenkins0e9402f2006-08-11 23:02:09 +000069# -submit-server Specifies a server to submit the test results too. If this
Misha Brukman12c8d1b2009-01-02 16:28:18 +000070# option is not specified it defaults to
71# llvm.org. This is basically just the address of the
Patrick Jenkins0e9402f2006-08-11 23:02:09 +000072# webserver
73# -submit-script Specifies which script to call on the submit server. If
74# this option is not specified it defaults to
Misha Brukman12c8d1b2009-01-02 16:28:18 +000075# /nightlytest/NightlyTestAccept.php. This is basically
Patrick Jenkins0e9402f2006-08-11 23:02:09 +000076# everything after the www.yourserver.org.
Daniel Dunbarcd3f9992009-05-18 23:24:26 +000077# -submit-aux If specified, an auxiliary script to run in addition to the
78# normal submit script. The script will be passed the path to
79# the "sentdata.txt" file as its sole argument.
Tanya Lattnerc1611882008-03-10 07:28:08 +000080# -nosubmit Do not report the test results back to a submit server.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +000081#
82# CVSROOT is the CVS repository from which the tree will be checked out,
83# specified either in the full :method:user@host:/dir syntax, or
84# just /dir if using a local repo.
85# BUILDDIR is the directory where sources for this test run will be checked out
86# AND objects for this test run will be built. This directory MUST NOT
87# exist before the script is run; it will be created by the cvs checkout
88# process and erased (unless -noremove is specified; see above.)
89# WEBDIR is the directory into which the test results web page will be written,
90# AND in which the "index.html" is assumed to be a symlink to the most recent
91# copy of the results. This directory will be created if it does not exist.
92# LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
93# to. This is the same as you would have for a normal LLVM build.
94#
95##############################################################
96#
97# Getting environment variables
98#
99##############################################################
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000100my $HOME = $ENV{'HOME'};
Reid Spencer99e865a2007-04-07 04:41:16 +0000101my $SVNURL = $ENV{"SVNURL"};
Duncan Sands45db29c2009-06-12 13:02:52 +0000102$SVNURL = 'http://llvm.org/svn/llvm-project' unless $SVNURL;
Evan Cheng53df0a22009-06-18 21:39:50 +0000103my $TestSVNURL = $ENV{"TestSVNURL"};
Evan Chenge11c4db2009-07-14 06:23:41 +0000104$TestSVNURL = 'http://llvm.org/svn/llvm-project' unless $TestSVNURL;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000105my $CVSRootDir = $ENV{'CVSROOT'};
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000106$CVSRootDir = "/home/vadve/shared/PublicCVS" unless $CVSRootDir;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000107my $BuildDir = $ENV{'BUILDDIR'};
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000108$BuildDir = "$HOME/buildtest" unless $BuildDir;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000109my $WebDir = $ENV{'WEBDIR'};
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000110$WebDir = "$HOME/cvs/testresults-X86" unless $WebDir;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000111
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000112my $LLVMSrcDir = $ENV{'LLVMSRCDIR'};
113$LLVMSrcDir = "$BuildDir/llvm" unless $LLVMSrcDir;
114my $LLVMObjDir = $ENV{'LLVMOBJDIR'};
115$LLVMObjDir = "$BuildDir/llvm" unless $LLVMObjDir;
116my $LLVMTestDir = $ENV{'LLVMTESTDIR'};
117$LLVMTestDir = "$BuildDir/llvm/projects/llvm-test" unless $LLVMTestDir;
118
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000119##############################################################
120#
121# Calculate the date prefix...
122#
123##############################################################
124@TIME = localtime;
Daniel Dunbar42cdc382009-07-01 14:52:59 +0000125my $DATE = sprintf "%4d-%02d-%02d_%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3], $TIME[1], $TIME[0];
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000126
127##############################################################
128#
129# Parse arguments...
130#
131##############################################################
132$CONFIGUREARGS="";
Patrick Jenkins49717a42006-07-21 01:39:42 +0000133$nickname="";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000134$NOTEST=0;
John Criswelleecd7112007-06-29 19:12:50 +0000135$USESVN=1;
Patrick Jenkins1cd46912006-07-27 01:17:17 +0000136$MAKECMD="make";
Patrick Jenkins0e9402f2006-08-11 23:02:09 +0000137$SUBMITSERVER = "llvm.org";
Jim Laskey6d8a1b72006-09-15 17:03:36 +0000138$SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
Daniel Dunbarcd3f9992009-05-18 23:24:26 +0000139$SUBMITAUX="";
Tanya Lattnerc1611882008-03-10 07:28:08 +0000140$SUBMIT = 1;
Daniel Dunbar056dbd02009-05-28 22:45:24 +0000141$PARALLELJOBS = "2";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000142
143while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000144 shift;
145 last if /^--$/; # Stop processing arguments on --
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000146
147 # List command line options here...
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000148 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
149 if (/^-nocvsstats$/) { $NOCVSSTATS = 1; next; }
150 if (/^-noremove$/) { $NOREMOVE = 1; next; }
Daniel Dunbar0c39e382009-07-13 22:17:49 +0000151 if (/^-noremoveatend$/) { $NOREMOVEATEND = 1; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000152 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
Daniel Dunbarf5a59502009-06-02 21:14:15 +0000153 if (/^-notest$/) { $NOTEST = 1; next; }
154 if (/^-norunningtests$/) { next; } # Backward compatibility, ignored.
Daniel Dunbar056dbd02009-05-28 22:45:24 +0000155 if (/^-parallel-jobs$/) { $PARALLELJOBS = "$ARGV[0]"; shift; next;}
156 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j$PARALLELJOBS -l3.0"; next; }
Duncan Sands45db29c2009-06-12 13:02:52 +0000157 if (/^-with-clang$/) { $WITHCLANG = 1; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000158 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
159 "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
Jim Laskey27b8ba02006-09-28 17:49:20 +0000160 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
Dan Gohmanc6e22412008-10-30 01:08:03 +0000161 "DISABLE_ASSERTIONS=1 ".
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000162 "OPTIMIZE_OPTION=-O2";
Reid Spencer93c456c2006-10-19 15:24:04 +0000163 $BUILDTYPE="release-asserts"; next;}
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000164 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
Duncan Sands45db29c2009-06-12 13:02:52 +0000165 if (/^-disable-pic$/) { $CONFIGUREARGS .= " --enable-pic=no"; next; }
Reid Spencer2bae1f52006-11-24 20:34:16 +0000166 if (/^-enable-lli$/) { $PROGTESTOPTS .= " ENABLE_LLI=1";
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000167 $CONFIGUREARGS .= " --enable-lli"; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000168 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000169 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000170 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
171 $CONFIGUREARGS .= " --disable-jit"; next; }
Daniel Dunbar111def82009-03-10 19:33:13 +0000172 if (/^-disable-bindings$/) { $CONFIGUREARGS .= " --disable-bindings"; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000173 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
Evan Chenge04c90b2008-01-12 04:27:18 +0000174 if (/^-disable-lto$/) { $PROGTESTOPTS .= " DISABLE_LTO=1"; next; }
Evan Cheng3d64f1c2008-01-14 17:58:03 +0000175 if (/^-test-opts$/) { $PROGTESTOPTS .= " $ARGV[0]"; shift; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000176 if (/^-verbose$/) { $VERBOSE = 1; next; }
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000177 if (/^-teelogs$/) { $TEELOGS = 1; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000178 if (/^-debug$/) { $DEBUG = 1; next; }
179 if (/^-nice$/) { $NICE = "nice "; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000180 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000181 shift; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000182 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000183 shift; next; }
Daniel Dunbarff79ef42009-07-13 22:31:58 +0000184 if (/^-configure-args$/) { $CONFIGUREARGS .= " $ARGV[0]";
185 shift; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000186 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
187 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
Daniel Dunbarcd3f9992009-05-18 23:24:26 +0000188 if (/^-submit-aux/) { $SUBMITAUX = "$ARGV[0]"; shift; next; }
Tanya Lattnerc1611882008-03-10 07:28:08 +0000189 if (/^-nosubmit$/) { $SUBMIT = 0; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000190 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
191 if (/^-gccpath/) { $CONFIGUREARGS .=
192 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000193 $GCCPATH=$ARGV[0]; shift; next; }
194 else { $GCCPATH=""; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000195 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000196 else { $CVSCOOPT="";}
Reid Spencerece1f682007-07-02 06:19:57 +0000197 if (/^-usecvs/) { $USESVN = 0; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000198 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000199 shift; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000200 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000201 shift; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000202 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000203 shift; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000204 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000205 shift; next; }
206 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
207 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000208 if (/^-extraflags/) { $CONFIGUREARGS .=
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000209 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
210 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
211 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
212 if (/^-nobuild$/) { $NOBUILD = 1; next; }
213 print "Unknown option: $_ : ignoring!\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000214}
215
216if ($ENV{'LLVMGCCDIR'}) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000217 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
Bob Wilson85cdfad2009-03-12 19:47:24 +0000218 $LLVMGCCPATH = $ENV{'LLVMGCCDIR'} . '/bin';
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000219}
Tanya Lattner849c9a22007-04-13 04:36:48 +0000220else {
221 $LLVMGCCPATH = "";
222}
223
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000224if ($CONFIGUREARGS !~ /--disable-jit/) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000225 $CONFIGUREARGS .= " --enable-jit";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000226}
227
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000228if (@ARGV != 0 and @ARGV != 3 and $VERBOSE) {
229 foreach $x (@ARGV) {
230 print "$x\n";
231 }
232 print "Must specify 0 or 3 options!";
Patrick Jenkinsf58473f2006-07-27 01:03:46 +0000233}
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000234
235if (@ARGV == 3) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000236 $CVSRootDir = $ARGV[0];
237 $BuildDir = $ARGV[1];
238 $WebDir = $ARGV[2];
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000239}
240
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000241if ($CVSRootDir eq "" or
242 $BuildDir eq "" or
243 $WebDir eq "") {
244 die("please specify a cvs root directory, a build directory, and a ".
Patrick Jenkinsf58473f2006-07-27 01:03:46 +0000245 "web directory");
246 }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000247
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000248if ($nickname eq "") {
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000249 die ("Please invoke NewNightlyTest.pl with command line option " .
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000250 "\"-nickname <nickname>\"");
Patrick Jenkins514e2582006-07-20 22:28:43 +0000251}
Patrick Jenkins1cd46912006-07-27 01:17:17 +0000252
Jim Laskey27b8ba02006-09-28 17:49:20 +0000253if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000254 $BUILDTYPE = "debug";
Patrick Jenkins26ba6092006-07-23 22:57:28 +0000255}
Patrick Jenkins514e2582006-07-20 22:28:43 +0000256
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000257##############################################################
258#
259#define the file names we'll use
260#
261##############################################################
262my $Prefix = "$WebDir/$DATE";
263my $BuildLog = "$Prefix-Build-Log.txt";
Reid Spencer99e865a2007-04-07 04:41:16 +0000264my $COLog = "$Prefix-CVS-Log.txt";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000265my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
266my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
Patrick Jenkins26ba6092006-07-23 22:57:28 +0000267my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000268my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
269my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
270my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
271if (! -d $WebDir) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000272 mkdir $WebDir, 0777;
Patrick Jenkins03137752006-08-21 20:45:57 +0000273 if($VERBOSE){
274 warn "$WebDir did not exist; creating it.\n";
275 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000276}
277
278if ($VERBOSE) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000279 print "INITIALIZED\n";
Reid Spencer99e865a2007-04-07 04:41:16 +0000280 if ($USESVN) {
281 print "SVN URL = $SVNURL\n";
282 } else {
283 print "CVS Root = $CVSRootDir\n";
284 }
285 print "COLog = $COLog\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000286 print "BuildDir = $BuildDir\n";
287 print "WebDir = $WebDir\n";
288 print "Prefix = $Prefix\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000289 print "BuildLog = $BuildLog\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000290}
291
292##############################################################
293#
294# Helper functions
295#
296##############################################################
297sub GetDir {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000298 my $Suffix = shift;
299 opendir DH, $WebDir;
300 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
301 closedir DH;
302 return @Result;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000303}
304
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000305sub RunLoggedCommand {
306 my $Command = shift;
307 my $Log = shift;
Daniel Dunbarfc0fc3a2009-06-26 02:30:49 +0000308 my $Title = shift;
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000309 if ($TEELOGS) {
Daniel Dunbarfc0fc3a2009-06-26 02:30:49 +0000310 if ($VERBOSE) {
311 print "$Title\n";
312 print "$Command 2>&1 | tee $Log\n";
313 }
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000314 system "$Command 2>&1 | tee $Log";
315 } else {
Daniel Dunbarfc0fc3a2009-06-26 02:30:49 +0000316 if ($VERBOSE) {
317 print "$Title\n";
318 print "$Command 2>&1 > $Log\n";
319 }
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000320 system "$Command 2>&1 > $Log";
321 }
322}
323
324sub RunAppendingLoggedCommand {
325 my $Command = shift;
326 my $Log = shift;
Daniel Dunbarfc0fc3a2009-06-26 02:30:49 +0000327 my $Title = shift;
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000328 if ($TEELOGS) {
Daniel Dunbarfc0fc3a2009-06-26 02:30:49 +0000329 if ($VERBOSE) {
330 print "$Title\n";
331 print "$Command 2>&1 | tee -a $Log\n";
332 }
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000333 system "$Command 2>&1 | tee -a $Log";
334 } else {
Daniel Dunbarfc0fc3a2009-06-26 02:30:49 +0000335 if ($VERBOSE) {
336 print "$Title\n";
337 print "$Command 2>&1 > $Log\n";
338 }
339 system "$Command 2>&1 >> $Log";
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000340 }
341}
342
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000343#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
344#
345# DiffFiles - Diff the current version of the file against the last version of
346# the file, reporting things added and removed. This is used to report, for
347# example, added and removed warnings. This returns a pair (added, removed)
348#
349#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
350sub DiffFiles {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000351 my $Suffix = shift;
352 my @Others = GetDir $Suffix;
353 if (@Others == 0) { # No other files? We added all entries...
354 return (`cat $WebDir/$DATE$Suffix`, "");
355 }
356# Diff the files now...
357 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
358 my $Added = join "\n", grep /^</, @Diffs;
359 my $Removed = join "\n", grep /^>/, @Diffs;
360 $Added =~ s/^< //gm;
361 $Removed =~ s/^> //gm;
362 return ($Added, $Removed);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000363}
364
365#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
366#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
367sub GetRegex { # (Regex with ()'s, value)
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000368 $_[1] =~ /$_[0]/m;
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000369 return $1
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000370 if (defined($1));
371 return "0";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000372}
373
374#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
375#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
376sub GetRegexNum {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000377 my ($Regex, $Num, $Regex2, $File) = @_;
378 my @Items = split "\n", `grep '$Regex' $File`;
379 return GetRegex $Regex2, $Items[$Num];
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000380}
381
382#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
383#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
384sub ChangeDir { # directory, logical name
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000385 my ($dir,$name) = @_;
386 chomp($dir);
387 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
388 $result = chdir($dir);
389 if (!$result) {
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000390 print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000391 return false;
392 }
393 return true;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000394}
395
396#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
397#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
398sub ReadFile {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000399 if (open (FILE, $_[0])) {
400 undef $/;
401 my $Ret = <FILE>;
402 close FILE;
403 $/ = '\n';
404 return $Ret;
405 } else {
406 print "Could not open file '$_[0]' for reading!\n";
407 return "";
408 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000409}
410
411#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
412#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
413sub WriteFile { # (filename, contents)
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000414 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
415 print FILE $_[1];
416 close FILE;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000417}
418
419#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
420#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
421sub CopyFile { #filename, newfile
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000422 my ($file, $newfile) = @_;
423 chomp($file);
424 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
425 copy($file, $newfile);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000426}
427
428#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
429#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
430sub AddRecord {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000431 my ($Val, $Filename,$WebDir) = @_;
432 my @Records;
433 if (open FILE, "$WebDir/$Filename") {
434 @Records = grep !/$DATE/, split "\n", <FILE>;
435 close FILE;
436 }
437 push @Records, "$DATE: $Val";
438 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000439}
440
441#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
442#
443# FormatTime - Convert a time from 1m23.45 into 83.45
444#
445#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
446sub FormatTime {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000447 my $Time = shift;
448 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
449 $Time = sprintf("%7.4f", $1*60.0+$2);
450 }
451 return $Time;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000452}
453
454#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000455#
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000456# This function is meant to read in the dejagnu sum file and
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000457# return a string with only the results (i.e. PASS/FAIL/XPASS/
458# XFAIL).
459#
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000460#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
461sub GetDejagnuTestResults { # (filename, log)
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000462 my ($filename, $DejagnuLog) = @_;
463 my @lines;
464 $/ = "\n"; #Make sure we're going line at a time.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000465
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000466 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000467
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000468 if (open SRCHFILE, $filename) {
469 # Process test results
470 while ( <SRCHFILE> ) {
471 if ( length($_) > 1 ) {
472 chomp($_);
Jim Laskey01d7bcf2006-09-20 09:20:22 +0000473 if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\/test\/(.*)$/ ) {
474 push(@lines, "$1: test/$2");
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000475 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000476 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000477 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000478 }
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000479 close SRCHFILE;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000480
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000481 my $content = join("\n", @lines);
482 return $content;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000483}
484
485
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000486
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000487#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
488#
489# This function acts as a mini web browswer submitting data
490# to our central server via the post method
491#
492#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
493sub SendData{
494 $host = $_[0];
495 $file = $_[1];
496 $variables=$_[2];
497
Daniel Dunbar94a37a42009-05-28 18:31:40 +0000498 # Write out the "...-sentdata.txt" file.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000499
Daniel Dunbar94a37a42009-05-28 18:31:40 +0000500 my $sentdata="";
501 foreach $x (keys (%$variables)){
502 $value = $variables->{$x};
503 $sentdata.= "$x => $value\n";
504 }
505 WriteFile "$Prefix-sentdata.txt", $sentdata;
506
507 if (!($SUBMITAUX eq "")) {
Daniel Dunbarf7f02a92009-06-26 22:33:28 +0000508 system "$SUBMITAUX \"$Prefix-sentdata.txt\"";
509 }
510
511 if (!$SUBMIT) {
512 return "Skipped standard submit.\n";
Daniel Dunbar94a37a42009-05-28 18:31:40 +0000513 }
514
515 # Create the content to send to the server.
516
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000517 my $content;
518 foreach $key (keys (%$variables)){
519 $value = $variables->{$key};
520 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
521 $content .= "$key=$value&";
522 }
523
Daniel Dunbar94a37a42009-05-28 18:31:40 +0000524 # Send the data to the server.
525 #
526 # FIXME: This code should be more robust?
527
528 $port=80;
529 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
530 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
531 die "Bad socket\n";
532 connect SOCK, $socketaddr or die "Bad connection\n";
533 select((select(SOCK), $| = 1)[0]);
534
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000535 $length = length($content);
536
537 my $send= "POST $file HTTP/1.0\n";
Lauro Ramos Venancio46040232007-05-03 14:05:07 +0000538 $send.= "Host: $host\n";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000539 $send.= "Content-Type: application/x-www-form-urlencoded\n";
540 $send.= "Content-length: $length\n\n";
541 $send.= "$content";
542
Patrick Jenkinse8501eb2006-08-07 01:54:37 +0000543 print SOCK $send;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000544 my $result;
545 while(<SOCK>){
546 $result .= $_;
547 }
548 close(SOCK);
549
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000550 return $result;
551}
552
Patrick Jenkins215b48f2006-07-07 18:50:51 +0000553##############################################################
554#
555# Getting Start timestamp
556#
557##############################################################
Patrick Jenkinsb67e1182006-07-21 21:43:09 +0000558$starttime = `date "+20%y-%m-%d %H:%M:%S"`;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000559
560##############################################################
561#
562# Create the CVS repository directory
563#
564##############################################################
565if (!$NOCHECKOUT) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000566 if (-d $BuildDir) {
567 if (!$NOREMOVE) {
568 if ( $VERBOSE ) {
569 print "Build directory exists! Removing it\n";
570 }
571 system "rm -rf $BuildDir";
Reid Spencer99e865a2007-04-07 04:41:16 +0000572 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000573 } else {
Jim Laskey6d8a1b72006-09-15 17:03:36 +0000574 if ( $VERBOSE ) {
575 print "Build directory exists!\n";
576 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000577 }
Jim Laskey6d8a1b72006-09-15 17:03:36 +0000578 } else {
Reid Spencer99e865a2007-04-07 04:41:16 +0000579 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000580 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000581}
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000582
583
584##############################################################
585#
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000586# Check out the llvm tree, using either SVN or CVS
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000587#
588##############################################################
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000589if (!$NOCHECKOUT) {
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000590 ChangeDir( $BuildDir, "checkout directory" );
Reid Spencer99e865a2007-04-07 04:41:16 +0000591 if ($USESVN) {
Duncan Sands45db29c2009-06-12 13:02:52 +0000592 my $SVNCMD = "$NICE svn co --non-interactive $SVNURL";
Evan Cheng53df0a22009-06-18 21:39:50 +0000593 my $SVNCMD2 = "$NICE svn co --non-interactive $TestSVNURL";
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000594 RunLoggedCommand("( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
Daniel Dunbarfc0fc3a2009-06-26 02:30:49 +0000595 "$SVNCMD2/test-suite/trunk llvm-test )", $COLog,
596 "CHECKOUT LLVM");
Evan Cheng53df0a22009-06-18 21:39:50 +0000597 if ($WITHCLANG) {
598 my $SVNCMD = "$NICE svn co --non-interactive $SVNURL/cfe/trunk";
Daniel Dunbarfc0fc3a2009-06-26 02:30:49 +0000599 RunLoggedCommand("( time -p cd llvm/tools ; $SVNCMD clang )", $COLog,
600 "CHECKOUT CLANG");
Evan Cheng53df0a22009-06-18 21:39:50 +0000601 }
Reid Spencer99e865a2007-04-07 04:41:16 +0000602 } else {
603 my $CVSOPT = "";
604 $CVSOPT = "-z3" # Use compression if going over ssh.
605 if $CVSRootDir =~ /^:ext:/;
606 my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co -P $CVSCOOPT";
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000607 RunLoggedCommand("( time -p $CVSCMD llvm; cd llvm/projects ; " .
Daniel Dunbarfc0fc3a2009-06-26 02:30:49 +0000608 "$CVSCMD llvm-test )", $COLog,
609 "CHECKOUT LLVM-TEST");
Reid Spencer99e865a2007-04-07 04:41:16 +0000610 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000611}
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000612ChangeDir( $LLVMSrcDir , "llvm source directory") ;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000613
614##############################################################
615#
616# Get some static statistics about the current state of CVS
617#
618# This can probably be put on the server side
619#
620##############################################################
Reid Spencer99e865a2007-04-07 04:41:16 +0000621my $CheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $COLog`;
622my $CheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $COLog`;
623my $CheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $COLog`;
624my $CheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000625
Reid Spencer99e865a2007-04-07 04:41:16 +0000626my $NumFilesInCVS = 0;
627my $NumDirsInCVS = 0;
628if ($USESVN) {
629 $NumFilesInCVS = `egrep '^A' $COLog | wc -l` + 0;
Nick Lewyckyef7d2bb2008-06-05 12:54:44 +0000630 $NumDirsInCVS = `sed -e 's#/[^/]*\$##' $COLog | sort | uniq | wc -l` + 0;
Reid Spencer99e865a2007-04-07 04:41:16 +0000631} else {
632 $NumFilesInCVS = `egrep '^U' $COLog | wc -l` + 0;
633 $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $COLog | wc -l` + 0;
634}
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000635
636##############################################################
637#
638# Extract some information from the CVS history... use a hash so no duplicate
639# stuff is stored. This gets the history from the previous days worth
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000640# of cvs activity and parses it.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000641#
642##############################################################
643
Reid Spencer99e865a2007-04-07 04:41:16 +0000644# This just computes a reasonably accurate #of seconds since 2000. It doesn't
645# have to be perfect as its only used for comparing date ranges within a couple
646# of days.
647sub ConvertToSeconds {
648 my ($sec, $min, $hour, $day, $mon, $yr) = @_;
649 my $Result = ($yr - 2000) * 12;
650 $Result += $mon;
651 $Result *= 31;
652 $Result += $day;
653 $Result *= 24;
654 $Result += $hour;
655 $Result *= 60;
656 $Result += $min;
657 $Result *= 60;
658 $Result += $sec;
659 return $Result;
660}
661
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000662my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
663
Reid Spencer99e865a2007-04-07 04:41:16 +0000664if (!$NOCVSSTATS) {
665 if ($VERBOSE) { print "CHANGE HISTORY ANALYSIS STAGE\n"; }
Reid Spencer776964a2007-04-04 06:59:36 +0000666
Reid Spencer99e865a2007-04-07 04:41:16 +0000667 if ($USESVN) {
Duncan Sands45db29c2009-06-12 13:02:52 +0000668 @SVNHistory = split /<logentry/, `svn log --non-interactive --xml --verbose -r{$DATE}:HEAD`;
Reid Spencer99e865a2007-04-07 04:41:16 +0000669 # Skip very first entry because it is the XML header cruft
670 shift @SVNHistory;
671 my $Now = time();
672 foreach $Record (@SVNHistory) {
673 my @Lines = split "\n", $Record;
674 my ($Author, $Date, $Revision);
675 # Get the date and see if its one we want to process.
676 my ($Year, $Month, $Day, $Hour, $Min, $Sec);
677 if ($Lines[3] =~ /<date>(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/){
678 $Year = $1; $Month = $2; $Day = $3; $Hour = $4; $Min = $5; $Sec = $6;
679 }
680 my $Then = ConvertToSeconds($Sec, $Min, $Hour, $Day, $Month, $Year);
681 # Get the current date and compute when "yesterday" is.
682 my ($NSec, $NMin, $NHour, $NDay, $NMon, $NYear) = gmtime();
683 my $Now = ConvertToSeconds( $NSec, $NMin, $NHour, $NDay, $NMon, $NYear);
684 if (($Now - 24*60*60) > $Then) {
685 next;
686 }
687 if ($Lines[1] =~ / revision="([0-9]*)">/) {
688 $Revision = $1;
689 }
690 if ($Lines[2] =~ /<author>([^<]*)<\/author>/) {
691 $Author = $1;
692 }
693 $UsersCommitted{$Author} = 1;
694 $Date = $Year . "-" . $Month . "-" . $Day;
695 $Time = $Hour . ":" . $Min . ":" . $Sec;
696 print "Rev: $Revision, Author: $Author, Date: $Date, Time: $Time\n";
697 for ($i = 6; $i < $#Lines; $i += 2 ) {
698 if ($Lines[$i] =~ /^ action="(.)">([^<]*)</) {
699 if ($1 == "A") {
700 $AddedFiles{$2} = 1;
701 } elsif ($1 == 'D') {
702 $RemovedFiles{$2} = 1;
703 } elsif ($1 == 'M' || $1 == 'R' || $1 == 'C') {
704 $ModifiedFiles{$2} = 1;
705 } else {
706 print "UNMATCHABLE: $Lines[$i]\n";
707 }
708 }
709 }
710 }
711 } else {
712 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000713#print join "\n", @CVSHistory; print "\n";
714
Reid Spencer99e865a2007-04-07 04:41:16 +0000715 my $DateRE = '[-/:0-9 ]+\+[0-9]+';
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000716
717# Loop over every record from the CVS history, filling in the hashes.
Reid Spencer99e865a2007-04-07 04:41:16 +0000718 foreach $File (@CVSHistory) {
719 my ($Type, $Date, $UID, $Rev, $Filename);
720 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
721 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
722 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
723 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
724 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
725 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
726 } else {
727 print "UNMATCHABLE: $File\n";
728 next;
729 }
730 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000731
Reid Spencer99e865a2007-04-07 04:41:16 +0000732 if ($Filename =~ /^llvm/) {
733 if ($Type eq 'M') { # Modified
734 $ModifiedFiles{$Filename} = 1;
735 $UsersCommitted{$UID} = 1;
736 } elsif ($Type eq 'A') { # Added
737 $AddedFiles{$Filename} = 1;
738 $UsersCommitted{$UID} = 1;
739 } elsif ($Type eq 'R') { # Removed
740 $RemovedFiles{$Filename} = 1;
741 $UsersCommitted{$UID} = 1;
742 } else {
743 $UsersUpdated{$UID} = 1;
744 }
745 }
746 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000747
Reid Spencer99e865a2007-04-07 04:41:16 +0000748 my $TestError = 1;
749 } #$USESVN
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000750}#!NOCVSSTATS
751
752my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
753my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
754my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
755my $UserCommitList = join "\n", sort keys %UsersCommitted;
756my $UserUpdateList = join "\n", sort keys %UsersUpdated;
757
758##############################################################
759#
760# Build the entire tree, saving build messages to the build log
761#
762##############################################################
763if (!$NOCHECKOUT && !$NOBUILD) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000764 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000765 RunLoggedCommand("(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) ",
Daniel Dunbarfc0fc3a2009-06-26 02:30:49 +0000766 $BuildLog, "CONFIGURE");
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000767 # Build the entire tree, capturing the output into $BuildLog
Daniel Dunbarfc0fc3a2009-06-26 02:30:49 +0000768 RunAppendingLoggedCommand("(time -p $NICE $MAKECMD clean)", $BuildLog, "BUILD CLEAN");
769 RunAppendingLoggedCommand("(time -p $NICE $MAKECMD $MAKEOPTS)", $BuildLog, "BUILD");
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000770}
771
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000772##############################################################
773#
774# Get some statistics about the build...
775#
776##############################################################
777#this can de done on server
778#my @Linked = split '\n', `grep Linking $BuildLog`;
779#my $NumExecutables = scalar(grep(/executable/, @Linked));
780#my $NumLibraries = scalar(grep(!/executable/, @Linked));
781#my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
782
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000783# Get the number of lines of source code. Must be here after the build is done
784# because countloc.sh uses the llvm-config script which must be built.
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000785my $LOC = `utils/countloc.sh -topdir $LLVMSrcDir`;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000786
787# Get the time taken by the configure script
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000788my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
789my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
790my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
791my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
792
793$ConfigTime=-1 unless $ConfigTime;
794$ConfigWallTime=-1 unless $ConfigWallTime;
795
796my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
797my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
798my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
799my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
800
801$BuildTime=-1 unless $BuildTime;
802$BuildWallTime=-1 unless $BuildWallTime;
803
804my $BuildError = 0, $BuildStatus = "OK";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000805if ($NOBUILD) {
806 $BuildStatus = "Skipped by user";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000807}
Patrick Jenkinsf58473f2006-07-27 01:03:46 +0000808elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000809 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
810 $BuildStatus = "Error: compilation aborted";
811 $BuildError = 1;
812 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000813}
814if ($BuildError) { $NODEJAGNU=1; }
815
Patrick Jenkins169357e2006-07-23 21:38:07 +0000816my $a_file_sizes="";
817my $o_file_sizes="";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000818if (!$BuildError) {
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000819 print "Organizing size of .o and .a files\n"
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000820 if ( $VERBOSE );
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000821 ChangeDir( "$LLVMObjDir", "Build Directory" );
Bob Wilson6dc11b42009-06-19 17:19:38 +0000822
823 my @dirs = ('utils', 'lib', 'tools');
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000824 if($BUILDTYPE eq "release"){
Bob Wilson6dc11b42009-06-19 17:19:38 +0000825 push @dirs, 'Release';
Jim Laskey27b8ba02006-09-28 17:49:20 +0000826 } elsif($BUILDTYPE eq "release-asserts") {
Bob Wilson6dc11b42009-06-19 17:19:38 +0000827 push @dirs, 'Release-Asserts';
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000828 } else {
Bob Wilson6dc11b42009-06-19 17:19:38 +0000829 push @dirs, 'Debug';
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000830 }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000831
Bob Wilson6dc11b42009-06-19 17:19:38 +0000832 find(sub {
833 $a_file_sizes .= (-s $_)." $File::Find::name $BUILDTYPE\n" if /\.a$/i;
834 $o_file_sizes .= (-s $_)." $File::Find::name $BUILDTYPE\n" if /\.o$/i;
835 }, @dirs);
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000836} else {
837 $a_file_sizes="No data due to a bad build.";
838 $o_file_sizes="No data due to a bad build.";
Patrick Jenkins169357e2006-07-23 21:38:07 +0000839}
Patrick Jenkins169357e2006-07-23 21:38:07 +0000840
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000841##############################################################
842#
843# Running dejagnu tests
844#
845##############################################################
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +0000846my $DejangnuTestResults=""; # String containing the results of the dejagnu
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000847my $dejagnu_output = "$DejagnuTestsLog";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000848if (!$NODEJAGNU) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000849 #Run the feature and regression tests, results are put into testrun.sum
850 #Full log in testrun.log
Daniel Dunbarfc0fc3a2009-06-26 02:30:49 +0000851 RunLoggedCommand("(time -p $MAKECMD $MAKEOPTS check)", $dejagnu_output, "DEJAGNU");
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000852
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000853 #Copy the testrun.log and testrun.sum to our webdir
854 CopyFile("test/testrun.log", $DejagnuLog);
855 CopyFile("test/testrun.sum", $DejagnuSum);
856 #can be done on server
857 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
858 $unexpfail_tests = $DejagnuTestResults;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000859}
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000860
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000861#Extract time of dejagnu tests
862my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
863my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
864$DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000865$DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
866$DejagnuTestResults =
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000867 "Dejagnu skipped by user choice." unless $DejagnuTestResults;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000868$DejagnuTime = "0.0" unless $DejagnuTime;
869$DejagnuWallTime = "0.0" unless $DejagnuWallTime;
870
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000871##############################################################
872#
873# Get warnings from the build
874#
875##############################################################
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000876if (!$NODEJAGNU) {
877 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
878 my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
879 my @Warnings;
880 my $CurDir = "";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000881
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000882 foreach $Warning (@Warn) {
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000883 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000884 $CurDir = $1; # Keep track of directory warning is in...
885 # Remove buildir prefix if included
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000886 if ($CurDir =~ m#$LLVMSrcDir/(.*)#) { $CurDir = $1; }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000887 } else {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000888 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000889 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000890 }
891 my $WarningsFile = join "\n", @Warnings;
892 $WarningsFile =~ s/:[0-9]+:/::/g;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000893
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000894 # Emit the warnings file, so we can diff...
895 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
896 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000897
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000898 # Output something to stdout if something has changed
899 #print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
900 #print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000901
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000902 #my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
903 #my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000904
905} #endif !NODEGAGNU
906
907##############################################################
908#
909# If we built the tree successfully, run the nightly programs tests...
910#
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000911# A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000912# "External")
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000913#
914##############################################################
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000915
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000916sub TestDirectory {
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000917 my $SubDir = shift;
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000918 ChangeDir( "$LLVMTestDir/$SubDir",
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000919 "Programs Test Subdirectory" ) || return ("", "");
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000920
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000921 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000922
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000923 # Run the programs tests... creating a report.nightly.csv file
924 if (!$NOTEST) {
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000925 if( $VERBOSE) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000926 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000927 "TEST=nightly > $ProgramTestLog 2>&1\n";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000928 }
Daniel Dunbar2f90daf2009-06-26 01:53:05 +0000929 RunLoggedCommand("$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
Daniel Dunbarfc0fc3a2009-06-26 02:30:49 +0000930 "TEST=nightly", $ProgramTestLog, "TEST DIRECTORY $SubDir");
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000931 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000932 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000933
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000934 my $ProgramsTable;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000935 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000936 $TestError = 1;
937 $ProgramsTable="Error running test $SubDir\n";
938 print "ERROR TESTING\n";
939 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
940 $TestError = 1;
941 $ProgramsTable="Makefile error running tests $SubDir!\n";
942 print "ERROR TESTING\n";
943 } else {
944 $TestError = 0;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000945 #
946 # Create a list of the tests which were run...
947 #
948 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000949 "| sort > $Prefix-$SubDir-Tests.txt";
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000950 }
951 $ProgramsTable = ReadFile "report.nightly.csv";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000952
Patrick Jenkins59d1a662006-07-27 18:28:50 +0000953 ChangeDir( "../../..", "Programs Test Parent Directory" );
954 return ($ProgramsTable, $llcbeta_options);
Patrick Jenkins9e384ab2006-08-14 16:07:14 +0000955} #end sub TestDirectory
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000956
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000957##############################################################
958#
959# Calling sub TestDirectory
960#
961##############################################################
Patrick Jenkinsc281b0d2006-07-27 19:00:01 +0000962if (!$BuildError) {
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000963 ($SingleSourceProgramsTable, $llcbeta_options) =
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000964 TestDirectory("SingleSource");
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000965 WriteFile "$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000966 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000967 WriteFile "$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000968 if ( ! $NOEXTERNALS ) {
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000969 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000970 WriteFile "$Prefix-External-Performance.txt", $ExternalProgramsTable;
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000971 system "cat $Prefix-SingleSource-Tests.txt " .
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000972 "$Prefix-MultiSource-Tests.txt ".
973 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000974 system "cat $Prefix-SingleSource-Performance.txt " .
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000975 "$Prefix-MultiSource-Performance.txt ".
976 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000977 } else {
978 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
979 if ( $VERBOSE ) {
980 print "External TEST STAGE SKIPPED\n";
981 }
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000982 system "cat $Prefix-SingleSource-Tests.txt " .
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000983 "$Prefix-MultiSource-Tests.txt ".
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000984 " | sort > $Prefix-Tests.txt";
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000985 system "cat $Prefix-SingleSource-Performance.txt " .
Patrick Jenkins4b7f7aa2006-08-17 22:11:03 +0000986 "$Prefix-MultiSource-Performance.txt ".
987 " | sort > $Prefix-Performance.txt";
Reid Spencerfa34d7b2006-08-13 09:53:02 +0000988 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +0000989
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000990 ##############################################################
991 #
Misha Brukman12c8d1b2009-01-02 16:28:18 +0000992 #
993 # gathering tests added removed broken information here
Patrick Jenkinsad6f7582006-08-22 18:11:19 +0000994 #
995 #
996 ##############################################################
997 my $dejagnu_test_list = ReadFile "$Prefix-Tests.txt";
998 my @DEJAGNU = split "\n", $dejagnu_test_list;
999 my ($passes, $fails, $xfails) = "";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001000
Patrick Jenkinsad6f7582006-08-22 18:11:19 +00001001 if(!$NODEJAGNU) {
1002 for ($x=0; $x<@DEJAGNU; $x++) {
1003 if ($DEJAGNU[$x] =~ m/^PASS:/) {
1004 $passes.="$DEJAGNU[$x]\n";
1005 }
1006 elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
1007 $fails.="$DEJAGNU[$x]\n";
1008 }
1009 elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
1010 $xfails.="$DEJAGNU[$x]\n";
1011 }
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001012 }
1013 }
Misha Brukman12c8d1b2009-01-02 16:28:18 +00001014
Patrick Jenkinsad6f7582006-08-22 18:11:19 +00001015} #end if !$BuildError
1016
Patrick Jenkins215b48f2006-07-07 18:50:51 +00001017##############################################################
1018#
1019# Getting end timestamp
1020#
1021##############################################################
Patrick Jenkinsb67e1182006-07-21 21:43:09 +00001022$endtime = `date "+20%y-%m-%d %H:%M:%S"`;
Patrick Jenkins215b48f2006-07-07 18:50:51 +00001023
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001024
1025##############################################################
1026#
1027# Place all the logs neatly into one humungous file
1028#
1029##############################################################
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001030if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
1031
Misha Brukman12c8d1b2009-01-02 16:28:18 +00001032$machine_data = "uname: ".`uname -a`.
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001033 "hardware: ".`uname -m`.
1034 "os: ".`uname -sr`.
1035 "name: ".`uname -n`.
1036 "date: ".`date \"+20%y-%m-%d\"`.
Misha Brukman12c8d1b2009-01-02 16:28:18 +00001037 "time: ".`date +\"%H:%M:%S\"`;
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001038
1039my @CVS_DATA;
1040my $cvs_data;
Reid Spencer99e865a2007-04-07 04:41:16 +00001041@CVS_DATA = ReadFile "$COLog";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001042$cvs_data = join("\n", @CVS_DATA);
1043
1044my @BUILD_DATA;
1045my $build_data;
1046@BUILD_DATA = ReadFile "$BuildLog";
1047$build_data = join("\n", @BUILD_DATA);
1048
Patrick Jenkins03137752006-08-21 20:45:57 +00001049my (@DEJAGNU_LOG, @DEJAGNU_SUM, @DEJAGNULOG_FULL, @GCC_VERSION);
1050my ($dejagnutests_log ,$dejagnutests_sum, $dejagnulog_full) = "";
1051my ($gcc_version, $gcc_version_long) = "";
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001052
Patrick Jenkinsad6f7582006-08-22 18:11:19 +00001053$gcc_version_long="";
1054if ($GCCPATH ne "") {
1055 $gcc_version_long = `$GCCPATH/gcc --version`;
Jeff Cohen75454222007-04-10 19:13:43 +00001056} elsif ($ENV{"CC"}) {
1057 $gcc_version_long = `$ENV{"CC"} --version`;
Patrick Jenkinsad6f7582006-08-22 18:11:19 +00001058} else {
1059 $gcc_version_long = `gcc --version`;
1060}
1061@GCC_VERSION = split '\n', $gcc_version_long;
1062$gcc_version = $GCC_VERSION[0];
1063
Tanya Lattner849c9a22007-04-13 04:36:48 +00001064$llvmgcc_version_long="";
1065if ($LLVMGCCPATH ne "") {
1066 $llvmgcc_version_long = `$LLVMGCCPATH/llvm-gcc -v 2>&1`;
1067} else {
1068 $llvmgcc_version_long = `llvm-gcc -v 2>&1`;
1069}
1070@LLVMGCC_VERSION = split '\n', $llvmgcc_version_long;
1071$llvmgcc_versionTarget = $LLVMGCC_VERSION[1];
1072$llvmgcc_versionTarget =~ /Target: (.+)/;
1073$targetTriple = $1;
1074
Patrick Jenkins03137752006-08-21 20:45:57 +00001075if(!$BuildError){
1076 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
1077 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
1078 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
1079 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001080
Patrick Jenkins03137752006-08-21 20:45:57 +00001081 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
1082 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
Patrick Jenkins79fbf7f2006-07-14 20:44:09 +00001083}
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001084
1085##############################################################
1086#
1087# Send data via a post request
1088#
1089##############################################################
1090
1091if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
1092
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001093my %hash_of_data = (
1094 'machine_data' => $machine_data,
1095 'build_data' => $build_data,
1096 'gcc_version' => $gcc_version,
1097 'nickname' => $nickname,
1098 'dejagnutime_wall' => $DejagnuWallTime,
1099 'dejagnutime_cpu' => $DejagnuTime,
Reid Spencer99e865a2007-04-07 04:41:16 +00001100 'cvscheckouttime_wall' => $CheckoutTime_Wall,
1101 'cvscheckouttime_cpu' => $CheckoutTime_CPU,
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001102 'configtime_wall' => $ConfigWallTime,
1103 'configtime_cpu'=> $ConfigTime,
1104 'buildtime_wall' => $BuildWallTime,
1105 'buildtime_cpu' => $BuildTime,
1106 'warnings' => $WarningsFile,
1107 'cvsusercommitlist' => $UserCommitList,
1108 'cvsuserupdatelist' => $UserUpdateList,
1109 'cvsaddedfiles' => $CVSAddedFiles,
1110 'cvsmodifiedfiles' => $CVSModifiedFiles,
1111 'cvsremovedfiles' => $CVSRemovedFiles,
1112 'lines_of_code' => $LOC,
1113 'cvs_file_count' => $NumFilesInCVS,
1114 'cvs_dir_count' => $NumDirsInCVS,
1115 'buildstatus' => $BuildStatus,
1116 'singlesource_programstable' => $SingleSourceProgramsTable,
1117 'multisource_programstable' => $MultiSourceProgramsTable,
1118 'externalsource_programstable' => $ExternalProgramsTable,
1119 'llcbeta_options' => $multisource_llcbeta_options,
1120 'warnings_removed' => $WarningsRemoved,
1121 'warnings_added' => $WarningsAdded,
1122 'passing_tests' => $passes,
1123 'expfail_tests' => $xfails,
1124 'unexpfail_tests' => $fails,
1125 'all_tests' => $dejagnu_test_list,
1126 'new_tests' => "",
1127 'removed_tests' => "",
Patrick Jenkinsb9c65eb2006-08-18 18:00:21 +00001128 'dejagnutests_results' => $DejagnuTestResults,
1129 'dejagnutests_log' => $dejagnulog_full,
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001130 'starttime' => $starttime,
1131 'endtime' => $endtime,
1132 'o_file_sizes' => $o_file_sizes,
Tanya Lattner849c9a22007-04-13 04:36:48 +00001133 'a_file_sizes' => $a_file_sizes,
1134 'target_triple' => $targetTriple
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001135);
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001136
Daniel Dunbarf7f02a92009-06-26 22:33:28 +00001137if ($SUBMIT || !($SUBMITAUX eq "")) {
Tanya Lattnerc1611882008-03-10 07:28:08 +00001138 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
1139 if( $VERBOSE) { print "============================\n$response"; }
1140} else {
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001141 print "============================\n";
1142 foreach $x(keys %hash_of_data){
1143 print "$x => $hash_of_data{$x}\n";
1144 }
Patrick Jenkinsfe030d72006-07-06 21:19:32 +00001145}
1146
1147##############################################################
1148#
1149# Remove the cvs tree...
1150#
1151##############################################################
Misha Brukman12c8d1b2009-01-02 16:28:18 +00001152system ( "$NICE rm -rf $BuildDir")
Daniel Dunbar0c39e382009-07-13 22:17:49 +00001153 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVEATEND);
Misha Brukman12c8d1b2009-01-02 16:28:18 +00001154system ( "$NICE rm -rf $WebDir")
Reid Spencerfa34d7b2006-08-13 09:53:02 +00001155 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);