1
1

Revamped test_build.pl script to be a bit more robust. Also committed

sample configuration file (the comments are much longer than the
configurations! :-).

This commit was SVN r2286.
Этот коммит содержится в:
Jeff Squyres 2004-08-24 21:30:42 +00:00
родитель 21402b68bb
Коммит 4a1a26c35b
2 изменённых файлов: 176 добавлений и 58 удалений

40
contrib/nightly/build_sample_config.txt Обычный файл
Просмотреть файл

@ -0,0 +1,40 @@
#
# $HEADER$
#
# Sample configuration file for the test_build.pl script.
#
# First argument: String name of the configuration, used for
# describing and labeling the result. Names should not be repeated in
# one configuration file (no error checking is performed; if multiple
# lines have the same name, the results of only one of them will be
# reported).
#
# Second argument: Whether to combine stdout and stderr (1), or leave
# them separate (blank). You should probably only use (1) for when
# you want to see the warnings from "make all", and leave it blank for
# all other cases.
#
# Third argument: VPATH mode. Must be the strings "absolute",
# "relative", or blank. If "absolute", then the configure script will
# be run as an absolute VPATH (i.e., top_builddir != top_srcdir, and
# configure's absolute path will be used for invocation). If
# "relative", the setup as the same except that a relative path to
# configure is used. If blank (or any other value), a non-VPATH build
# is used.
#
# Fourth argument: arbitrary strings to pass to configure. You can
# set environment flags here, specific options to configure, etc. You
# should *not* specify a --prefix argument; that is the only argument
# supplied by the testing script.
#
# Examples:
#
# warnings:1::--enable-debug --enable-picky
# default build:::
# absolute vpath:::absolute:CFLAGS=-g
# static build:::--disable-shared --enable-static
#
warnings:1::--enable-debug --enable-picky --disable-f77
default build:::--disable-f77
static build:::--disable-shared --enable-static
non-threaded build:::--without-threads

Просмотреть файл

@ -81,22 +81,29 @@ sub test_abort {
# run a command and save the stdout / stderr # run a command and save the stdout / stderr
sub do_command { sub do_command {
my ($cmd) = @_; my ($merge_output, $cmd) = @_;
print "*** Running command: $cmd\n" if ($debug); print "*** Running command: $cmd\n" if ($debug);
pipe OUTread, OUTwrite; pipe OUTread, OUTwrite;
pipe ERRread, ERRwrite; pipe ERRread, ERRwrite
if (!$merge_output);
# Child # Child
my $pid; my $pid;
if (($pid = fork()) == 0) { if (($pid = fork()) == 0) {
close OUTread; close OUTread;
close ERRread; close ERRread
if (!$merge_output);
close(STDERR); close(STDERR);
open STDERR, ">&ERRwrite" || if ($merge_output) {
die "Can't redirect stderr\n"; open STDERR, ">&OUTwrite" ||
die "Can't redirect stderr\n";
} else {
open STDERR, ">&ERRwrite" ||
die "Can't redirect stderr\n";
}
select STDERR; select STDERR;
$| = 1; $| = 1;
@ -106,21 +113,56 @@ sub do_command {
select STDOUT; select STDOUT;
$| = 1; $| = 1;
exec(split(' ', $cmd)) || # Turn shell-quoted words ("foo bar baz") into individual tokens
my @tokens;
while ($cmd =~ /\".*\"/) {
my $prefix;
my $middle;
my $suffix;
$cmd =~ /(.*?)\"(.*?)\"(.*)/;
$prefix = $1;
$middle = $2;
$suffix = $3;
if ($prefix) {
foreach my $token (split(' ', $prefix)) {
push(@tokens, $token);
}
}
if ($middle) {
push(@tokens, $middle);
} else {
push(@tokens, "");
}
$cmd = $suffix;
}
if ($cmd) {
push(@tokens, split(' ', $cmd));
}
# Run it!
exec(@tokens) ||
die "Can't execute command: $cmd\n"; die "Can't execute command: $cmd\n";
} }
close OUTwrite; close OUTwrite;
close ERRwrite; close ERRwrite
if (!$merge_output);
# Parent # Parent
my (@out, @err); my (@out, @err);
my ($rin, $rout); my ($rin, $rout);
my $done = 2; my $done = $merge_output ? 1 : 2;
# Keep watching over the pipe(s)
$rin = ''; $rin = '';
vec($rin, fileno(OUTread), 1) = 1; vec($rin, fileno(OUTread), 1) = 1;
vec($rin, fileno(ERRread), 1) = 1; vec($rin, fileno(ERRread), 1) = 1
if (!$merge_output);
while ($done > 0) { while ($done > 0) {
my $nfound = select($rout = $rin, undef, undef, undef); my $nfound = select($rout = $rin, undef, undef, undef);
@ -135,7 +177,7 @@ sub do_command {
} }
} }
if (vec($rout, fileno(ERRread), 1) == 1) { if (!$merge_output && vec($rout, fileno(ERRread), 1) == 1) {
my $data = <ERRread>; my $data = <ERRread>;
if (!defined($data)) { if (!defined($data)) {
vec($rin, fileno(ERRread), 1) = 0; vec($rin, fileno(ERRread), 1) = 0;
@ -147,7 +189,10 @@ sub do_command {
} }
} }
close OUTerr; close OUTerr;
close OUTread; close OUTread
if (!$merge_output);
# The pipes are closed, so the process should be dead. Reap it.
waitpid($pid, 0); waitpid($pid, 0);
my $status = $?; my $status = $?;
@ -155,11 +200,16 @@ sub do_command {
# Return an anonymous hash containing the relevant data # Return an anonymous hash containing the relevant data
return { my $ret = {
stdout => \@out, stdout => \@out,
stderr => \@err,
status => $status status => $status
}; };
# If we had stderr, return that, too
$ret->{stderr} = \@err
if (!$merge_output);
return $ret;
} }
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
@ -206,11 +256,13 @@ sub trim {
# subroutine for building a single configuration # subroutine for building a single configuration
sub try_build { sub try_build {
my ($tarball, $srcroot, $installdir, $vpath_mode, $confargs) = @_; my ($name, $merge_output, $tarball, $srcroot, $installdir,
$vpath_mode, $confargs) = @_;
my $ret; my $ret;
my $startdir = `pwd`; my $startdir = `pwd`;
our $version; our $version;
our $scratch_root_arg; our $scratch_root_arg;
our $leave_install_arg;
chomp($startdir); chomp($startdir);
@ -220,11 +272,6 @@ sub try_build {
} }
chdir($srcroot); chdir($srcroot);
# save what we're testing
my $name = "[default]";
$name = $confargs
if ($confargs);
# expand the tarball (do NOT assume GNU tar). don't use # expand the tarball (do NOT assume GNU tar). don't use
# do_command here because we need to use a pipe. This isn't an # do_command here because we need to use a pipe. This isn't an
# "interesting" command, anyway -- we don't need any stdout or # "interesting" command, anyway -- we don't need any stdout or
@ -251,14 +298,14 @@ sub try_build {
$config_command = "$srcroot/openmpi-$version/configure"; $config_command = "$srcroot/openmpi-$version/configure";
} }
} }
$ret = do_command("$config_command --prefix=$installdir $confargs"); $ret = do_command(1, "$config_command $confargs --prefix=$installdir");
if ($ret->{status} != 0) { if ($ret->{status} != 0) {
$ret->{message} = "Failed to unzip the tarball"; $ret->{message} = "Failed to unzip the tarball";
return $ret; return $ret;
} }
# build it # build it
$ret = do_command("make all"); $ret = do_command($merge_output, "make all");
if ($ret->{status} != 0) { if ($ret->{status} != 0) {
$ret->{message} = "Failed to \"make all\""; $ret->{message} = "Failed to \"make all\"";
return $ret; return $ret;
@ -268,7 +315,7 @@ sub try_build {
my $make_all_stderr = $ret->{stderr}; my $make_all_stderr = $ret->{stderr};
# install it # install it
$ret = do_command("make install"); $ret = do_command(1, "make install");
if ($ret->{status} != 0) { if ($ret->{status} != 0) {
$ret->{make_all_stderr} = $make_all_stderr; $ret->{make_all_stderr} = $make_all_stderr;
$ret->{message} = "Failed to \"make install\""; $ret->{message} = "Failed to \"make install\"";
@ -288,7 +335,7 @@ int main(int argc, char* argv[]) {
MPI_Finalize(); MPI_Finalize();
return 0; return 0;
}\n"; }\n";
$ret = do_command("$installdir/bin/mpicc hello.c -o hello"); $ret = do_command(1, "$installdir/bin/mpicc hello.c -o hello");
if ($ret->{status} != 0) { if ($ret->{status} != 0) {
$ret->{make_all_stderr} = $make_all_stderr; $ret->{make_all_stderr} = $make_all_stderr;
$ret->{message} = "Failed to compile/link C \"hello world\" MPI app"; $ret->{message} = "Failed to compile/link C \"hello world\" MPI app";
@ -311,7 +358,7 @@ int main(int argc, char* argv[]) {
MPI::Finalize(); MPI::Finalize();
return 0; return 0;
}\n"; }\n";
do_command("$installdir/bin/mpic++ hello.cc -o hello"); do_command(1, "$installdir/bin/mpic++ hello.cc -o hello");
if ($ret->{status} != 0) { if ($ret->{status} != 0) {
$ret->{make_all_stderr} = $make_all_stderr; $ret->{make_all_stderr} = $make_all_stderr;
$ret->{message} = $ret->{message} =
@ -337,7 +384,7 @@ int main(int argc, char* argv[]) {
call MPI_FINALIZE(ierr) call MPI_FINALIZE(ierr)
stop stop
end\n"; end\n";
do_command("$installdir/bin/mpif77 hello.f -o hello"); do_command(1, "$installdir/bin/mpif77 hello.f -o hello");
if ($ret->{status} != 0) { if ($ret->{status} != 0) {
$ret->{make_all_stderr} = $make_all_stderr; $ret->{make_all_stderr} = $make_all_stderr;
$ret->{message} = $ret->{message} =
@ -348,9 +395,14 @@ int main(int argc, char* argv[]) {
print "COMPILE: F77 ok\n"; print "COMPILE: F77 ok\n";
} }
# all done -- clean up # all done -- clean up (unless user specified --leave-install)
chdir($startdir); chdir($startdir);
system("rm -rf $srcroot"); if ($leave_install_arg) {
system("rm -rf $srcroot/openmpi* $srcroot/test");
} else {
system("rm -rf $srcroot");
}
return { return {
make_all_stderr => $make_all_stderr, make_all_stderr => $make_all_stderr,
status => 0, status => 0,
@ -370,6 +422,7 @@ our $url_arg;
our $config_arg; our $config_arg;
our $debug_arg; our $debug_arg;
our $file_arg; our $file_arg;
our $leave_install_arg;
my $help_arg; my $help_arg;
&Getopt::Long::Configure("bundling", "require_order"); &Getopt::Long::Configure("bundling", "require_order");
@ -379,6 +432,7 @@ my $ok = Getopt::Long::GetOptions("url|u=s" => \$url_arg,
"config|c=s" => \$config_arg, "config|c=s" => \$config_arg,
"file|f=s" => \$file_arg, "file|f=s" => \$file_arg,
"debug|d" => \$debug_arg, "debug|d" => \$debug_arg,
"leave-install|l" => \$leave_install_arg,
"help|h" => \$help_arg, "help|h" => \$help_arg,
); );
@ -481,26 +535,25 @@ our $version;
if ($url_arg) { if ($url_arg) {
chdir("downloads"); chdir("downloads");
unlink($latest_name); unlink($latest_name);
do_command("$download $url_arg/$latest_name"); do_command(1, "$download $url_arg/$latest_name");
test_abort("Could not download latest snapshot number -- aborting") test_abort("Could not download latest snapshot number -- aborting")
if (! -f $latest_name); if (! -f $latest_name);
$version = `cat $latest_name`; $version = `cat $latest_name`;
chomp($version); chomp($version);
push(@email_output, "Snapshot: $version\n\n");
# see if we need to download the tarball # see if we need to download the tarball
$tarball_name = "openmpi-$version.tar.gz"; $tarball_name = "openmpi-$version.tar.gz";
if (! -f $tarball_name) { if (! -f $tarball_name) {
do_command("$download $url_arg/$tarball_name"); do_command(1, "$download $url_arg/$tarball_name");
test_abort "Could not download tarball -- aborting" test_abort "Could not download tarball -- aborting"
if (! -f $tarball_name); if (! -f $tarball_name);
# get the checksums # get the checksums
unlink($md5_checksums); unlink($md5_checksums);
do_command("$download $url_arg/$md5_checksums"); do_command(1, "$download $url_arg/$md5_checksums");
unlink($sha1_checksums); unlink($sha1_checksums);
do_command("$download $url_arg/$sha1_checksums"); do_command(1, "$download $url_arg/$sha1_checksums");
} }
# compare the md5sum # compare the md5sum
@ -555,6 +608,7 @@ WARNING: checksums. Proceeding anyway...\n\n");
$version = $tarball_name; $version = $tarball_name;
$version =~ s/.*openmpi-(.+).tar.gz/$1/; $version =~ s/.*openmpi-(.+).tar.gz/$1/;
} }
push(@email_output, "Snapshot: $version\n\n");
# Make a root for this build to play in (scratch_root_arg is absolute, so # Make a root for this build to play in (scratch_root_arg is absolute, so
# root will be absolute) # root will be absolute)
@ -572,7 +626,8 @@ if (! $config_arg || ! -f $config_arg) {
my $dir = "$root/default"; my $dir = "$root/default";
my $name = "[default]"; my $name = "[default]";
my $config = "CFLAGS=-g --disable-f77 --enable-debug"; my $config = "CFLAGS=-g --disable-f77 --enable-debug";
$ret = try_build($tarball_name, $dir, "$dir/install", "", $config); $ret = try_build($name, 0, $tarball_name,
$dir, "$dir/install", "", $config);
$results->{$name} = $ret; $results->{$name} = $ret;
$results->{$name}->{config} = $config; $results->{$name}->{config} = $config;
$results->{$name}->{want_stderr} = 1; $results->{$name}->{want_stderr} = 1;
@ -583,23 +638,35 @@ if (! $config_arg || ! -f $config_arg) {
while (<CONF>) { while (<CONF>) {
my $line = $_; my $line = $_;
chomp($line); chomp($line);
my ($name, $want_stderr, $vpath_mode, $config) = split(/:/, $line);
if (! $config) {
$config = $name;
}
if (! $config && ! $name) {
$name = "[default]";
$config = "CFLAGS=-g";
}
my $dir = "$root/config-$i"; # skip comments and blank lines
$ret = try_build($tarball_name, $dir, "$dir/install",
$vpath_mode, $config); if ($line && ! ($line =~ /[ \t]*\#/) && ! ($line =~ /^[ \t]+$/)) {
$results->{$name} = $ret;
$results->{$name}->{config} = $config; # Parse out the parts
$results->{$name}->{want_stderr} = $want_stderr;
$results->{$name}->{vpath_mode} = $vpath_mode; my ($name, $want_stderr, $vpath_mode, $config) = split(/:/, $line);
++$i; if (! $config) {
$config = $name;
}
if (! $config && ! $name) {
$name = "[build-$i]";
$config = "CFLAGS=-g";
}
# try to actually build it
my $dir = "$root/config-$i";
my $merge_output = $want_stderr ? 0 : 1;
$ret = try_build($name, $merge_output, $tarball_name,
$dir, "$dir/install",
$vpath_mode, $config);
$results->{$name} = $ret;
$results->{$name}->{config} = $config;
$results->{$name}->{want_stderr} = $want_stderr;
$results->{$name}->{vpath_mode} = $vpath_mode;
++$i;
}
} }
close CONF; close CONF;
} }
@ -643,17 +710,18 @@ push(@email_output,
# Include additional details if relevant # Include additional details if relevant
my $header = 0; my $header = 0;
my $displayed = 0; my $displayed = 0;
push(@email_output, "DETAILED RESULTS (as necessary):\n\n");
foreach my $config (keys(%$results)) { foreach my $config (keys(%$results)) {
my $output = 0; my $output = 0;
my $str; my $str;
$str .= "DETAILED RESULTS (as necessary):\n\n" $str .= "==> Build: " . $config . "
if (! $header); ==> Config options: " . $results->{$config}->{config} . "
==> Result: " . ($results->{$config}->{status} == 0 ?
$str .= "Build: " . $config . " "Success" : "FAILURE") . "
Config options: " . $results->{$config}->{config} . " ==> Output: " . ($results->{$config}->{want_stderr} ?
Result: " . ($results->{$config}->{status} == 0 ? "stderr and stdout shown separately below" :
"Success" : "FAILURE") . "\n"; "stdout and stderr merged below") . "\n";
if ($results->{$config}->{status} != 0 && if ($results->{$config}->{status} != 0 &&
$results->{$config}->{stdout} && $results->{$config}->{stdout} &&
@ -661,12 +729,22 @@ Result: " . ($results->{$config}->{status} == 0 ?
push(@email_output, $str); push(@email_output, $str);
$header = $displayed = $output = 1; $header = $displayed = $output = 1;
push(@email_output, if ($results->{$config}->{want_stderr}) {
push(@email_output,
"--Standard output---------------------------------------------------------\n"); "--Standard output---------------------------------------------------------\n");
} else {
push(@email_output,
"--Standard output and standard error--------------------------------------\n");
}
my $tmp = trim($max_log_len, $results->{$config}->{stdout}); my $tmp = trim($max_log_len, $results->{$config}->{stdout});
push(@email_output, @$tmp); push(@email_output, @$tmp);
push(@email_output, if ($results->{$config}->{want_stderr}) {
push(@email_output,
"--Standard output end-----------------------------------------------------\n"); "--Standard output end-----------------------------------------------------\n");
} else {
push(@email_output,
"--Standard output and standard error end----------------------------------\n");
}
} }
if ($results->{$config}->{stderr} && if ($results->{$config}->{stderr} &&
$#{$results->{$config}->{stderr}} >= 0) { $#{$results->{$config}->{stderr}} >= 0) {