2 use POSIX qw(strftime);
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]
17 # OPTIONS may include one or more of the following:
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
25 # -nickname NAME The NAME argument specifieds the nickname this script
26 # will submit to the nightlytest results repository.
27 # -submit-server Specifies a server to submit the test results too. If this
28 # option is not specified it defaults to
29 # llvm.org. This is basically just the address of the
31 # -submit-script Specifies which script to call on the submit server. If
32 # this option is not specified it defaults to
33 # /nightlytest/NightlyTestAccept.php. This is basically
34 # everything after the www.yourserver.org.
35 # -submit-aux If specified, an auxiliary script to run in addition to the
36 # normal submit script. The script will be passed the path to
37 # the "sentdata.txt" file as its sole argument.
38 # -nosubmit Do not report the test results back to a submit server.
41 # BUILD OPTIONS (not used with -config):
42 # -nocheckout Do not create, checkout, update, or configure
44 # -noremove Do not remove the BUILDDIR after it has been built.
45 # -noremoveresults Do not remove the WEBDIR after it has been built.
46 # -nobuild Do not build llvm. If tests are enabled perform them
47 # on the llvm build specified in the build directory
48 # -release Build an LLVM Release version
49 # -release-asserts Build an LLVM ReleaseAsserts version
50 # -disable-bindings Disable building LLVM bindings.
51 # -with-clang Checkout Clang source into tools/clang.
52 # -compileflags Next argument specifies extra options passed to make when
54 # -use-gmake Use gmake instead of the default make command to build
58 # -notest Do not even attempt to run the test programs.
59 # -nodejagnu Do not run feature or regression tests
60 # -enable-llcbeta Enable testing of beta features in llc.
61 # -enable-lli Enable testing of lli (interpreter) features, default is off
62 # -disable-pic Disable building with Position Independent Code.
63 # -disable-llc Disable LLC tests in the nightly tester.
64 # -disable-jit Disable JIT tests in the nightly tester.
65 # -disable-cbe Disable C backend tests in the nightly tester.
66 # -disable-lto Disable link time optimization.
67 # -test-cflags Next argument specifies that C compilation options that
68 # override the default when running the testsuite.
69 # -test-cxxflags Next argument specifies that C++ compilation options that
70 # override the default when running the testsuite.
71 # -extraflags Next argument specifies extra options that are passed to
73 # -noexternals Do not run the external tests (for cases where povray
74 # or SPEC are not installed)
75 # -with-externals Specify a directory where the external tests are located.
78 # -parallel Run parallel jobs with GNU Make (see -parallel-jobs).
79 # -parallel-jobs The number of parallel Make jobs to use (default is two).
80 # -verbose Turn on some debug output
81 # -nice Checkout/Configure/Build with "nice" to reduce impact
83 # -f2c Next argument specifies path to F2C utility
84 # -gccpath Path to gcc/g++ used to build LLVM
85 # -target Specify the target triplet
86 # -cflags Next argument specifies that C compilation options that
87 # override the default.
88 # -cxxflags Next argument specifies that C++ compilation options that
89 # override the default.
90 # -ldflags Next argument specifies that linker options that override
93 # CVSROOT is ignored, it is passed for backwards compatibility.
94 # BUILDDIR is the directory where sources for this test run will be checked out
95 # AND objects for this test run will be built. This directory MUST NOT
96 # exist before the script is run; it will be created by the svn checkout
97 # process and erased (unless -noremove is specified; see above.)
98 # WEBDIR is the directory into which the test results web page will be written,
99 # AND in which the "index.html" is assumed to be a symlink to the most recent
100 # copy of the results. This directory will be created if it does not exist.
101 # LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
102 # to. This is the same as you would have for a normal LLVM build.
104 ##############################################################
106 # Getting environment variables
108 ##############################################################
109 my $HOME = $ENV{'HOME'};
110 my $SVNURL = $ENV{"SVNURL"};
111 $SVNURL = 'http://llvm.org/svn/llvm-project' unless $SVNURL;
112 my $TestSVNURL = $ENV{"TestSVNURL"};
113 $TestSVNURL = 'http://llvm.org/svn/llvm-project' unless $TestSVNURL;
114 my $BuildDir = $ENV{'BUILDDIR'};
115 my $WebDir = $ENV{'WEBDIR'};
117 my $LLVMSrcDir = $ENV{'LLVMSRCDIR'};
118 $LLVMSrcDir = "$BuildDir/llvm" unless $LLVMSrcDir;
119 my $LLVMObjDir = $ENV{'LLVMOBJDIR'};
120 $LLVMObjDir = "$BuildDir/llvm" unless $LLVMObjDir;
121 my $LLVMTestDir = $ENV{'LLVMTESTDIR'};
122 $LLVMTestDir = "$BuildDir/llvm/projects/llvm-test" unless $LLVMTestDir;
124 ##############################################################
126 # Calculate the date prefix...
128 ##############################################################
130 my $DATE = sprintf "%4d-%02d-%02d_%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3], $TIME[1], $TIME[0];
132 ##############################################################
136 ##############################################################
142 $SUBMITSERVER = "llvm.org";
143 $SUBMITSCRIPT = "/nightlytest/NightlyTestAccept.php";
149 while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
151 last if /^--$/; # Stop processing arguments on --
153 # List command line options here...
154 if (/^-config$/) { $CONFIG_PATH = "$ARGV[0]"; shift; next; }
155 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
156 if (/^-noremove$/) { $NOREMOVE = 1; next; }
157 if (/^-noremoveatend$/) { $NOREMOVEATEND = 1; next; }
158 if (/^-noremoveresults$/){ $NOREMOVERESULTS = 1; next; }
159 if (/^-notest$/) { $NOTEST = 1; next; }
160 if (/^-norunningtests$/) { next; } # Backward compatibility, ignored.
161 if (/^-parallel-jobs$/) { $PARALLELJOBS = "$ARGV[0]"; shift; next;}
162 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j$PARALLELJOBS -l3.0"; next; }
163 if (/^-with-clang$/) { $WITHCLANG = 1; next; }
164 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
165 "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
166 if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
167 "DISABLE_ASSERTIONS=1 ".
168 "OPTIMIZE_OPTION=-O2";
169 $BUILDTYPE="release-asserts"; next;}
170 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
171 if (/^-disable-pic$/) { $CONFIGUREARGS .= " --enable-pic=no"; next; }
172 if (/^-enable-lli$/) { $PROGTESTOPTS .= " ENABLE_LLI=1";
173 $CONFIGUREARGS .= " --enable-lli"; next; }
174 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
175 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
176 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
177 $CONFIGUREARGS .= " --disable-jit"; next; }
178 if (/^-disable-bindings$/) { $CONFIGUREARGS .= " --disable-bindings"; next; }
179 if (/^-disable-cbe$/) { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
180 if (/^-disable-lto$/) { $PROGTESTOPTS .= " DISABLE_LTO=1"; next; }
181 if (/^-test-opts$/) { $PROGTESTOPTS .= " $ARGV[0]"; shift; next; }
182 if (/^-verbose$/) { $VERBOSE = 1; next; }
183 if (/^-teelogs$/) { $TEELOGS = 1; next; }
184 if (/^-nice$/) { $NICE = "nice "; next; }
185 if (/^-f2c$/) { $CONFIGUREARGS .= " --with-f2c=$ARGV[0]";
187 if (/^-with-externals$/) { $CONFIGUREARGS .= " --with-externals=$ARGV[0]";
189 if (/^-configure-args$/) { $CONFIGUREARGS .= " $ARGV[0]";
191 if (/^-submit-server/) { $SUBMITSERVER = "$ARGV[0]"; shift; next; }
192 if (/^-submit-script/) { $SUBMITSCRIPT = "$ARGV[0]"; shift; next; }
193 if (/^-submit-aux/) { $SUBMITAUX = "$ARGV[0]"; shift; next; }
194 if (/^-nosubmit$/) { $SUBMIT = 0; next; }
195 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
196 if (/^-gccpath/) { $CONFIGUREARGS .=
197 " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++";
198 $GCCPATH=$ARGV[0]; shift; next; }
199 else { $GCCPATH=""; }
200 if (/^-target/) { $CONFIGUREARGS .= " --target=$ARGV[0]";
202 if (/^-cflags/) { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'";
204 if (/^-cxxflags/) { $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'";
206 if (/^-ldflags/) { $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'";
208 if (/^-test-cflags/) { $TESTFLAGS = "$TESTFLAGS CFLAGS=\'$ARGV[0]\'";
210 if (/^-test-cxxflags/) { $TESTFLAGS = "$TESTFLAGS CXXFLAGS=\'$ARGV[0]\'";
212 if (/^-compileflags/) { $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next; }
213 if (/^-use-gmake/) { $MAKECMD = "gmake"; shift; next; }
214 if (/^-extraflags/) { $CONFIGUREARGS .=
215 " --with-extra-options=\'$ARGV[0]\'"; shift; next;}
216 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
217 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
218 if (/^-nobuild$/) { $NOBUILD = 1; next; }
219 print "Unknown option: $_ : ignoring!\n";
222 if ($ENV{'LLVMGCCDIR'}) {
223 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
224 $LLVMGCCPATH = $ENV{'LLVMGCCDIR'} . '/bin';
230 if ($CONFIGUREARGS !~ /--disable-jit/) {
231 $CONFIGUREARGS .= " --enable-jit";
234 if (@ARGV != 0 and @ARGV != 3) {
235 die "error: must specify 0 or 3 options!";
239 if ($CONFIG_PATH ne "") {
240 die "error: arguments are unsupported in -config mode,";
243 # ARGV[0] used to be the CVS root, ignored for backward compatibility.
244 $BuildDir = $ARGV[1];
248 if ($BuildDir eq "" or
250 die("please specify a build directory, and a web directory");
253 if ($nickname eq "") {
254 die ("Please invoke NewNightlyTest.pl with command line option " .
255 "\"-nickname <nickname>\"");
258 if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
259 $BUILDTYPE = "debug";
262 if ($CONFIG_PATH ne "") {
263 die "error: -config mode is not yet implemented,";
266 ##############################################################
268 # Define the file names we'll use
270 ##############################################################
271 my $Prefix = "$WebDir/$DATE";
272 my $BuildLog = "$Prefix-Build-Log.txt";
273 my $COLog = "$Prefix-CVS-Log.txt";
274 my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
275 my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
276 my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
277 my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
278 my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
279 my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
281 mkdir $WebDir, 0777 or die "Unable to create web directory: '$WebDir'.";
283 warn "$WebDir did not exist; creating it.\n";
288 print "INITIALIZED\n";
289 print "SVN URL = $SVNURL\n";
290 print "COLog = $COLog\n";
291 print "BuildDir = $BuildDir\n";
292 print "WebDir = $WebDir\n";
293 print "Prefix = $Prefix\n";
294 print "BuildLog = $BuildLog\n";
297 ##############################################################
301 ##############################################################
306 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
311 sub RunLoggedCommand {
318 print "$Command 2>&1 | tee $Log\n";
320 system "$Command 2>&1 | tee $Log";
324 print "$Command 2>&1 > $Log\n";
326 system "$Command 2>&1 > $Log";
330 sub RunAppendingLoggedCommand {
337 print "$Command 2>&1 | tee -a $Log\n";
339 system "$Command 2>&1 | tee -a $Log";
343 print "$Command 2>&1 > $Log\n";
345 system "$Command 2>&1 >> $Log";
349 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
350 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
351 sub GetRegex { # (Regex with ()'s, value)
358 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
359 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
361 my ($Regex, $Num, $Regex2, $File) = @_;
362 my @Items = split "\n", `grep '$Regex' $File`;
363 return GetRegex $Regex2, $Items[$Num];
366 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
367 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
368 sub ChangeDir { # directory, logical name
369 my ($dir,$name) = @_;
371 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
372 $result = chdir($dir);
374 print "ERROR!!! Cannot change directory to: $name ($dir) because $!";
380 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
381 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
383 if (open (FILE, $_[0])) {
390 print "Could not open file '$_[0]' for reading!\n";
395 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
396 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
397 sub WriteFile { # (filename, contents)
398 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!\n";
403 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
404 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
405 sub CopyFile { #filename, newfile
406 my ($file, $newfile) = @_;
408 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
409 copy($file, $newfile);
412 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
413 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
415 my ($Val, $Filename,$WebDir) = @_;
417 if (open FILE, "$WebDir/$Filename") {
418 @Records = grep !/$DATE/, split "\n", <FILE>;
421 push @Records, "$DATE: $Val";
422 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
425 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
427 # FormatTime - Convert a time from 1m23.45 into 83.45
429 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
432 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
433 $Time = sprintf("%7.4f", $1*60.0+$2);
438 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
440 # This function is meant to read in the dejagnu sum file and
441 # return a string with only the results (i.e. PASS/FAIL/XPASS/
444 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
445 sub GetDejagnuTestResults { # (filename, log)
446 my ($filename, $DejagnuLog) = @_;
448 $/ = "\n"; #Make sure we're going line at a time.
450 if( $VERBOSE) { print "DEJAGNU TEST RESULTS:\n"; }
452 if (open SRCHFILE, $filename) {
453 # Process test results
454 while ( <SRCHFILE> ) {
455 if ( length($_) > 1 ) {
457 if ( m/^(PASS|XPASS|FAIL|XFAIL): .*\/llvm\/test\/(.*)$/ ) {
458 push(@lines, "$1: test/$2");
465 my $content = join("\n", @lines);
471 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
473 # This function acts as a mini web browswer submitting data
474 # to our central server via the post method
476 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
482 # Write out the "...-sentdata.txt" file.
485 foreach $x (keys (%$variables)){
486 $value = $variables->{$x};
487 $sentdata.= "$x => $value\n";
489 WriteFile "$Prefix-sentdata.txt", $sentdata;
491 if (!($SUBMITAUX eq "")) {
492 system "$SUBMITAUX \"$Prefix-sentdata.txt\"";
496 return "Skipped standard submit.\n";
499 # Create the content to send to the server.
502 foreach $key (keys (%$variables)){
503 $value = $variables->{$key};
504 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
505 $content .= "$key=$value&";
508 # Send the data to the server.
510 # FIXME: This code should be more robust?
513 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
514 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or
516 connect SOCK, $socketaddr or die "Bad connection\n";
517 select((select(SOCK), $| = 1)[0]);
519 $length = length($content);
521 my $send= "POST $file HTTP/1.0\n";
522 $send.= "Host: $host\n";
523 $send.= "Content-Type: application/x-www-form-urlencoded\n";
524 $send.= "Content-length: $length\n\n";
537 ##############################################################
539 # Getting Start timestamp
541 ##############################################################
542 $starttime = `date "+20%y-%m-%d %H:%M:%S"`;
544 ##############################################################
546 # Create the source repository directory
548 ##############################################################
553 print "Build directory exists! Removing it\n";
555 system "rm -rf $BuildDir";
556 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
559 print "Build directory exists!\n";
563 mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
568 ##############################################################
570 # Check out the llvm tree with SVN
572 ##############################################################
574 ChangeDir( $BuildDir, "checkout directory" );
575 my $SVNCMD = "$NICE svn co --non-interactive $SVNURL";
576 my $SVNCMD2 = "$NICE svn co --non-interactive $TestSVNURL";
577 RunLoggedCommand("( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
578 "$SVNCMD2/test-suite/trunk llvm-test )", $COLog,
581 my $SVNCMD = "$NICE svn co --non-interactive $SVNURL/cfe/trunk";
582 RunLoggedCommand("( time -p cd llvm/tools ; $SVNCMD clang )", $COLog,
586 ChangeDir( $LLVMSrcDir , "llvm source directory") ;
588 ##############################################################
590 # Get some static statistics about the current source code
592 # This can probably be put on the server side
594 ##############################################################
595 my $CheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $COLog`;
596 my $CheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $COLog`;
597 my $CheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $COLog`;
598 my $CheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
600 ##############################################################
602 # Build the entire tree, saving build messages to the build log
604 ##############################################################
605 if (!$NOCHECKOUT && !$NOBUILD) {
606 my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
607 RunLoggedCommand("(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) ",
608 $BuildLog, "CONFIGURE");
609 # Build the entire tree, capturing the output into $BuildLog
610 RunAppendingLoggedCommand("(time -p $NICE $MAKECMD clean)", $BuildLog, "BUILD CLEAN");
611 RunAppendingLoggedCommand("(time -p $NICE $MAKECMD $MAKEOPTS)", $BuildLog, "BUILD");
614 ##############################################################
616 # Get some statistics about the build...
618 ##############################################################
620 # Get the time taken by the configure script
621 my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
622 my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
623 my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
624 my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
626 $ConfigTime=-1 unless $ConfigTime;
627 $ConfigWallTime=-1 unless $ConfigWallTime;
629 my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
630 my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
631 my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
632 my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
634 $BuildTime=-1 unless $BuildTime;
635 $BuildWallTime=-1 unless $BuildWallTime;
637 my $BuildError = 0, $BuildStatus = "OK";
639 $BuildStatus = "Skipped by user";
641 elsif (`grep '^$MAKECMD\[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
642 `grep '^$MAKECMD: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
643 $BuildStatus = "Error: compilation aborted";
645 if( $VERBOSE) { print "\n***ERROR BUILDING TREE\n\n"; }
647 if ($BuildError) { $NODEJAGNU=1; }
649 ##############################################################
651 # Running dejagnu tests
653 ##############################################################
654 my $DejangnuTestResults=""; # String containing the results of the dejagnu
655 my $dejagnu_output = "$DejagnuTestsLog";
657 #Run the feature and regression tests, results are put into testrun.sum
658 #Full log in testrun.log
659 RunLoggedCommand("(time -p $MAKECMD $MAKEOPTS check)", $dejagnu_output, "DEJAGNU");
661 #Copy the testrun.log and testrun.sum to our webdir
662 CopyFile("test/testrun.log", $DejagnuLog);
663 CopyFile("test/testrun.sum", $DejagnuSum);
664 #can be done on server
665 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
666 $unexpfail_tests = $DejagnuTestResults;
669 #Extract time of dejagnu tests
670 my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
671 my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
672 $DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
673 $DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
674 $DejagnuTestResults =
675 "Dejagnu skipped by user choice." unless $DejagnuTestResults;
676 $DejagnuTime = "0.0" unless $DejagnuTime;
677 $DejagnuWallTime = "0.0" unless $DejagnuWallTime;
680 if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
683 ##############################################################
685 # If we built the tree successfully, run the nightly programs tests...
687 # A set of tests to run is passed in (i.e. "SingleSource" "MultiSource"
690 ##############################################################
694 ChangeDir( "$LLVMTestDir/$SubDir",
695 "Programs Test Subdirectory" ) || return ("", "");
697 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
699 # Run the programs tests... creating a report.nightly.csv file
702 print "$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
703 "$TESTFLAGS TEST=nightly > $ProgramTestLog 2>&1\n";
705 RunLoggedCommand("$MAKECMD -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv ".
706 "$TESTFLAGS TEST=nightly",
707 $ProgramTestLog, "TEST DIRECTORY $SubDir");
708 $llcbeta_options=`$MAKECMD print-llcbeta-option`;
712 if (`grep '^$MAKECMD\[^:]: .*Error' $ProgramTestLog | wc -l` + 0) {
714 $ProgramsTable="Error running test $SubDir\n";
715 print "ERROR TESTING\n";
716 } elsif (`grep '^$MAKECMD\[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
718 $ProgramsTable="Makefile error running tests $SubDir!\n";
719 print "ERROR TESTING\n";
723 # Create a list of the tests which were run...
725 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog ".
726 "| sort > $Prefix-$SubDir-Tests.txt";
728 $ProgramsTable = ReadFile "report.nightly.csv";
730 ChangeDir( "../../..", "Programs Test Parent Directory" );
731 return ($ProgramsTable, $llcbeta_options);
732 } #end sub TestDirectory
734 ##############################################################
736 # Calling sub TestDirectory
738 ##############################################################
740 ($SingleSourceProgramsTable, $llcbeta_options) =
741 TestDirectory("SingleSource");
742 WriteFile "$Prefix-SingleSource-Performance.txt", $SingleSourceProgramsTable;
743 ($MultiSourceProgramsTable, $llcbeta_options) = TestDirectory("MultiSource");
744 WriteFile "$Prefix-MultiSource-Performance.txt", $MultiSourceProgramsTable;
745 if ( ! $NOEXTERNALS ) {
746 ($ExternalProgramsTable, $llcbeta_options) = TestDirectory("External");
747 WriteFile "$Prefix-External-Performance.txt", $ExternalProgramsTable;
748 system "cat $Prefix-SingleSource-Tests.txt " .
749 "$Prefix-MultiSource-Tests.txt ".
750 "$Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
751 system "cat $Prefix-SingleSource-Performance.txt " .
752 "$Prefix-MultiSource-Performance.txt ".
753 "$Prefix-External-Performance.txt | sort > $Prefix-Performance.txt";
755 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
757 print "External TEST STAGE SKIPPED\n";
759 system "cat $Prefix-SingleSource-Tests.txt " .
760 "$Prefix-MultiSource-Tests.txt ".
761 " | sort > $Prefix-Tests.txt";
762 system "cat $Prefix-SingleSource-Performance.txt " .
763 "$Prefix-MultiSource-Performance.txt ".
764 " | sort > $Prefix-Performance.txt";
767 ##############################################################
770 # gathering tests added removed broken information here
773 ##############################################################
774 my $dejagnu_test_list = ReadFile "$Prefix-Tests.txt";
775 my @DEJAGNU = split "\n", $dejagnu_test_list;
776 my ($passes, $fails, $xfails) = "";
779 for ($x=0; $x<@DEJAGNU; $x++) {
780 if ($DEJAGNU[$x] =~ m/^PASS:/) {
781 $passes.="$DEJAGNU[$x]\n";
783 elsif ($DEJAGNU[$x] =~ m/^FAIL:/) {
784 $fails.="$DEJAGNU[$x]\n";
786 elsif ($DEJAGNU[$x] =~ m/^XFAIL:/) {
787 $xfails.="$DEJAGNU[$x]\n";
792 } #end if !$BuildError
794 ##############################################################
796 # Getting end timestamp
798 ##############################################################
799 $endtime = `date "+20%y-%m-%d %H:%M:%S"`;
802 ##############################################################
804 # Place all the logs neatly into one humungous file
806 ##############################################################
807 if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
809 $machine_data = "uname: ".`uname -a`.
810 "hardware: ".`uname -m`.
813 "date: ".`date \"+20%y-%m-%d\"`.
814 "time: ".`date +\"%H:%M:%S\"`;
818 @CVS_DATA = ReadFile "$COLog";
819 $cvs_data = join("\n", @CVS_DATA);
823 @BUILD_DATA = ReadFile "$BuildLog";
824 $build_data = join("\n", @BUILD_DATA);
826 my (@DEJAGNU_LOG, @DEJAGNU_SUM, @DEJAGNULOG_FULL, @GCC_VERSION);
827 my ($dejagnutests_log ,$dejagnutests_sum, $dejagnulog_full) = "";
828 my ($gcc_version, $gcc_version_long) = "";
830 $gcc_version_long="";
831 if ($GCCPATH ne "") {
832 $gcc_version_long = `$GCCPATH/gcc --version`;
833 } elsif ($ENV{"CC"}) {
834 $gcc_version_long = `$ENV{"CC"} --version`;
836 $gcc_version_long = `gcc --version`;
838 @GCC_VERSION = split '\n', $gcc_version_long;
839 $gcc_version = $GCC_VERSION[0];
841 $llvmgcc_version_long="";
842 if ($LLVMGCCPATH ne "") {
843 $llvmgcc_version_long = `$LLVMGCCPATH/llvm-gcc -v 2>&1`;
845 $llvmgcc_version_long = `llvm-gcc -v 2>&1`;
847 @LLVMGCC_VERSION = split '\n', $llvmgcc_version_long;
848 $llvmgcc_versionTarget = $LLVMGCC_VERSION[1];
849 $llvmgcc_versionTarget =~ /Target: (.+)/;
853 @DEJAGNU_LOG = ReadFile "$DejagnuLog";
854 @DEJAGNU_SUM = ReadFile "$DejagnuSum";
855 $dejagnutests_log = join("\n", @DEJAGNU_LOG);
856 $dejagnutests_sum = join("\n", @DEJAGNU_SUM);
858 @DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
859 $dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
862 ##############################################################
864 # Send data via a post request
866 ##############################################################
868 if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
871 'machine_data' => $machine_data,
872 'build_data' => $build_data,
873 'gcc_version' => $gcc_version,
874 'nickname' => $nickname,
875 'dejagnutime_wall' => $DejagnuWallTime,
876 'dejagnutime_cpu' => $DejagnuTime,
877 'cvscheckouttime_wall' => $CheckoutTime_Wall,
878 'cvscheckouttime_cpu' => $CheckoutTime_CPU,
879 'configtime_wall' => $ConfigWallTime,
880 'configtime_cpu'=> $ConfigTime,
881 'buildtime_wall' => $BuildWallTime,
882 'buildtime_cpu' => $BuildTime,
884 'cvsusercommitlist' => "",
885 'cvsuserupdatelist' => "",
886 'cvsaddedfiles' => "",
887 'cvsmodifiedfiles' => "",
888 'cvsremovedfiles' => "",
889 'lines_of_code' => "",
890 'cvs_file_count' => 0,
891 'cvs_dir_count' => 0,
892 'buildstatus' => $BuildStatus,
893 'singlesource_programstable' => $SingleSourceProgramsTable,
894 'multisource_programstable' => $MultiSourceProgramsTable,
895 'externalsource_programstable' => $ExternalProgramsTable,
896 'llcbeta_options' => $multisource_llcbeta_options,
897 'warnings_removed' => "",
898 'warnings_added' => "",
899 'passing_tests' => $passes,
900 'expfail_tests' => $xfails,
901 'unexpfail_tests' => $fails,
902 'all_tests' => $dejagnu_test_list,
904 'removed_tests' => "",
905 'dejagnutests_results' => $DejagnuTestResults,
906 'dejagnutests_log' => $dejagnulog_full,
907 'starttime' => $starttime,
908 'endtime' => $endtime,
909 'o_file_sizes' => "",
910 'a_file_sizes' => "",
911 'target_triple' => $targetTriple
914 if ($SUBMIT || !($SUBMITAUX eq "")) {
915 my $response = SendData $SUBMITSERVER,$SUBMITSCRIPT,\%hash_of_data;
916 if( $VERBOSE) { print "============================\n$response"; }
918 print "============================\n";
919 foreach $x(keys %hash_of_data){
920 print "$x => $hash_of_data{$x}\n";
924 ##############################################################
926 # Remove the source tree...
928 ##############################################################
929 system ( "$NICE rm -rf $BuildDir")
930 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVEATEND);
931 system ( "$NICE rm -rf $WebDir")
932 if (!$NOCHECKOUT and !$NOREMOVE and !$NOREMOVERESULTS);