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