Dummy implementation of the pthread library.
[oota-llvm.git] / utils / NightlyTest.pl
1 #!/usr/dcs/software/supported/bin/perl -w
2 #
3 # Program:  NightlyTest.pl
4 #
5 # Synopsis: Perform a series of tests which are designed to be run nightly.
6 #           This is used to keep track of the status of the LLVM tree, tracking
7 #           regressions and performance changes.  This generates one web page a
8 #           day which can be used to access this information.
9 #
10 # Syntax:   NightlyTest.pl [OPTIONS] [CVSROOT BUILDDIR WEBDIR]
11 #   where
12 # OPTIONS may include one or more of the following:
13 #  -nocheckout      Do not create, checkout, update, or configure
14 #                   the source tree.
15 #  -noremove        Do not remove the BUILDDIR after it has been built.
16 #  -notest          Do not even attempt to run the test programs. Implies
17 #                   -norunningtests.
18 #  -norunningtests  Do not run the Olden benchmark suite with
19 #                   LARGE_PROBLEM_SIZE enabled.
20 #  -parallel        Run two parallel jobs with GNU Make.
21 # CVSROOT is the CVS repository from which the tree will be checked out,
22 #  specified either in the full :method:user@host:/dir syntax, or
23 #  just /dir if using a local repo.
24 # BUILDDIR is the directory where sources for this test run will be checked out
25 #  AND objects for this test run will be built. This directory MUST NOT
26 #  exist before the script is run; it will be created by the cvs checkout
27 #  process and erased (unless -noremove is specified; see above.)
28 # WEBDIR is the directory into which the test results web page will be written,
29 #  AND in which the "index.html" is assumed to be a symlink to the most recent
30 #  copy of the results. This directory MUST exist before the script is run.
31 #
32 use POSIX qw(strftime);
33
34 my $HOME = $ENV{'HOME'};
35 my $CVSRootDir = $ENV{'CVSROOT'};
36    $CVSRootDir = "/home/vadve/shared/PublicCVS"
37     unless $CVSRootDir;
38 my $BuildDir   = "$HOME/buildtest";
39 my $WebDir     = "$HOME/cvs/testresults-X86";
40
41 # Calculate the date prefix...
42 @TIME = localtime;
43 my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
44 my $DateString = strftime "%B %d, %Y", localtime;
45
46 sub ReadFile {
47   undef $/;
48   if (open (FILE, $_[0])) {
49     my $Ret = <FILE>;
50     close FILE;
51     return $Ret;
52   } else {
53     print "Could not open file '$_[0]' for reading!";
54     return "";
55   }
56 }
57
58 sub WriteFile {  # (filename, contents)
59   open (FILE, ">$_[0]") or die "Could not open file '$_[0]' for writing!";
60   print FILE $_[1];
61   close FILE;
62 }
63
64 sub GetRegex {   # (Regex with ()'s, value)
65   $_[1] =~ /$_[0]/m;
66   if (defined($1)) {
67     return $1;
68   }
69   return "?";
70 }
71
72 sub AddPreTag {  # Add pre tags around nonempty list, or convert to "none"
73   $_ = shift;
74   if (length) { return "<ul><pre>$_</pre></ul>"; } else { "<b>none</b><br>"; }
75 }
76
77 sub GetDir {
78   my $Suffix = shift;
79   opendir DH, $WebDir;
80   my @Result = reverse sort grep !/$DATE/, grep /[-0-9]+$Suffix/, readdir DH;
81   closedir DH;
82   return @Result;
83 }
84
85 # DiffFiles - Diff the current version of the file against the last version of
86 # the file, reporting things added and removed.  This is used to report, for
87 # example, added and removed warnings.  This returns a pair (added, removed)
88 #
89 sub DiffFiles {
90   my $Suffix = shift;
91   my @Others = GetDir $Suffix;
92   if (@Others == 0) {  # No other files?  We added all entries...
93     return (`cat $WebDir/$DATE$Suffix`, "");
94   }
95   # Diff the files now...
96   my @Diffs = split "\n", `diff $WebDir/$DATE$Suffix $WebDir/$Others[0]`;
97   my $Added   = join "\n", grep /^</, @Diffs;
98   my $Removed = join "\n", grep /^>/, @Diffs;
99   $Added =~ s/^< //gm;
100   $Removed =~ s/^> //gm;
101   return ($Added, $Removed);
102 }
103
104 # FormatTime - Convert a time from 1m23.45 into 83.45
105 sub FormatTime {
106   my $Time = shift;
107   if ($Time =~ m/([0-9]+)m([0-9.]+)/) {
108     $Time = sprintf("%7.4f", $1*60.0+$2);
109   }
110   return $Time;
111 }
112
113
114 # Command line argument settings...
115 my $NOCHECKOUT = 0;
116 my $NOREMOVE   = 0;
117 my $NOTEST     = 0;
118 my $NORUNNINGTESTS = 0;
119 my $MAKEOPTS   = "";
120
121
122 # Parse arguments...
123 while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
124   shift;
125   last if /^--$/;  # Stop processing arguments on --
126
127   # List command line options here...
128   if (/^-nocheckout$/)     { $NOCHECKOUT = 1; next; }
129   if (/^-noremove$/)       { $NOREMOVE   = 1; next; }
130   if (/^-notest$/)         { $NOTEST     = 1; $NORUNNINGTESTS = 1; next; }
131   if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
132   if (/^-parallel$/)       { $MAKEOPTS   = "-j2 -l3.0"; next; }
133
134   print "Unknown option: $_ : ignoring!\n";
135 }
136
137 die "Must specify 0 or 3 options!" if (@ARGV != 0 and @ARGV != 3);
138
139 if (@ARGV == 3) {
140   $CVSRootDir = $ARGV[0];
141   $BuildDir   = $ARGV[1];
142   $WebDir     = $ARGV[2];
143 }
144
145 my $Template = "$BuildDir/llvm/utils/NightlyTestTemplate.html";
146 my $Prefix = "$WebDir/$DATE";
147
148 if (0) {
149   print "CVS Root = $CVSRootDir\n";
150   print "BuildDir = $BuildDir\n";
151   print "WebDir   = $WebDir\n";
152   print "Prefix   = $Prefix\n";
153 }
154
155
156 #
157 # Create the CVS repository directory
158 #
159 if (!$NOCHECKOUT) {
160   mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
161 }
162 chdir $BuildDir or die "Could not change to CVS checkout directory $BuildDir!";
163
164
165 #
166 # Check out the llvm tree, saving CVS messages to the cvs log...
167 #
168 $CVSOPT = "";
169 $CVSOPT = "-z3" if $CVSRootDir =~ /^:ext:/; # Use compression if going over ssh.
170 system "(time -p cvs $CVSOPT -d $CVSRootDir co llvm) > $Prefix-CVS-Log.txt 2>&1"
171   if (!$NOCHECKOUT);
172
173 chdir "llvm" or die "Could not change into llvm directory!";
174
175 system "cvs up -P -d > /dev/null 2>&1" if (!$NOCHECKOUT);
176
177 # Read in the HTML template file...
178 my $TemplateContents = ReadFile $Template;
179
180
181 #
182 # Get some static statistics about the current state of CVS
183 #
184 my $CVSCheckoutTime = GetRegex "([0-9.]+)", `grep '^real' $Prefix-CVS-Log.txt`;
185 my $NumFilesInCVS = `egrep '^U' $Prefix-CVS-Log.txt | wc -l` + 0;
186 my $NumDirsInCVS  = `egrep '^cvs (checkout|server|update):' $Prefix-CVS-Log.txt | wc -l` + 0;
187 $LOC = GetRegex "([0-9]+) +total", `wc -l \`utils/getsrcs.sh\` | grep total`;
188
189 #
190 # Build the entire tree, saving build messages to the build log
191 #
192 if (!$NOCHECKOUT) {
193   system "(time -p ./configure --enable-jit --enable-spec --with-objroot=.) > $Prefix-Build-Log.txt 2>&1";
194
195   # Build the entire tree, capturing the output into $Prefix-Build-Log.txt
196   system "(time -p gmake $MAKEOPTS) >> $Prefix-Build-Log.txt 2>&1";
197 }
198
199
200 sub GetRegexNum {
201   my ($Regex, $Num, $Regex2, $File) = @_;
202   my @Items = split "\n", `grep '$Regex' $File`;
203   return GetRegex $Regex2, $Items[$Num];
204 }
205
206 #
207 # Get some statistics about the build...
208 #
209 my @Linked = split '\n', `grep Linking $Prefix-Build-Log.txt`;
210 my $NumExecutables = scalar(grep(/executable/, @Linked));
211 my $NumLibraries   = scalar(grep(!/executable/, @Linked));
212 my $NumObjects     = `grep '^Compiling' $Prefix-Build-Log.txt | wc -l` + 0;
213
214 my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$Prefix-Build-Log.txt";
215 my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$Prefix-Build-Log.txt";
216 my $ConfigTime  = $ConfigTimeU+$ConfigTimeS;  # ConfigTime = User+System
217 my $ConfigWallTime = GetRegexNum "^real", 0,"([0-9.]+)","$Prefix-Build-Log.txt";
218
219 my $BuildTimeU = GetRegexNum "^user", 1, "([0-9.]+)", "$Prefix-Build-Log.txt";
220 my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$Prefix-Build-Log.txt";
221 my $BuildTime  = $BuildTimeU+$BuildTimeS;  # BuildTime = User+System
222 my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$Prefix-Build-Log.txt";
223
224 my $BuildError = "";
225 if (`grep '^gmake[^:]*: .*Error' $Prefix-Build-Log.txt | wc -l` + 0 ||
226     `grep '^gmake: \*\*\*.*Stop.' $Prefix-Build-Log.txt | wc -l`+0) {
227   $BuildError = "<h3><font color='red'>Build error: compilation " .
228                 "<a href=\"$DATE-Build-Log.txt\">aborted</a></font></h3>";
229   print "BUILD ERROR\n";
230 }
231
232 #
233 # Get warnings from the build
234 #
235 my @Warn = split "\n", `egrep 'warning:|Entering dir' $Prefix-Build-Log.txt`;
236 my @Warnings;
237 my $CurDir = "";
238
239 foreach $Warning (@Warn) {
240   if ($Warning =~ m/Entering directory \`([^\`]+)\'/) {
241     $CurDir = $1;                 # Keep track of directory warning is in...
242     if ($CurDir =~ m#$BuildDir/llvm/(.*)#) { # Remove buildir prefix if included
243       $CurDir = $1;
244     }
245   } else {
246     push @Warnings, "$CurDir/$Warning";     # Add directory to warning...
247   }
248 }
249 my $WarningsFile =  join "\n", @Warnings;
250 my $WarningsList = AddPreTag $WarningsFile;
251 $WarningsFile =~ s/:[0-9]+:/::/g;
252
253 # Emit the warnings file, so we can diff...
254 WriteFile "$WebDir/$DATE-Warnings.txt", $WarningsFile . "\n";
255 my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
256
257 # Output something to stdout if something has changed
258 print "ADDED   WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
259 print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
260
261 $WarningsAdded = AddPreTag $WarningsAdded;
262 $WarningsRemoved = AddPreTag $WarningsRemoved;
263
264 #
265 # Get some statistics about CVS commits over the current day...
266 #
267 @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
268 #print join "\n", @CVSHistory; print "\n";
269
270 # Extract some information from the CVS history... use a hash so no duplicate
271 # stuff is stored.
272 my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
273
274 my $DateRE = "[-:0-9 ]+\\+[0-9]+";
275
276 # Loop over every record from the CVS history, filling in the hashes.
277 foreach $File (@CVSHistory) {
278   my ($Type, $Date, $UID, $Rev, $Filename);
279   if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
280     ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
281   } elsif ($File =~ /([W]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+)/) {
282     ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
283   } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
284     ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
285   } else {
286     print "UNMATCHABLE: $File\n";
287   }
288   # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
289
290   if ($Filename =~ /^llvm/) {
291     if ($Type eq 'M') {        # Modified
292       $ModifiedFiles{$Filename} = 1;
293       $UsersCommitted{$UID} = 1;
294     } elsif ($Type eq 'A') {   # Added
295       $AddedFiles{$Filename} = 1;
296       $UsersCommitted{$UID} = 1;
297     } elsif ($Type eq 'R') {   # Removed
298       $RemovedFiles{$Filename} = 1;
299       $UsersCommitted{$UID} = 1;
300     } else {
301       $UsersUpdated{$UID} = 1;
302     }
303   }
304 }
305
306 my $UserCommitList = join "\n", keys %UsersCommitted;
307 my $UserUpdateList = join "\n", keys %UsersUpdated;
308 my $AddedFilesList = AddPreTag join "\n", sort keys %AddedFiles;
309 my $ModifiedFilesList = AddPreTag join "\n", sort keys %ModifiedFiles;
310 my $RemovedFilesList = AddPreTag join "\n", sort keys %RemovedFiles;
311
312 my $TestError = 1;
313 my $SingleSourceProgramsTable;
314 my $MultiSourceProgramsTable;
315 my $ExternalProgramsTable;
316
317
318 sub TestDirectory {
319   my $SubDir = shift;
320
321   chdir "test/Programs/$SubDir" or
322     die "Could not change into test/Programs/$SubDir testdir!";
323
324   # Run the programs tests... creating a report.nightly.html file
325   if (!$NOTEST) {
326     system "gmake -k $MAKEOPTS report.nightly.html TEST=nightly "
327          . "> $Prefix-$SubDir-ProgramTest.txt 2>&1";
328   } else {
329     system "gunzip $Prefix-$SubDir-ProgramTest.txt.gz";
330   }
331
332   my $ProgramsTable;
333   if (`grep '^gmake[^:]: .*Error' $Prefix-$SubDir-ProgramTest.txt | wc -l` + 0){
334     $TestError = 1;
335     $ProgramsTable = "<font color=white><h2>Error running tests!</h2></font>";
336     print "ERROR TESTING\n";
337   } elsif (`grep '^gmake[^:]: .*No rule to make target' $Prefix-$SubDir-ProgramTest.txt | wc -l` + 0) {
338     $TestError = 1;
339     $ProgramsTable =
340       "<font color=white><h2>Makefile error running tests!</h2></font>";
341     print "ERROR TESTING\n";
342   } else {
343     $TestError = 0;
344     $ProgramsTable = ReadFile "report.nightly.html";
345
346     #
347     # Create a list of the tests which were run...
348     #
349     system "egrep 'TEST-(PASS|FAIL)' < $Prefix-$SubDir-ProgramTest.txt "
350          . "| sort > $Prefix-$SubDir-Tests.txt";
351   }
352
353   # Compress the test output
354   system "gzip -f $Prefix-$SubDir-ProgramTest.txt";
355   chdir "../../.." or die "Cannot return to parent directory!";
356   return $ProgramsTable;
357 }
358
359 # If we build the tree successfully, run the nightly programs tests...
360 if ($BuildError eq "") {
361   $SingleSourceProgramsTable = TestDirectory("SingleSource");
362   $MultiSourceProgramsTable = TestDirectory("MultiSource");
363   $ExternalProgramsTable = TestDirectory("External");
364   system "cat $Prefix-SingleSource-Tests.txt $Prefix-MultiSource-Tests.txt ".
365          " $Prefix-External-Tests.txt | sort > $Prefix-Tests.txt";
366 }
367
368 my ($TestsAdded, $TestsRemoved, $TestsFixed, $TestsBroken) = ("","","","");
369
370 if ($TestError) {
371   $TestsAdded   = "<b>error testing</b><br>";
372   $TestsRemoved = "<b>error testing</b><br>";
373   $TestsFixed   = "<b>error testing</b><br>";
374   $TestsBroken  = "<b>error testing</b><br>";
375 } else {
376   my ($RTestsAdded, $RTestsRemoved) = DiffFiles "-Tests.txt";
377
378   my @RawTestsAddedArray = split '\n', $RTestsAdded;
379   my @RawTestsRemovedArray = split '\n', $RTestsRemoved;
380
381   my %OldTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
382     @RawTestsRemovedArray;
383   my %NewTests = map {GetRegex('TEST-....: (.+)', $_)=>$_}
384     @RawTestsAddedArray;
385
386   foreach $Test (keys %NewTests) {
387     if (!exists $OldTests{$Test}) {  # TestAdded if in New but not old
388       $TestsAdded = "$TestsAdded$Test\n";
389     } else {
390       if ($OldTests{$Test} =~ /TEST-PASS/) {  # Was the old one a pass?
391         $TestsBroken = "$TestsBroken$Test\n";  # New one must be a failure
392       } else {
393         $TestsFixed = "$TestsFixed$Test\n";    # No, new one is a pass.
394       }
395     }
396   }
397   foreach $Test (keys %OldTests) {  # TestRemoved if in Old but not New
398     $TestsRemoved = "$TestsRemoved$Test\n" if (!exists $NewTests{$Test});
399   }
400
401   print "\nTESTS ADDED:  \n\n$TestsAdded\n\n"   if (length $TestsAdded);
402   print "\nTESTS REMOVED:\n\n$TestsRemoved\n\n" if (length $TestsRemoved);
403   print "\nTESTS FIXED:  \n\n$TestsFixed\n\n"   if (length $TestsFixed);
404   print "\nTESTS BROKEN: \n\n$TestsBroken\n\n"  if (length $TestsBroken);
405
406   $TestsAdded   = AddPreTag $TestsAdded;
407   $TestsRemoved = AddPreTag $TestsRemoved;
408   $TestsFixed   = AddPreTag $TestsFixed;
409   $TestsBroken  = AddPreTag $TestsBroken;
410 }
411
412
413 # If we built the tree successfully, runs of the Olden suite with
414 # LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
415 if ($BuildError eq "") {
416   my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
417       $MachCodeSize) = ("","","","","","","");
418   if (!$NORUNNINGTESTS) {
419     chdir "test/Programs/MultiSource/Benchmarks/Olden" or die "Olden tests moved?";
420
421     # Clean out previous results...
422     system "gmake $MAKEOPTS clean > /dev/null 2>&1";
423
424     # Run the nightly test in this directory, with LARGE_PROBLEM_SIZE enabled!
425     system "gmake -k $MAKEOPTS report.nightly.raw.out TEST=nightly " .
426            " LARGE_PROBLEM_SIZE=1 > /dev/null 2>&1";
427     system "cp report.nightly.raw.out $Prefix-Olden-tests.txt";
428   } else {
429     system "gunzip $Prefix-Olden-tests.txt.gz";
430   }
431
432   # Now we know we have $Prefix-Olden-tests.txt as the raw output file.  Split
433   # it up into records and read the useful information.
434   my @Records = split />>> ========= /, ReadFile "$Prefix-Olden-tests.txt";
435   shift @Records;  # Delete the first (garbage) record
436
437   # Loop over all of the records, summarizing them into rows for the running
438   # totals file.
439   my $WallTimeRE = "[A-Za-z0-9.: ]+\\(([0-9.]+) wall clock";
440   foreach $Rec (@Records) {
441     my $rNATTime = GetRegex 'TEST-RESULT-nat-time: real\s*([.0-9m]+)', $Rec;
442     my $rCBETime = GetRegex 'TEST-RESULT-cbe-time: real\s*([.0-9m]+)', $Rec;
443     my $rLLCTime = GetRegex 'TEST-RESULT-llc-time: real\s*([.0-9m]+)', $Rec;
444     my $rJITTime = GetRegex 'TEST-RESULT-jit-time: real\s*([.0-9m]+)', $Rec;
445     my $rOptTime = GetRegex "TEST-RESULT-compile: $WallTimeRE", $Rec;
446     my $rBytecodeSize = GetRegex 'TEST-RESULT-compile: *([0-9]+)', $Rec;
447     my $rMachCodeSize = GetRegex 'TEST-RESULT-jit-machcode: *([0-9]+).*bytes of machine code', $Rec;
448
449     $NATTime .= " " . FormatTime($rNATTime);
450     $CBETime .= " " . FormatTime($rCBETime);
451     $LLCTime .= " " . FormatTime($rLLCTime);
452     $JITTime .= " " . FormatTime($rJITTime);
453     $OptTime .= " $rOptTime";
454     $BytecodeSize .= " $rBytecodeSize";
455     $MachCodeSize .= " $rMachCodeSize";
456   }
457
458   # Now that we have all of the numbers we want, add them to the running totals
459   # files.
460   AddRecord($NATTime, "running_Olden_nat_time.txt");
461   AddRecord($CBETime, "running_Olden_cbe_time.txt");
462   AddRecord($LLCTime, "running_Olden_llc_time.txt");
463   AddRecord($JITTime, "running_Olden_jit_time.txt");
464   AddRecord($OptTime, "running_Olden_opt_time.txt");
465   AddRecord($BytecodeSize, "running_Olden_bytecode.txt");
466   AddRecord($MachCodeSize, "running_Olden_machcode.txt");
467
468   system "gzip -f $Prefix-Olden-tests.txt";
469 }
470
471
472
473
474 #
475 # Get a list of the previous days that we can link to...
476 #
477 my @PrevDays = map {s/.html//; $_} GetDir ".html";
478
479 splice @PrevDays, 20;  # Trim down list to something reasonable...
480
481 my $PrevDaysList =     # Format list for sidebar
482   join "\n  ", map { "<a href=\"$_.html\">$_</a><br>" } @PrevDays;
483
484 #
485 # Start outputing files into the web directory
486 #
487 chdir $WebDir or die "Could not change into web directory!";
488
489 # Add information to the files which accumulate information for graphs...
490 AddRecord($LOC, "running_loc.txt");
491 AddRecord($BuildTime, "running_build_time.txt");
492
493 #
494 # Rebuild the graphs now...
495 #
496 $GNUPLOT = "/usr/dcs/software/supported/bin/gnuplot";
497 $GNUPLOT = "gnuplot" if ! -x $GNUPLOT;
498 $PlotScriptFilename = "$BuildDir/llvm/utils/NightlyTest.gnuplot";
499 system ($GNUPLOT, $PlotScriptFilename);
500
501 #
502 # Remove the cvs tree...
503 #
504 system "rm -rf $BuildDir" if (!$NOCHECKOUT and !$NOREMOVE);
505
506 #
507 # Print out information...
508 #
509 if (0) {
510   print "DateString: $DateString\n";
511   print "CVS Checkout: $CVSCheckoutTime seconds\n";
512   print "Files/Dirs/LOC in CVS: $NumFilesInCVS/$NumDirsInCVS/$LOC\n";
513
514   print "Build Time: $BuildTime seconds\n";
515   print "Libraries/Executables/Objects built: $NumLibraries/$NumExecutables/$NumObjects\n";
516
517   print "WARNINGS:\n  $WarningsList\n";
518
519   print "Users committed: $UserCommitList\n";
520   print "Added Files: \n  $AddedFilesList\n";
521   print "Modified Files: \n  $ModifiedFilesList\n";
522   print "Removed Files: \n  $RemovedFilesList\n";
523
524   print "Previous Days =\n  $PrevDaysList\n";
525 }
526
527
528 #
529 # Output the files...
530 #
531
532 # Main HTML file...
533 my $Output;
534 eval "\$Output = <<ENDOFFILE;$TemplateContents\nENDOFFILE\n";
535 WriteFile "$DATE.html", $Output;
536
537 # Change the index.html symlink...
538 system "ln -sf $DATE.html index.html";
539
540 sub AddRecord {
541   my ($Val, $Filename) = @_;
542   my @Records;
543   if (open FILE, "$WebDir/$Filename") {
544     @Records = grep !/$DATE/, split "\n", <FILE>;
545     close FILE;
546   }
547   push @Records, "$DATE: $Val";
548   WriteFile "$WebDir/$Filename", (join "\n", @Records) . "\n";
549   return @Records;
550 }