blob: 10a8810784b1f2e0673f4e5a3aa7f581f7611f61 [file] [log] [blame]
Patrick Jenkins0e316b42006-07-06 21:19:32 +00001#!/usr/bin/perl
2
3use POSIX qw(strftime);
4use File::Copy;
5use 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
12# regressions and performance changes. Submits this information
13# to llvm.org where it is placed into the nightlytestresults database.
14#
15# Modified heavily by Patrick Jenkins, July 2006
16#
17# Syntax: NightlyTest.pl [OPTIONS] [CVSROOT BUILDDIR WEBDIR]
18# where
19# OPTIONS may include one or more of the following:
20# -nocheckout Do not create, checkout, update, or configure
21# the source tree.
22# -noremove Do not remove the BUILDDIR after it has been built.
Patrick Jenkins5053e152006-07-07 17:31:38 +000023# -noremoveresults Do not remove the WEBDIR after it has been built.
Patrick Jenkins0e316b42006-07-06 21:19:32 +000024# -nobuild Do not build llvm. If tests are enabled perform them
25# on the llvm build specified in the build directory
26# -notest Do not even attempt to run the test programs. Implies
27# -norunningtests.
28# -norunningtests Do not run the Olden benchmark suite with
29# LARGE_PROBLEM_SIZE enabled.
Patrick Jenkins0e316b42006-07-06 21:19:32 +000030# -nodejagnu Do not run feature or regression tests
31# -parallel Run two parallel jobs with GNU Make.
32# -release Build an LLVM Release version
33# -enable-llcbeta Enable testing of beta features in llc.
34# -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.
37# -verbose Turn on some debug output
38# -debug Print information useful only to maintainers of this script.
39# -nice Checkout/Configure/Build with "nice" to reduce impact
40# on busy servers.
41# -f2c Next argument specifies path to F2C utility
42# -nickname The next argument specifieds the nickname this script
43# will submit to the nightlytest results repository.
44# -gccpath Path to gcc/g++ used to build LLVM
45# -cvstag Check out a specific CVS tag to build LLVM (useful for
46# testing release branches)
47# -target Specify the target triplet
48# -cflags Next argument specifies that C compilation options that
49# override the default.
50# -cxxflags Next argument specifies that C++ compilation options that
51# override the default.
52# -ldflags Next argument specifies that linker options that override
53# the default.
Patrick Jenkinsf976a5c2006-07-07 18:50:51 +000054# -compileflags Next argument specifies extra options passed to make when
55# building LLVM.
Patrick Jenkins0e316b42006-07-06 21:19:32 +000056#
57# ---------------- Options to configure llvm-test ----------------------------
Patrick Jenkinsf976a5c2006-07-07 18:50:51 +000058# -extraflags Next argument specifies extra options that are passed to
59# compile the tests.
60# -noexternals Do not run the external tests (for cases where povray
61# or SPEC are not installed)
62# -with-externals Specify a directory where the external tests are located.
Patrick Jenkins0e316b42006-07-06 21:19:32 +000063#
64# CVSROOT is the CVS repository from which the tree will be checked out,
65# specified either in the full :method:user@host:/dir syntax, or
66# just /dir if using a local repo.
67# BUILDDIR is the directory where sources for this test run will be checked out
68# AND objects for this test run will be built. This directory MUST NOT
69# exist before the script is run; it will be created by the cvs checkout
70# process and erased (unless -noremove is specified; see above.)
71# WEBDIR is the directory into which the test results web page will be written,
72# AND in which the "index.html" is assumed to be a symlink to the most recent
73# copy of the results. This directory will be created if it does not exist.
74# LLVMGCCDIR is the directory in which the LLVM GCC Front End is installed
75# to. This is the same as you would have for a normal LLVM build.
76#
77##############################################################
78#
79# Getting environment variables
80#
81##############################################################
82my $HOME = $ENV{'HOME'};
83my $CVSRootDir = $ENV{'CVSROOT'};
84 $CVSRootDir = "/home/vadve/shared/PublicCVS"
85 unless $CVSRootDir;
86my $BuildDir = $ENV{'BUILDDIR'};
87 $BuildDir = "$HOME/buildtest"
88 unless $BuildDir;
89my $WebDir = $ENV{'WEBDIR'};
90 $WebDir = "$HOME/cvs/testresults-X86"
91 unless $WebDir;
92
93##############################################################
94#
95# Calculate the date prefix...
96#
97##############################################################
98@TIME = localtime;
99my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
100my $DateString = strftime "%B %d, %Y", localtime;
101my $TestStartTime = gmtime() . "GMT<br>" . localtime() . " (local)";
102
103##############################################################
104#
105# Parse arguments...
106#
107##############################################################
108$CONFIGUREARGS="";
109
110$NOTEST=0;
111$NORUNNINGTESTS=0;
112
113while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
114 shift;
115 last if /^--$/; # Stop processing arguments on --
116
117 # List command line options here...
118 if (/^-nocheckout$/) { $NOCHECKOUT = 1; next; }
119 if (/^-nocvsstats$/) { $NOCVSSTATS = 1; next; }
120 if (/^-noremove$/) { $NOREMOVE = 1; next; }
Patrick Jenkins5053e152006-07-07 17:31:38 +0000121 if (/^-noremoveresults$/) { $NOREMOVERESULTS = 1; next; }
Patrick Jenkins0e316b42006-07-06 21:19:32 +0000122 if (/^-notest$/) { $NOTEST = 1; $NORUNNINGTESTS = 1; next; }
123 if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
124 if (/^-parallel$/) { $MAKEOPTS = "$MAKEOPTS -j2 -l3.0"; next; }
125 if (/^-release$/) { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 OPTIMIZE_OPTION=-O2"; next; }
126 if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
127 if (/^-disable-llc$/) { $PROGTESTOPTS .= " DISABLE_LLC=1";
128 $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
129 if (/^-disable-jit$/) { $PROGTESTOPTS .= " DISABLE_JIT=1";
130 $CONFIGUREARGS .= " --disable-jit"; next; }
131 if (/^-verbose$/) { $VERBOSE = 1; next; }
132 if (/^-debug$/) { $DEBUG = 1; next; }
133 if (/^-nice$/) { $NICE = "nice "; next; }
134 if (/^-f2c$/) {
135 $CONFIGUREARGS .= " --with-f2c=$ARGV[0]"; shift; next;
136 }
137 if (/^-with-externals/) {
138 $CONFIGUREARGS .= "--with-externals=$ARGV[0]"; shift; next;
139 }
140 if (/^-nickname$/) { $nickname = "$ARGV[0]"; shift; next; }
141 if (/^-gccpath/) { $CONFIGUREARGS .= " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++"; shift; next;}
142 if (/^-cvstag/) { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; } else{ $CVSCOOPT="";}
143 if (/^-target/) {
144 $CONFIGUREARGS .= " --target=$ARGV[0]"; shift; next;
145 }
146 if (/^-cflags/) {
147 $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'"; shift; next;
148 }
149 if (/^-cxxflags/) {
150 $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'"; shift; next;
151 }
152 if (/^-ldflags/) {
153 $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'"; shift; next;
154 }
155 if (/^-compileflags/) {
156 $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next;
157 }
158 if (/^-extraflags/) {
159 $PROGTESTOPTS .= " EXTRA_FLAGS=\'$ARGV[0]\'"; shift; next;
160 }
161 if (/^-noexternals$/) { $NOEXTERNALS = 1; next; }
162 if (/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
163 if (/^-nobuild$/) { $NOBUILD = 1; next; }
164 if (/^-spec2000path$/) {
165 $LLVMTESTCONFIGARGS .= " --enable-spec2000=$ARGV[0]"; shift; next;
166 } else{ $LLVMTESTCONFIGARGS=""; }
167 if (/^-spec95path$/) {
168 $LLVMTESTCONFIGARGS .= " --enable-spec95=$ARGV[0]"; shift; next;
169 }
170 if (/^-povraypath$/) {
171 $LLVMTESTCONFIGARGS .= " --enable-povray=$ARGV[0]"; shift; next;
172 }
173 if (/^-namdpath$/) {
174 $LLVMTESTCONFIGARGS .= " --enable-namd=$ARGV[0]"; shift; next;
175 }
176 print "Unknown option: $_ : ignoring!\n";
177}
178
179if ($ENV{'LLVMGCCDIR'}) {
180 $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
181}
182if ($CONFIGUREARGS !~ /--disable-jit/) {
183 $CONFIGUREARGS .= " --enable-jit";
184}
185
186die "Must specify 0 or 3 options!" if (@ARGV != 0 and @ARGV != 3);
187
188if (@ARGV == 3) {
189 $CVSRootDir = $ARGV[0];
190 $BuildDir = $ARGV[1];
191 $WebDir = $ARGV[2];
192}
193
194##############################################################
195#
196#define the file names we'll use
197#
198##############################################################
199my $Prefix = "$WebDir/$DATE";
200my $BuildLog = "$Prefix-Build-Log.txt";
201my $CVSLog = "$Prefix-CVS-Log.txt";
202my $OldenTestsLog = "$Prefix-Olden-tests.txt";
203my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
204my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
205my $ExternalLog = "$Prefix-External-ProgramTest.txt.gz";
206my $DejagnuLog = "$Prefix-Dejagnu-testrun.log";
207my $DejagnuSum = "$Prefix-Dejagnu-testrun.sum";
208my $DejagnuTestsLog = "$Prefix-DejagnuTests-Log.txt";
209if (! -d $WebDir) {
210 mkdir $WebDir, 0777;
211 warn "$WebDir did not exist; creating it.\n";
212}
213
214if ($VERBOSE) {
215 print "INITIALIZED\n";
216 print "CVS Root = $CVSRootDir\n";
217 print "BuildDir = $BuildDir\n";
218 print "WebDir = $WebDir\n";
219 print "Prefix = $Prefix\n";
220 print "CVSLog = $CVSLog\n";
221 print "BuildLog = $BuildLog\n";
222}
223
224##############################################################
225#
226# Helper functions
227#
228##############################################################
229sub GetDir {
230 my $Suffix = shift;
231 opendir DH, $WebDir;
232 my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
233 closedir DH;
234 return @Result;
235}
236
237#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
238#
239# DiffFiles - Diff the current version of the file against the last version of
240# the file, reporting things added and removed. This is used to report, for
241# example, added and removed warnings. This returns a pair (added, removed)
242#
243#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
244sub DiffFiles {
245 my $Suffix = shift;
246 my @Others = GetDir $Suffix;
247 if (@Others == 0) { # No other files? We added all entries...
248 return (`cat $WebDir/$DATE$Suffix`, "");
249 }
250 # Diff the files now...
251 my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
252 my $Added = join "\n", grep /^</, @Diffs;
253 my $Removed = join "\n", grep /^>/, @Diffs;
254 $Added =~ s/^< //gm;
255 $Removed =~ s/^> //gm;
256 return ($Added, $Removed);
257}
258
259#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
260#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
261sub GetRegex { # (Regex with ()'s, value)
262 $_[1] =~ /$_[0]/m;
263 if (defined($1)) {
264 return $1;
265 }
266 return "0";
267}
268
269#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
270#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
271sub GetRegexNum {
272 my ($Regex, $Num, $Regex2, $File) = @_;
273 my @Items = split "\n", `grep '$Regex' $File`;
274 return GetRegex $Regex2, $Items[$Num];
275}
276
277#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
278#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
279sub ChangeDir { # directory, logical name
280 my ($dir,$name) = @_;
281 chomp($dir);
282 if ( $VERBOSE ) { print "Changing To: $name ($dir)\n"; }
283 chdir($dir) || die "Cannot change directory to: $name ($dir) ";
284}
285
286#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
287#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
288sub ReadFile {
289 if (open (FILE, $_[0])) {
290 undef $/;
291 my $Ret = <FILE>;
292 close FILE;
293 $/ = '\n';
294 return $Ret;
295 } else {
296 print "Could not open file '$_[0]' for reading!";
297 return "";
298 }
299}
300
301#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
302#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
303sub WriteFile { # (filename, contents)
304 open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!";
305 print FILE $_[1];
306 close FILE;
307}
308
309#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
310#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
311sub CopyFile { #filename, newfile
312 my ($file, $newfile) = @_;
313 chomp($file);
314 if ($VERBOSE) { print "Copying $file to $newfile\n"; }
315 copy($file, $newfile);
316}
317
318#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
319#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
320sub AddRecord {
321 my ($Val, $Filename,$WebDir) = @_;
322 my @Records;
323 if (open FILE, "$WebDir/$Filename") {
324 @Records = grep !/$DATE/, split "\n", <FILE>;
325 close FILE;
326 }
327 push @Records, "$DATE: $Val";
328 WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
329}
330
331#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
332#
333# FormatTime - Convert a time from 1m23.45 into 83.45
334#
335#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
336sub FormatTime {
337 my $Time = shift;
338 if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
339 $Time = sprintf("%7.4f", $1*60.0+$2);
340 }
341 return $Time;
342}
343
344#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
345#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
346sub GetDejagnuTestResults { # (filename, log)
347 my ($filename, $DejagnuLog) = @_;
348 my @lines;
349 my $firstline;
350 $/ = "\n"; #Make sure we're going line at a time.
351
352 print "DEJAGNU TEST RESULTS:\n";
353
354 if (open SRCHFILE, $filename) {
355 # Process test results
356 my $first_list = 1;
357 my $should_break = 1;
358 my $nocopy = 0;
359 my $readingsum = 0;
360 while ( <SRCHFILE> ) {
361 if ( length($_) > 1 ) {
362 chomp($_);
363 if ( m/^XPASS:/ || m/^FAIL:/ ) {
364 $nocopy = 0;
365 if ( $first_list ) {
366 push(@lines, "UNEXPECTED TEST RESULTS\n");
367 $first_list = 0;
368 $should_break = 1;
369 push(@lines, "$_\n");
370 print " $_\n";
371 } else {
372 push(@lines, "$_\n");
373 print " $_\n";
374 }
375 } #elsif ( m/Summary/ ) {
376 # if ( $first_list ) {
377 # push(@lines, "PERFECT!");
378 # print " PERFECT!\n";
379 # } else {
380 # push(@lines, "</li></ol>\n");
381 # }
382 # push(@lines, "STATISTICS\n");
383 # print "\nDEJAGNU STATISTICS:\n";
384 # $should_break = 0;
385 # $nocopy = 0;
386 # $readingsum = 1;
387 #}
388 elsif ( $readingsum ) {
389 push(@lines,"$_\n");
390 print " $_\n";
391 }
392
393 }
394 }
395 }
396 close SRCHFILE;
397
398 my $content = join("", @lines);
399 return $content;
400}
401
402
403#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
404#
405# This function acts as a mini web browswer submitting data
406# to our central server via the post method
407#
408#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
409sub SendData{
410 $host = $_[0];
411 $file = $_[1];
412 $variables=$_[2];
413
414 $port=80;
415 $socketaddr= sockaddr_in $port, inet_aton $host or die "Bad hostname\n";
416 socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or die "Bad socket\n";
417 connect SOCK, $socketaddr or die "Bad connection\n";
418 select((select(SOCK), $| = 1)[0]);
419
420 #creating content here
421 my $content;
422 foreach $key (keys (%$variables)){
423 $value = $variables->{$key};
424 $value =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
425 $content .= "$key=$value&";
426 }
427
428 $length = length($content);
429
430 my $send= "POST $file HTTP/1.0\n";
431 $send.= "Content-Type: application/x-www-form-urlencoded\n";
432 $send.= "Content-length: $length\n\n";
433 $send.= "$content";
434
435 print SOCK $send;
436 my $result;
437 while(<SOCK>){
438 $result .= $_;
439 }
440 close(SOCK);
441
442 my $sentdata="";
443 foreach $x(keys(%hash_of_data)){
Patrick Jenkins15956a12006-07-07 17:08:02 +0000444 $sentdata.= "$x => $hash_of_data{$x}\n";
Patrick Jenkins0e316b42006-07-06 21:19:32 +0000445 }
446 WriteFile "$Prefix-sentdata.txt", $sentdata;
447
448
449 return $result;
450}
451
Patrick Jenkinsf976a5c2006-07-07 18:50:51 +0000452##############################################################
453#
454# Getting Start timestamp
455#
456##############################################################
457$starttime = `date`;
Patrick Jenkins0e316b42006-07-06 21:19:32 +0000458
459##############################################################
460#
461# Create the CVS repository directory
462#
463##############################################################
464if (!$NOCHECKOUT) {
465 if (-d $BuildDir) {
466 if (!$NOREMOVE) {
467 system "rm -rf $BuildDir";
468 } else {
469 die "CVS checkout directory $BuildDir already exists!";
470 }
471 }
472 mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
473}
474ChangeDir( $BuildDir, "CVS checkout directory" );
475
476
477##############################################################
478#
479# Check out the llvm tree, saving CVS messages to the cvs log...
480#
481##############################################################
482my $CVSOPT = "";
483# Use compression if going over ssh.
484$CVSOPT = "-z3" if $CVSRootDir =~ /^:ext:/;
485my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co $CVSCOOPT";
486if (!$NOCHECKOUT) {
487 if ( $VERBOSE )
488 {
489 print "CHECKOUT STAGE:\n";
490 print "( time -p $CVSCMD llvm; cd llvm/projects ; $CVSCMD llvm-test ) > $CVSLog 2>&1\n";
491 }
492 system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
493 "$CVSCMD llvm-test ) > $CVSLog 2>&1";
494 ChangeDir( $BuildDir , "CVS Checkout directory") ;
495}
496ChangeDir( "llvm" , "llvm source directory") ;
497if (!$NOCHECKOUT) {
498 if ( $VERBOSE ) { print "UPDATE STAGE\n"; }
499 system "$NICE cvs update -PdRA >> $CVSLog 2>&1" ;
500}
501
502##############################################################
503#
504# Get some static statistics about the current state of CVS
505#
506# This can probably be put on the server side
507#
508##############################################################
509my $CVSCheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $CVSLog`;
510my $CVSCheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $CVSLog`;
511my $CVSCheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $CVSLog`;
512my $CVSCheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
513
514my $NumFilesInCVS = `egrep '^U' $CVSLog | wc -l` + 0;
515my $NumDirsInCVS = `egrep '^cvs (checkout|server|update):' $CVSLog | wc -l` + 0;
516my $LOC = `utils/countloc.sh`;
517
518##############################################################
519#
520# Extract some information from the CVS history... use a hash so no duplicate
521# stuff is stored. This gets the history from the previous days worth
522# of cvs activit and parses it.
523#
524##############################################################
525
526my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
527
528if(!$NOCVSSTATS){
529
530if ($VERBOSE) { print "CVS HISTORY ANALYSIS STAGE\n"; }
531@CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
532#print join "\n", @CVSHistory; print "\n";
533
534my $DateRE = '[-/:0-9 ]+\+[0-9]+';
535
536# Loop over every record from the CVS history, filling in the hashes.
537foreach $File (@CVSHistory) {
538 my ($Type, $Date, $UID, $Rev, $Filename);
539 if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
540 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
541 } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
542 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
543 } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
544 ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
545 } else {
546 print "UNMATCHABLE: $File\n";
547 next;
548 }
549 # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
550
551 if ($Filename =~ /^llvm/) {
552 if ($Type eq 'M') { # Modified
553 $ModifiedFiles{$Filename} = 1;
554 $UsersCommitted{$UID} = 1;
555 } elsif ($Type eq 'A') { # Added
556 $Addediles{$Filename} = 1;
557 $UsersCommitted{$UID} = 1;
558 } elsif ($Type eq 'R') { # Removed
559 $RemovedFiles{$Filename} = 1;
560 $UsersCommitted{$UID} = 1;
561 } else {
562 $UsersUpdated{$UID} = 1;
563 }
564 }
565}
566
567my $TestError = 1;
568
569}#!NOCVSSTATS
570
571my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
572my $CVSModifiedFiles = join "\n", sort keys %ModifiedFiles;
573my $CVSRemovedFiles = join "\n", sort keys %RemovedFiles;
574my $UserCommitList = join "\n", sort keys %UsersCommitted;
575my $UserUpdateList = join "\n", sort keys %UsersUpdated;
576
577##############################################################
578#
579# Build the entire tree, saving build messages to the build log
580#
581##############################################################
582if (!$NOCHECKOUT && !$NOBUILD) {
583 my $EXTRAFLAGS = "--enable-spec --with-objroot=.$LLVMTESTCONFIGARGS";
584 if ( $VERBOSE )
585 {
586 print "CONFIGURE STAGE:\n";
587 print "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) > $BuildLog 2>&1\n";
588 }
589 system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) > $BuildLog 2>&1";
590 if ( $VERBOSE )
591 {
592 print "BUILD STAGE:\n";
593 print "(time -p $NICE make $MAKEOPTS) >> $BuildLog 2>&1\n";
594 }
595 # Build the entire tree, capturing the output into $BuildLog
596 system "(time -p $NICE make $MAKEOPTS) >> $BuildLog 2>&1";
597}
598
599
600##############################################################
601#
602# Get some statistics about the build...
603#
604##############################################################
605#this can de done on server
606#my @Linked = split '\n', `grep Linking $BuildLog`;
607#my $NumExecutables = scalar(grep(/executable/, @Linked));
608#my $NumLibraries = scalar(grep(!/executable/, @Linked));
609#my $NumObjects = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
610
611
612my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
613my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
614my $ConfigTime = $ConfigTimeU+$ConfigTimeS; # ConfigTime = User+System
615my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$BuildLog";
616
617$ConfigTime=-1 unless $ConfigTime;
618$ConfigWallTime=-1 unless $ConfigWallTime;
619
620my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$BuildLog";
621my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
622my $BuildTime = $BuildTimeU+$BuildTimeS; # BuildTime = User+System
623my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
624
625$BuildTime=-1 unless $BuildTime;
626$BuildWallTime=-1 unless $BuildWallTime;
627
628my $BuildError = 0, $BuildStatus = "OK";
629if($NOBUILD){
630 $BuildStatus = "Skipped by user";
631 $BuildError = 1;
632}
633elsif (`grep '^make[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
634 `grep '^make: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
635 $BuildStatus = "Error: compilation aborted";
636 $BuildError = 1;
637 print "\n***ERROR BUILDING TREE\n\n";
638}
639if ($BuildError) { $NODEJAGNU=1; }
640
641##############################################################
642#
643# Running dejagnu tests
644#
645##############################################################
646my $DejangnuTestResults; # String containing the results of the dejagnu
647my $dejagnu_output = "$DejagnuTestsLog";
648if(!$NODEJAGNU) {
649 if($VERBOSE)
650 {
651 print "DEJAGNU FEATURE/REGRESSION TEST STAGE:\n";
652 print "(time -p make $MAKEOPTS check) > $dejagnu_output 2>&1\n";
653 }
654
655 #Run the feature and regression tests, results are put into testrun.sum
656 #Full log in testrun.log
657 system "(time -p make $MAKEOPTS check) > $dejagnu_output 2>&1";
658
659 #Copy the testrun.log and testrun.sum to our webdir
660 CopyFile("test/testrun.log", $DejagnuLog);
661 CopyFile("test/testrun.sum", $DejagnuSum);
662 #can be done on server
663 $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
664 $unexpfail_tests = $DejagnuTestResults;
665}
666#Extract time of dejagnu tests
667my $DejagnuTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$dejagnu_output";
668my $DejagnuTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$dejagnu_output";
669$DejagnuTime = $DejagnuTimeU+$DejagnuTimeS; # DejagnuTime = User+System
670$DejagnuWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$dejagnu_output";
671$DejagnuTestResults = "Dejagnu skipped by user choice." unless $DejagnuTestResults;
672$DejagnuTime = "0.0" unless $DejagnuTime;
673$DejagnuWallTime = "0.0" unless $DejagnuWallTime;
674
675if ($DEBUG) {
676 print $DejagnuTestResults;
677}
678
679##############################################################
680#
681# Get warnings from the build
682#
683##############################################################
684if(!$NODEJAGNU){
685
686if ( $VERBOSE ) { print "BUILD INFORMATION COLLECTION STAGE\n"; }
687my @Warn = split "\n", `egrep 'warning:|Entering dir' $BuildLog`;
688my @Warnings;
689my $CurDir = "";
690
691foreach $Warning (@Warn) {
692 if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
693 $CurDir = $1; # Keep track of directory warning is in...
694 if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { # Remove buildir prefix if included
695 $CurDir = $1;
696 }
697 } else {
698 push @Warnings, "$CurDir/$Warning"; # Add directory to warning...
699 }
700}
701my $WarningsFile = join "\n", @Warnings;
702$WarningsFile =~ s/:[0-9]+:/::/g;
703
704# Emit the warnings file, so we can diff...
705WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
Patrick Jenkinsd0a7c2b2006-07-06 22:32:15 +0000706my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
Patrick Jenkins0e316b42006-07-06 21:19:32 +0000707
708# Output something to stdout if something has changed
709#print "ADDED WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
710#print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
711
712#my @TmpWarningsAdded = split "\n", $WarningsAdded; ~PJ on upgrade
713#my @TmpWarningsRemoved = split "\n", $WarningsRemoved; ~PJ on upgrade
714
715} #endif !NODEGAGNU
716
717##############################################################
718#
719# If we built the tree successfully, run the nightly programs tests...
720#
721# A set of tests to run is passed in (i.e. "SingleSource" "MultiSource" "External")
722#
723##############################################################
724sub TestDirectory {
725 my $SubDir = shift;
726
727 ChangeDir( "projects/llvm-test/$SubDir", "Programs Test Subdirectory" );
728
729 my $ProgramTestLog = "$Prefix-$SubDir-ProgramTest.txt";
730 #my $ProgramTestLog = "$Prefix-MultiSource-ProgramTest.txt"; #CHANGE ME!
731
732 # Run the programs tests... creating a report.nightly.csv file
733 if (!$NOTEST) {
734 print "make -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv "
735 . "TEST=nightly > $ProgramTestLog 2>&1\n";
736 system "make -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv "
737 . "TEST=nightly > $ProgramTestLog 2>&1";
738 $llcbeta_options=`make print-llcbeta-option`;
739 }
740
741 my $ProgramsTable;
742 if (`grep '^make[^:]: .*Error' $ProgramTestLog | wc -l` + 0){
743 $TestError = 1;
744 $ProgramsTable="Error running test $SubDir\n";
745 print "ERROR TESTING\n";
746 } elsif (`grep '^make[^:]: .*No rule to make target' $ProgramTestLog | wc -l` + 0) {
747 $TestError = 1;
748 $ProgramsTable="Makefile error running tests $SubDir!\n";
749 print "ERROR TESTING\n";
750 } else {
751 $TestError = 0;
752
753 #
754 # Create a list of the tests which were run...
755 #
756 system "egrep 'TEST-(PASS|FAIL)' < $ProgramTestLog "
757 . "| sort > $Prefix-multisourceprogramstable.txt";
758 }
759 $ProgramsTable = ReadFile "report.nightly.csv";
760
761 ChangeDir( "../../..", "Programs Test Parent Directory" );
762 return ($ProgramsTable, $llcbeta_options);
763}
764
765$patrickjenkins=1;
766if(!$patrickjenkins){
767 if ( $VERBOSE ) {
768 print "Modified Multisource Olden test stage\n";
769 }
770 ($MultiSourceProgramsTable, $multisource_llcbeta_options) = TestDirectory("MultiSource/");
771 ChangeDir( "../../..", "Programs Test Parent Directory" );
772
773
774 WriteFile "$WebDir/multisourceprogramstable.txt", $MultiSourceProgramsTable;
775}
776if (!$BuildError && $patrickjenkins) {
777 if ( $VERBOSE ) {
778 print "SingleSource TEST STAGE\n";
779 }
780 ($SingleSourceProgramsTable, $singlesource_llcbeta_options) = TestDirectory("SingleSource");
781 WriteFile "$Prefix-singlesourceprogramstable.txt", $SingleSourceProgramsTable;
782 if ( $VERBOSE ) {
783 print "MultiSource TEST STAGE\n";
784 }
785 ($MultiSourceProgramsTable, $multisource_llcbeta_options) = TestDirectory("MultiSource");
786 WriteFile "$Prefix-multisourceprogramstable.txt", $MultiSourceProgramsTable;
787 if ( ! $NOEXTERNALS ) {
788 if ( $VERBOSE ) {
789 print "External TEST STAGE\n";
790 }
791 ($ExternalProgramsTable, $externalsource_llcbeta_options) = TestDirectory("External");
792 system "cat $Prefix-singlesourceprogramstable.txt $Prefix-multisourceprogramstable.txt ".
793 " $Prefix-externalprogramstable.txt | sort > $Prefix-Tests.txt";
794 } else {
795 $ExternalProgramsTable = "External TEST STAGE SKIPPED\n";
796 if ( $VERBOSE ) {
797 print "External TEST STAGE SKIPPED\n";
798 }
799 system "cat $Prefix-singlesourceprogramstable.txt $Prefix-multisourceprogramstable.txt ".
800 " | sort > $Prefix-Tests.txt";
801 }
802 WriteFile "$Prefix-externalprogramstable.txt", $ExternalProgramsTable;
803
804}
805
806##############################################################
807#
808#
809# gathering tests added removed broken information here
810#
811#
812##############################################################
813my ($TestsAdded, $TestsRemoved, $TestsFixed, $TestsBroken) = ("","","","");
814
815if ($TestError) {
816 $TestsAdded = "<b>error testing</b><br>";
817 $TestsRemoved = "<b>error testing</b><br>";
818 $TestsFixed = "<b>error testing</b><br>";
819 $TestsBroken = "<b>error testing</b><br>";
820} else {
Patrick Jenkinsd0a7c2b2006-07-06 22:32:15 +0000821 my ($RTestsAdded, $RTestsRemoved) = DiffFiles "-Tests.txt";
Patrick Jenkins0e316b42006-07-06 21:19:32 +0000822
823 my @RawTestsAddedArray = split '\n', $RTestsAdded;
824 my @RawTestsRemovedArray = split '\n', $RTestsRemoved;
825
826 my %OldTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
827 @RawTestsRemovedArray;
828 my %NewTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
829 @RawTestsAddedArray;
830
831 foreach $Test (keys %NewTests) {
832 if (!exists $OldTests{$Test}) { # TestAdded if in New but not old
833 $TestsAdded = "$TestsAdded$Test\n";
834 } else {
835 if ($OldTests{$Test} =~ /TEST-PASS/) { # Was the old one a pass?
836 $TestsBroken = "$TestsBroken$Test\n"; # New one must be a failure
837 } else {
838 $TestsFixed = "$TestsFixed$Test\n"; # No, new one is a pass.
839 }
840 }
841 }
842 foreach $Test (keys %OldTests) { # TestRemoved if in Old but not New
843 $TestsRemoved = "$TestsRemoved$Test\n" if (!exists $NewTests{$Test});
844 }
845
846 #print "\nTESTS ADDED: \n\n$TestsAdded\n\n" if (length $TestsAdded);
847 #print "\nTESTS REMOVED:\n\n$TestsRemoved\n\n" if (length $TestsRemoved);
848 #print "\nTESTS FIXED: \n\n$TestsFixed\n\n" if (length $TestsFixed);
849 #print "\nTESTS BROKEN: \n\n$TestsBroken\n\n" if (length $TestsBroken);
850
851 #$TestsAdded = AddPreTag $TestsAdded;
852 #$TestsRemoved = AddPreTag $TestsRemoved;
853 #$TestsFixed = AddPreTag $TestsFixed;
854 #$TestsBroken = AddPreTag $TestsBroken;
855}
856
857##############################################################
858#
859# If we built the tree successfully, runs of the Olden suite with
860# LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
861#
862##############################################################
863if (!$BuildError) {
864 if ( $VERBOSE ) { print "OLDEN TEST SUITE STAGE\n"; }
865 my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
866 $MachCodeSize) = ("","","","","","","");
867 if (!$NORUNNINGTESTS) {
868 ChangeDir( "$BuildDir/llvm/projects/llvm-test/MultiSource/Benchmarks/Olden",
869 "Olden Test Directory");
870
871 # Clean out previous results...
872 system "$NICE make $MAKEOPTS clean > /dev/null 2>&1";
873
874 # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE and
875 # GET_STABLE_NUMBERS enabled!
876 if( $VERBOSE ) { print "make -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out TEST=nightly " .
877 " LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 > /dev/null 2>&1\n"; }
878 system "make -k $MAKEOPTS $PROGTESTOPTS report.nightly.csv.out TEST=nightly " .
879 " LARGE_PROBLEM_SIZE=1 GET_STABLE_NUMBERS=1 > /dev/null 2>&1";
880 system "cp report.nightly.csv $OldenTestsLog";
881 } #else {
882 #system "gunzip ${OldenTestsLog}.gz";
883 #}
884
885 # Now we know we have $OldenTestsLog as the raw output file. Split
886 # it up into records and read the useful information.
887 #my @Records = split />>> ========= /, ReadFile "$OldenTestsLog";
888 #shift @Records; # Delete the first (garbage) record
889
890 # Loop over all of the records, summarizing them into rows for the running
891 # totals file.
892 #my $WallTimeRE = "Time: ([0-9.]+) seconds \\([0-9.]+ wall clock";
893 #foreach $Rec (@Records) {
894 #my $rNATTime = GetRegex 'TEST-RESULT-nat-time: program\s*([.0-9m]+)', $Rec;
895 #my $rCBETime = GetRegex 'TEST-RESULT-cbe-time: program\s*([.0-9m]+)', $Rec;
896 #my $rLLCTime = GetRegex 'TEST-RESULT-llc-time: program\s*([.0-9m]+)', $Rec;
897 #my $rJITTime = GetRegex 'TEST-RESULT-jit-time: program\s*([.0-9m]+)', $Rec;
898 #my $rOptTime = GetRegex "TEST-RESULT-compile: .*$WallTimeRE", $Rec;
899 #my $rBytecodeSize = GetRegex 'TEST-RESULT-compile: *([0-9]+)', $Rec;
900
901 #$NATTime .= " " . FormatTime($rNATTime);
902 #$CBETime .= " " . FormatTime($rCBETime);
903 #$LLCTime .= " " . FormatTime($rLLCTime);
904 #$JITTime .= " " . FormatTime($rJITTime);
905 #$OptTime .= " $rOptTime";
906 #$BytecodeSize .= " $rBytecodeSize";
907 #}
908 #
909 # Now that we have all of the numbers we want, add them to the running totals
910 # files.
911 #AddRecord($NATTime, "running_Olden_nat_time.txt", $WebDir);
912 #AddRecord($CBETime, "running_Olden_cbe_time.txt", $WebDir);
913 #AddRecord($LLCTime, "running_Olden_llc_time.txt", $WebDir);
914 #AddRecord($JITTime, "running_Olden_jit_time.txt", $WebDir);
915 #AddRecord($OptTime, "running_Olden_opt_time.txt", $WebDir);
916 #AddRecord($BytecodeSize, "running_Olden_bytecode.txt", $WebDir);
917}
918
Patrick Jenkinsf976a5c2006-07-07 18:50:51 +0000919##############################################################
920#
921# Getting end timestamp
922#
923##############################################################
924$endtime = `date`;
925
Patrick Jenkins0e316b42006-07-06 21:19:32 +0000926
927##############################################################
928#
929# Place all the logs neatly into one humungous file
930#
931##############################################################
932
933if ( $VERBOSE ) { print "PREPARING LOGS TO BE SENT TO SERVER\n"; }
934
935$machine_data = "uname: ".`uname -a`.
936 "hardware: ".`uname -m`.
937 "os: ".`uname -sr`.
938 "name: ".`uname -n`.
939 "date: ".`date \"+20%y-%m-%d\"`.
940 "time: ".`date +\"%H:%M:%S\"`;
941
942my @CVS_DATA;
943my $cvs_data;
944@CVS_DATA = ReadFile "$CVSLog";
945$cvs_data = join("\n", @CVS_DATA);
946
947my @BUILD_DATA;
948my $build_data;
949@BUILD_DATA = ReadFile "$BuildLog";
950$build_data = join("\n", @BUILD_DATA);
951
952my @DEJAGNU_LOG;
953my @DEJAGNU_SUM;
954my $dejagnutests_log;
955my $dejagnutests_sum;
956@DEJAGNU_LOG = ReadFile "$DejagnuLog";
957@DEJAGNU_SUM = ReadFile "$DejagnuSum";
958$dejagnutests_log = join("\n", @DEJAGNU_LOG);
959$dejagnutests_sum = join("\n", @DEJAGNU_SUM);
960
961my @DEJAGNULOG_FULL;
962my $dejagnulog_full;
963@DEJAGNULOG_FULL = ReadFile "$DejagnuTestsLog";
964$dejagnulog_full = join("\n", @DEJAGNULOG_FULL);
965
966my $gcc_version_long = `gcc --version`;
967@GCC_VERSION = split "\n", $gcc_version_long;
968my $gcc_version = $GCC_VERSION[0];
969
970##############################################################
971#
972# Send data via a post request
973#
974##############################################################
975
976if ( $VERBOSE ) { print "SEND THE DATA VIA THE POST REQUEST\n"; }
977
978
979my $host = "llvm.org";
980my $file = "/nightlytest/NightlyTestAccept.cgi";
981my %hash_of_data = ('machine_data' => $machine_data,
982 'build_data' => $build_data,
983 'gcc_version' => $gcc_version,
984 'nickname' => $nickname,
985 'dejagnutime_wall' => $DejagnuWallTime,
986 'dejagnutime_cpu' => $DejagnuTime,
987 'cvscheckouttime_wall' => $CVSCheckoutTime_Wall,
988 'cvscheckouttime_cpu' => $CVSCheckoutTime_CPU,
989 'configtime_wall' => $ConfigWallTime,
990 'configtime_cpu'=> $ConfigTime,
991 'buildtime_wall' => $BuildWallTime,
992 'buildtime_cpu' => $BuildTime,
993 'warnings' => $WarningsFile,
994 'cvsusercommitlist' => $UserCommitList,
995 'cvsuserupdatelist' => $UserUpdateList,
996 'cvsaddedfiles' => $CVSAddedFiles,
997 'cvsmodifiedfiles' => $CVSModifiedFiles,
998 'cvsremovedfiles' => $CVSRemovedFiles,
999 'lines_of_code' => $LOC,
1000 'cvs_file_count' => $NumFilesInCVS,
1001 'cvs_dir_count' => $NumDirsInCVS,
1002 'buildstatus' => $BuildStatus,
1003 'singlesource_programstable' => $SingleSourceProgramsTable,
1004 'multisource_programstable' => $MultiSourceProgramsTable,
1005 'externalsource_programstable' => $ExternalSourceProgramsTable,
1006 'llcbeta_options' => $multisource_llcbeta_options,
1007 'warnings_removed' => $WarningsRemoved,
1008 'warnings_added' => $WarningsAdded,
1009 'newly_passing_tests' => $TestsFixed,
1010 'newly_failing_tests' => $TestsBroken,
1011 'new_tests' => $TestsAdded,
1012 'removed_tests' => $TestsRemoved,
1013 'unexpfail_tests' => $unexpfail_tests,
1014 'dejagnutests_log' => $dejagnutests_log,
Patrick Jenkinsf976a5c2006-07-07 18:50:51 +00001015 'dejagnutests_sum' => $dejagnutests_sum
1016 'starttime' => $starttime,
1017 'endtime' => $endtime);
Patrick Jenkins0e316b42006-07-06 21:19:32 +00001018
1019$TESTING = 0;
1020
1021if($TESTING){
1022 print "============================\n";
1023 foreach $x(keys %hash_of_data){
1024 print "$x => $hash_of_data{$x}\n";
1025 }
1026}
1027else{
1028 my $response = SendData $host,$file,\%hash_of_data;
1029 print "============================\n$response";
1030}
1031
1032##############################################################
1033#
1034# Remove the cvs tree...
1035#
1036##############################################################
1037system ( "$NICE rm -rf $BuildDir") if (!$NOCHECKOUT and !$NOREMOVE);
Patrick Jenkins5053e152006-07-07 17:31:38 +00001038system ( "$NICE rm -rf $WebDir") if (!$NOCHECKOUT and !$NOREMOVE and !NOREMOVERESULTS);
Patrick Jenkins0e316b42006-07-06 21:19:32 +00001039
1040