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_load_list = undef;
54 my $opt_libnss_wrapper_so_path = "";
55 my $opt_libresolv_wrapper_so_path = "";
56 my $opt_libsocket_wrapper_so_path = "";
57 my $opt_libuid_wrapper_so_path = "";
58 my $opt_use_dns_faking = 0;
70 my ($list, $fullname) = @_;
73 if ($fullname =~ /$$_[0]/) {
74 return ($$_[1]) if ($$_[1]);
86 return find_in_list
(\
@excludes, $name);
95 return unless ($opt_socket_wrapper_pcap);
96 return unless defined($ENV{SOCKET_WRAPPER_PCAP_DIR
});
99 $fname =~ s
%[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\
-]%_%g;
101 my $pcap_file = "$ENV{SOCKET_WRAPPER_PCAP_DIR}/$fname.pcap";
103 SocketWrapper
::setup_pcap
($pcap_file);
110 my ($pcap_file, $exitcode) = @_;
112 return unless ($opt_socket_wrapper_pcap);
113 return if ($opt_socket_wrapper_keep_pcap);
114 return unless ($exitcode == 0);
115 return unless defined($pcap_file);
120 # expand strings from %ENV
121 sub expand_environment_strings
($)
124 # we use a reverse sort so we do the longer ones first
125 foreach my $k (sort { $b cmp $a } keys %ENV) {
126 $s =~ s/\$$k/$ENV{$k}/g;
131 sub run_testsuite
($$$$$)
133 my ($envname, $name, $cmd, $i, $totalsuites) = @_;
134 my $pcap_file = setup_pcap
($name);
136 Subunit
::start_testsuite
($name);
137 Subunit
::progress_push
();
138 Subunit
::report_time
(time());
140 Subunit
::report_time
(time());
141 Subunit
::progress_pop
();
144 Subunit
::progress_pop
();
145 Subunit
::end_testsuite
($name, "error", "Unable to run $cmd: $!");
148 Subunit
::end_testsuite
($name, "error",
149 sprintf("%s died with signal %d, %s coredump\n", $cmd, ($?
& 127), ($?
& 128) ?
'with' : 'without'));
153 my $exitcode = $?
>> 8;
155 my $envlog = getlog_env
($envname);
157 print "envlog: $envlog\n";
160 print "command: $cmd\n";
161 printf "expanded command: %s\n", expand_environment_strings
($cmd);
163 if ($exitcode == 0) {
164 Subunit
::end_testsuite
($name, "success");
166 Subunit
::end_testsuite
($name, "failure", "Exit code was $exitcode");
169 cleanup_pcap
($pcap_file, $exitcode);
171 if (not $opt_socket_wrapper_keep_pcap and defined($pcap_file)) {
172 print "PCAP FILE: $pcap_file\n";
175 if ($exitcode != 0) {
176 exit(1) if ($opt_one);
184 print "Samba test runner
185 Copyright (C) Jelmer Vernooij <jelmer\@samba.org>
186 Copyright (C) Stefan Metzmacher <metze\@samba.org>
188 Usage: $Script [OPTIONS] TESTNAME-REGEX
191 --help this help page
192 --target=samba[3]|win Samba version to target
193 --testlist=FILE file to read available tests from
194 --exclude=FILE Exclude tests listed in the file
195 --include=FILE Include tests listed in the file
198 --prefix=DIR prefix to run tests in [st]
199 --srcdir=DIR source directory [.]
200 --bindir=DIR binaries directory [./bin]
203 --nss_wrapper_so_path=FILE the nss_wrapper library to preload
204 --resolv_wrapper_so_path=FILE the resolv_wrapper library to preload
205 --socket_wrapper_so_path=FILE the socket_wrapper library to preload
206 --uid_wrapper_so_path=FILE the uid_wrapper library to preload
209 --use-dns-faking Fake DNS entries rather than talking to our
213 --socket-wrapper-pcap save traffic to pcap directories
214 --socket-wrapper-keep-pcap keep all pcap files, not just those for tests that
216 --socket-wrapper enable socket wrapper
219 --ldap=openldap|fedora-ds back samba onto specified ldap server
222 --quick run quick overall test
223 --one abort when the first test fails
224 --testenv run a shell in the requested test environment
225 --list list available tests
230 my $result = GetOptions
(
231 'help|h|?' => \
$opt_help,
232 'target=s' => \
$opt_target,
233 'prefix=s' => \
$prefix,
234 'socket-wrapper' => \
$opt_socket_wrapper,
235 'socket-wrapper-pcap' => \
$opt_socket_wrapper_pcap,
236 'socket-wrapper-keep-pcap' => \
$opt_socket_wrapper_keep_pcap,
237 'quick' => \
$opt_quick,
239 'exclude=s' => \
@opt_exclude,
240 'include=s' => \
@opt_include,
241 'srcdir=s' => \
$srcdir,
242 'bindir=s' => \
$bindir,
243 'testenv' => \
$opt_testenv,
244 'list' => \
$opt_list,
246 'resetup-environment' => \
$opt_resetup_env,
247 'testlist=s' => \
@testlists,
248 'random-order' => \
$opt_random_order,
249 'load-list=s' => \
$opt_load_list,
250 'nss_wrapper_so_path=s' => \
$opt_libnss_wrapper_so_path,
251 'resolv_wrapper_so_path=s' => \
$opt_libresolv_wrapper_so_path,
252 'socket_wrapper_so_path=s' => \
$opt_libsocket_wrapper_so_path,
253 'uid_wrapper_so_path=s' => \
$opt_libuid_wrapper_so_path,
254 'use-dns-faking' => \
$opt_use_dns_faking
257 exit(1) if (not $result);
259 ShowHelp
() if ($opt_help);
261 die("--list and --testenv are mutually exclusive") if ($opt_list and $opt_testenv);
263 # we want unbuffered output
268 # quick hack to disable rpc validation when using valgrind - its way too slow
269 unless (defined($ENV{VALGRIND
})) {
270 $ENV{VALIDATE
} = "validate";
271 $ENV{MALLOC_CHECK_
} = 3;
274 # make all our python scripts unbuffered
275 $ENV{PYTHONUNBUFFERED
} = 1;
277 my $bindir_abs = abs_path
($bindir);
279 # Backwards compatibility:
280 if (defined($ENV{TEST_LDAP
}) and $ENV{TEST_LDAP
} eq "yes") {
281 if (defined($ENV{FEDORA_DS_ROOT
})) {
288 my $torture_maxtime = ($ENV{TORTURE_MAXTIME
} or 1200);
291 $torture_maxtime *= 2;
298 die("using an empty prefix isn't allowed") unless $prefix ne "";
300 # Ensure we have the test prefix around.
302 # We need restrictive
303 # permissions on this as some subdirectories in this tree will have
304 # wider permissions (ie 0777) and this would allow other users on the
305 # host to subvert the test process.
306 mkdir($prefix, 0700) unless -d
$prefix;
309 my $prefix_abs = abs_path
($prefix);
310 my $tmpdir_abs = abs_path
("$prefix/tmp");
311 mkdir($tmpdir_abs, 0777) unless -d
$tmpdir_abs;
313 my $srcdir_abs = abs_path
($srcdir);
315 die("using an empty absolute prefix isn't allowed") unless $prefix_abs ne "";
316 die("using '/' as absolute prefix isn't allowed") unless $prefix_abs ne "/";
318 $ENV{PREFIX
} = $prefix;
319 $ENV{KRB5CCNAME
} = "$prefix/krb5ticket";
320 $ENV{PREFIX_ABS
} = $prefix_abs;
321 $ENV{SRCDIR
} = $srcdir;
322 $ENV{SRCDIR_ABS
} = $srcdir_abs;
323 $ENV{BINDIR
} = $bindir_abs;
325 my $tls_enabled = not $opt_quick;
326 $ENV{TLS_ENABLED
} = ($tls_enabled?
"yes":"no");
328 sub prefix_pathvar
($$)
330 my ($name, $newpath) = @_;
331 if (defined($ENV{$name})) {
332 $ENV{$name} = "$newpath:$ENV{$name}";
334 $ENV{$name} = $newpath;
337 prefix_pathvar
("PKG_CONFIG_PATH", "$bindir_abs/pkgconfig");
338 prefix_pathvar
("PYTHONPATH", "$bindir_abs/python");
340 if ($opt_socket_wrapper_keep_pcap) {
341 # Socket wrapper keep pcap implies socket wrapper pcap
342 $opt_socket_wrapper_pcap = 1;
345 if ($opt_socket_wrapper_pcap) {
346 # Socket wrapper pcap implies socket wrapper
347 $opt_socket_wrapper = 1;
350 my $ld_preload = $ENV{LD_PRELOAD
};
352 if ($opt_libnss_wrapper_so_path) {
354 $ld_preload = "$ld_preload:$opt_libnss_wrapper_so_path";
356 $ld_preload = "$opt_libnss_wrapper_so_path";
360 if ($opt_libresolv_wrapper_so_path) {
362 $ld_preload = "$ld_preload:$opt_libresolv_wrapper_so_path";
364 $ld_preload = "$opt_libresolv_wrapper_so_path";
368 if ($opt_libsocket_wrapper_so_path) {
370 $ld_preload = "$ld_preload:$opt_libsocket_wrapper_so_path";
372 $ld_preload = "$opt_libsocket_wrapper_so_path";
376 if ($opt_libuid_wrapper_so_path) {
378 $ld_preload = "$ld_preload:$opt_libuid_wrapper_so_path";
380 $ld_preload = "$opt_libuid_wrapper_so_path";
384 $ENV{LD_PRELOAD
} = $ld_preload;
385 print "LD_PRELOAD=$ENV{LD_PRELOAD}\n";
387 # Enable uid_wrapper globally
388 $ENV{UID_WRAPPER
} = 1;
390 # Disable RTLD_DEEPBIND hack for Samba bind dlz module
392 # This is needed in order to allow the ldb_*ldap module
393 # to work with a preloaded socket wrapper.
394 $ENV{LDB_MODULES_DISABLE_DEEPBIND
} = 1;
396 my $socket_wrapper_dir;
397 if ($opt_socket_wrapper) {
398 $socket_wrapper_dir = SocketWrapper
::setup_dir
("$prefix_abs/w", $opt_socket_wrapper_pcap);
399 print "SOCKET_WRAPPER_DIR=$socket_wrapper_dir\n";
400 } elsif (not $opt_list) {
402 warn("not using socket wrapper, but also not running as root. Will not be able to listen on proper ports");
406 if ($opt_use_dns_faking) {
407 print "DNS: Faking nameserver\n";
408 $ENV{SAMBA_DNS_FAKING
} = 1;
412 my $testenv_default = "none";
414 # After this many seconds, the server will self-terminate. All tests
415 # must terminate in this time, and testenv will only stay alive this
418 my $server_maxtime = 10800;
419 if (defined($ENV{SMBD_MAXTIME
}) and $ENV{SMBD_MAXTIME
} ne "") {
420 $server_maxtime = $ENV{SMBD_MAXTIME
};
424 if ($opt_target eq "samba") {
425 $testenv_default = "ad_dc_ntvfs";
426 require target
::Samba
;
427 $target = new Samba
($bindir, $ldap, $srcdir, $server_maxtime);
428 } elsif ($opt_target eq "samba3") {
429 $testenv_default = "nt4_member";
430 require target
::Samba3
;
431 $target = new Samba3
($bindir, $srcdir_abs, $server_maxtime);
435 sub read_test_regexes
($)
439 open(LF
, "<$name") or die("unable to read $name: $!");
443 if (/^(.*?)([ \t]+)\#([\t ]*)(.*?)$/) {
444 push (@ret, [$1, $4]);
446 s/^(.*?)([ \t]+)\#([\t ]*)(.*?)$//;
447 push (@ret, [$_, undef]);
454 foreach (@opt_exclude) {
455 push (@excludes, read_test_regexes
($_));
458 foreach (@opt_include) {
459 push (@includes, read_test_regexes
($_));
462 my $interfaces = join(',', ("127.0.0.11/8",
469 my $clientdir = "$prefix_abs/client";
471 my $conffile = "$clientdir/client.conf";
472 $ENV{SMB_CONF_PATH
} = $conffile;
474 sub write_clientconf
($$$)
476 my ($conffile, $clientdir, $vars) = @_;
478 mkdir("$clientdir", 0777) unless -d
"$clientdir";
480 if ( -d
"$clientdir/private" ) {
481 unlink <$clientdir/private/*>;
483 mkdir("$clientdir/private", 0777);
486 if ( -d
"$clientdir/lockdir" ) {
487 unlink <$clientdir/lockdir/*>;
489 mkdir("$clientdir/lockdir", 0777);
492 if ( -d
"$clientdir/statedir" ) {
493 unlink <$clientdir/statedir/*>;
495 mkdir("$clientdir/statedir", 0777);
498 if ( -d
"$clientdir/cachedir" ) {
499 unlink <$clientdir/cachedir/*>;
501 mkdir("$clientdir/cachedir", 0777);
504 # this is ugly, but the ncalrpcdir needs exactly 0755
505 # otherwise tests fail.
508 if ( -d
"$clientdir/ncalrpcdir/np" ) {
509 unlink <$clientdir/ncalrpcdir/np
/*>;
510 rmdir "$clientdir/ncalrpcdir/np";
512 if ( -d
"$clientdir/ncalrpcdir" ) {
513 unlink <$clientdir/ncalrpcdir/*>;
514 rmdir "$clientdir/ncalrpcdir";
516 mkdir("$clientdir/ncalrpcdir", 0755);
519 open(CF
, ">$conffile");
520 print CF
"[global]\n";
521 print CF
"\tnetbios name = client\n";
522 if (defined($vars->{DOMAIN
})) {
523 print CF
"\tworkgroup = $vars->{DOMAIN}\n";
525 if (defined($vars->{REALM
})) {
526 print CF
"\trealm = $vars->{REALM}\n";
528 if ($opt_socket_wrapper) {
529 print CF
"\tinterfaces = $interfaces\n";
532 private dir = $clientdir/private
533 lock dir = $clientdir/lockdir
534 state directory = $clientdir/statedir
535 cache directory = $clientdir/cachedir
536 ncalrpc dir = $clientdir/ncalrpcdir
537 panic action = $RealBin/gdb_backtrace \%d
539 notify:inotify = false
541 system:anonymous = true
542 client lanman auth = Yes
544 torture:basedir = $clientdir
545 #We don't want to pass our self-tests if the PAC code is wrong
546 gensec:require_pac = true
547 #We don't want to run 'speed' tests for very long
548 torture:timelimit = 1
549 winbind separator = /
556 sub should_run_test
($)
562 for (my $i=0; $i <= $#tests; $i++) {
563 if ($name =~ /$tests[$i]/i) {
575 open(IN
, $filename) or die("Unable to open $filename: $!");
578 if (/-- TEST(-LOADLIST|) --\n/) {
579 my $supports_loadlist = (defined($1) and $1 eq "-LOADLIST");
585 if ($supports_loadlist) {
587 $loadlist =~ s/\n//g;
591 if (should_run_test
($name) == 1) {
592 push (@ret, [$name, $env, $cmdline, $loadlist]);
598 close(IN
) or die("Error creating recipe from $filename");
602 if ($#testlists == -1) {
603 die("No testlists specified");
606 $ENV{SELFTEST_PREFIX
} = "$prefix_abs";
607 $ENV{SELFTEST_TMPDIR
} = "$tmpdir_abs";
608 $ENV{TEST_DATA_PREFIX
} = "$tmpdir_abs";
609 if ($opt_socket_wrapper) {
610 $ENV{SELFTEST_INTERFACES
} = $interfaces;
612 $ENV{SELFTEST_INTERFACES
} = "";
615 $ENV{SELFTEST_QUICK
} = "1";
617 $ENV{SELFTEST_QUICK
} = "";
619 $ENV{SELFTEST_MAXTIME
} = $torture_maxtime;
622 foreach my $fn (@testlists) {
623 foreach (read_testlist
($fn)) {
625 next if (@includes and not defined(find_in_list
(\
@includes, $name)));
626 push (@available, $_);
630 my $restricted = undef;
631 my $restricted_used = {};
633 if ($opt_load_list) {
635 open(LOAD_LIST
, "<$opt_load_list") or die("Unable to open $opt_load_list");
636 while (<LOAD_LIST
>) {
638 push (@
$restricted, $_);
643 my $individual_tests = undef;
644 $individual_tests = {};
646 foreach my $testsuite (@available) {
647 my $name = $$testsuite[0];
648 my $skipreason = skip
($name);
649 if (defined($restricted)) {
650 # Find the testsuite for this test
652 foreach my $r (@
$restricted) {
654 $individual_tests->{$name} = [];
656 $restricted_used->{$r} = 1;
657 } elsif (substr($r, 0, length($name)+1) eq "$name.") {
658 push(@
{$individual_tests->{$name}}, $r);
660 $restricted_used->{$r} = 1;
664 if (defined($skipreason)) {
666 Subunit
::skip_testsuite
($name, $skipreason);
669 push(@todo, $testsuite);
672 } elsif (defined($skipreason)) {
674 Subunit
::skip_testsuite
($name, $skipreason);
677 push(@todo, $testsuite);
681 if (defined($restricted)) {
682 foreach (@
$restricted) {
683 unless (defined($restricted_used->{$_})) {
684 print "No test or testsuite found matching $_\n";
687 } elsif ($#todo == -1) {
688 print STDERR
"No tests to run\n";
692 my $suitestotal = $#todo + 1;
695 Subunit
::progress
($suitestotal);
696 Subunit
::report_time
(time());
702 my %running_envs = ();
704 sub get_running_env
($)
712 return $running_envs{$envname};
715 my @exported_envvars = (
720 # domain controller stuff
730 "MEMBER_SERVER_IPV6",
731 "MEMBER_NETBIOSNAME",
732 "MEMBER_NETBIOSALIAS",
734 # rpc proxy controller stuff
736 "RPC_PROXY_SERVER_IP",
737 "RPC_PROXY_SERVER_IPV6",
738 "RPC_PROXY_NETBIOSNAME",
739 "RPC_PROXY_NETBIOSALIAS",
741 # domain controller stuff for Vampired DC
743 "VAMPIRE_DC_SERVER_IP",
744 "VAMPIRE_DC_SERVER_IPV6",
745 "VAMPIRE_DC_NETBIOSNAME",
746 "VAMPIRE_DC_NETBIOSALIAS",
748 "PROMOTED_DC_SERVER",
749 "PROMOTED_DC_SERVER_IP",
750 "PROMOTED_DC_SERVER_IPV6",
751 "PROMOTED_DC_NETBIOSNAME",
752 "PROMOTED_DC_NETBIOSALIAS",
768 # UID/GID for rfc2307 mapping tests
774 "SELFTEST_WINBINDD_SOCKET_DIR",
775 "WINBINDD_PRIV_PIPE_DIR",
780 "NSS_WRAPPER_PASSWD",
783 "NSS_WRAPPER_MODULE_SO_PATH",
784 "NSS_WRAPPER_MODULE_FN_PREFIX",
787 "RESOLV_WRAPPER_CONF",
788 "RESOLV_WRAPPER_HOSTS",
795 $SIG{INT
} = $SIG{QUIT
} = $SIG{TERM
} = 'DEFAULT';
796 $SIG{PIPE
} = 'IGNORE';
798 open(STDOUT
, ">&STDERR") or die "can't dup STDOUT to STDERR: $!";
800 print "$0: PID[$$]: Got SIG${signame} teardown environments.\n";
801 teardown_env
($_) foreach(keys %running_envs);
802 system("pstree -p $$");
803 print "$0: PID[$$]: Exiting...\n";
807 $SIG{INT
} = $SIG{QUIT
} = $SIG{TERM
} = $SIG{PIPE
} = \
&sighandler
;
811 my ($name, $prefix) = @_;
813 my $testenv_vars = undef;
819 $option =~ s/^[^:]*//;
822 $option = "client" if $option eq "";
824 if ($envname eq "none") {
826 } elsif (defined(get_running_env
($envname))) {
827 $testenv_vars = get_running_env
($envname);
828 if (not $testenv_vars->{target
}->check_env($testenv_vars)) {
829 print $testenv_vars->{target
}->getlog_env($testenv_vars);
830 $testenv_vars = undef;
833 $testenv_vars = $target->setup_env($envname, $prefix);
834 if (defined($testenv_vars) and $testenv_vars eq "UNKNOWN") {
835 return $testenv_vars;
836 } elsif (defined($testenv_vars) && not defined($testenv_vars->{target
})) {
837 $testenv_vars->{target
} = $target;
839 if (not defined($testenv_vars)) {
840 warn("$opt_target can't start up known environment '$envname'");
844 return undef unless defined($testenv_vars);
846 $running_envs{$envname} = $testenv_vars;
848 if ($option eq "local") {
849 SocketWrapper
::set_default_iface
($testenv_vars->{SOCKET_WRAPPER_DEFAULT_IFACE
});
850 $ENV{SMB_CONF_PATH
} = $testenv_vars->{SERVERCONFFILE
};
851 } elsif ($option eq "client") {
852 SocketWrapper
::set_default_iface
(11);
853 write_clientconf
($conffile, $clientdir, $testenv_vars);
854 $ENV{SMB_CONF_PATH
} = $conffile;
856 die("Unknown option[$option] for envname[$envname]");
859 foreach (@exported_envvars) {
860 if (defined($testenv_vars->{$_})) {
861 $ENV{$_} = $testenv_vars->{$_};
867 return $testenv_vars;
870 sub exported_envvars_str
($)
872 my ($testenv_vars) = @_;
875 foreach (@exported_envvars) {
876 next unless defined($testenv_vars->{$_});
877 $out .= $_."=".$testenv_vars->{$_}."\n";
886 return "" if ($envname eq "none");
887 my $env = get_running_env
($envname);
888 return $env->{target
}->getlog_env($env);
894 return 1 if ($envname eq "none");
895 my $env = get_running_env
($envname);
896 return $env->{target
}->check_env($env);
902 return if ($envname eq "none");
903 print STDERR
"teardown_env($envname)\n";
904 my $env = get_running_env
($envname);
905 $env->{target
}->teardown_env($env);
906 delete $running_envs{$envname};
909 # This 'global' file needs to be empty when we start
910 unlink("$prefix_abs/dns_host_file");
911 unlink("$prefix_abs/hosts");
913 if ($opt_random_order) {
915 my @newtodo = List
::Util
::shuffle
(@todo);
920 my $testenv_name = $ENV{SELFTEST_TESTENV
};
921 $testenv_name = $testenv_default unless defined($testenv_name);
923 my $testenv_vars = setup_env
($testenv_name, $prefix);
925 if (not $testenv_vars or $testenv_vars eq "UNKNOWN") {
926 die("Unable to setup environment $testenv_name");
929 $ENV{PIDDIR
} = $testenv_vars->{PIDDIR
};
930 $ENV{ENVNAME
} = $testenv_name;
932 my $envvarstr = exported_envvars_str
($testenv_vars);
934 my @term_args = ("echo -e \"
935 Welcome to the Samba4 Test environment '$testenv_name'
937 This matches the client environment used in make test
938 server is pid `cat \$PIDDIR/samba.pid`
940 Some useful environment variables:
941 TORTURE_OPTIONS=\$TORTURE_OPTIONS
942 SMB_CONF_PATH=\$SMB_CONF_PATH
945 \" && LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH} bash");
947 if ($ENV{TERMINAL
}) {
948 @term = ($ENV{TERMINAL
});
950 @term = ("xterm", "-e");
951 unshift(@term_args, ("bash", "-c"));
954 system(@term, @term_args);
956 teardown_env
($testenv_name);
957 } elsif ($opt_list) {
960 my $envname = $$_[1];
962 my $listcmd = $$_[3];
964 unless (defined($listcmd)) {
965 warn("Unable to list tests in $name");
966 # Rather than ignoring this testsuite altogether, just pretend the entire testsuite is
975 die("Unable to run $listcmd: $!");
977 die(sprintf("%s died with signal %d, %s coredump\n", $listcmd, ($?
& 127), ($?
& 128) ?
'with' : 'without'));
980 my $exitcode = $?
>> 8;
981 if ($exitcode != 0) {
982 die("$cmd exited with exit code $exitcode");
990 my $envname = $$_[1];
992 my $envvars = setup_env
($envname, $prefix);
993 if (not defined($envvars)) {
994 Subunit
::start_testsuite
($name);
995 Subunit
::end_testsuite
($name, "error",
996 "unable to set up environment $envname - exiting");
998 } elsif ($envvars eq "UNKNOWN") {
999 Subunit
::start_testsuite
($name);
1000 Subunit
::end_testsuite
($name, "skip",
1001 "environment $envname is unknown in this test backend - skipping");
1005 # Generate a file with the individual tests to run, if the
1006 # test runner for this test suite supports it.
1007 if ($individual_tests and $individual_tests->{$name}) {
1009 my ($fh, $listid_file) = tempfile
(UNLINK
=> 0);
1010 foreach my $test (@
{$individual_tests->{$name}}) {
1011 print $fh substr($test, length($name)+1) . "\n";
1013 $cmd =~ s/\$LOADLIST/--load-list=$listid_file/g;
1015 warn("Unable to run individual tests in $name, it does not support --loadlist.");
1019 run_testsuite
($envname, $name, $cmd, $i, $suitestotal);
1021 teardown_env
($envname) if ($opt_resetup_env);
1027 teardown_env
($_) foreach (keys %running_envs);
1031 # if there were any valgrind failures, show them
1032 foreach (<$prefix/valgrind
.log*>) {
1033 next unless (-s
$_);
1034 print "VALGRIND FAILURE\n";