2 # Bootstrap Samba and run a number of tests against it.
3 # Copyright (C) 2005-2010 Jelmer Vernooij <jelmer@samba.org>
4 # Copyright (C) 2007-2009 Stefan Metzmacher <metze@samba.org>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 use FindBin
qw($RealBin $Script);
23 use File::Temp qw(tempfile);
33 Time
::HiRes
->import("time");
36 print "You don't have Time::Hires installed !\n";
40 my $opt_target = "samba";
42 my $opt_socket_wrapper = 0;
43 my $opt_socket_wrapper_pcap = undef;
44 my $opt_socket_wrapper_keep_pcap = undef;
45 my $opt_random_order = 0;
52 my $opt_resetup_env = undef;
53 my $opt_binary_mapping = "";
54 my $opt_load_list = undef;
55 my $opt_libnss_wrapper_so_path = "";
56 my $opt_libsocket_wrapper_so_path = "";
57 my $opt_libuid_wrapper_so_path = "";
69 my ($list, $fullname) = @_;
72 if ($fullname =~ /$$_[0]/) {
73 return ($$_[1]) if ($$_[1]);
85 return find_in_list
(\
@excludes, $name);
94 return unless ($opt_socket_wrapper_pcap);
95 return unless defined($ENV{SOCKET_WRAPPER_PCAP_DIR
});
98 $fname =~ s
%[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\
-]%_%g;
100 my $pcap_file = "$ENV{SOCKET_WRAPPER_PCAP_DIR}/$fname.pcap";
102 SocketWrapper
::setup_pcap
($pcap_file);
109 my ($pcap_file, $exitcode) = @_;
111 return unless ($opt_socket_wrapper_pcap);
112 return if ($opt_socket_wrapper_keep_pcap);
113 return unless ($exitcode == 0);
114 return unless defined($pcap_file);
119 # expand strings from %ENV
120 sub expand_environment_strings
($)
123 # we use a reverse sort so we do the longer ones first
124 foreach my $k (sort { $b cmp $a } keys %ENV) {
125 $s =~ s/\$$k/$ENV{$k}/g;
130 sub run_testsuite
($$$$$)
132 my ($envname, $name, $cmd, $i, $totalsuites) = @_;
133 my $pcap_file = setup_pcap
($name);
135 Subunit
::start_testsuite
($name);
136 Subunit
::progress_push
();
137 Subunit
::report_time
(time());
139 Subunit
::report_time
(time());
140 Subunit
::progress_pop
();
143 Subunit
::progress_pop
();
144 Subunit
::end_testsuite
($name, "error", "Unable to run $cmd: $!");
147 Subunit
::end_testsuite
($name, "error",
148 sprintf("%s died with signal %d, %s coredump\n", $cmd, ($?
& 127), ($?
& 128) ?
'with' : 'without'));
152 my $exitcode = $?
>> 8;
154 my $envlog = getlog_env
($envname);
156 print "envlog: $envlog\n";
159 print "command: $cmd\n";
160 printf "expanded command: %s\n", expand_environment_strings
($cmd);
162 if ($exitcode == 0) {
163 Subunit
::end_testsuite
($name, "success");
165 Subunit
::end_testsuite
($name, "failure", "Exit code was $exitcode");
168 cleanup_pcap
($pcap_file, $exitcode);
170 if (not $opt_socket_wrapper_keep_pcap and defined($pcap_file)) {
171 print "PCAP FILE: $pcap_file\n";
174 if ($exitcode != 0) {
175 exit(1) if ($opt_one);
183 print "Samba test runner
184 Copyright (C) Jelmer Vernooij <jelmer\@samba.org>
185 Copyright (C) Stefan Metzmacher <metze\@samba.org>
187 Usage: $Script [OPTIONS] TESTNAME-REGEX
190 --help this help page
191 --target=samba[3]|win Samba version to target
192 --testlist=FILE file to read available tests from
195 --prefix=DIR prefix to run tests in [st]
196 --srcdir=DIR source directory [.]
197 --bindir=DIR binaries directory [./bin]
200 --nss_wrapper_so_path=FILE the nss_wrapper library to preload
201 --socket_wrapper_so_path=FILE the socket_wrapper library to preload
202 --uid_wrapper_so_path=FILE the uid_wrapper library to preload
205 --socket-wrapper-pcap save traffic to pcap directories
206 --socket-wrapper-keep-pcap keep all pcap files, not just those for tests that
208 --socket-wrapper enable socket wrapper
211 --ldap=openldap|fedora-ds back samba onto specified ldap server
214 --quick run quick overall test
215 --one abort when the first test fails
216 --testenv run a shell in the requested test environment
217 --list list available tests
222 my $result = GetOptions
(
223 'help|h|?' => \
$opt_help,
224 'target=s' => \
$opt_target,
225 'prefix=s' => \
$prefix,
226 'socket-wrapper' => \
$opt_socket_wrapper,
227 'socket-wrapper-pcap' => \
$opt_socket_wrapper_pcap,
228 'socket-wrapper-keep-pcap' => \
$opt_socket_wrapper_keep_pcap,
229 'quick' => \
$opt_quick,
231 'exclude=s' => \
@opt_exclude,
232 'include=s' => \
@opt_include,
233 'srcdir=s' => \
$srcdir,
234 'bindir=s' => \
$bindir,
235 'testenv' => \
$opt_testenv,
236 'list' => \
$opt_list,
238 'resetup-environment' => \
$opt_resetup_env,
239 'testlist=s' => \
@testlists,
240 'random-order' => \
$opt_random_order,
241 'load-list=s' => \
$opt_load_list,
242 'binary-mapping=s' => \
$opt_binary_mapping,
243 'nss_wrapper_so_path=s' => \
$opt_libnss_wrapper_so_path,
244 'socket_wrapper_so_path=s' => \
$opt_libsocket_wrapper_so_path,
245 'uid_wrapper_so_path=s' => \
$opt_libuid_wrapper_so_path
248 exit(1) if (not $result);
250 ShowHelp
() if ($opt_help);
252 die("--list and --testenv are mutually exclusive") if ($opt_list and $opt_testenv);
254 # we want unbuffered output
259 # quick hack to disable rpc validation when using valgrind - its way too slow
260 unless (defined($ENV{VALGRIND
})) {
261 $ENV{VALIDATE
} = "validate";
262 $ENV{MALLOC_CHECK_
} = 3;
265 # make all our python scripts unbuffered
266 $ENV{PYTHONUNBUFFERED
} = 1;
268 my $bindir_abs = abs_path
($bindir);
270 # Backwards compatibility:
271 if (defined($ENV{TEST_LDAP
}) and $ENV{TEST_LDAP
} eq "yes") {
272 if (defined($ENV{FEDORA_DS_ROOT
})) {
279 my $torture_maxtime = ($ENV{TORTURE_MAXTIME
} or 1200);
282 $torture_maxtime *= 2;
289 die("using an empty prefix isn't allowed") unless $prefix ne "";
291 # Ensure we have the test prefix around.
293 # We need restrictive
294 # permissions on this as some subdirectories in this tree will have
295 # wider permissions (ie 0777) and this would allow other users on the
296 # host to subvert the test process.
297 mkdir($prefix, 0700) unless -d
$prefix;
300 my $prefix_abs = abs_path
($prefix);
301 my $tmpdir_abs = abs_path
("$prefix/tmp");
302 mkdir($tmpdir_abs, 0777) unless -d
$tmpdir_abs;
304 my $srcdir_abs = abs_path
($srcdir);
306 die("using an empty absolute prefix isn't allowed") unless $prefix_abs ne "";
307 die("using '/' as absolute prefix isn't allowed") unless $prefix_abs ne "/";
309 $ENV{PREFIX
} = $prefix;
310 $ENV{KRB5CCNAME
} = "$prefix/krb5ticket";
311 $ENV{PREFIX_ABS
} = $prefix_abs;
312 $ENV{SRCDIR
} = $srcdir;
313 $ENV{SRCDIR_ABS
} = $srcdir_abs;
314 $ENV{BINDIR
} = $bindir_abs;
316 my $tls_enabled = not $opt_quick;
317 $ENV{TLS_ENABLED
} = ($tls_enabled?
"yes":"no");
319 sub prefix_pathvar
($$)
321 my ($name, $newpath) = @_;
322 if (defined($ENV{$name})) {
323 $ENV{$name} = "$newpath:$ENV{$name}";
325 $ENV{$name} = $newpath;
328 prefix_pathvar
("PKG_CONFIG_PATH", "$bindir_abs/pkgconfig");
329 prefix_pathvar
("PYTHONPATH", "$bindir_abs/python");
331 if ($opt_socket_wrapper_keep_pcap) {
332 # Socket wrapper keep pcap implies socket wrapper pcap
333 $opt_socket_wrapper_pcap = 1;
336 if ($opt_socket_wrapper_pcap) {
337 # Socket wrapper pcap implies socket wrapper
338 $opt_socket_wrapper = 1;
341 my $ld_preload = $ENV{LD_PRELOAD
};
343 if ($opt_libnss_wrapper_so_path) {
345 $ld_preload = "$ld_preload:$opt_libnss_wrapper_so_path";
347 $ld_preload = "$opt_libnss_wrapper_so_path";
351 if ($opt_libsocket_wrapper_so_path) {
353 $ld_preload = "$ld_preload:$opt_libsocket_wrapper_so_path";
355 $ld_preload = "$opt_libsocket_wrapper_so_path";
359 if ($opt_libuid_wrapper_so_path) {
361 $ld_preload = "$ld_preload:$opt_libuid_wrapper_so_path";
363 $ld_preload = "$opt_libuid_wrapper_so_path";
367 $ENV{LD_PRELOAD
} = $ld_preload;
368 print "LD_PRELOAD=$ENV{LD_PRELOAD}\n";
370 # Enable uid_wrapper globally
371 $ENV{UID_WRAPPER
} = 1;
373 # Disable RTLD_DEEPBIND hack for Samba bind dlz module
375 # This is needed in order to allow the ldb_*ldap module
376 # to work with a preloaded socket wrapper.
377 $ENV{LDB_MODULES_DISABLE_DEEPBIND
} = 1;
379 my $socket_wrapper_dir;
380 if ($opt_socket_wrapper) {
381 $socket_wrapper_dir = SocketWrapper
::setup_dir
("$prefix_abs/w", $opt_socket_wrapper_pcap);
382 print "SOCKET_WRAPPER_DIR=$socket_wrapper_dir\n";
383 } elsif (not $opt_list) {
385 warn("not using socket wrapper, but also not running as root. Will not be able to listen on proper ports");
390 my $testenv_default = "none";
392 my %binary_mapping = ();
393 if ($opt_binary_mapping) {
394 my @binmapping_list = split(/,/, $opt_binary_mapping);
395 foreach my $mapping (@binmapping_list) {
396 my ($bin, $map) = split(/\:/, $mapping);
397 $binary_mapping{$bin} = $map;
401 $ENV{BINARY_MAPPING
} = $opt_binary_mapping;
403 # After this many seconds, the server will self-terminate. All tests
404 # must terminate in this time, and testenv will only stay alive this
407 my $server_maxtime = 7500;
408 if (defined($ENV{SMBD_MAXTIME
}) and $ENV{SMBD_MAXTIME
} ne "") {
409 $server_maxtime = $ENV{SMBD_MAXTIME
};
413 if ($opt_target eq "samba") {
414 $testenv_default = "dc";
415 require target
::Samba
;
416 $target = new Samba
($bindir, \
%binary_mapping, $ldap, $srcdir, $server_maxtime);
417 } elsif ($opt_target eq "samba3") {
418 $testenv_default = "member";
419 require target
::Samba3
;
420 $target = new Samba3
($bindir, \
%binary_mapping, $srcdir_abs, $server_maxtime);
424 sub read_test_regexes
($)
428 open(LF
, "<$name") or die("unable to read $name: $!");
432 if (/^(.*?)([ \t]+)\#([\t ]*)(.*?)$/) {
433 push (@ret, [$1, $4]);
435 s/^(.*?)([ \t]+)\#([\t ]*)(.*?)$//;
436 push (@ret, [$_, undef]);
443 foreach (@opt_exclude) {
444 push (@excludes, read_test_regexes
($_));
447 foreach (@opt_include) {
448 push (@includes, read_test_regexes
($_));
451 my $interfaces = join(',', ("127.0.0.11/8",
458 my $clientdir = "$prefix_abs/client";
460 my $conffile = "$clientdir/client.conf";
461 $ENV{SMB_CONF_PATH
} = $conffile;
463 sub write_clientconf
($$$)
465 my ($conffile, $clientdir, $vars) = @_;
467 mkdir("$clientdir", 0777) unless -d
"$clientdir";
469 if ( -d
"$clientdir/private" ) {
470 unlink <$clientdir/private/*>;
472 mkdir("$clientdir/private", 0777);
475 if ( -d
"$clientdir/lockdir" ) {
476 unlink <$clientdir/lockdir/*>;
478 mkdir("$clientdir/lockdir", 0777);
481 if ( -d
"$clientdir/statedir" ) {
482 unlink <$clientdir/statedir/*>;
484 mkdir("$clientdir/statedir", 0777);
487 if ( -d
"$clientdir/cachedir" ) {
488 unlink <$clientdir/cachedir/*>;
490 mkdir("$clientdir/cachedir", 0777);
493 # this is ugly, but the ncalrpcdir needs exactly 0755
494 # otherwise tests fail.
497 if ( -d
"$clientdir/ncalrpcdir/np" ) {
498 unlink <$clientdir/ncalrpcdir/np
/*>;
499 rmdir "$clientdir/ncalrpcdir/np";
501 if ( -d
"$clientdir/ncalrpcdir" ) {
502 unlink <$clientdir/ncalrpcdir/*>;
503 rmdir "$clientdir/ncalrpcdir";
505 mkdir("$clientdir/ncalrpcdir", 0755);
508 open(CF
, ">$conffile");
509 print CF
"[global]\n";
510 print CF
"\tnetbios name = client\n";
511 if (defined($vars->{DOMAIN
})) {
512 print CF
"\tworkgroup = $vars->{DOMAIN}\n";
514 if (defined($vars->{REALM
})) {
515 print CF
"\trealm = $vars->{REALM}\n";
517 if ($opt_socket_wrapper) {
518 print CF
"\tinterfaces = $interfaces\n";
521 private dir = $clientdir/private
522 lock dir = $clientdir/lockdir
523 state directory = $clientdir/statedir
524 cache directory = $clientdir/cachedir
525 ncalrpc dir = $clientdir/ncalrpcdir
526 name resolve order = file bcast
527 panic action = $RealBin/gdb_backtrace \%d
529 notify:inotify = false
531 system:anonymous = true
532 client lanman auth = Yes
534 torture:basedir = $clientdir
535 #We don't want to pass our self-tests if the PAC code is wrong
536 gensec:require_pac = true
537 resolv:host file = $prefix_abs/dns_host_file
538 #We don't want to run 'speed' tests for very long
539 torture:timelimit = 1
540 winbind separator = /
547 sub should_run_test
($)
553 for (my $i=0; $i <= $#tests; $i++) {
554 if ($name =~ /$tests[$i]/i) {
566 open(IN
, $filename) or die("Unable to open $filename: $!");
569 if (/-- TEST(-LOADLIST|-IDLIST|) --\n/) {
570 my $supports_loadlist = (defined($1) and $1 eq "-LOADLIST");
571 my $supports_idlist = (defined($1) and $1 eq "-IDLIST");
578 if (should_run_test
($name) == 1) {
579 push (@ret, [$name, $env, $cmdline, $supports_loadlist, $supports_idlist]);
585 close(IN
) or die("Error creating recipe from $filename");
589 if ($#testlists == -1) {
590 die("No testlists specified");
593 $ENV{SELFTEST_PREFIX
} = "$prefix_abs";
594 $ENV{SELFTEST_TMPDIR
} = "$tmpdir_abs";
595 $ENV{TEST_DATA_PREFIX
} = "$tmpdir_abs";
596 if ($opt_socket_wrapper) {
597 $ENV{SELFTEST_INTERFACES
} = $interfaces;
599 $ENV{SELFTEST_INTERFACES
} = "";
602 $ENV{SELFTEST_QUICK
} = "1";
604 $ENV{SELFTEST_QUICK
} = "";
606 $ENV{SELFTEST_MAXTIME
} = $torture_maxtime;
609 foreach my $fn (@testlists) {
610 foreach (read_testlist
($fn)) {
612 next if (@includes and not defined(find_in_list
(\
@includes, $name)));
613 push (@available, $_);
617 my $restricted = undef;
618 my $restricted_used = {};
620 if ($opt_load_list) {
622 open(LOAD_LIST
, "<$opt_load_list") or die("Unable to open $opt_load_list");
623 while (<LOAD_LIST
>) {
625 push (@
$restricted, $_);
630 my $individual_tests = undef;
631 $individual_tests = {};
633 foreach my $testsuite (@available) {
634 my $name = $$testsuite[0];
635 my $skipreason = skip
($name);
636 if (defined($restricted)) {
637 # Find the testsuite for this test
639 foreach my $r (@
$restricted) {
641 $individual_tests->{$name} = [];
643 $restricted_used->{$r} = 1;
644 } elsif (substr($r, 0, length($name)+1) eq "$name.") {
645 push(@
{$individual_tests->{$name}}, $r);
647 $restricted_used->{$r} = 1;
651 if (defined($skipreason)) {
653 Subunit
::skip_testsuite
($name, $skipreason);
656 push(@todo, $testsuite);
659 } elsif (defined($skipreason)) {
661 Subunit
::skip_testsuite
($name, $skipreason);
664 push(@todo, $testsuite);
668 if (defined($restricted)) {
669 foreach (@
$restricted) {
670 unless (defined($restricted_used->{$_})) {
671 print "No test or testsuite found matching $_\n";
674 } elsif ($#todo == -1) {
675 print STDERR
"No tests to run\n";
679 my $suitestotal = $#todo + 1;
682 Subunit
::progress
($suitestotal);
683 Subunit
::report_time
(time());
689 my %running_envs = ();
691 sub get_running_env
($)
699 return $running_envs{$envname};
702 my @exported_envvars = (
707 # domain controller stuff
717 "MEMBER_SERVER_IPV6",
718 "MEMBER_NETBIOSNAME",
719 "MEMBER_NETBIOSALIAS",
721 # rpc proxy controller stuff
723 "RPC_PROXY_SERVER_IP",
724 "RPC_PROXY_SERVER_IPV6",
725 "RPC_PROXY_NETBIOSNAME",
726 "RPC_PROXY_NETBIOSALIAS",
728 # domain controller stuff for Vampired DC
730 "VAMPIRE_DC_SERVER_IP",
731 "VAMPIRE_DC_SERVER_IPV6",
732 "VAMPIRE_DC_NETBIOSNAME",
733 "VAMPIRE_DC_NETBIOSALIAS",
735 "PROMOTED_DC_SERVER",
736 "PROMOTED_DC_SERVER_IP",
737 "PROMOTED_DC_SERVER_IPV6",
738 "PROMOTED_DC_NETBIOSNAME",
739 "PROMOTED_DC_NETBIOSALIAS",
757 "SELFTEST_WINBINDD_SOCKET_DIR",
758 "WINBINDD_PRIV_PIPE_DIR",
763 "NSS_WRAPPER_PASSWD",
766 # UID/GID for rfc2307 mapping tests
775 $SIG{INT
} = $SIG{QUIT
} = $SIG{TERM
} = 'DEFAULT';
776 $SIG{PIPE
} = 'IGNORE';
778 open(STDOUT
, ">&STDERR") or die "can't dup STDOUT to STDERR: $!";
780 print "$0: PID[$$]: Got SIG${signame} teardown environments.\n";
781 teardown_env
($_) foreach(keys %running_envs);
782 system("pstree -p $$");
783 print "$0: PID[$$]: Exiting...\n";
787 $SIG{INT
} = $SIG{QUIT
} = $SIG{TERM
} = $SIG{PIPE
} = \
&sighandler
;
791 my ($name, $prefix) = @_;
793 my $testenv_vars = undef;
799 $option =~ s/^[^:]*//;
802 $option = "client" if $option eq "";
804 if ($envname eq "none") {
806 } elsif (defined(get_running_env
($envname))) {
807 $testenv_vars = get_running_env
($envname);
808 if (not $testenv_vars->{target
}->check_env($testenv_vars)) {
809 print $testenv_vars->{target
}->getlog_env($testenv_vars);
810 $testenv_vars = undef;
813 $testenv_vars = $target->setup_env($envname, $prefix);
814 if (defined($testenv_vars) and $testenv_vars eq "UNKNOWN") {
815 return $testenv_vars;
816 } elsif (defined($testenv_vars) && not defined($testenv_vars->{target
})) {
817 $testenv_vars->{target
} = $target;
819 if (not defined($testenv_vars)) {
820 warn("$opt_target can't start up known environment '$envname'");
825 return undef unless defined($testenv_vars);
827 $running_envs{$envname} = $testenv_vars;
829 if ($option eq "local") {
830 SocketWrapper
::set_default_iface
($testenv_vars->{SOCKET_WRAPPER_DEFAULT_IFACE
});
831 $ENV{SMB_CONF_PATH
} = $testenv_vars->{SERVERCONFFILE
};
832 } elsif ($option eq "client") {
833 SocketWrapper
::set_default_iface
(11);
834 write_clientconf
($conffile, $clientdir, $testenv_vars);
835 $ENV{SMB_CONF_PATH
} = $conffile;
837 die("Unknown option[$option] for envname[$envname]");
840 foreach (@exported_envvars) {
841 if (defined($testenv_vars->{$_})) {
842 $ENV{$_} = $testenv_vars->{$_};
848 return $testenv_vars;
851 sub exported_envvars_str
($)
853 my ($testenv_vars) = @_;
856 foreach (@exported_envvars) {
857 next unless defined($testenv_vars->{$_});
858 $out .= $_."=".$testenv_vars->{$_}."\n";
867 return "" if ($envname eq "none");
868 my $env = get_running_env
($envname);
869 return $env->{target
}->getlog_env($env);
875 return 1 if ($envname eq "none");
876 my $env = get_running_env
($envname);
877 return $env->{target
}->check_env($env);
883 return if ($envname eq "none");
884 print STDERR
"teardown_env($envname)\n";
885 my $env = get_running_env
($envname);
886 $env->{target
}->teardown_env($env);
887 delete $running_envs{$envname};
890 # This 'global' file needs to be empty when we start
891 unlink("$prefix_abs/dns_host_file");
892 unlink("$prefix_abs/hosts");
894 if ($opt_random_order) {
896 my @newtodo = List
::Util
::shuffle
(@todo);
901 my $testenv_name = $ENV{SELFTEST_TESTENV
};
902 $testenv_name = $testenv_default unless defined($testenv_name);
904 my $testenv_vars = setup_env
($testenv_name, $prefix);
906 if (not $testenv_vars or $testenv_vars eq "UNKNOWN") {
907 die("Unable to setup environment $testenv_name");
910 $ENV{PIDDIR
} = $testenv_vars->{PIDDIR
};
911 $ENV{ENVNAME
} = $testenv_name;
913 my $envvarstr = exported_envvars_str
($testenv_vars);
915 my @term_args = ("echo -e \"
916 Welcome to the Samba4 Test environment '$testenv_name'
918 This matches the client environment used in make test
919 server is pid `cat \$PIDDIR/samba.pid`
921 Some useful environment variables:
922 TORTURE_OPTIONS=\$TORTURE_OPTIONS
923 SMB_CONF_PATH=\$SMB_CONF_PATH
926 \" && LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH} bash");
928 if ($ENV{TERMINAL
}) {
929 @term = ($ENV{TERMINAL
});
931 @term = ("xterm", "-e");
932 unshift(@term_args, ("bash", "-c"));
935 system(@term, @term_args);
937 teardown_env
($testenv_name);
938 } elsif ($opt_list) {
942 my $envname = $$_[1];
944 unless($cmd =~ /\$LISTOPT/) {
945 warn("Unable to list tests in $name");
946 # Rather than ignoring this testsuite altogether, just pretend the entire testsuite is
952 $cmd =~ s/\$LISTOPT/--list/g;
957 die("Unable to run $cmd: $!");
959 die(sprintf("%s died with signal %d, %s coredump\n", $cmd, ($?
& 127), ($?
& 128) ?
'with' : 'without'));
962 my $exitcode = $?
>> 8;
963 if ($exitcode != 0) {
964 die("$cmd exited with exit code $exitcode");
972 my $envname = $$_[1];
974 my $envvars = setup_env
($envname, $prefix);
975 if (not defined($envvars)) {
976 Subunit
::start_testsuite
($name);
977 Subunit
::end_testsuite
($name, "error",
978 "unable to set up environment $envname - exiting");
980 } elsif ($envvars eq "UNKNOWN") {
981 Subunit
::start_testsuite
($name);
982 Subunit
::end_testsuite
($name, "skip",
983 "environment $envname is unknown in this test backend - skipping");
987 # Generate a file with the individual tests to run, if the
988 # test runner for this test suite supports it.
989 if ($individual_tests and $individual_tests->{$name}) {
991 my ($fh, $listid_file) = tempfile
(UNLINK
=> 0);
992 foreach my $test (@
{$individual_tests->{$name}}) {
993 print $fh substr($test, length($name)+1) . "\n";
995 $cmd =~ s/\$LOADLIST/--load-list=$listid_file/g;
997 $cmd =~ s/\s+[^\s]+\s*$//;
998 $cmd .= " " . join(' ', @
{$individual_tests->{$name}});
1002 run_testsuite
($envname, $name, $cmd, $i, $suitestotal);
1004 teardown_env
($envname) if ($opt_resetup_env);
1010 teardown_env
($_) foreach (keys %running_envs);
1014 # if there were any valgrind failures, show them
1015 foreach (<$prefix/valgrind
.log*>) {
1016 next unless (-s
$_);
1017 print "VALGRIND FAILURE\n";