~louis/ubuntu/trusty/clamav/lp799623_fix_logrotate

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/utils/NewNightlyTest.pl

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-03-12 11:30:04 UTC
  • mfrom: (0.41.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100312113004-b0fop4bkycszdd0z
Tags: 0.96~rc1+dfsg-0ubuntu1
* New upstream RC - FFE (LP: #537636):
  - Add OfficialDatabaseOnly option to clamav-base.postinst.in
  - Add LocalSocketGroup option to clamav-base.postinst.in
  - Add LocalSocketMode option to clamav-base.postinst.in
  - Add CrossFilesystems option to clamav-base.postinst.in
  - Add ClamukoScannerCount option to clamav-base.postinst.in
  - Add BytecodeSecurity opiton to clamav-base.postinst.in
  - Add DetectionStatsHostID option to clamav-freshclam.postinst.in
  - Add Bytecode option to clamav-freshclam.postinst.in
  - Add MilterSocketGroup option to clamav-milter.postinst.in
  - Add MilterSocketMode option to clamav-milter.postinst.in
  - Add ReportHostname option to clamav-milter.postinst.in
  - Bump libclamav SO version to 6.1.0 in libclamav6.install
  - Drop clamdmon from clamav.examples (no longer shipped by upstream)
  - Drop libclamav.a from libclamav-dev.install (not built by upstream)
  - Update SO version for lintian override for libclamav6
  - Add new Bytecode Testing Tool, usr/bin/clambc, to clamav.install
  - Add build-depends on python and python-setuptools for new test suite
  - Update debian/copyright for the embedded copy of llvm (using the system
    llvm is not currently feasible)

Show diffs side-by-side

added added

removed removed

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