s3: shortcut uid_to_sid when "ldapsam:trusted = yes"
[Samba/bb.git] / selftest / selftest.pl
blob3536d410aeeb26992ba09c95cc9eeb22710b9dbf
1 #!/usr/bin/perl
2 # Bootstrap Samba and run a number of tests against it.
3 # Copyright (C) 2005-2009 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/>.
19 =pod
21 =head1 NAME
23 selftest - Samba test runner
25 =head1 SYNOPSIS
27 selftest --help
29 selftest [--srcdir=DIR] [--builddir=DIR] [--exeext=EXT][--target=samba4|samba3|win|kvm] [--socket-wrapper] [--quick] [--exclude=FILE] [--include=FILE] [--one] [--prefix=prefix] [--testlist=FILE] [TESTS]
31 =head1 DESCRIPTION
33 A simple test runner. TESTS is a regular expression with tests to run.
35 =head1 OPTIONS
37 =over 4
39 =item I<--help>
41 Show list of available options.
43 =item I<--srcdir=DIR>
45 Source directory.
47 =item I<--builddir=DIR>
49 Build directory.
51 =item I<--exeext=EXT>
53 Executable extention
55 =item I<--prefix=DIR>
57 Change directory to run tests in. Default is 'st'.
59 =item I<--target samba4|samba3|win|kvm>
61 Specify test target against which to run. Default is 'samba4'.
63 =item I<--quick>
65 Run only a limited number of tests. Intended to run in about 30 seconds on
66 moderately recent systems.
68 =item I<--socket-wrapper>
70 Use socket wrapper library for communication with server. Only works
71 when the server is running locally.
73 Will prevent TCP and UDP ports being opened on the local host but
74 (transparently) redirects these calls to use unix domain sockets.
76 =item I<--exclude>
78 Specify a file containing a list of tests that should be skipped. Possible
79 candidates are tests that segfault the server, flip or don't end.
81 =item I<--include>
83 Specify a file containing a list of tests that should be run. Same format
84 as the --exclude flag.
86 Not includes specified means all tests will be run.
88 =item I<--one>
90 Abort as soon as one test fails.
92 =item I<--testlist>
94 Load a list of tests from the specified location.
96 =back
98 =head1 ENVIRONMENT
100 =over 4
102 =item I<SMBD_VALGRIND>
104 =item I<TORTURE_MAXTIME>
106 =item I<VALGRIND>
108 =item I<TLS_ENABLED>
110 =item I<srcdir>
112 =back
114 =head1 LICENSE
116 selftest is licensed under the GNU General Public License L<http://www.gnu.org/licenses/gpl.html>.
118 =head1 AUTHOR
120 Jelmer Vernooij
122 =cut
124 use strict;
126 use FindBin qw($RealBin $Script);
127 use File::Spec;
128 use Getopt::Long;
129 use POSIX;
130 use Cwd qw(abs_path);
131 use lib "$RealBin";
132 use Subunit qw(parse_results);
133 use Subunit::Filter;
134 use SocketWrapper;
136 my $opt_help = 0;
137 my $opt_target = "samba4";
138 my $opt_quick = 0;
139 my $opt_socket_wrapper = 0;
140 my $opt_socket_wrapper_pcap = undef;
141 my $opt_socket_wrapper_keep_pcap = undef;
142 my $opt_one = 0;
143 my @opt_exclude = ();
144 my @opt_include = ();
145 my $opt_verbose = 0;
146 my $opt_image = undef;
147 my $opt_testenv = 0;
148 my $ldap = undef;
149 my $opt_analyse_cmd = undef;
150 my $opt_resetup_env = undef;
151 my $opt_bindir = undef;
152 my $opt_no_lazy_setup = undef;
153 my @testlists = ();
155 my $srcdir = ".";
156 my $builddir = ".";
157 my $exeext = "";
158 my $prefix = "./st";
160 my @includes = ();
161 my @excludes = ();
163 sub find_in_list($$)
165 my ($list, $fullname) = @_;
167 foreach (@$list) {
168 if ($fullname =~ /$$_[0]/) {
169 return ($$_[1]) if ($$_[1]);
170 return "";
174 return undef;
177 sub skip($)
179 my ($name) = @_;
181 return find_in_list(\@excludes, $name);
184 sub getlog_env($);
186 sub setup_pcap($)
188 my ($name) = @_;
190 return unless ($opt_socket_wrapper_pcap);
191 return unless defined($ENV{SOCKET_WRAPPER_PCAP_DIR});
193 my $fname = $name;
194 $fname =~ s%[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\-]%_%g;
196 my $pcap_file = "$ENV{SOCKET_WRAPPER_PCAP_DIR}/$fname.pcap";
198 SocketWrapper::setup_pcap($pcap_file);
200 return $pcap_file;
203 sub cleanup_pcap($$)
205 my ($pcap_file, $exitcode) = @_;
207 return unless ($opt_socket_wrapper_pcap);
208 return if ($opt_socket_wrapper_keep_pcap);
209 return unless ($exitcode == 0);
210 return unless defined($pcap_file);
212 unlink($pcap_file);
215 sub run_testsuite($$$$$)
217 my ($envname, $name, $cmd, $i, $totalsuites) = @_;
218 my $pcap_file = setup_pcap($name);
220 Subunit::start_testsuite($name);
221 Subunit::report_time(time());
223 open(RESULTS, "$cmd 2>&1|");
224 my $statistics = {
225 TESTS_UNEXPECTED_OK => 0,
226 TESTS_EXPECTED_OK => 0,
227 TESTS_UNEXPECTED_FAIL => 0,
228 TESTS_EXPECTED_FAIL => 0,
229 TESTS_ERROR => 0,
230 TESTS_SKIP => 0,
233 my $msg_ops = new Subunit::Filter("$name\.", []);
235 parse_results($msg_ops, $statistics, *RESULTS);
237 my $ret = 0;
239 unless (close(RESULTS)) {
240 if ($!) {
241 Subunit::end_testsuite($name, "error", "Unable to run $cmd: $!");
242 return 0;
243 } else {
244 $ret = $?;
248 if ($ret & 127) {
249 Subunit::end_testsuite($name, "error", sprintf("Testsuite died with signal %d, %s coredump", ($ret & 127), ($ret & 128) ? "with": "without"));
250 return 0;
252 my $envlog = getlog_env($envname);
253 if ($envlog ne "") {
254 print "envlog: $envlog\n";
257 print "command: $cmd\n";
259 my $exitcode = $ret >> 8;
261 Subunit::report_time(time());
262 if ($exitcode == 0) {
263 Subunit::end_testsuite($name, "success");
264 } else {
265 Subunit::end_testsuite($name, "failure", "Exit code was $exitcode");
268 cleanup_pcap($pcap_file, $exitcode);
270 if (not $opt_socket_wrapper_keep_pcap and defined($pcap_file)) {
271 print "PCAP FILE: $pcap_file\n";
274 if ($exitcode != 0) {
275 exit(1) if ($opt_one);
278 return $exitcode;
281 sub ShowHelp()
283 print "Samba test runner
284 Copyright (C) Jelmer Vernooij <jelmer\@samba.org>
285 Copyright (C) Stefan Metzmacher <metze\@samba.org>
287 Usage: $Script [OPTIONS] TESTNAME-REGEX
289 Generic options:
290 --help this help page
291 --target=samba[34]|win|kvm Samba version to target
292 --testlist=FILE file to read available tests from
294 Paths:
295 --prefix=DIR prefix to run tests in [st]
296 --srcdir=DIR source directory [.]
297 --builddir=DIR output directory [.]
298 --exeext=EXT executable extention []
300 Target Specific:
301 --socket-wrapper-pcap save traffic to pcap directories
302 --socket-wrapper-keep-pcap keep all pcap files, not just those for tests that
303 failed
304 --socket-wrapper enable socket wrapper
305 --bindir=PATH path to target binaries
307 Samba4 Specific:
308 --ldap=openldap|fedora-ds back samba onto specified ldap server
310 Kvm Specific:
311 --image=PATH path to KVM image
313 Behaviour:
314 --quick run quick overall test
315 --one abort when the first test fails
316 --verbose be verbose
317 --analyse-cmd CMD command to run after each test
319 exit(0);
322 my $result = GetOptions (
323 'help|h|?' => \$opt_help,
324 'target=s' => \$opt_target,
325 'prefix=s' => \$prefix,
326 'socket-wrapper' => \$opt_socket_wrapper,
327 'socket-wrapper-pcap' => \$opt_socket_wrapper_pcap,
328 'socket-wrapper-keep-pcap' => \$opt_socket_wrapper_keep_pcap,
329 'quick' => \$opt_quick,
330 'one' => \$opt_one,
331 'exclude=s' => \@opt_exclude,
332 'include=s' => \@opt_include,
333 'srcdir=s' => \$srcdir,
334 'builddir=s' => \$builddir,
335 'exeext=s' => \$exeext,
336 'verbose' => \$opt_verbose,
337 'testenv' => \$opt_testenv,
338 'ldap:s' => \$ldap,
339 'analyse-cmd=s' => \$opt_analyse_cmd,
340 'no-lazy-setup' => \$opt_no_lazy_setup,
341 'resetup-environment' => \$opt_resetup_env,
342 'bindir:s' => \$opt_bindir,
343 'image=s' => \$opt_image,
344 'testlist=s' => \@testlists
347 exit(1) if (not $result);
349 ShowHelp() if ($opt_help);
351 # we want unbuffered output
352 $| = 1;
354 my @tests = @ARGV;
356 # quick hack to disable rpc validation when using valgrind - its way too slow
357 unless (defined($ENV{VALGRIND})) {
358 $ENV{VALIDATE} = "validate";
359 $ENV{MALLOC_CHECK_} = 2;
362 # make all our python scripts unbuffered
363 $ENV{PYTHONUNBUFFERED} = 1;
365 my $bindir = ($opt_bindir or "$builddir/bin");
366 my $bindir_abs = abs_path($bindir);
368 # Backwards compatibility:
369 if (defined($ENV{TEST_LDAP}) and $ENV{TEST_LDAP} eq "yes") {
370 if (defined($ENV{FEDORA_DS_ROOT})) {
371 $ldap = "fedora-ds";
372 } else {
373 $ldap = "openldap";
377 my $torture_maxtime = ($ENV{TORTURE_MAXTIME} or 1200);
378 if ($ldap) {
379 # LDAP is slow
380 $torture_maxtime *= 2;
383 $prefix =~ s+//+/+;
384 $prefix =~ s+/./+/+;
385 $prefix =~ s+/$++;
387 die("using an empty prefix isn't allowed") unless $prefix ne "";
389 #Ensure we have the test prefix around
390 mkdir($prefix, 0777) unless -d $prefix;
392 my $prefix_abs = abs_path($prefix);
393 my $srcdir_abs = abs_path($srcdir);
394 my $builddir_abs = abs_path($builddir);
396 die("using an empty absolute prefix isn't allowed") unless $prefix_abs ne "";
397 die("using '/' as absolute prefix isn't allowed") unless $prefix_abs ne "/";
399 $ENV{PREFIX} = $prefix;
400 $ENV{KRB5CCNAME} = "$prefix/krb5ticket";
401 $ENV{PREFIX_ABS} = $prefix_abs;
402 $ENV{SRCDIR} = $srcdir;
403 $ENV{SRCDIR_ABS} = $srcdir_abs;
404 $ENV{BUILDDIR} = $builddir;
405 $ENV{BUILDDIR_ABS} = $builddir_abs;
406 $ENV{EXEEXT} = $exeext;
408 my $tls_enabled = not $opt_quick;
409 $ENV{TLS_ENABLED} = ($tls_enabled?"yes":"no");
410 $ENV{LDB_MODULES_PATH} = "$bindir_abs/modules/ldb";
411 $ENV{LD_SAMBA_MODULE_PATH} = "$bindir_abs/modules";
412 sub prefix_pathvar($$)
414 my ($name, $newpath) = @_;
415 if (defined($ENV{$name})) {
416 $ENV{$name} = "$newpath:$ENV{$name}";
417 } else {
418 $ENV{$name} = $newpath;
421 prefix_pathvar("PKG_CONFIG_PATH", "$bindir_abs/pkgconfig");
422 prefix_pathvar("PYTHONPATH", "$bindir_abs/python");
424 if ($opt_socket_wrapper_keep_pcap) {
425 # Socket wrapper keep pcap implies socket wrapper pcap
426 $opt_socket_wrapper_pcap = 1;
429 if ($opt_socket_wrapper_pcap) {
430 # Socket wrapper pcap implies socket wrapper
431 $opt_socket_wrapper = 1;
434 my $socket_wrapper_dir;
435 if ($opt_socket_wrapper) {
436 $socket_wrapper_dir = SocketWrapper::setup_dir("$prefix/w", $opt_socket_wrapper_pcap);
437 print "SOCKET_WRAPPER_DIR=$socket_wrapper_dir\n";
438 } else {
439 unless ($< == 0) {
440 print "WARNING: Not using socket wrapper, but also not running as root. Will not be able to listen on proper ports\n";
444 my $target;
445 my $testenv_default = "none";
447 if ($opt_target eq "samba4") {
448 $testenv_default = "member";
449 require target::Samba4;
450 $target = new Samba4($bindir, $ldap, "$srcdir/setup", $exeext);
451 } elsif ($opt_target eq "samba3") {
452 if ($opt_socket_wrapper and `$bindir/smbd -b | grep SOCKET_WRAPPER` eq "") {
453 die("You must include --enable-socket-wrapper when compiling Samba in order to execute 'make test'. Exiting....");
455 $testenv_default = "member";
456 require target::Samba3;
457 $target = new Samba3($bindir);
458 } elsif ($opt_target eq "win") {
459 die("Windows tests will not run with socket wrapper enabled.")
460 if ($opt_socket_wrapper);
461 $testenv_default = "dc";
462 require target::Windows;
463 $target = new Windows();
464 } elsif ($opt_target eq "kvm") {
465 die("Kvm tests will not run with socket wrapper enabled.")
466 if ($opt_socket_wrapper);
467 require target::Kvm;
468 die("No image specified") unless ($opt_image);
469 $target = new Kvm($opt_image, undef);
473 # Start a Virtual Distributed Ethernet Switch
474 # Returns the pid of the switch.
476 sub start_vde_switch($)
478 my ($path) = @_;
480 system("vde_switch --pidfile $path/vde.pid --sock $path/vde.sock --daemon");
482 open(PID, "$path/vde.pid");
483 <PID> =~ /([0-9]+)/;
484 my $pid = $1;
485 close(PID);
487 return $pid;
490 # Stop a Virtual Distributed Ethernet Switch
491 sub stop_vde_switch($)
493 my ($pid) = @_;
494 kill 9, $pid;
497 sub read_test_regexes($)
499 my ($name) = @_;
500 my @ret = ();
501 open(LF, "<$name") or die("unable to read $name: $!");
502 while (<LF>) {
503 chomp;
504 next if (/^#/);
505 if (/^(.*?)([ \t]+)\#([\t ]*)(.*?)$/) {
506 push (@ret, [$1, $4]);
507 } else {
508 s/^(.*?)([ \t]+)\#([\t ]*)(.*?)$//;
509 push (@ret, [$_, undef]);
512 close(LF);
513 return @ret;
516 foreach (@opt_exclude) {
517 push (@excludes, read_test_regexes($_));
520 foreach (@opt_include) {
521 push (@includes, read_test_regexes($_));
524 my $interfaces = join(',', ("127.0.0.6/8",
525 "127.0.0.7/8",
526 "127.0.0.8/8",
527 "127.0.0.9/8",
528 "127.0.0.10/8",
529 "127.0.0.11/8"));
531 my $conffile = "$prefix_abs/client/client.conf";
532 $ENV{SMB_CONF_PATH} = $conffile;
534 sub write_clientconf($$)
536 my ($conffile, $vars) = @_;
538 mkdir("$prefix/client", 0777) unless -d "$prefix/client";
540 if ( -d "$prefix/client/private" ) {
541 unlink <$prefix/client/private/*>;
542 } else {
543 mkdir("$prefix/client/private", 0777);
546 if ( -d "$prefix/client/lockdir" ) {
547 unlink <$prefix/client/lockdir/*>;
548 } else {
549 mkdir("$prefix/client/lockdir", 0777);
552 if ( -d "$prefix_abs/client/ncalrpcdir" ) {
553 unlink <$prefix/client/ncalrpcdir/*>;
554 } else {
555 mkdir("$prefix/client/ncalrpcdir", 0777);
558 open(CF, ">$conffile");
559 print CF "[global]\n";
560 if (defined($ENV{VALGRIND})) {
561 print CF "\ticonv:native = true\n";
562 } else {
563 print CF "\ticonv:native = false\n";
565 print CF "\tnetbios name = client\n";
566 if (defined($vars->{DOMAIN})) {
567 print CF "\tworkgroup = $vars->{DOMAIN}\n";
569 if (defined($vars->{REALM})) {
570 print CF "\trealm = $vars->{REALM}\n";
572 if ($opt_socket_wrapper) {
573 print CF "\tinterfaces = $interfaces\n";
575 print CF "
576 private dir = $prefix_abs/client/private
577 lock dir = $prefix_abs/client/lockdir
578 ncalrpc dir = $prefix_abs/client/ncalrpcdir
579 name resolve order = bcast
580 panic action = $RealBin/gdb_backtrace \%PID\% \%PROG\%
581 max xmit = 32K
582 notify:inotify = false
583 ldb:nosync = true
584 system:anonymous = true
585 client lanman auth = Yes
586 torture:basedir = $prefix_abs/client
587 #We don't want to pass our self-tests if the PAC code is wrong
588 gensec:require_pac = true
589 modules dir = $ENV{LD_SAMBA_MODULE_PATH}
591 close(CF);
594 my @todo = ();
596 my $testsdir = "$srcdir/selftest";
598 my %required_envs = ();
600 sub should_run_test($)
602 my $name = shift;
603 if ($#tests == -1) {
604 return 1;
606 for (my $i=0; $i <= $#tests; $i++) {
607 if ($name =~ /$tests[$i]/i) {
608 return 1;
611 return 0;
614 sub read_testlist($)
616 my ($filename) = @_;
618 my @ret = ();
619 open(IN, $filename) or die("Unable to open $filename: $!");
621 while (<IN>) {
622 if ($_ eq "-- TEST --\n") {
623 my $name = <IN>;
624 $name =~ s/\n//g;
625 my $env = <IN>;
626 $env =~ s/\n//g;
627 my $cmdline = <IN>;
628 $cmdline =~ s/\n//g;
629 if (should_run_test($name) == 1) {
630 $required_envs{$env} = 1;
631 push (@ret, [$name, $env, $cmdline]);
633 } else {
634 print;
637 close(IN) or die("Error creating recipe");
638 return @ret;
641 if ($#testlists == -1) {
642 die("No testlists specified");
645 $ENV{SELFTEST_PREFIX} = "$prefix_abs";
646 if ($opt_socket_wrapper) {
647 $ENV{SELFTEST_INTERFACES} = $interfaces;
648 } else {
649 $ENV{SELFTEST_INTERFACES} = "";
651 if ($opt_verbose) {
652 $ENV{SELFTEST_VERBOSE} = "1";
653 } else {
654 $ENV{SELFTEST_VERBOSE} = "";
656 if ($opt_quick) {
657 $ENV{SELFTEST_QUICK} = "1";
658 } else {
659 $ENV{SELFTEST_QUICK} = "";
661 $ENV{SELFTEST_TARGET} = $opt_target;
662 $ENV{SELFTEST_MAXTIME} = $torture_maxtime;
664 my @available = ();
665 foreach my $fn (@testlists) {
666 foreach (read_testlist($fn)) {
667 my $name = $$_[0];
668 next if (@includes and not defined(find_in_list(\@includes, $name)));
669 push (@available, $_);
673 Subunit::testsuite_count($#available+1);
674 Subunit::report_time(time());
676 foreach (@available) {
677 my $name = $$_[0];
678 my $skipreason = skip($name);
679 if (defined($skipreason)) {
680 Subunit::skip_testsuite($name, $skipreason);
681 } else {
682 push(@todo, $_);
686 if ($#todo == -1) {
687 print STDERR "No tests to run\n";
688 exit(1);
691 my $suitestotal = $#todo + 1;
692 my $i = 0;
693 $| = 1;
695 my %running_envs = ();
697 sub get_running_env($)
699 my ($name) = @_;
701 my $envname = $name;
703 $envname =~ s/:.*//;
705 return $running_envs{$envname};
708 my @exported_envvars = (
709 # domain stuff
710 "DOMAIN",
711 "REALM",
713 # domain controller stuff
714 "DC_SERVER",
715 "DC_SERVER_IP",
716 "DC_NETBIOSNAME",
717 "DC_NETBIOSALIAS",
719 # server stuff
720 "SERVER",
721 "SERVER_IP",
722 "NETBIOSNAME",
723 "NETBIOSALIAS",
725 # user stuff
726 "USERNAME",
727 "PASSWORD",
728 "DC_USERNAME",
729 "DC_PASSWORD",
731 # misc stuff
732 "KRB5_CONFIG",
733 "WINBINDD_SOCKET_DIR",
734 "WINBINDD_PRIV_PIPE_DIR"
737 $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
738 my $signame = shift;
739 teardown_env($_) foreach(keys %running_envs);
740 die("Received signal $signame");
743 sub setup_env($)
745 my ($name) = @_;
747 my $testenv_vars = undef;
749 my $envname = $name;
750 my $option = $name;
752 $envname =~ s/:.*//;
753 $option =~ s/^[^:]*//;
754 $option =~ s/^://;
756 $option = "client" if $option eq "";
758 if ($envname eq "none") {
759 $testenv_vars = {};
760 } elsif (defined(get_running_env($envname))) {
761 $testenv_vars = get_running_env($envname);
762 if (not $target->check_env($testenv_vars)) {
763 $testenv_vars = undef;
765 } else {
766 $testenv_vars = $target->setup_env($envname, $prefix);
769 return undef unless defined($testenv_vars);
771 $running_envs{$envname} = $testenv_vars;
773 if ($option eq "local") {
774 SocketWrapper::set_default_iface($testenv_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
775 $ENV{SMB_CONF_PATH} = $testenv_vars->{SERVERCONFFILE};
776 } elsif ($option eq "client") {
777 SocketWrapper::set_default_iface(6);
778 write_clientconf($conffile, $testenv_vars);
779 $ENV{SMB_CONF_PATH} = $conffile;
780 } else {
781 die("Unknown option[$option] for envname[$envname]");
784 foreach (@exported_envvars) {
785 if (defined($testenv_vars->{$_})) {
786 $ENV{$_} = $testenv_vars->{$_};
787 } else {
788 delete $ENV{$_};
792 return $testenv_vars;
795 sub exported_envvars_str($)
797 my ($testenv_vars) = @_;
798 my $out = "";
800 foreach (@exported_envvars) {
801 next unless defined($testenv_vars->{$_});
802 $out .= $_."=".$testenv_vars->{$_}."\n";
805 return $out;
808 sub getlog_env($)
810 my ($envname) = @_;
811 return "" if ($envname eq "none");
812 return $target->getlog_env(get_running_env($envname));
815 sub check_env($)
817 my ($envname) = @_;
818 return 1 if ($envname eq "none");
819 return $target->check_env(get_running_env($envname));
822 sub teardown_env($)
824 my ($envname) = @_;
825 return if ($envname eq "none");
826 $target->teardown_env(get_running_env($envname));
827 delete $running_envs{$envname};
830 if ($opt_no_lazy_setup) {
831 setup_env($_) foreach (keys %required_envs);
834 if ($opt_testenv) {
835 my $testenv_name = $ENV{SELFTEST_TESTENV};
836 $testenv_name = $testenv_default unless defined($testenv_name);
838 my $testenv_vars = setup_env($testenv_name);
840 $ENV{PIDDIR} = $testenv_vars->{PIDDIR};
842 my $envvarstr = exported_envvars_str($testenv_vars);
844 my $term = ($ENV{TERMINAL} or "xterm");
845 system("$term -e 'echo -e \"
846 Welcome to the Samba4 Test environment '$testenv_name'
848 This matches the client environment used in make test
849 server is pid `cat \$PIDDIR/samba.pid`
851 Some useful environment variables:
852 TORTURE_OPTIONS=\$TORTURE_OPTIONS
853 SMB_CONF_PATH=\$SMB_CONF_PATH
855 $envvarstr
856 \" && LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH} bash'");
857 teardown_env($testenv_name);
858 } else {
859 foreach (@todo) {
860 $i++;
861 my $cmd = $$_[2];
862 $cmd =~ s/([\(\)])/\\$1/g;
863 my $name = $$_[0];
864 my $envname = $$_[1];
866 my $envvars = setup_env($envname);
867 if (not defined($envvars)) {
868 Subunit::skip_testsuite($name,
869 "unable to set up environment $envname");
870 next;
873 run_testsuite($envname, $name, $cmd, $i, $suitestotal);
875 if (defined($opt_analyse_cmd)) {
876 system("$opt_analyse_cmd \"$name\"");
879 teardown_env($envname) if ($opt_resetup_env);
883 print "\n";
885 teardown_env($_) foreach (keys %running_envs);
887 $target->stop();
889 my $failed = 0;
891 # if there were any valgrind failures, show them
892 foreach (<$prefix/valgrind.log*>) {
893 next unless (-s $_);
894 print "VALGRIND FAILURE\n";
895 $failed++;
896 system("cat $_");
898 exit 0;