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_libresolv_wrapper_so_path = "";
57 my $opt_libsocket_wrapper_so_path = "";
58 my $opt_libuid_wrapper_so_path = "";
59 my $opt_use_dns_faking = 0;
71 my ($list, $fullname) = @_;
74 if ($fullname =~ /$$_[0]/) {
75 return ($$_[1]) if ($$_[1]);
87 return find_in_list
(\
@excludes, $name);
96 return unless ($opt_socket_wrapper_pcap);
97 return unless defined($ENV{SOCKET_WRAPPER_PCAP_DIR
});
100 $fname =~ s
%[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\
-]%_%g;
102 my $pcap_file = "$ENV{SOCKET_WRAPPER_PCAP_DIR}/$fname.pcap";
104 SocketWrapper
::setup_pcap
($pcap_file);
111 my ($pcap_file, $exitcode) = @_;
113 return unless ($opt_socket_wrapper_pcap);
114 return if ($opt_socket_wrapper_keep_pcap);
115 return unless ($exitcode == 0);
116 return unless defined($pcap_file);
121 # expand strings from %ENV
122 sub expand_environment_strings
($)
125 # we use a reverse sort so we do the longer ones first
126 foreach my $k (sort { $b cmp $a } keys %ENV) {
127 $s =~ s/\$$k/$ENV{$k}/g;
132 sub run_testsuite
($$$$$)
134 my ($envname, $name, $cmd, $i, $totalsuites) = @_;
135 my $pcap_file = setup_pcap
($name);
137 Subunit
::start_testsuite
($name);
138 Subunit
::progress_push
();
139 Subunit
::report_time
(time());
141 Subunit
::report_time
(time());
142 Subunit
::progress_pop
();
145 Subunit
::progress_pop
();
146 Subunit
::end_testsuite
($name, "error", "Unable to run $cmd: $!");
149 Subunit
::end_testsuite
($name, "error",
150 sprintf("%s died with signal %d, %s coredump\n", $cmd, ($?
& 127), ($?
& 128) ?
'with' : 'without'));
154 my $exitcode = $?
>> 8;
156 my $envlog = getlog_env
($envname);
158 print "envlog: $envlog\n";
161 print "command: $cmd\n";
162 printf "expanded command: %s\n", expand_environment_strings
($cmd);
164 if ($exitcode == 0) {
165 Subunit
::end_testsuite
($name, "success");
167 Subunit
::end_testsuite
($name, "failure", "Exit code was $exitcode");
170 cleanup_pcap
($pcap_file, $exitcode);
172 if (not $opt_socket_wrapper_keep_pcap and defined($pcap_file)) {
173 print "PCAP FILE: $pcap_file\n";
176 if ($exitcode != 0) {
177 exit(1) if ($opt_one);
185 print "Samba test runner
186 Copyright (C) Jelmer Vernooij <jelmer\@samba.org>
187 Copyright (C) Stefan Metzmacher <metze\@samba.org>
189 Usage: $Script [OPTIONS] TESTNAME-REGEX
192 --help this help page
193 --target=samba[3]|win Samba version to target
194 --testlist=FILE file to read available tests from
195 --exclude=FILE Exclude tests listed in the file
196 --include=FILE Include tests listed in the file
199 --prefix=DIR prefix to run tests in [st]
200 --srcdir=DIR source directory [.]
201 --bindir=DIR binaries directory [./bin]
204 --nss_wrapper_so_path=FILE the nss_wrapper library to preload
205 --resolv_wrapper_so_path=FILE the resolv_wrapper library to preload
206 --socket_wrapper_so_path=FILE the socket_wrapper library to preload
207 --uid_wrapper_so_path=FILE the uid_wrapper library to preload
210 --use-dns-faking Fake DNS entries rather than talking to our
214 --socket-wrapper-pcap save traffic to pcap directories
215 --socket-wrapper-keep-pcap keep all pcap files, not just those for tests that
217 --socket-wrapper enable socket wrapper
220 --ldap=openldap|fedora-ds back samba onto specified ldap server
223 --quick run quick overall test
224 --one abort when the first test fails
225 --testenv run a shell in the requested test environment
226 --list list available tests
231 my $result = GetOptions
(
232 'help|h|?' => \
$opt_help,
233 'target=s' => \
$opt_target,
234 'prefix=s' => \
$prefix,
235 'socket-wrapper' => \
$opt_socket_wrapper,
236 'socket-wrapper-pcap' => \
$opt_socket_wrapper_pcap,
237 'socket-wrapper-keep-pcap' => \
$opt_socket_wrapper_keep_pcap,
238 'quick' => \
$opt_quick,
240 'exclude=s' => \
@opt_exclude,
241 'include=s' => \
@opt_include,
242 'srcdir=s' => \
$srcdir,
243 'bindir=s' => \
$bindir,
244 'testenv' => \
$opt_testenv,
245 'list' => \
$opt_list,
247 'resetup-environment' => \
$opt_resetup_env,
248 'testlist=s' => \
@testlists,
249 'random-order' => \
$opt_random_order,
250 'load-list=s' => \
$opt_load_list,
251 'binary-mapping=s' => \
$opt_binary_mapping,
252 'nss_wrapper_so_path=s' => \
$opt_libnss_wrapper_so_path,
253 'resolv_wrapper_so_path=s' => \
$opt_libresolv_wrapper_so_path,
254 'socket_wrapper_so_path=s' => \
$opt_libsocket_wrapper_so_path,
255 'uid_wrapper_so_path=s' => \
$opt_libuid_wrapper_so_path,
256 'use-dns-faking' => \
$opt_use_dns_faking
259 exit(1) if (not $result);
261 ShowHelp
() if ($opt_help);
263 die("--list and --testenv are mutually exclusive") if ($opt_list and $opt_testenv);
265 # we want unbuffered output
270 # quick hack to disable rpc validation when using valgrind - its way too slow
271 unless (defined($ENV{VALGRIND
})) {
272 $ENV{VALIDATE
} = "validate";
273 $ENV{MALLOC_CHECK_
} = 3;
276 # make all our python scripts unbuffered
277 $ENV{PYTHONUNBUFFERED
} = 1;
279 my $bindir_abs = abs_path
($bindir);
281 # Backwards compatibility:
282 if (defined($ENV{TEST_LDAP
}) and $ENV{TEST_LDAP
} eq "yes") {
283 if (defined($ENV{FEDORA_DS_ROOT
})) {
290 my $torture_maxtime = ($ENV{TORTURE_MAXTIME
} or 1200);
293 $torture_maxtime *= 2;
300 die("using an empty prefix isn't allowed") unless $prefix ne "";
302 # Ensure we have the test prefix around.
304 # We need restrictive
305 # permissions on this as some subdirectories in this tree will have
306 # wider permissions (ie 0777) and this would allow other users on the
307 # host to subvert the test process.
308 mkdir($prefix, 0700) unless -d
$prefix;
311 my $prefix_abs = abs_path
($prefix);
312 my $tmpdir_abs = abs_path
("$prefix/tmp");
313 mkdir($tmpdir_abs, 0777) unless -d
$tmpdir_abs;
315 my $srcdir_abs = abs_path
($srcdir);
317 die("using an empty absolute prefix isn't allowed") unless $prefix_abs ne "";
318 die("using '/' as absolute prefix isn't allowed") unless $prefix_abs ne "/";
320 $ENV{PREFIX
} = $prefix;
321 $ENV{KRB5CCNAME
} = "$prefix/krb5ticket";
322 $ENV{PREFIX_ABS
} = $prefix_abs;
323 $ENV{SRCDIR
} = $srcdir;
324 $ENV{SRCDIR_ABS
} = $srcdir_abs;
325 $ENV{BINDIR
} = $bindir_abs;
327 my $tls_enabled = not $opt_quick;
328 $ENV{TLS_ENABLED
} = ($tls_enabled?
"yes":"no");
330 sub prefix_pathvar
($$)
332 my ($name, $newpath) = @_;
333 if (defined($ENV{$name})) {
334 $ENV{$name} = "$newpath:$ENV{$name}";
336 $ENV{$name} = $newpath;
339 prefix_pathvar
("PKG_CONFIG_PATH", "$bindir_abs/pkgconfig");
340 prefix_pathvar
("PYTHONPATH", "$bindir_abs/python");
342 if ($opt_socket_wrapper_keep_pcap) {
343 # Socket wrapper keep pcap implies socket wrapper pcap
344 $opt_socket_wrapper_pcap = 1;
347 if ($opt_socket_wrapper_pcap) {
348 # Socket wrapper pcap implies socket wrapper
349 $opt_socket_wrapper = 1;
352 my $ld_preload = $ENV{LD_PRELOAD
};
354 if ($opt_libnss_wrapper_so_path) {
356 $ld_preload = "$ld_preload:$opt_libnss_wrapper_so_path";
358 $ld_preload = "$opt_libnss_wrapper_so_path";
362 if ($opt_libresolv_wrapper_so_path) {
364 $ld_preload = "$ld_preload:$opt_libresolv_wrapper_so_path";
366 $ld_preload = "$opt_libresolv_wrapper_so_path";
370 if ($opt_libsocket_wrapper_so_path) {
372 $ld_preload = "$ld_preload:$opt_libsocket_wrapper_so_path";
374 $ld_preload = "$opt_libsocket_wrapper_so_path";
378 if ($opt_libuid_wrapper_so_path) {
380 $ld_preload = "$ld_preload:$opt_libuid_wrapper_so_path";
382 $ld_preload = "$opt_libuid_wrapper_so_path";
386 $ENV{LD_PRELOAD
} = $ld_preload;
387 print "LD_PRELOAD=$ENV{LD_PRELOAD}\n";
389 # Enable uid_wrapper globally
390 $ENV{UID_WRAPPER
} = 1;
392 # Disable RTLD_DEEPBIND hack for Samba bind dlz module
394 # This is needed in order to allow the ldb_*ldap module
395 # to work with a preloaded socket wrapper.
396 $ENV{LDB_MODULES_DISABLE_DEEPBIND
} = 1;
398 my $socket_wrapper_dir;
399 if ($opt_socket_wrapper) {
400 $socket_wrapper_dir = SocketWrapper
::setup_dir
("$prefix_abs/w", $opt_socket_wrapper_pcap);
401 print "SOCKET_WRAPPER_DIR=$socket_wrapper_dir\n";
402 } elsif (not $opt_list) {
404 warn("not using socket wrapper, but also not running as root. Will not be able to listen on proper ports");
408 if ($opt_use_dns_faking) {
409 print "DNS: Faking nameserver\n";
410 $ENV{SAMBA_DNS_FAKING
} = 1;
414 my $testenv_default = "none";
416 my %binary_mapping = ();
417 if ($opt_binary_mapping) {
418 my @binmapping_list = split(/,/, $opt_binary_mapping);
419 foreach my $mapping (@binmapping_list) {
420 my ($bin, $map) = split(/\:/, $mapping);
421 $binary_mapping{$bin} = $map;
425 $ENV{BINARY_MAPPING
} = $opt_binary_mapping;
427 # After this many seconds, the server will self-terminate. All tests
428 # must terminate in this time, and testenv will only stay alive this
431 my $server_maxtime = 9000;
432 if (defined($ENV{SMBD_MAXTIME
}) and $ENV{SMBD_MAXTIME
} ne "") {
433 $server_maxtime = $ENV{SMBD_MAXTIME
};
437 if ($opt_target eq "samba") {
438 $testenv_default = "ad_dc_ntvfs";
439 require target
::Samba
;
440 $target = new Samba
($bindir, \
%binary_mapping, $ldap, $srcdir, $server_maxtime);
441 } elsif ($opt_target eq "samba3") {
442 $testenv_default = "nt4_member";
443 require target
::Samba3
;
444 $target = new Samba3
($bindir, \
%binary_mapping, $srcdir_abs, $server_maxtime);
448 sub read_test_regexes
($)
452 open(LF
, "<$name") or die("unable to read $name: $!");
456 if (/^(.*?)([ \t]+)\#([\t ]*)(.*?)$/) {
457 push (@ret, [$1, $4]);
459 s/^(.*?)([ \t]+)\#([\t ]*)(.*?)$//;
460 push (@ret, [$_, undef]);
467 foreach (@opt_exclude) {
468 push (@excludes, read_test_regexes
($_));
471 foreach (@opt_include) {
472 push (@includes, read_test_regexes
($_));
475 my $interfaces = join(',', ("127.0.0.11/8",
482 my $clientdir = "$prefix_abs/client";
484 my $conffile = "$clientdir/client.conf";
485 $ENV{SMB_CONF_PATH
} = $conffile;
487 sub write_clientconf
($$$)
489 my ($conffile, $clientdir, $vars) = @_;
491 mkdir("$clientdir", 0777) unless -d
"$clientdir";
493 if ( -d
"$clientdir/private" ) {
494 unlink <$clientdir/private/*>;
496 mkdir("$clientdir/private", 0777);
499 if ( -d
"$clientdir/lockdir" ) {
500 unlink <$clientdir/lockdir/*>;
502 mkdir("$clientdir/lockdir", 0777);
505 if ( -d
"$clientdir/statedir" ) {
506 unlink <$clientdir/statedir/*>;
508 mkdir("$clientdir/statedir", 0777);
511 if ( -d
"$clientdir/cachedir" ) {
512 unlink <$clientdir/cachedir/*>;
514 mkdir("$clientdir/cachedir", 0777);
517 # this is ugly, but the ncalrpcdir needs exactly 0755
518 # otherwise tests fail.
521 if ( -d
"$clientdir/ncalrpcdir/np" ) {
522 unlink <$clientdir/ncalrpcdir/np
/*>;
523 rmdir "$clientdir/ncalrpcdir/np";
525 if ( -d
"$clientdir/ncalrpcdir" ) {
526 unlink <$clientdir/ncalrpcdir/*>;
527 rmdir "$clientdir/ncalrpcdir";
529 mkdir("$clientdir/ncalrpcdir", 0755);
532 open(CF
, ">$conffile");
533 print CF
"[global]\n";
534 print CF
"\tnetbios name = client\n";
535 if (defined($vars->{DOMAIN
})) {
536 print CF
"\tworkgroup = $vars->{DOMAIN}\n";
538 if (defined($vars->{REALM
})) {
539 print CF
"\trealm = $vars->{REALM}\n";
541 if ($opt_socket_wrapper) {
542 print CF
"\tinterfaces = $interfaces\n";
545 private dir = $clientdir/private
546 lock dir = $clientdir/lockdir
547 state directory = $clientdir/statedir
548 cache directory = $clientdir/cachedir
549 ncalrpc dir = $clientdir/ncalrpcdir
550 panic action = $RealBin/gdb_backtrace \%d
552 notify:inotify = false
554 system:anonymous = true
555 client lanman auth = Yes
557 torture:basedir = $clientdir
558 #We don't want to pass our self-tests if the PAC code is wrong
559 gensec:require_pac = true
560 #We don't want to run 'speed' tests for very long
561 torture:timelimit = 1
562 winbind separator = /
569 sub should_run_test
($)
575 for (my $i=0; $i <= $#tests; $i++) {
576 if ($name =~ /$tests[$i]/i) {
588 open(IN
, $filename) or die("Unable to open $filename: $!");
591 if (/-- TEST(-LOADLIST|) --\n/) {
592 my $supports_loadlist = (defined($1) and $1 eq "-LOADLIST");
598 if ($supports_loadlist) {
600 $loadlist =~ s/\n//g;
604 if (should_run_test
($name) == 1) {
605 push (@ret, [$name, $env, $cmdline, $loadlist]);
611 close(IN
) or die("Error creating recipe from $filename");
615 if ($#testlists == -1) {
616 die("No testlists specified");
619 $ENV{SELFTEST_PREFIX
} = "$prefix_abs";
620 $ENV{SELFTEST_TMPDIR
} = "$tmpdir_abs";
621 $ENV{TEST_DATA_PREFIX
} = "$tmpdir_abs";
622 if ($opt_socket_wrapper) {
623 $ENV{SELFTEST_INTERFACES
} = $interfaces;
625 $ENV{SELFTEST_INTERFACES
} = "";
628 $ENV{SELFTEST_QUICK
} = "1";
630 $ENV{SELFTEST_QUICK
} = "";
632 $ENV{SELFTEST_MAXTIME
} = $torture_maxtime;
635 foreach my $fn (@testlists) {
636 foreach (read_testlist
($fn)) {
638 next if (@includes and not defined(find_in_list
(\
@includes, $name)));
639 push (@available, $_);
643 my $restricted = undef;
644 my $restricted_used = {};
646 if ($opt_load_list) {
648 open(LOAD_LIST
, "<$opt_load_list") or die("Unable to open $opt_load_list");
649 while (<LOAD_LIST
>) {
651 push (@
$restricted, $_);
656 my $individual_tests = undef;
657 $individual_tests = {};
659 foreach my $testsuite (@available) {
660 my $name = $$testsuite[0];
661 my $skipreason = skip
($name);
662 if (defined($restricted)) {
663 # Find the testsuite for this test
665 foreach my $r (@
$restricted) {
667 $individual_tests->{$name} = [];
669 $restricted_used->{$r} = 1;
670 } elsif (substr($r, 0, length($name)+1) eq "$name.") {
671 push(@
{$individual_tests->{$name}}, $r);
673 $restricted_used->{$r} = 1;
677 if (defined($skipreason)) {
679 Subunit
::skip_testsuite
($name, $skipreason);
682 push(@todo, $testsuite);
685 } elsif (defined($skipreason)) {
687 Subunit
::skip_testsuite
($name, $skipreason);
690 push(@todo, $testsuite);
694 if (defined($restricted)) {
695 foreach (@
$restricted) {
696 unless (defined($restricted_used->{$_})) {
697 print "No test or testsuite found matching $_\n";
700 } elsif ($#todo == -1) {
701 print STDERR
"No tests to run\n";
705 my $suitestotal = $#todo + 1;
708 Subunit
::progress
($suitestotal);
709 Subunit
::report_time
(time());
715 my %running_envs = ();
717 sub get_running_env
($)
725 return $running_envs{$envname};
728 my @exported_envvars = (
733 # domain controller stuff
743 "MEMBER_SERVER_IPV6",
744 "MEMBER_NETBIOSNAME",
745 "MEMBER_NETBIOSALIAS",
747 # rpc proxy controller stuff
749 "RPC_PROXY_SERVER_IP",
750 "RPC_PROXY_SERVER_IPV6",
751 "RPC_PROXY_NETBIOSNAME",
752 "RPC_PROXY_NETBIOSALIAS",
754 # domain controller stuff for Vampired DC
756 "VAMPIRE_DC_SERVER_IP",
757 "VAMPIRE_DC_SERVER_IPV6",
758 "VAMPIRE_DC_NETBIOSNAME",
759 "VAMPIRE_DC_NETBIOSALIAS",
761 "PROMOTED_DC_SERVER",
762 "PROMOTED_DC_SERVER_IP",
763 "PROMOTED_DC_SERVER_IPV6",
764 "PROMOTED_DC_NETBIOSNAME",
765 "PROMOTED_DC_NETBIOSALIAS",
781 # UID/GID for rfc2307 mapping tests
787 "SELFTEST_WINBINDD_SOCKET_DIR",
788 "WINBINDD_PRIV_PIPE_DIR",
793 "NSS_WRAPPER_PASSWD",
796 "NSS_WRAPPER_MODULE_SO_PATH",
797 "NSS_WRAPPER_MODULE_FN_PREFIX",
800 "RESOLV_WRAPPER_CONF",
801 "RESOLV_WRAPPER_HOSTS",
808 $SIG{INT
} = $SIG{QUIT
} = $SIG{TERM
} = 'DEFAULT';
809 $SIG{PIPE
} = 'IGNORE';
811 open(STDOUT
, ">&STDERR") or die "can't dup STDOUT to STDERR: $!";
813 print "$0: PID[$$]: Got SIG${signame} teardown environments.\n";
814 teardown_env
($_) foreach(keys %running_envs);
815 system("pstree -p $$");
816 print "$0: PID[$$]: Exiting...\n";
820 $SIG{INT
} = $SIG{QUIT
} = $SIG{TERM
} = $SIG{PIPE
} = \
&sighandler
;
824 my ($name, $prefix) = @_;
826 my $testenv_vars = undef;
832 $option =~ s/^[^:]*//;
835 $option = "client" if $option eq "";
837 if ($envname eq "none") {
839 } elsif (defined(get_running_env
($envname))) {
840 $testenv_vars = get_running_env
($envname);
841 if (not $testenv_vars->{target
}->check_env($testenv_vars)) {
842 print $testenv_vars->{target
}->getlog_env($testenv_vars);
843 $testenv_vars = undef;
846 $testenv_vars = $target->setup_env($envname, $prefix);
847 if (defined($testenv_vars) and $testenv_vars eq "UNKNOWN") {
848 return $testenv_vars;
849 } elsif (defined($testenv_vars) && not defined($testenv_vars->{target
})) {
850 $testenv_vars->{target
} = $target;
852 if (not defined($testenv_vars)) {
853 warn("$opt_target can't start up known environment '$envname'");
857 return undef unless defined($testenv_vars);
859 $running_envs{$envname} = $testenv_vars;
861 if ($option eq "local") {
862 SocketWrapper
::set_default_iface
($testenv_vars->{SOCKET_WRAPPER_DEFAULT_IFACE
});
863 $ENV{SMB_CONF_PATH
} = $testenv_vars->{SERVERCONFFILE
};
864 } elsif ($option eq "client") {
865 SocketWrapper
::set_default_iface
(11);
866 write_clientconf
($conffile, $clientdir, $testenv_vars);
867 $ENV{SMB_CONF_PATH
} = $conffile;
869 die("Unknown option[$option] for envname[$envname]");
872 foreach (@exported_envvars) {
873 if (defined($testenv_vars->{$_})) {
874 $ENV{$_} = $testenv_vars->{$_};
880 return $testenv_vars;
883 sub exported_envvars_str
($)
885 my ($testenv_vars) = @_;
888 foreach (@exported_envvars) {
889 next unless defined($testenv_vars->{$_});
890 $out .= $_."=".$testenv_vars->{$_}."\n";
899 return "" if ($envname eq "none");
900 my $env = get_running_env
($envname);
901 return $env->{target
}->getlog_env($env);
907 return 1 if ($envname eq "none");
908 my $env = get_running_env
($envname);
909 return $env->{target
}->check_env($env);
915 return if ($envname eq "none");
916 print STDERR
"teardown_env($envname)\n";
917 my $env = get_running_env
($envname);
918 $env->{target
}->teardown_env($env);
919 delete $running_envs{$envname};
922 # This 'global' file needs to be empty when we start
923 unlink("$prefix_abs/dns_host_file");
924 unlink("$prefix_abs/hosts");
926 if ($opt_random_order) {
928 my @newtodo = List
::Util
::shuffle
(@todo);
933 my $testenv_name = $ENV{SELFTEST_TESTENV
};
934 $testenv_name = $testenv_default unless defined($testenv_name);
936 my $testenv_vars = setup_env
($testenv_name, $prefix);
938 if (not $testenv_vars or $testenv_vars eq "UNKNOWN") {
939 die("Unable to setup environment $testenv_name");
942 $ENV{PIDDIR
} = $testenv_vars->{PIDDIR
};
943 $ENV{ENVNAME
} = $testenv_name;
945 my $envvarstr = exported_envvars_str
($testenv_vars);
947 my @term_args = ("echo -e \"
948 Welcome to the Samba4 Test environment '$testenv_name'
950 This matches the client environment used in make test
951 server is pid `cat \$PIDDIR/samba.pid`
953 Some useful environment variables:
954 TORTURE_OPTIONS=\$TORTURE_OPTIONS
955 SMB_CONF_PATH=\$SMB_CONF_PATH
958 \" && LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH} bash");
960 if ($ENV{TERMINAL
}) {
961 @term = ($ENV{TERMINAL
});
963 @term = ("xterm", "-e");
964 unshift(@term_args, ("bash", "-c"));
967 system(@term, @term_args);
969 teardown_env
($testenv_name);
970 } elsif ($opt_list) {
973 my $envname = $$_[1];
975 my $listcmd = $$_[3];
977 unless (defined($listcmd)) {
978 warn("Unable to list tests in $name");
979 # Rather than ignoring this testsuite altogether, just pretend the entire testsuite is
988 die("Unable to run $listcmd: $!");
990 die(sprintf("%s died with signal %d, %s coredump\n", $listcmd, ($?
& 127), ($?
& 128) ?
'with' : 'without'));
993 my $exitcode = $?
>> 8;
994 if ($exitcode != 0) {
995 die("$cmd exited with exit code $exitcode");
1003 my $envname = $$_[1];
1005 my $envvars = setup_env
($envname, $prefix);
1006 if (not defined($envvars)) {
1007 Subunit
::start_testsuite
($name);
1008 Subunit
::end_testsuite
($name, "error",
1009 "unable to set up environment $envname - exiting");
1011 } elsif ($envvars eq "UNKNOWN") {
1012 Subunit
::start_testsuite
($name);
1013 Subunit
::end_testsuite
($name, "skip",
1014 "environment $envname is unknown in this test backend - skipping");
1018 # Generate a file with the individual tests to run, if the
1019 # test runner for this test suite supports it.
1020 if ($individual_tests and $individual_tests->{$name}) {
1022 my ($fh, $listid_file) = tempfile
(UNLINK
=> 0);
1023 foreach my $test (@
{$individual_tests->{$name}}) {
1024 print $fh substr($test, length($name)+1) . "\n";
1026 $cmd =~ s/\$LOADLIST/--load-list=$listid_file/g;
1028 warn("Unable to run individual tests in $name, it does not support --loadlist.");
1032 run_testsuite
($envname, $name, $cmd, $i, $suitestotal);
1034 teardown_env
($envname) if ($opt_resetup_env);
1040 teardown_env
($_) foreach (keys %running_envs);
1044 # if there were any valgrind failures, show them
1045 foreach (<$prefix/valgrind
.log*>) {
1046 next unless (-s
$_);
1047 print "VALGRIND FAILURE\n";