1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607
|
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
& eval 'exec perl -S $0 $argv:q'
if 0;
# -*- perl -*-
# $Id: auto_compile 80826 2008-03-04 14:51:23Z wotte $
#
# This script checkouts ACE from CVS, updates the "clone" directory,
# compiles $ACE_ROOT/ace and $ACE_ROOT/tests and finally runs
# $ACE_ROOT/tests/run_tests.sh.
#
# If it detects any problem it send email.
#
# DO NOT invoke this script from your crontab, use
# auto_compile_wrapper for that.
#
# This script requires Perl5.
#
# TODO: Modify the script or split it in such a way that the main copy
# can be obtained either using cvs or downloading the lastest beta
# from the WWW.
#
# The first three lines above let this script run without specifying the
# full path to perl, as long as it is in the user's PATH.
# Taken from perlrun man page.
use File::Basename;
use File::Copy;
use FileHandle;
require POSIX;
# This are the sub-directories (in the module) we really compile.
# Find out the command name.
$CMD = basename($0);
$dont_update = 0;
# $copy_logs = 1;
# $LOG_DESTINATION = $ENV{'HOME'}.'/.www-docs/auto_compile';
$copy_logs = 0;
$LOG_DESTINATION='bugzilla'.'@cs.wustl.edu';
$dont_build_tao = 0;
$dont_run = 0;
$makefile_suffix = "";
$pre_realclean = 0;
$post_realclean = 0;
$report_success = 0;
$debug = 0;
$sandbox = '';
$sandbox_timeout = 600;
$sendreport = 0;
@BUILD_LIST= ();
@CONFIGURATION_OPTIONS = ();
@ARGS = ();
while ($#ARGV >= 0) {
if (!($ARGV[0] =~ m/^-/)) {
push @ARGS, $ARGV[0];
} elsif ($ARGV[0] eq "-single_threaded") {
print STDERR "$CMD: obsolete option $ARGV[0], "
."please use -config instead\n";
push @CONFIGURATION_OPTIONS, 'ST';
} elsif ($ARGV[0] eq "-minimum_corba") {
print STDERR "$CMD: obsolete option $ARGV[0], "
."please use -config instead\n";
push @CONFIGURATION_OPTIONS, 'MINIMUM';
} elsif ($ARGV[0] eq "-ami") {
print STDERR "$CMD: obsolete option $ARGV[0], "
."please use -config instead\n";
push @CONFIGURATION_OPTIONS, 'AMI';
} elsif ($ARGV[0] eq "-smart_proxies") {
print STDERR "$CMD: obsolete option $ARGV[0], "
."please use -config instead\n";
push @CONFIGURATION_OPTIONS, 'SMART_PROXIES';
} elsif ($ARGV[0] eq "-static") {
print STDERR "$CMD: obsolete option $ARGV[0], "
."please use -config instead\n";
push @CONFIGURATION_OPTIONS, 'STATIC';
} elsif ($ARGV[0] eq "-config") {
shift;
push @CONFIGURATION_OPTIONS, $ARGV[0];
} elsif ($ARGV[0] eq "-build_list") {
shift;
@BUILD_LIST = split (/,/, $ARGV[0]);
} elsif ($ARGV[0] eq "-dont_update") {
$dont_update = 1;
} elsif ($ARGV[0] eq "-copy_logs") {
shift;
$copy_logs = 1;
$LOG_DESTINATION = $ARGV[0];
} elsif ($ARGV[0] eq "-sandbox") {
shift;
$sandbox = $ARGV[0];
} elsif ($ARGV[0] eq "-sandbox_timeout") {
shift;
$sandbox_timeout = $ARGV[0];
} elsif ($ARGV[0] eq "-dont_run") {
$dont_run = 1;
} elsif ($ARGV[0] eq "-pre_realclean") {
$pre_realclean = 1;
} elsif ($ARGV[0] eq "-post_realclean") {
$post_realclean = 1;
} elsif ($ARGV[0] eq "-report_success") {
$report_success = 1;
} elsif ($ARGV[0] eq "-debug") {
$debug = 1;
} elsif ($ARGV[0] eq "-sendreport") {
$sendreport = 1;
} elsif ($ARGV[0] eq "-notao") {
$dont_build_tao = 1;
} elsif ($ARGV[0] eq "-make_type") {
shift;
$makefile_suffix = $ARGV[0];
} else {
print "Ignoring option $ARGV[0]\n";
}
shift;
}
# Extract configuration information from command line.
# TODO: Some validation and checking should be done here.
$CHECKOUT = $ARGS[0];
$BUILD = $ARGS[1];
$LOGDIR = $ARGS[2];
$ADMIN = $ARGS[3];
$MAIL = "mail";
if ($#ARGS >= 4) {
$MAIL = $ARGS[4];
}
$LOG_URL = "http://ace.cs.wustl.edu/~bugzilla/auto_compile_logs/";
if ($#ARGS >= 5) {
$LOG_URL = $ARGS[5];
}
# This is the module we will checkout unless a different one is on the
# command line.
$MODULE='ACE_wrappers';
if ($#ARGS >= 6) {
$MODULE = $ARGS[6];
}
$ENV{'ACE_ROOT'} = $CHECKOUT . '/' . $MODULE . '/build/' . $BUILD;
$ENV{'TAO_ROOT'} = $CHECKOUT . '/' . $MODULE . '/build/' . $BUILD . '/TAO';
# We obtain our revision to report errors.
$REVISION='$Revision: 80826 $ ';
# When an error is found we try to die gracefully and send some email
# to ADMIN.
$disable_file = $LOGDIR . '/.disable';
$histfile = $LOGDIR . '/history';
$LOGBASE = POSIX::strftime("%Y_%m_%d_%H_%M", localtime);
$LOGFILE = $LOGDIR . '/' . $LOGBASE . '.txt';
$HOST = `hostname`;
chop $HOST;
$LOG_NAME = $HOST . '_' . $BUILD . '/' . $LOGBASE . '.txt';
$STATUS = "OK";
if ($debug) {
print "CHECKOUT = $CHECKOUT\n";
print "BUILD = $BUILD\n";
print "LOGDIR = $LOGDIR\n";
print "ADMIN = $ADMIN\n";
print "MAIL = $MAIL\n";
print "ACE_ROOT = $ENV{ACE_ROOT}\n";
print "TAO_ROOT = $ENV{TAO_ROOT}\n";
print "CONFIGURATION_OPTIONS = ", @CONFIGURATION_OPTIONS, "\n";
}
push @INC, $CHECKOUT . '/' . $MODULE . '/bin';
require PerlACE::ConfigList;
$config_list = new PerlACE::ConfigList;
$config_list->my_config_list (@CONFIGURATION_OPTIONS);
if ($#BUILD_LIST == -1) {
if ($dont_build_tao) {
@BUILD_LIST=('ace', 'netsvcs', 'tests');
}
else {
@BUILD_LIST=('.', 'TAO');
}
}
sub mydie {
my $DEST_DIR = $LOG_DESTINATION.'/'.$HOST.'_'.$BUILD;
mkdir $DEST_DIR,0755 if (!-d $DEST_DIR);
if (open(STATUS, '>'.$DEST_DIR.'/status.txt')) {
print STATUS "SCOREBOARD_STATUS: Inactive\n";
close STATUS;
}
unlink $disable_file;
die $_ . "\n";
}
@RUN_LIST = ();
if ($debug) {
@BUILD_LIST = ('ace');
@RUN_LIST = ('TAO/tests/OctetSeq/run_test.pl');
$ADMIN = $ENV{'LOGNAME'};
} else {
$config_list->load ($CHECKOUT . '/' . $MODULE . '/' . 'build/' . $BUILD . '/bin/auto_run_tests.lst');
@RUN_LIST = $config_list->valid_entries ();
}
sub mail_logs {
open (MAIL, "|".$MAIL.' -s AUTO_COMPILE_LOG='.$LOG_NAME.' '.$LOG_DESTINATION)
|| mydie "Cannot open mail pipe for: $LOG_NAME\n";
print MAIL 'This is the log for: ', "\n";
print MAIL $CMD, ' [', $REVISION, "] for $HOST/$BUILD\n";
print MAIL "\n================================================================\n";
if (open (THELOG, "$LOGFILE"))
{
while (<THELOG>) {
print MAIL $_;
}
close (THELOG);
}
close (MAIL); # Ignore errors....
}
sub copy_logs {
local $DEST_DIR = $LOG_DESTINATION.'/'.$HOST.'_'.$BUILD;
mkdir $DEST_DIR,0755 if (!-d $DEST_DIR);
copy($LOGFILE, $DEST_DIR.'/'.$LOGBASE.'.txt');
local $MAKE_PRETTY="$CHECKOUT/$MODULE/bin/make_pretty.pl";
system ("perl $MAKE_PRETTY -b -i $LOGFILE >$DEST_DIR/$LOGBASE"."_brief.html");
system ("perl $MAKE_PRETTY -i $LOGFILE >$DEST_DIR/$LOGBASE".".html");
chmod 0644, $DEST_DIR.'/'.$LOGBASE.'.txt'
, $DEST_DIR.'/'.$LOGBASE.'_brief.html'
, $DEST_DIR.'/'.$LOGBASE.'.html' ;
}
sub report_errors {
# First clear the lock, so the next execution works...
unlink $disable_file; # Ignore errors!
if ($sendreport) {
# Now send a summary of the errors to the ADMIN account, if there are any.
if ($#_ >= 0) {
local $to = $ADMIN;
open (MAIL, "|".$MAIL.' -s "[AUTO_COMPILE] '.$HOST.' '.$BUILD.'" '.$to)
|| mydie "Cannot open mail pipe for: $_\n";
print MAIL 'The following message is brought to you by: ', "\n";
print MAIL $CMD, ' [', $REVISION, "] for $BUILD on $HOST\n\n";
print MAIL "\nPlease check the following log for more info:\n\n";
print MAIL $LOG_URL, '?', $HOST, '_', $BUILD, "\n\n";
local $m;
foreach $m (@_) {
print MAIL $m, "\n";
}
close (MAIL); # Ignore errors....
}
}
# Now send the complete log to bugzilla...
if ($copy_logs) {
copy_logs ();
} else {
mail_logs ();
}
}
### MAIN FUNCTION
if (-f $disable_file) {
print 'The following message is brought to you by: ', "\n";
print $CMD, ' [', $REVISION, "] for $BUILD on $CHECKOUT\n";
print "DISABLED\n";
exit 0;
}
open (DISABLE, '>' . $disable_file)
|| die "cannot open disable file <$disable_file>\n";
print DISABLE "auto_compile <$date> is running\n";
close (DISABLE)
|| die "cannot close disable file";
open(HIST, '>>' . $histfile)
# Do not use 'mydie' to report the problem, it tries to remove the
# disable file
|| mydie "cannot open history file \"$histfile\"\n";
$date = localtime;
print HIST $CMD, ': running at ', $date, ' ';
open(LOG, '>' . $LOGFILE)
|| mydie "cannot open log file";
LOG->autoflush ();
# The following lines are useful when debugging the script or wrapper.
# print LOG $CHECKOUT, " ", $BUILD, " ", $LOGDIR, " ", $ADMIN, "\n";
#while (($key,$value) = each %ENV) {
# print LOG $key, " = ", $value, "\n";
#}
print LOG "#################### CVS\n";
my $DEST_DIR = $LOG_DESTINATION.'/'.$HOST.'_'.$BUILD;
mkdir $DEST_DIR,0755 if !-d $DEST_DIR;
if (open(STATUS, '>'.$DEST_DIR.'/status.txt')) {
print STATUS "SCOREBOARD_STATUS: CVS\n";
close STATUS;
}
chdir($CHECKOUT)
|| mydie "Cannot chdir to $CHECKOUT";
if ($dont_update == 0) {
$date = localtime;
print LOG "$CMD: starting checkout at ", $date, "\n";
open(CVS, "cvs -q checkout -P $MODULE 2>&1 |")
|| mydie "cannot start checkout of $MODULE";
$conflicts = 0;
while (<CVS>) {
if (m/^C /) {
($unused, $entry) = split('/');
if (($entry ne "ChangeLog\n") && ($entry ne "THANKS\n")) {
$conflicts = 1;
}
}
print LOG $_;
}
close(CVS);
# || mydie "error while checking out $MODULE";
$date = localtime;
print LOG "$CMD: checkout finished at ", $date, "\n";
if ($conflicts != 0) {
mydie "conflicts on checkout";
}
}
chdir($MODULE)
|| mydie "cannot chdir to $MODULE";
$date = localtime;
print LOG "$CMD: starting clone at ", $date, "\n";
open(CLONE, "perl bin/create_ace_build -a -v $BUILD 2>&1 |")
|| mydie "cannot clone directory";
while(<CLONE>) {
print LOG $_;
}
close(CLONE)
|| mydie "error while cloning ACE_ROOT";
$date = localtime;
print LOG "$CMD: clone finished at ", $date, "\n";
chdir('build/' . $BUILD)
|| mydie "cannot chdir to $BUILD";
@failures = ();
if ($makefile_suffix ne "") {
$MAKEFLAGS = "-f Makefile.$makefile_suffix";
}
print LOG "#################### Compiler\n";
if (open(STATUS, '>'.$DEST_DIR.'/status.txt')) {
print STATUS "SCOREBOARD_STATUS: Compile\n";
close STATUS;
}
if ($pre_realclean) {
foreach $i (reverse(@BUILD_LIST)) {
$date = localtime;
print LOG "$CMD: =============================================\n";
print LOG "$CMD: make realclean in $i started at ", $date, "\n";
open(MAKE, "make -k $MAKEFLAGS -C $i realclean 2>&1 |")
|| mydie "cannot start make in $i";
while (<MAKE>) {
# Ignore errors....
}
if (close(MAKE) == 0) {
push @failures, "errors while cleaning $i";
}
$date = localtime;
print LOG "$CMD: make realclean in $i finished at ", $date, "\n";
print LOG "$CMD: =============================================\n\n";
}
}
$MAKEFLAGS .= "";
foreach $i (@BUILD_LIST) {
$date = localtime;
print LOG "$CMD: =============================================\n";
print LOG "$CMD: make for $i started at ", $date, "\n";
open(MAKE, "make -k $MAKEFLAGS -C $i 2>&1 |")
|| mydie "cannot start make for $i";
local $current_dir = $i;
local $last_error = "";
local $this_error = 0;
local $this_warning = 0;
while (<MAKE>) {
chop;
$this_error = $this_warning = 0;
if ($^O eq 'hpux'
&& m/^Warning:[ \t]+[0-9]+ future errors were detected/) {
next;
}
print LOG $_, "\n";
if (m/^make(\[[0-9]+\])?: Entering directory /) {
s/^make(\[[0-9]+\])?: Entering directory //;
s%^$ENV{'ACE_ROOT'}/%%;
$current_dir = $_;
}
if (m/error:/i || m/error /i
|| m/^make(\[[0-9]+\])?: \*\*\*/) {
$this_error = 1;
}
if ($^O eq 'aix'
&& m/\d+-\d+ \([SI]\)/) {
$this_error = 1;
}
if ($this_error) {
if ($last_error ne $current_dir
|| STATUS eq "COMPILATION WARNING") {
$STATUS = "COMPILATION ERROR";
push @failures, "Error while compiling in $current_dir \n";
$last_error = $current_dir;
}
}
if (m/warning:/i
|| m/warning /i
|| m/Info: /i) {
$this_warning = 1;
if ($^O eq 'aix'
&& m/^ld: \d+-\d+ WARNING: Duplicate symbol: .*ACE.*/) {
$this_warning = 0;
}
}
if ($^O eq 'aix'
&& m/\d+-\d+ \(W\)/) {
$this_warning = 1;
}
if ($this_warning) {
if ($last_error ne $current_dir) {
if ($STATUS eq "OK") {
$STATUS = "COMPILATION WARNING";
}
push @failures, "Warning while compiling in $current_dir\n";
$last_error = $current_dir;
}
}
}
if (close(MAKE) == 0) {
push @failures, "errors while running make in $i";
}
$date = localtime;
print LOG "$CMD: make for $i finished at ", $date, "\n";
print LOG "$CMD: =============================================\n\n";
}
print LOG "#################### Tests\n";
if (open(STATUS, '>'.$DEST_DIR.'/status.txt')) {
print STATUS "SCOREBOARD_STATUS: Tests\n";
close STATUS;
}
if ($dont_run == 0) {
my $config_params;
if ($#CONFIGURATION_OPTIONS != -1) {
$config_params = ' -Config ';
}
$config_params .= join ' -Config ', @CONFIGURATION_OPTIONS;
foreach my $i (@RUN_LIST) {
local $directory = '.';
local $program = $i;
if ($i =~ /(.*)\/([^\/]*)$/) {
$directory = $1;
$program = $2;
}
$date = localtime;
print LOG "\n\n$CMD: ================ $date ================\n";
print LOG "auto_run_tests: $i\n";
local $subdir =
$CHECKOUT .'/'. $MODULE .'/build/'. $BUILD .'/'. $directory;
chdir ($subdir)
|| mydie "cannot chdir to $subdir";
$run_error = 0;
my $prefix = '';
if ($sandbox ne "") {
$prefix = $sandbox.' '.$sandbox_timeout.' ';
}
if (open(RUN, $prefix."perl $program $config_params 2>&1 |") == 0) {
push @failures, "cannot run $program in $directory";
next;
}
while (<RUN>) {
print LOG $_;
if (m/Error/
|| m/ERROR/
|| m/FAILED/
|| m/EXCEPTION/
|| m/pure virtual /i) {
if ($STATUS eq "OK") {
$STATUS = "RUNTIME ERROR";
}
$run_error = 1;
}
}
if (close(RUN) == 0) {
if ($STATUS eq "OK") {
$STATUS = "RUNTIME ERROR";
}
print LOG "ERROR, non-zero status returned by test script\n";
push @failures, "Error when closing pipe for $program in $directory";
next;
}
$date = localtime;
print LOG "$CMD: $program finished ", $date, "\n";
if ($run_error != 0) {
push @failures,
"errors detected while running $program in $directory";
}
}
}
if ($post_realclean) {
foreach $i (reverse(@BUILD_LIST)) {
$date = localtime;
print LOG "$CMD: =============================================\n";
print LOG "$CMD: make realclean in $i started at ", $date, "\n";
open(MAKE, "make -k $MAKEFLAGS -C $i realclean 2>&1 |");
while (<MAKE>) {
# Ignore errors....
}
if (close(MAKE) == 0) {
push @failures, "errors while cleaning $i";
}
$date = localtime;
print LOG "$CMD: make realclean in $i finished at ", $date, "\n";
print LOG "$CMD: =============================================\n\n";
}
}
print LOG "#################### Config\n";
chdir($CHECKOUT . "/" . $MODULE . "/build/" . $BUILD)
|| mydie "Cannot chdir to $CHECKOUT/$MODULE/build/$BUILD";
open (CONFIG, "perl bin/nightlybuilds/print_config.pl $CHECKOUT/$MODULE/build/$BUILD 2>&1 |")
|| mydie "Cannot run print_config.pl script";
while (<CONFIG>) {
print LOG $_;
}
close (CONFIG)
|| mydie "Error while running print_config.pl script";
report_errors @failures;
print LOG "#################### End\n";
if (open(STATUS, '>'.$DEST_DIR.'/status.txt')) {
print STATUS "SCOREBOARD_STATUS: Inactive\n";
close STATUS;
}
close(LOG)
|| mydie "cannot close LOGFILE";
print HIST "$STATUS\n";
close(HIST)
|| mydie "cannot close history file";
unlink $disable_file
|| die "cannot unlink disable file";
if ($report_success && $STATUS eq "OK") {
report_errors "Congratulations: No errors or warnings detected\n";
}
exit 0;
|