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
420 # 1 year should be enough :-)
421 $server_maxtime = 365 * 24 * 60 * 60;
423 # make test should run under 3 hours
424 $server_maxtime = 3 * 60 * 60;
427 if (defined($ENV{SMBD_MAXTIME
}) and $ENV{SMBD_MAXTIME
} ne "") {
428 $server_maxtime = $ENV{SMBD_MAXTIME
};
432 if ($opt_target eq "samba") {
433 $testenv_default = "ad_dc_ntvfs";
434 require target
::Samba
;
435 $target = new Samba
($bindir, $ldap, $srcdir, $server_maxtime);
436 } elsif ($opt_target eq "samba3") {
437 $testenv_default = "nt4_member";
438 require target
::Samba3
;
439 $target = new Samba3
($bindir, $srcdir_abs, $server_maxtime);
443 sub read_test_regexes
($)
447 open(LF
, "<$name") or die("unable to read $name: $!");
451 if (/^(.*?)([ \t]+)\#([\t ]*)(.*?)$/) {
452 push (@ret, [$1, $4]);
454 s/^(.*?)([ \t]+)\#([\t ]*)(.*?)$//;
455 push (@ret, [$_, undef]);
462 foreach (@opt_exclude) {
463 push (@excludes, read_test_regexes
($_));
466 foreach (@opt_include) {
467 push (@includes, read_test_regexes
($_));
470 my $interfaces = join(',', ("127.0.0.11/8",
477 my $clientdir = "$prefix_abs/client";
479 my $conffile = "$clientdir/client.conf";
480 $ENV{SMB_CONF_PATH
} = $conffile;
482 sub write_clientconf
($$$)
484 my ($conffile, $clientdir, $vars) = @_;
486 mkdir("$clientdir", 0777) unless -d
"$clientdir";
488 if ( -d
"$clientdir/private" ) {
489 unlink <$clientdir/private/*>;
491 mkdir("$clientdir/private", 0777);
494 if ( -d
"$clientdir/lockdir" ) {
495 unlink <$clientdir/lockdir/*>;
497 mkdir("$clientdir/lockdir", 0777);
500 if ( -d
"$clientdir/statedir" ) {
501 unlink <$clientdir/statedir/*>;
503 mkdir("$clientdir/statedir", 0777);
506 if ( -d
"$clientdir/cachedir" ) {
507 unlink <$clientdir/cachedir/*>;
509 mkdir("$clientdir/cachedir", 0777);
512 # this is ugly, but the ncalrpcdir needs exactly 0755
513 # otherwise tests fail.
516 if ( -d
"$clientdir/ncalrpcdir/np" ) {
517 unlink <$clientdir/ncalrpcdir/np
/*>;
518 rmdir "$clientdir/ncalrpcdir/np";
520 if ( -d
"$clientdir/ncalrpcdir" ) {
521 unlink <$clientdir/ncalrpcdir/*>;
522 rmdir "$clientdir/ncalrpcdir";
524 mkdir("$clientdir/ncalrpcdir", 0755);
527 open(CF
, ">$conffile");
528 print CF
"[global]\n";
529 print CF
"\tnetbios name = client\n";
530 if (defined($vars->{DOMAIN
})) {
531 print CF
"\tworkgroup = $vars->{DOMAIN}\n";
533 if (defined($vars->{REALM
})) {
534 print CF
"\trealm = $vars->{REALM}\n";
536 if ($opt_socket_wrapper) {
537 print CF
"\tinterfaces = $interfaces\n";
540 private dir = $clientdir/private
541 lock dir = $clientdir/lockdir
542 state directory = $clientdir/statedir
543 cache directory = $clientdir/cachedir
544 ncalrpc dir = $clientdir/ncalrpcdir
545 panic action = $RealBin/gdb_backtrace \%d
547 notify:inotify = false
549 system:anonymous = true
550 client lanman auth = Yes
552 torture:basedir = $clientdir
553 #We don't want to pass our self-tests if the PAC code is wrong
554 gensec:require_pac = true
555 #We don't want to run 'speed' tests for very long
556 torture:timelimit = 1
557 winbind separator = /
564 sub should_run_test
($)
570 for (my $i=0; $i <= $#tests; $i++) {
571 if ($name =~ /$tests[$i]/i) {
583 open(IN
, $filename) or die("Unable to open $filename: $!");
586 if (/-- TEST(-LOADLIST|) --\n/) {
587 my $supports_loadlist = (defined($1) and $1 eq "-LOADLIST");
593 if ($supports_loadlist) {
595 $loadlist =~ s/\n//g;
599 if (should_run_test
($name) == 1) {
600 push (@ret, [$name, $env, $cmdline, $loadlist]);
606 close(IN
) or die("Error creating recipe from $filename");
610 if ($#testlists == -1) {
611 die("No testlists specified");
614 $ENV{SELFTEST_PREFIX
} = "$prefix_abs";
615 $ENV{SELFTEST_TMPDIR
} = "$tmpdir_abs";
616 $ENV{TEST_DATA_PREFIX
} = "$tmpdir_abs";
617 if ($opt_socket_wrapper) {
618 $ENV{SELFTEST_INTERFACES
} = $interfaces;
620 $ENV{SELFTEST_INTERFACES
} = "";
623 $ENV{SELFTEST_QUICK
} = "1";
625 $ENV{SELFTEST_QUICK
} = "";
627 $ENV{SELFTEST_MAXTIME
} = $torture_maxtime;
630 foreach my $fn (@testlists) {
631 foreach (read_testlist
($fn)) {
633 next if (@includes and not defined(find_in_list
(\
@includes, $name)));
634 push (@available, $_);
638 my $restricted = undef;
639 my $restricted_used = {};
641 if ($opt_load_list) {
643 open(LOAD_LIST
, "<$opt_load_list") or die("Unable to open $opt_load_list");
644 while (<LOAD_LIST
>) {
646 push (@
$restricted, $_);
651 my $individual_tests = undef;
652 $individual_tests = {};
654 foreach my $testsuite (@available) {
655 my $name = $$testsuite[0];
656 my $skipreason = skip
($name);
657 if (defined($restricted)) {
658 # Find the testsuite for this test
660 foreach my $r (@
$restricted) {
662 $individual_tests->{$name} = [];
664 $restricted_used->{$r} = 1;
665 } elsif (substr($r, 0, length($name)+1) eq "$name.") {
666 push(@
{$individual_tests->{$name}}, $r);
668 $restricted_used->{$r} = 1;
672 if (defined($skipreason)) {
674 Subunit
::skip_testsuite
($name, $skipreason);
677 push(@todo, $testsuite);
680 } elsif (defined($skipreason)) {
682 Subunit
::skip_testsuite
($name, $skipreason);
685 push(@todo, $testsuite);
689 if (defined($restricted)) {
690 foreach (@
$restricted) {
691 unless (defined($restricted_used->{$_})) {
692 print "No test or testsuite found matching $_\n";
695 } elsif ($#todo == -1) {
696 print STDERR
"No tests to run\n";
700 my $suitestotal = $#todo + 1;
703 Subunit
::progress
($suitestotal);
704 Subunit
::report_time
(time());
710 my %running_envs = ();
712 sub get_running_env
($)
720 return $running_envs{$envname};
723 my @exported_envvars = (
728 # stuff related to a trusted domain
738 # domain controller stuff
748 "MEMBER_SERVER_IPV6",
749 "MEMBER_NETBIOSNAME",
750 "MEMBER_NETBIOSALIAS",
752 # rpc proxy controller stuff
754 "RPC_PROXY_SERVER_IP",
755 "RPC_PROXY_SERVER_IPV6",
756 "RPC_PROXY_NETBIOSNAME",
757 "RPC_PROXY_NETBIOSALIAS",
759 # domain controller stuff for Vampired DC
761 "VAMPIRE_DC_SERVER_IP",
762 "VAMPIRE_DC_SERVER_IPV6",
763 "VAMPIRE_DC_NETBIOSNAME",
764 "VAMPIRE_DC_NETBIOSALIAS",
766 "PROMOTED_DC_SERVER",
767 "PROMOTED_DC_SERVER_IP",
768 "PROMOTED_DC_SERVER_IPV6",
769 "PROMOTED_DC_NETBIOSNAME",
770 "PROMOTED_DC_NETBIOSALIAS",
786 # UID/GID for rfc2307 mapping tests
792 "SELFTEST_WINBINDD_SOCKET_DIR",
793 "WINBINDD_PRIV_PIPE_DIR",
798 "NSS_WRAPPER_PASSWD",
801 "NSS_WRAPPER_MODULE_SO_PATH",
802 "NSS_WRAPPER_MODULE_FN_PREFIX",
805 "RESOLV_WRAPPER_CONF",
806 "RESOLV_WRAPPER_HOSTS",
813 $SIG{INT
} = $SIG{QUIT
} = $SIG{TERM
} = 'DEFAULT';
814 $SIG{PIPE
} = 'IGNORE';
816 open(STDOUT
, ">&STDERR") or die "can't dup STDOUT to STDERR: $!";
818 print "$0: PID[$$]: Got SIG${signame} teardown environments.\n";
819 teardown_env
($_) foreach(keys %running_envs);
820 system("pstree -p $$");
821 print "$0: PID[$$]: Exiting...\n";
825 $SIG{INT
} = $SIG{QUIT
} = $SIG{TERM
} = $SIG{PIPE
} = \
&sighandler
;
829 my ($name, $prefix) = @_;
831 my $testenv_vars = undef;
837 $option =~ s/^[^:]*//;
840 $option = "client" if $option eq "";
842 if (defined(get_running_env
($envname))) {
843 $testenv_vars = get_running_env
($envname);
844 if (not $testenv_vars->{target
}->check_env($testenv_vars)) {
845 print $testenv_vars->{target
}->getlog_env($testenv_vars);
846 $testenv_vars = undef;
849 $testenv_vars = $target->setup_env($envname, $prefix);
850 if (defined($testenv_vars) and $testenv_vars eq "UNKNOWN") {
851 return $testenv_vars;
852 } elsif (defined($testenv_vars) && not defined($testenv_vars->{target
})) {
853 $testenv_vars->{target
} = $target;
855 if (not defined($testenv_vars)) {
856 warn("$opt_target can't start up known environment '$envname'");
860 return undef unless defined($testenv_vars);
862 $running_envs{$envname} = $testenv_vars;
864 if ($option eq "local") {
865 SocketWrapper
::set_default_iface
($testenv_vars->{SOCKET_WRAPPER_DEFAULT_IFACE
});
866 $ENV{SMB_CONF_PATH
} = $testenv_vars->{SERVERCONFFILE
};
867 } elsif ($option eq "client") {
868 SocketWrapper
::set_default_iface
(11);
869 write_clientconf
($conffile, $clientdir, $testenv_vars);
870 $ENV{SMB_CONF_PATH
} = $conffile;
872 die("Unknown option[$option] for envname[$envname]");
875 foreach (@exported_envvars) {
876 if (defined($testenv_vars->{$_})) {
877 $ENV{$_} = $testenv_vars->{$_};
883 return $testenv_vars;
886 sub exported_envvars_str
($)
888 my ($testenv_vars) = @_;
891 foreach (@exported_envvars) {
892 next unless defined($testenv_vars->{$_});
893 $out .= $_."=".$testenv_vars->{$_}."\n";
902 return "" if ($envname eq "none");
903 my $env = get_running_env
($envname);
904 return $env->{target
}->getlog_env($env);
910 my $env = get_running_env
($envname);
911 return $env->{target
}->check_env($env);
917 return if ($envname eq "none");
918 print STDERR
"teardown_env($envname)\n";
919 my $env = get_running_env
($envname);
920 $env->{target
}->teardown_env($env);
921 delete $running_envs{$envname};
924 # This 'global' file needs to be empty when we start
925 unlink("$prefix_abs/dns_host_file");
926 unlink("$prefix_abs/hosts");
928 if ($opt_random_order) {
930 my @newtodo = List
::Util
::shuffle
(@todo);
935 my $testenv_name = $ENV{SELFTEST_TESTENV
};
936 $testenv_name = $testenv_default unless defined($testenv_name);
938 my $testenv_vars = setup_env
($testenv_name, $prefix);
940 if (not $testenv_vars or $testenv_vars eq "UNKNOWN") {
941 die("Unable to setup environment $testenv_name");
944 $ENV{PIDDIR
} = $testenv_vars->{PIDDIR
};
945 $ENV{ENVNAME
} = $testenv_name;
947 my $envvarstr = exported_envvars_str
($testenv_vars);
949 my @term_args = ("echo -e \"
950 Welcome to the Samba4 Test environment '$testenv_name'
952 This matches the client environment used in make test
953 server is pid `cat \$PIDDIR/samba.pid`
955 Some useful environment variables:
956 TORTURE_OPTIONS=\$TORTURE_OPTIONS
957 SMB_CONF_PATH=\$SMB_CONF_PATH
960 \" && LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH} bash");
962 if ($ENV{TERMINAL
}) {
963 @term = ($ENV{TERMINAL
});
965 @term = ("xterm", "-e");
966 unshift(@term_args, ("bash", "-c"));
969 system(@term, @term_args);
971 teardown_env
($testenv_name);
972 } elsif ($opt_list) {
975 my $envname = $$_[1];
977 my $listcmd = $$_[3];
979 unless (defined($listcmd)) {
980 warn("Unable to list tests in $name");
981 # Rather than ignoring this testsuite altogether, just pretend the entire testsuite is
990 die("Unable to run $listcmd: $!");
992 die(sprintf("%s died with signal %d, %s coredump\n", $listcmd, ($?
& 127), ($?
& 128) ?
'with' : 'without'));
995 my $exitcode = $?
>> 8;
996 if ($exitcode != 0) {
997 die("$cmd exited with exit code $exitcode");
1005 my $envname = $$_[1];
1007 my $envvars = setup_env
($envname, $prefix);
1008 if (not defined($envvars)) {
1009 Subunit
::start_testsuite
($name);
1010 Subunit
::end_testsuite
($name, "error",
1011 "unable to set up environment $envname - exiting");
1013 } elsif ($envvars eq "UNKNOWN") {
1014 Subunit
::start_testsuite
($name);
1015 Subunit
::end_testsuite
($name, "skip",
1016 "environment $envname is unknown in this test backend - skipping");
1020 # Generate a file with the individual tests to run, if the
1021 # test runner for this test suite supports it.
1022 if ($individual_tests and $individual_tests->{$name}) {
1024 my ($fh, $listid_file) = tempfile
(UNLINK
=> 0);
1025 foreach my $test (@
{$individual_tests->{$name}}) {
1026 print $fh substr($test, length($name)+1) . "\n";
1028 $cmd =~ s/\$LOADLIST/--load-list=$listid_file/g;
1030 warn("Unable to run individual tests in $name, it does not support --loadlist.");
1034 run_testsuite
($envname, $name, $cmd, $i, $suitestotal);
1036 teardown_env
($envname) if ($opt_resetup_env);
1042 teardown_env
($_) foreach (keys %running_envs);
1046 # if there were any valgrind failures, show them
1047 foreach (<$prefix/valgrind
.log*>) {
1048 next unless (-s
$_);
1049 print "VALGRIND FAILURE\n";