Add the select optimization recently added to instcombine to constant folding.
[llvm.git] / utils / NewNightlyTest.pl
blob1b48168262a5f3354628b900b4b0ce76a1bb3bcb
1 #!/usr/bin/perl
2 use POSIX qw(strftime);
3 use File::Copy;
4 use File::Find;
5 use Socket;
8 # Program: NewNightlyTest.pl
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
12 # regressions and performance changes. Submits this information
13 # to llvm.org where it is placed into the nightlytestresults database.
15 # Syntax: NightlyTest.pl [OPTIONS] [CVSROOT BUILDDIR WEBDIR]
16 # where
17 # OPTIONS may include one or more of the following:
19 # MAIN OPTIONS:
20 # -config LLVMPATH If specified, use an existing LLVM build and only run and
21 # report the test information. The LLVMCONFIG argument should
22 # be the path to the llvm-config executable in the LLVM build.
23 # This should be the first argument if given. NOT YET
24 # IMPLEMENTED.
25 # -nickname NAME The NAME argument specifieds the nickname this script
26 # will submit to the nightlytest results repository.
27 # -nouname Don't include uname data (machine will be identified by nickname only).
28 # -submit-server Specifies a server to submit the test results too. If this
29 # option is not specified it defaults to
30 # llvm.org. This is basically just the address of the
31 # webserver
32 # -submit-script Specifies which script to call on the submit server. If
33 # this option is not specified it defaults to
34 # /nightlytest/NightlyTestAccept.php. This is basically
35 # everything after the www.yourserver.org.
36 # -submit-aux If specified, an auxiliary script to run in addition to the
37 # normal submit script. The script will be passed the path to
38 # the "sentdata.txt" file as its sole argument.
39 # -nosubmit Do not report the test results back to a submit server.
42 # BUILD OPTIONS (not used with -config):
43 # -nocheckout Do not create, checkout, update, or configure
44 # the source tree.
45 # -noremove Do not remove the BUILDDIR after it has been built.
46 # -noremoveresults Do not remove the WEBDIR after it has been built.
47 # -noclean Do not run 'make clean' before building.
48 # -nobuild Do not build llvm. If tests are enabled perform them
49 # on the llvm build specified in the build directory
50 # -release Build an LLVM Release+Asserts version
51 # -release-asserts Build an LLVM Release version
52 # -disable-bindings Disable building LLVM bindings.
53 # -with-clang Checkout Clang source into tools/clang.
54 # -compileflags Next argument specifies extra options passed to make when
55 # building LLVM.
56 # -use-gmake Use gmake instead of the default make command to build
57 # llvm and run tests.
58 # -llvmgccdir Next argument specifies the llvm-gcc install prefix.
60 # TESTING OPTIONS:
61 # -notest Do not even attempt to run the test programs.
62 # -nodejagnu Do not run feature or regression tests
63 # -enable-llcbeta Enable testing of beta features in llc.
64 # -enable-lli Enable testing of lli (interpreter) features, default is off
65 # -disable-pic Disable building with Position Independent Code.
66 # -disable-llc Disable LLC tests in the nightly tester.
67 # -disable-jit Disable JIT tests in the nightly tester.
68 # -disable-cbe Disable C backend tests in the nightly tester.
69 # -disable-lto Disable link time optimization.
70 # -test-cflags Next argument specifies that C compilation options that
71 # override the default when running the testsuite.
72 # -test-cxxflags Next argument specifies that C++ compilation options that
73 # override the default when running the testsuite.
74 # -extraflags Next argument specifies extra options that are passed to
75 # compile the tests.
76 # -noexternals Do not run the external tests (for cases where povray
77 # or SPEC are not installed)
78 # -with-externals Specify a directory where the external tests are located.
80 # OTHER OPTIONS:
81 # -parallel Run parallel jobs with GNU Make (see -parallel-jobs).
82 # -parallel-jobs The number of parallel Make jobs to use (default is two).
83 # -parallel-test Allow parallel execution of llvm-test
84 # -verbose Turn on some debug output
85 # -nice Checkout/Configure/Build with "nice" to reduce impact
86 # on busy servers.
87 # -f2c Next argument specifies path to F2C utility
88 # -gccpath Path to gcc/g++ used to build LLVM
89 # -target Specify the target triplet
90 # -cflags Next argument specifies that C compilation options that
91 # override the default.
92 # -cxxflags Next argument specifies that C++ compilation options that
93 # override the default.
94 # -ldflags Next argument specifies that linker options that override
95 # the default.
97 # CVSROOT is ignored, it is passed for backwards compatibility.
98 # BUILDDIR is the directory where sources for this test run will be checked out
99 # AND objects for this test run will be built. This directory MUST NOT
100 # exist before the script is run; it will be created by the svn checkout
101 # process and erased (unless -noremove is specified; see above.)
102 # WEBDIR is the directory into which the test results web page will be written,
103 # AND in which the "index.html" is assumed to be a symlink to the most recent
104 # copy of the results. This directory will be created if it does not exist.
105 # LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
106 # to. This is the same as you would have for a normal LLVM build.
108 ##############################################################
110 # Getting environment variables
112 ##############################################################
113 my $HOME = $ENV{'HOME'};
114 my $SVNURL = $ENV{"SVNURL"};
115 $SVNURL = 'http://llvm.org/svn/llvm-project' unless $SVNURL;
116 my $TestSVNURL = $ENV{"TestSVNURL"};
117 $TestSVNURL = 'http://llvm.org/svn/llvm-project' unless $TestSVNURL;
118 my $BuildDir = $ENV{'BUILDDIR'};
119 my $WebDir = $ENV{'WEBDIR'};
121 ##############################################################
123 # Calculate the date prefix...
125 ##############################################################
126 use POSIX;
127 @TIME = localtime;
128 my $DATE = strftime("%Y-%m-%d_%H-%M-%S", localtime());
130 ##############################################################
132 # Parse arguments...
134 ##############################################################
135 $CONFIG_PATH="";
136 $CONFIGUREARGS="";
137 $nickname="";
138 $NOTEST=0;
139 $MAKECMD="make";
140 $SUBMITSERVER = "llvm.org";
141 $SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
142 $SUBMITAUX="";
143 $SUBMIT = 1;
144 $PARALLELJOBS = "2";
145 my $TESTFLAGS="";
147 if ($ENV{'LLVMGCCDIR'}) {
148 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
149 $LLVMGCCPATH = $ENV{'LLVMGCCDIR'} . '/bin';
151 else {
152 $LLVMGCCPATH = "";
155 while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
156 shift;
157 last if /^--$/; # Stop processing arguments on --
159 # List command line options here...
160 if (/^-config$/) { $CONFIG_PATH = "$ARGV[0]"; shift; next; }
161 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
162 if (/^-noclean$/) { $NOCLEAN = 1; next; }
163 if (/^-noremove$/) { $NOREMOVE = 1; next; }
164 if (/^-noremoveatend$/) { $NOREMOVEATEND = 1; next; }
165 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
166 if (/^-notest$/) { $NOTEST = 1; next; }
167 if (/^-norunningtests$/) { next; } # Backward compatibility, ignored.
168 if (/^-parallel-jobs$/) { $PARALLELJOBS = "$ARGV[0]"; shift; next;}
169 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j$PARALLELJOBS"; next; }
170 if (/^-parallel-test$/) { $PROGTESTOPTS .= " ENABLE_PARALLEL_REPORT=1"; next; }
171 if (/^-with-clang$/) { $WITHCLANG = 1; next; }
172 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
173 "OPTIMIZE_OPTION=-O2"; next;}
174 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
175 "DISABLE_ASSERTIONS=1 ".
176 "OPTIMIZE_OPTION=-O2"; next;}
177 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
178 if (/^-disable-pic$/) { $CONFIGUREARGS .= " --enable-pic=no"; next; }
179 if (/^-enable-lli$/) { $PROGTESTOPTS .= " ENABLE_LLI=1";
180 $CONFIGUREARGS .= " --enable-lli"; next; }
181 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
182 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
183 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
184 $CONFIGUREARGS .= " --disable-jit"; next; }
185 if (/^-disable-bindings$/) { $CONFIGUREARGS .= " --disable-bindings"; next; }
186 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
187 if (/^-disable-lto$/) { $PROGTESTOPTS .= " DISABLE_LTO=1"; next; }
188 if (/^-test-opts$/) { $PROGTESTOPTS .= " $ARGV[0]"; shift; next; }
189 if (/^-verbose$/) { $VERBOSE = 1; next; }
190 if (/^-teelogs$/) { $TEELOGS = 1; next; }
191 if (/^-nice$/) { $NICE = "nice "; next; }
192 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
193 shift; next; }
194 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
195 shift; next; }
196 if (/^-configure-args$/) { $CONFIGUREARGS .= " $ARGV[0]";
197 shift; next; }
198 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
199 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
200 if (/^-submit-aux/) { $SUBMITAUX = "$ARGV[0]"; shift; next; }
201 if (/^-nosubmit$/) { $SUBMIT = 0; next; }
202 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
203 if (/^-gccpath/) { $CONFIGUREARGS .=
204 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
205 $GCCPATH=$ARGV[0]; shift; next; }
206 else { $GCCPATH=""; }
207 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
208 shift; next; }
209 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
210 shift; next; }
211 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
212 shift; next; }
213 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
214 shift; next; }
215 if (/^-test-cflags/) { $TESTFLAGS = "$TESTFLAGS CFLAGS=\'$ARGV[0]\'";
216 shift; next; }
217 if (/^-test-cxxflags/) { $TESTFLAGS = "$TESTFLAGS CXXFLAGS=\'$ARGV[0]\'";
218 shift; next; }
219 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
220 if (/^-llvmgccdir/) { $CONFIGUREARGS .= " --with-llvmgccdir=\'$ARGV[0]\'";
221 $LLVMGCCPATH = $ARGV[0] . '/bin';
222 shift; next;}
223 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
224 if (/^-nouname$/) { $NOUNAME = 1; next; }
225 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
226 if (/^-extraflags/) { $CONFIGUREARGS .=
227 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
228 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
229 if (/^-nodejagnu$/) { next; }
230 if (/^-nobuild$/) { $NOBUILD = 1; next; }
231 print "Unknown option: $_ : ignoring!\n";
234 if ($CONFIGUREARGS !~ /--disable-jit/) {
235 $CONFIGUREARGS .= " --enable-jit";
238 if (@ARGV != 0 and @ARGV != 3) {
239 die "error: must specify 0 or 3 options!";
242 if (@ARGV == 3) {
243 if ($CONFIG_PATH ne "") {
244 die "error: arguments are unsupported in -config mode,";
247 # ARGV[0] used to be the CVS root, ignored for backward compatibility.
248 $BuildDir = $ARGV[1];
249 $WebDir = $ARGV[2];
252 if ($CONFIG_PATH ne "") {
253 $BuildDir = "";
254 $SVNURL = $TestSVNURL = "";
255 if ($WebDir eq "") {
256 die("please specify a web directory");
258 } else {
259 if ($BuildDir eq "" or
260 $WebDir eq "") {
261 die("please specify a build directory, and a web directory");
265 if ($nickname eq "") {
266 die ("Please invoke NewNightlyTest.pl with command line option " .
267 "\"-nickname <nickname>\"");
270 my $LLVMSrcDir = $ENV{'LLVMSRCDIR'};
271 $LLVMSrcDir = "$BuildDir/llvm" unless $LLVMSrcDir;
272 my $LLVMObjDir = $ENV{'LLVMOBJDIR'};
273 $LLVMObjDir = "$BuildDir/llvm" unless $LLVMObjDir;
274 my $LLVMTestDir = $ENV{'LLVMTESTDIR'};
275 $LLVMTestDir = "$BuildDir/llvm/projects/llvm-test" unless $LLVMTestDir;
277 ##############################################################
279 # Define the file names we'll use
281 ##############################################################
283 my $Prefix = "$WebDir/$DATE";
284 my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
285 my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
286 my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
288 # These are only valid in non-config mode.
289 my $ConfigureLog = "", $BuildLog = "", $COLog = "";
290 my $DejagnuLog = "", $DejagnuSum = "", $DejagnuLog = "";
292 # Are we in config mode?
293 my $ConfigMode = 0;
295 ##############################################################
297 # Helper functions
299 ##############################################################
301 sub GetDir {
302 my $Suffix = shift;
303 opendir DH, $WebDir;
304 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
305 closedir DH;
306 return @Result;
309 sub RunLoggedCommand {
310 my $Command = shift;
311 my $Log = shift;
312 my $Title = shift;
313 if ($TEELOGS) {
314 if ($VERBOSE) {
315 print "$Title\n";
316 print "$Command 2>&1 | tee $Log\n";
318 system "$Command 2>&1 | tee $Log";
319 } else {
320 if ($VERBOSE) {
321 print "$Title\n";
322 print "$Command > $Log 2>&1\n";
324 system "$Command > $Log 2>&1";
328 sub RunAppendingLoggedCommand {
329 my $Command = shift;
330 my $Log = shift;
331 my $Title = shift;
332 if ($TEELOGS) {
333 if ($VERBOSE) {
334 print "$Title\n";
335 print "$Command 2>&1 | tee -a $Log\n";
337 system "$Command 2>&1 | tee -a $Log";
338 } else {
339 if ($VERBOSE) {
340 print "$Title\n";
341 print "$Command >> $Log 2>&1\n";
343 system "$Command >> $Log 2>&1";
347 sub GetRegex { # (Regex with ()'s, value)
348 if ($_[1] =~ /$_[0]/m) {
349 return $1;
351 return "0";
354 sub ChangeDir { # directory, logical name
355 my ($dir,$name) = @_;
356 chomp($dir);
357 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
358 $result = chdir($dir);
359 if (!$result) {
360 print "ERROR!!! Cannot change directory to: $name ($dir) because $!\n";
361 return false;
363 return true;
366 sub ReadFile {
367 if (open (FILE, $_[0])) {
368 undef $/;
369 my $Ret = <FILE>;
370 close FILE;
371 $/ = '\n';
372 return $Ret;
373 } else {
374 print "Could not open file '$_[0]' for reading!\n";
375 return "";
379 sub WriteFile { # (filename, contents)
380 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
381 print FILE $_[1];
382 close FILE;
385 sub CopyFile { #filename, newfile
386 my ($file, $newfile) = @_;
387 chomp($file);
388 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
389 copy($file, $newfile);
392 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
394 # This function acts as a mini web browswer submitting data
395 # to our central server via the post method
397 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
398 sub WriteSentData {
399 $variables = $_[0];
401 # Write out the "...-sentdata.txt" file.
403 my $sentdata="";
404 foreach $x (keys (%$variables)){
405 $value = $variables->{$x};
406 $sentdata.= "$x => $value\n";
408 WriteFile "$Prefix-sentdata.txt", $sentdata;
411 sub SendData {
412 $host = $_[0];
413 $file = $_[1];
414 $variables = $_[2];
416 if (!($SUBMITAUX eq "")) {
417 system "$SUBMITAUX \"$Prefix-sentdata.txt\"";
420 if (!$SUBMIT) {
421 return "Skipped standard submit.\n";
424 # Create the content to send to the server.
426 my $content;
427 foreach $key (keys (%$variables)){
428 $value = $variables->{$key};
429 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
430 $content .= "$key=$value&";
433 # Send the data to the server.
435 # FIXME: This code should be more robust?
437 $port=80;
438 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
439 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
440 die "Bad socket\n";
441 connect SOCK, $socketaddr or die "Bad connection\n";
442 select((select(SOCK), $| = 1)[0]);
444 $length = length($content);
446 my $send= "POST $file HTTP/1.0\n";
447 $send.= "Host: $host\n";
448 $send.= "Content-Type: application/x-www-form-urlencoded\n";
449 $send.= "Content-length: $length\n\n";
450 $send.= "$content";
452 print SOCK $send;
453 my $result;
454 while(<SOCK>){
455 $result .= $_;
457 close(SOCK);
459 return $result;
462 ##############################################################
464 # Individual Build & Test Functions
466 ##############################################################
468 # Create the source repository directory.
469 sub CheckoutSource {
470 die "Invalid call!" unless $ConfigMode == 0;
471 if (-d $BuildDir) {
472 if (!$NOREMOVE) {
473 if ( $VERBOSE ) {
474 print "Build directory exists! Removing it\n";
476 system "rm -rf $BuildDir";
477 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
478 } else {
479 if ( $VERBOSE ) {
480 print "Build directory exists!\n";
483 } else {
484 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
487 ChangeDir( $BuildDir, "checkout directory" );
488 my $SVNCMD = "$NICE svn co --non-interactive";
489 RunLoggedCommand("( time -p $SVNCMD $SVNURL/llvm/trunk llvm; cd llvm/projects ; " .
490 " $SVNCMD $TestSVNURL/test-suite/trunk llvm-test )", $COLog,
491 "CHECKOUT LLVM");
492 if ($WITHCLANG) {
493 RunLoggedCommand("( cd llvm/tools ; " .
494 " $SVNCMD $SVNURL/cfe/trunk clang )", $COLog,
495 "CHECKOUT CLANG");
499 # Build the entire tree, saving build messages to the build log. Returns false
500 # on build failure.
501 sub BuildLLVM {
502 die "Invalid call!" unless $ConfigMode == 0;
503 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
504 RunLoggedCommand("(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) ",
505 $ConfigureLog, "CONFIGURE");
506 # Build the entire tree, capturing the output into $BuildLog
507 if (!$NOCLEAN) {
508 RunAppendingLoggedCommand("($NICE $MAKECMD $MAKEOPTS clean)", $BuildLog, "BUILD CLEAN");
510 RunAppendingLoggedCommand("(time -p $NICE $MAKECMD $MAKEOPTS)", $BuildLog, "BUILD");
512 if (`grep -a '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
513 `grep -a '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l` + 0) {
514 return 0;
517 return 1;
520 # Run the named tests (i.e. "SingleSource" "MultiSource" "External")
521 sub TestDirectory {
522 my $SubDir = shift;
523 ChangeDir( "$LLVMTestDir/$SubDir",
524 "Programs Test Subdirectory" ) || return ("", "");
526 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
528 # Make sure to clean the test results.
529 RunLoggedCommand("$MAKECMD -k $MAKEOPTS $PROGTESTOPTS clean $TESTFLAGS",
530 $ProgramTestLog, "TEST DIRECTORY $SubDir");
532 # Run the programs tests... creating a report.nightly.csv file.
533 my $LLCBetaOpts = "";
534 RunLoggedCommand("$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
535 "$TESTFLAGS TEST=nightly",
536 $ProgramTestLog, "TEST DIRECTORY $SubDir");
537 $LLCBetaOpts = `$MAKECMD print-llcbeta-option`;
539 my $ProgramsTable;
540 if (`grep -a '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
541 $ProgramsTable="Error running test $SubDir\n";
542 print "ERROR TESTING\n";
543 } elsif (`grep -a '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
544 $ProgramsTable="Makefile error running tests $SubDir!\n";
545 print "ERROR TESTING\n";
546 } else {
547 # Create a list of the tests which were run...
548 system "egrep -a 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
549 "| sort > $Prefix-$SubDir-Tests.txt";
551 $ProgramsTable = ReadFile "report.nightly.csv";
553 ChangeDir( "../../..", "Programs Test Parent Directory" );
554 return ($ProgramsTable, $LLCBetaOpts);
557 # Run all the nightly tests and return the program tables and the list of tests,
558 # passes, fails, and xfails.
559 sub RunNightlyTest() {
560 ($SSProgs, $llcbeta_options) = TestDirectory("SingleSource");
561 WriteFile "$Prefix-SingleSource-Performance.txt", $SSProgs;
562 ($MSProgs, $llcbeta_options) = TestDirectory("MultiSource");
563 WriteFile "$Prefix-MultiSource-Performance.txt", $MSProgs;
564 if ( ! $NOEXTERNALS ) {
565 ($ExtProgs, $llcbeta_options) = TestDirectory("External");
566 WriteFile "$Prefix-External-Performance.txt", $ExtProgs;
567 system "cat $Prefix-SingleSource-Tests.txt " .
568 "$Prefix-MultiSource-Tests.txt ".
569 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
570 system "cat $Prefix-SingleSource-Performance.txt " .
571 "$Prefix-MultiSource-Performance.txt ".
572 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
573 } else {
574 $ExtProgs = "External TEST STAGE SKIPPED\n";
575 if ( $VERBOSE ) {
576 print "External TEST STAGE SKIPPED\n";
578 system "cat $Prefix-SingleSource-Tests.txt " .
579 "$Prefix-MultiSource-Tests.txt ".
580 " | sort > $Prefix-Tests.txt";
581 system "cat $Prefix-SingleSource-Performance.txt " .
582 "$Prefix-MultiSource-Performance.txt ".
583 " | sort > $Prefix-Performance.txt";
586 # Compile passes, fails, xfails.
587 my $All = (ReadFile "$Prefix-Tests.txt");
588 my @TestSuiteResultLines = split "\n", $All;
589 my ($Passes, $Fails, $XFails) = "";
591 for ($x=0; $x < @TestSuiteResultLines; $x++) {
592 if (@TestSuiteResultLines[$x] =~ m/^PASS:/) {
593 $Passes .= "$TestSuiteResultLines[$x]\n";
595 elsif (@TestSuiteResultLines[$x] =~ m/^FAIL:/) {
596 $Fails .= "$TestSuiteResultLines[$x]\n";
598 elsif (@TestSuiteResultLines[$x] =~ m/^XFAIL:/) {
599 $XFails .= "$TestSuiteResultLines[$x]\n";
603 return ($SSProgs, $MSProgs, $ExtProgs, $All, $Passes, $Fails, $XFails);
606 ##############################################################
608 # Initialize filenames
610 ##############################################################
612 if (! -d $WebDir) {
613 mkdir $WebDir, 0777 or die "Unable to create web directory: '$WebDir'.";
614 if($VERBOSE){
615 warn "$WebDir did not exist; creating it.\n";
619 if ($CONFIG_PATH ne "") {
620 $ConfigMode = 1;
621 $LLVMSrcDir = GetRegex "^(.*)\\s+", `$CONFIG_PATH --src-root`;
622 $LLVMObjDir = GetRegex "^(.*)\\s+", `$CONFIG_PATH --obj-root`;
623 # FIXME: Add llvm-config hook for this?
624 $LLVMTestDir = $LLVMObjDir . "/projects/test-suite";
625 } else {
626 $ConfigureLog = "$Prefix-Configure-Log.txt";
627 $BuildLog = "$Prefix-Build-Log.txt";
628 $COLog = "$Prefix-CVS-Log.txt";
631 if ($VERBOSE) {
632 if ($CONFIG_PATH ne "") {
633 print "INITIALIZED (config mode)\n";
634 print "WebDir = $WebDir\n";
635 print "Prefix = $Prefix\n";
636 print "LLVM Src = $LLVMSrcDir\n";
637 print "LLVM Obj = $LLVMObjDir\n";
638 print "LLVM Test = $LLVMTestDir\n";
639 } else {
640 print "INITIALIZED\n";
641 print "SVN URL = $SVNURL\n";
642 print "COLog = $COLog\n";
643 print "BuildDir = $BuildDir\n";
644 print "WebDir = $WebDir\n";
645 print "Prefix = $Prefix\n";
646 print "BuildLog = $BuildLog\n";
650 ##############################################################
652 # The actual NewNightlyTest logic.
654 ##############################################################
656 $starttime = `date "+20%y-%m-%d %H:%M:%S"`;
658 my $BuildError = 0, $BuildStatus = "OK";
659 if ($ConfigMode == 0) {
660 if (!$NOCHECKOUT) {
661 CheckoutSource();
664 # Build LLVM.
665 ChangeDir( $LLVMSrcDir , "llvm source directory") ;
666 if ($NOCHECKOUT || $NOBUILD) {
667 $BuildStatus = "Skipped by user";
668 } else {
669 if (!BuildLLVM()) {
670 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
671 $BuildError = 1;
672 $BuildStatus = "Error: compilation aborted";
677 # Run the llvm-test tests.
678 my ($SingleSourceProgramsTable, $MultiSourceProgramsTable, $ExternalProgramsTable,
679 $all_tests, $passes, $fails, $xfails) = "";
680 if (!$NOTEST && !$BuildError) {
681 ($SingleSourceProgramsTable, $MultiSourceProgramsTable, $ExternalProgramsTable,
682 $all_tests, $passes, $fails, $xfails) = RunNightlyTest();
685 $endtime = `date "+20%y-%m-%d %H:%M:%S"`;
687 # The last bit of logic is to remove the build and web dirs, after sending data
688 # to the server.
690 ##############################################################
692 # Accumulate the information to send to the server.
694 ##############################################################
696 if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
698 if ( ! $NOUNAME ) {
699 $machine_data = "uname: ".`uname -a`.
700 "hardware: ".`uname -m`.
701 "os: ".`uname -sr`.
702 "name: ".`uname -n`.
703 "date: ".`date \"+20%y-%m-%d\"`.
704 "time: ".`date +\"%H:%M:%S\"`;
705 } else {
706 $machine_data = "uname: (excluded)\n".
707 "hardware: ".`uname -m`.
708 "os: ".`uname -sr`.
709 "name: $nickname\n".
710 "date: ".`date \"+20%y-%m-%d\"`.
711 "time: ".`date +\"%H:%M:%S\"`;
714 # Get gcc version.
715 my $gcc_version_long = "";
716 if ($GCCPATH ne "") {
717 $gcc_version_long = `$GCCPATH/gcc --version`;
718 } elsif ($ENV{"CC"}) {
719 $gcc_version_long = `$ENV{"CC"} --version`;
720 } else {
721 $gcc_version_long = `gcc --version`;
723 my $gcc_version = (split '\n', $gcc_version_long)[0];
725 # Get llvm-gcc target triple.
727 # FIXME: This shouldn't be hardwired to llvm-gcc.
728 my $llvmgcc_version_long = "";
729 if ($LLVMGCCPATH ne "") {
730 $llvmgcc_version_long = `$LLVMGCCPATH/llvm-gcc -v 2>&1`;
731 } else {
732 $llvmgcc_version_long = `llvm-gcc -v 2>&1`;
734 (split '\n', $llvmgcc_version_long)[1] =~ /Target: (.+)/;
735 my $targetTriple = $1;
737 # Logs.
738 my ($ConfigureLogData, $BuildLogData, $CheckoutLogData) = "";
739 if ($ConfigMode == 0) {
740 $ConfigureLogData = ReadFile $ConfigureLog;
741 $BuildLogData = ReadFile $BuildLog;
742 $CheckoutLogData = ReadFile $COLog;
745 # Checkout info.
746 my $CheckoutTime_Wall = GetRegex "^real ([0-9.]+)", $CheckoutLogData;
747 my $CheckoutTime_User = GetRegex "^user ([0-9.]+)", $CheckoutLogData;
748 my $CheckoutTime_Sys = GetRegex "^sys ([0-9.]+)", $CheckoutLogData;
749 my $CheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
751 # Configure info.
752 my $ConfigTimeU = GetRegex "^user ([0-9.]+)", $ConfigureLogData;
753 my $ConfigTimeS = GetRegex "^sys ([0-9.]+)", $ConfigureLogData;
754 my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
755 my $ConfigWallTime = GetRegex "^real ([0-9.]+)",$ConfigureLogData;
756 $ConfigTime=-1 unless $ConfigTime;
757 $ConfigWallTime=-1 unless $ConfigWallTime;
759 # Build info.
760 my $BuildTimeU = GetRegex "^user ([0-9.]+)", $BuildLogData;
761 my $BuildTimeS = GetRegex "^sys ([0-9.]+)", $BuildLogData;
762 my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
763 my $BuildWallTime = GetRegex "^real ([0-9.]+)", $BuildLogData;
764 $BuildTime=-1 unless $BuildTime;
765 $BuildWallTime=-1 unless $BuildWallTime;
767 if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
769 my %hash_of_data = (
770 'machine_data' => $machine_data,
771 'build_data' => $ConfigureLogData . $BuildLogData,
772 'gcc_version' => $gcc_version,
773 'nickname' => $nickname,
774 'dejagnutime_wall' => "0.0",
775 'dejagnutime_cpu' => "0.0",
776 'cvscheckouttime_wall' => $CheckoutTime_Wall,
777 'cvscheckouttime_cpu' => $CheckoutTime_CPU,
778 'configtime_wall' => $ConfigWallTime,
779 'configtime_cpu'=> $ConfigTime,
780 'buildtime_wall' => $BuildWallTime,
781 'buildtime_cpu' => $BuildTime,
782 'buildstatus' => $BuildStatus,
783 'singlesource_programstable' => $SingleSourceProgramsTable,
784 'multisource_programstable' => $MultiSourceProgramsTable,
785 'externalsource_programstable' => $ExternalProgramsTable,
786 'llcbeta_options' => $llcbeta_options,
787 'passing_tests' => $passes,
788 'expfail_tests' => $xfails,
789 'unexpfail_tests' => $fails,
790 'all_tests' => $all_tests,
791 'dejagnutests_results' => "Dejagnu skipped by user choice.",
792 'dejagnutests_log' => "",
793 'starttime' => $starttime,
794 'endtime' => $endtime,
795 'target_triple' => $targetTriple,
797 # Unused, but left around for backwards compatability.
798 'warnings' => "",
799 'cvsusercommitlist' => "",
800 'cvsuserupdatelist' => "",
801 'cvsaddedfiles' => "",
802 'cvsmodifiedfiles' => "",
803 'cvsremovedfiles' => "",
804 'lines_of_code' => "",
805 'cvs_file_count' => 0,
806 'cvs_dir_count' => 0,
807 'warnings_removed' => "",
808 'warnings_added' => "",
809 'new_tests' => "",
810 'removed_tests' => "",
811 'o_file_sizes' => "",
812 'a_file_sizes' => ""
815 # Write out the "...-sentdata.txt" file.
816 WriteSentData \%hash_of_data;
818 if ($SUBMIT || !($SUBMITAUX eq "")) {
819 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
820 if( $VERBOSE) { print "============================\n$response"; }
821 } else {
822 print "============================\n";
823 foreach $x(keys %hash_of_data){
824 print "$x => $hash_of_data{$x}\n";
828 ##############################################################
830 # Remove the source tree...
832 ##############################################################
833 system ( "$NICE rm -rf $BuildDir")
834 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVEATEND);
835 system ( "$NICE rm -rf $WebDir")
836 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);