Cosmetic corrections for the KERBEROS library
[Samba/fernandojvsilva.git] / source4 / selftest / selftest.pl
blob92aa67e8d3e2f74a68c6a1ab3b05a59f769fedb7
1 #!/usr/bin/perl
2 # Bootstrap Samba and run a number of tests against it.
3 # Copyright (C) 2005-2008 Jelmer Vernooij <jelmer@samba.org>
4 # Published under the GNU GPL, v3 or later.
6 =pod
8 =head1 NAME
10 selftest - Samba test runner
12 =head1 SYNOPSIS
14 selftest --help
16 selftest [--srcdir=DIR] [--builddir=DIR] [--target=samba4|samba3|win|kvm] [--socket-wrapper] [--quick] [--exclude=FILE] [--include=FILE] [--one] [--prefix=prefix] [--immediate] [--testlist=FILE] [TESTS]
18 =head1 DESCRIPTION
20 A simple test runner. TESTS is a regular expression with tests to run.
22 =head1 OPTIONS
24 =over 4
26 =item I<--help>
28 Show list of available options.
30 =item I<--srcdir=DIR>
32 Source directory.
34 =item I<--builddir=DIR>
36 Build directory.
38 =item I<--prefix=DIR>
40 Change directory to run tests in. Default is 'st'.
42 =item I<--immediate>
44 Show errors as soon as they happen rather than at the end of the test run.
46 =item I<--target samba4|samba3|win|kvm>
48 Specify test target against which to run. Default is 'samba4'.
50 =item I<--quick>
52 Run only a limited number of tests. Intended to run in about 30 seconds on
53 moderately recent systems.
55 =item I<--socket-wrapper>
57 Use socket wrapper library for communication with server. Only works
58 when the server is running locally.
60 Will prevent TCP and UDP ports being opened on the local host but
61 (transparently) redirects these calls to use unix domain sockets.
63 =item I<--expected-failures>
65 Specify a file containing a list of tests that are expected to fail. Failures for
66 these tests will be counted as successes, successes will be counted as failures.
68 The format for the file is, one entry per line:
70 TESTSUITE-NAME.TEST-NAME
72 The reason for a test can also be specified, by adding a hash sign (#) and the reason
73 after the test name.
75 =item I<--exclude>
77 Specify a file containing a list of tests that should be skipped. Possible
78 candidates are tests that segfault the server, flip or don't end. The format of this file is the same as
79 for the --expected-failures flag.
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 SocketWrapper;
135 my $opt_help = 0;
136 my $opt_target = "samba4";
137 my $opt_quick = 0;
138 my $opt_socket_wrapper = 0;
139 my $opt_socket_wrapper_pcap = undef;
140 my $opt_socket_wrapper_keep_pcap = undef;
141 my $opt_one = 0;
142 my $opt_immediate = 0;
143 my $opt_expected_failures = undef;
144 my @opt_exclude = ();
145 my @opt_include = ();
146 my $opt_verbose = 0;
147 my $opt_image = undef;
148 my $opt_testenv = 0;
149 my $ldap = undef;
150 my $opt_analyse_cmd = undef;
151 my $opt_resetup_env = undef;
152 my $opt_bindir = undef;
153 my $opt_no_lazy_setup = undef;
154 my $opt_format = "plain";
155 my @testlists = ();
157 my $srcdir = ".";
158 my $builddir = ".";
159 my $prefix = "./st";
161 my @expected_failures = ();
162 my @includes = ();
163 my @excludes = ();
165 my $statistics = {
166 SUITES_FAIL => 0,
168 TESTS_UNEXPECTED_OK => 0,
169 TESTS_EXPECTED_OK => 0,
170 TESTS_UNEXPECTED_FAIL => 0,
171 TESTS_EXPECTED_FAIL => 0,
172 TESTS_ERROR => 0,
173 TESTS_SKIP => 0,
176 sub find_in_list($$)
178 my ($list, $fullname) = @_;
180 foreach (@$list) {
181 if ($fullname =~ /$$_[0]/) {
182 return ($$_[1]) if ($$_[1]);
183 return "NO REASON SPECIFIED";
187 return undef;
190 sub expecting_failure($)
192 my ($name) = @_;
193 return find_in_list(\@expected_failures, $name);
196 sub skip($)
198 my ($name) = @_;
200 return find_in_list(\@excludes, $name);
203 sub getlog_env($);
205 sub setup_pcap($)
207 my ($name) = @_;
209 return unless ($opt_socket_wrapper_pcap);
210 return unless defined($ENV{SOCKET_WRAPPER_PCAP_DIR});
212 my $fname = $name;
213 $fname =~ s%[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\-]%_%g;
215 my $pcap_file = "$ENV{SOCKET_WRAPPER_PCAP_DIR}/$fname.pcap";
217 SocketWrapper::setup_pcap($pcap_file);
219 return $pcap_file;
222 sub cleanup_pcap($$$)
224 my ($pcap_file, $expected_ret, $ret) = @_;
226 return unless ($opt_socket_wrapper_pcap);
227 return if ($opt_socket_wrapper_keep_pcap);
228 return unless ($expected_ret == $ret);
229 return unless defined($pcap_file);
231 unlink($pcap_file);
234 sub run_testsuite($$$$$$)
236 my ($envname, $name, $cmd, $i, $totalsuites, $msg_ops) = @_;
237 my $pcap_file = setup_pcap($name);
239 $msg_ops->start_test([], $name);
241 unless (open(RESULT, "$cmd 2>&1|")) {
242 $statistics->{TESTS_ERROR}++;
243 $msg_ops->end_test([], $name, "error", 1, "Unable to run $cmd: $!");
244 $statistics->{SUITES_FAIL}++;
245 return 0;
248 my $expected_ret = parse_results(
249 $msg_ops, $statistics, *RESULT, \&expecting_failure, [$name]);
251 my $envlog = getlog_env($envname);
252 $msg_ops->output_msg("ENVLOG: $envlog\n") if ($envlog ne "");
254 $msg_ops->output_msg("CMD: $cmd\n");
256 my $ret = close(RESULT);
257 $ret = 0 unless $ret == 1;
259 my $exitcode = $? >> 8;
261 if ($ret == 1) {
262 $msg_ops->end_test([], $name, "success", $expected_ret != $ret, undef);
263 } else {
264 $msg_ops->end_test([], $name, "failure", $expected_ret != $ret, "Exit code was $exitcode");
267 cleanup_pcap($pcap_file, $expected_ret, $ret);
269 if (not $opt_socket_wrapper_keep_pcap and defined($pcap_file)) {
270 $msg_ops->output_msg("PCAP FILE: $pcap_file\n");
273 if ($ret != $expected_ret) {
274 $statistics->{SUITES_FAIL}++;
275 exit(1) if ($opt_one);
278 return ($ret == $expected_ret);
281 sub ShowHelp()
283 print "Samba test runner
284 Copyright (C) Jelmer Vernooij <jelmer\@samba.org>
286 Usage: $Script [OPTIONS] PREFIX
288 Generic options:
289 --help this help page
290 --target=samba[34]|win|kvm Samba version to target
291 --testlist=FILE file to read available tests from
293 Paths:
294 --prefix=DIR prefix to run tests in [st]
295 --srcdir=DIR source directory [.]
296 --builddir=DIR output directory [.]
298 Target Specific:
299 --socket-wrapper-pcap save traffic to pcap directories
300 --socket-wrapper-keep-pcap keep all pcap files, not just those for tests that
301 failed
302 --socket-wrapper enable socket wrapper
303 --expected-failures=FILE specify list of tests that is guaranteed to fail
305 Samba4 Specific:
306 --ldap=openldap|fedora-ds back samba onto specified ldap server
308 Samba3 Specific:
309 --bindir=PATH path to binaries
311 Kvm Specific:
312 --image=PATH path to KVM image
314 Behaviour:
315 --quick run quick overall test
316 --one abort when the first test fails
317 --immediate print test output for failed tests during run
318 --verbose be verbose
319 --analyse-cmd CMD command to run after each test
321 exit(0);
324 my $result = GetOptions (
325 'help|h|?' => \$opt_help,
326 'target=s' => \$opt_target,
327 'prefix=s' => \$prefix,
328 'socket-wrapper' => \$opt_socket_wrapper,
329 'socket-wrapper-pcap' => \$opt_socket_wrapper_pcap,
330 'socket-wrapper-keep-pcap' => \$opt_socket_wrapper_keep_pcap,
331 'quick' => \$opt_quick,
332 'one' => \$opt_one,
333 'immediate' => \$opt_immediate,
334 'expected-failures=s' => \$opt_expected_failures,
335 'exclude=s' => \@opt_exclude,
336 'include=s' => \@opt_include,
337 'srcdir=s' => \$srcdir,
338 'builddir=s' => \$builddir,
339 'verbose' => \$opt_verbose,
340 'testenv' => \$opt_testenv,
341 'ldap:s' => \$ldap,
342 'analyse-cmd=s' => \$opt_analyse_cmd,
343 'no-lazy-setup' => \$opt_no_lazy_setup,
344 'resetup-environment' => \$opt_resetup_env,
345 'bindir:s' => \$opt_bindir,
346 'format=s' => \$opt_format,
347 'image=s' => \$opt_image,
348 'testlist=s' => \@testlists
351 exit(1) if (not $result);
353 ShowHelp() if ($opt_help);
355 my $tests = shift;
357 # quick hack to disable rpc validation when using valgrind - its way too slow
358 unless (defined($ENV{VALGRIND})) {
359 $ENV{VALIDATE} = "validate";
360 $ENV{MALLOC_CHECK_} = 2;
363 my $old_pwd = "$RealBin/..";
365 # Backwards compatibility:
366 if (defined($ENV{TEST_LDAP}) and $ENV{TEST_LDAP} eq "yes") {
367 if (defined($ENV{FEDORA_DS_ROOT})) {
368 $ldap = "fedora-ds";
369 } else {
370 $ldap = "openldap";
374 my $torture_maxtime = ($ENV{TORTURE_MAXTIME} or 1200);
375 if ($ldap) {
376 # LDAP is slow
377 $torture_maxtime *= 2;
380 $prefix =~ s+//+/+;
381 $prefix =~ s+/./+/+;
382 $prefix =~ s+/$++;
384 die("using an empty prefix isn't allowed") unless $prefix ne "";
386 #Ensure we have the test prefix around
387 mkdir($prefix, 0777) unless -d $prefix;
389 my $prefix_abs = abs_path($prefix);
390 my $srcdir_abs = abs_path($srcdir);
392 die("using an empty absolute prefix isn't allowed") unless $prefix_abs ne "";
393 die("using '/' as absolute prefix isn't allowed") unless $prefix_abs ne "/";
395 $ENV{PREFIX} = $prefix;
396 $ENV{KRB5CCNAME} = "$prefix/krb5ticket";
397 $ENV{PREFIX_ABS} = $prefix_abs;
398 $ENV{SRCDIR} = $srcdir;
399 $ENV{SRCDIR_ABS} = $srcdir_abs;
401 if (defined($ENV{RUN_FROM_BUILD_FARM}) and
402 ($ENV{RUN_FROM_BUILD_FARM} eq "yes")) {
403 $opt_format = "buildfarm";
406 my $tls_enabled = not $opt_quick;
407 $ENV{TLS_ENABLED} = ($tls_enabled?"yes":"no");
408 $ENV{LDB_MODULES_PATH} = "$old_pwd/bin/modules/ldb";
409 $ENV{LD_SAMBA_MODULE_PATH} = "$old_pwd/bin/modules";
410 sub prefix_pathvar($$)
412 my ($name, $newpath) = @_;
413 if (defined($ENV{$name})) {
414 $ENV{$name} = "$newpath:$ENV{$name}";
415 } else {
416 $ENV{$name} = $newpath;
419 prefix_pathvar("PKG_CONFIG_PATH", "$old_pwd/bin/pkgconfig");
420 prefix_pathvar("PYTHONPATH", "$old_pwd/bin/python");
422 if ($opt_socket_wrapper_keep_pcap) {
423 # Socket wrapper keep pcap implies socket wrapper pcap
424 $opt_socket_wrapper_pcap = 1;
427 if ($opt_socket_wrapper_pcap) {
428 # Socket wrapper pcap implies socket wrapper
429 $opt_socket_wrapper = 1;
432 my $socket_wrapper_dir;
433 if ($opt_socket_wrapper) {
434 $socket_wrapper_dir = SocketWrapper::setup_dir("$prefix/w", $opt_socket_wrapper_pcap);
435 print "SOCKET_WRAPPER_DIR=$socket_wrapper_dir\n";
436 } else {
437 warn("Not using socket wrapper, but also not running as root. Will not be able to listen on proper ports") unless $< == 0;
440 my $target;
441 my $testenv_default = "none";
443 if ($opt_target eq "samba4") {
444 $testenv_default = "member";
445 require target::Samba4;
446 $target = new Samba4($opt_bindir or "$srcdir/bin", $ldap, "$srcdir/setup");
447 } elsif ($opt_target eq "samba3") {
448 if ($opt_socket_wrapper and `$opt_bindir/smbd -b | grep SOCKET_WRAPPER` eq "") {
449 die("You must include --enable-socket-wrapper when compiling Samba in order to execute 'make test'. Exiting....");
451 $testenv_default = "dc";
452 require target::Samba3;
453 $target = new Samba3($opt_bindir);
454 } elsif ($opt_target eq "win") {
455 die("Windows tests will not run with socket wrapper enabled.")
456 if ($opt_socket_wrapper);
457 $testenv_default = "dc";
458 require target::Windows;
459 $target = new Windows();
460 } elsif ($opt_target eq "kvm") {
461 die("Kvm tests will not run with socket wrapper enabled.")
462 if ($opt_socket_wrapper);
463 require target::Kvm;
464 die("No image specified") unless ($opt_image);
465 $target = new Kvm($opt_image, undef);
469 # Start a Virtual Distributed Ethernet Switch
470 # Returns the pid of the switch.
472 sub start_vde_switch($)
474 my ($path) = @_;
476 system("vde_switch --pidfile $path/vde.pid --sock $path/vde.sock --daemon");
478 open(PID, "$path/vde.pid");
479 <PID> =~ /([0-9]+)/;
480 my $pid = $1;
481 close(PID);
483 return $pid;
486 # Stop a Virtual Distributed Ethernet Switch
487 sub stop_vde_switch($)
489 my ($pid) = @_;
490 kill 9, $pid;
493 sub read_test_regexes($)
495 my ($name) = @_;
496 my @ret = ();
497 open(LF, "<$name") or die("unable to read $name: $!");
498 while (<LF>) {
499 chomp;
500 next if (/^#/);
501 if (/^(.*?)([ \t]+)\#([\t ]*)(.*?)$/) {
502 push (@ret, [$1, $4]);
503 } else {
504 s/^(.*?)([ \t]+)\#([\t ]*)(.*?)$//;
505 push (@ret, [$_, undef]);
508 close(LF);
509 return @ret;
512 if (defined($opt_expected_failures)) {
513 @expected_failures = read_test_regexes($opt_expected_failures);
516 foreach (@opt_exclude) {
517 push (@excludes, read_test_regexes($_));
520 if ($opt_quick) {
521 push (@includes, read_test_regexes("samba4-quick"));
524 foreach (@opt_include) {
525 push (@includes, read_test_regexes($_));
528 my $interfaces = join(',', ("127.0.0.6/8",
529 "127.0.0.7/8",
530 "127.0.0.8/8",
531 "127.0.0.9/8",
532 "127.0.0.10/8",
533 "127.0.0.11/8"));
535 my $conffile = "$prefix_abs/client/client.conf";
537 sub write_clientconf($$)
539 my ($conffile, $vars) = @_;
541 mkdir("$prefix/client", 0777) unless -d "$prefix/client";
543 if ( -d "$prefix/client/private" ) {
544 unlink <$prefix/client/private/*>;
545 } else {
546 mkdir("$prefix/client/private", 0777);
549 open(CF, ">$conffile");
550 print CF "[global]\n";
551 if (defined($ENV{VALGRIND})) {
552 print CF "\ticonv:native = true\n";
553 } else {
554 print CF "\ticonv:native = false\n";
556 print CF "\tnetbios name = client\n";
557 if (defined($vars->{DOMAIN})) {
558 print CF "\tworkgroup = $vars->{DOMAIN}\n";
560 if (defined($vars->{REALM})) {
561 print CF "\trealm = $vars->{REALM}\n";
563 if (defined($vars->{NCALRPCDIR})) {
564 print CF "\tncalrpc dir = $vars->{NCALRPCDIR}\n";
566 if (defined($vars->{PIDDIR})) {
567 print CF "\tpid directory = $vars->{PIDDIR}\n";
569 if (defined($vars->{WINBINDD_SOCKET_DIR})) {
570 print CF "\twinbindd socket directory = $vars->{WINBINDD_SOCKET_DIR}\n";
572 if ($opt_socket_wrapper) {
573 print CF "\tinterfaces = $interfaces\n";
575 print CF "
576 private dir = $prefix_abs/client/private
577 name resolve order = bcast
578 panic action = $srcdir_abs/script/gdb_backtrace \%PID\% \%PROG\%
579 max xmit = 32K
580 notify:inotify = false
581 ldb:nosync = true
582 system:anonymous = true
583 torture:basedir = $prefix_abs/client
584 #We don't want to pass our self-tests if the PAC code is wrong
585 gensec:require_pac = true
586 modules dir = $ENV{LD_SAMBA_MODULE_PATH}
588 close(CF);
591 my @torture_options = ();
592 push (@torture_options, "--configfile=$conffile");
593 # ensure any one smbtorture call doesn't run too long
594 push (@torture_options, "--maximum-runtime=$torture_maxtime");
595 push (@torture_options, "--target=$opt_target");
596 push (@torture_options, "--basedir=$prefix_abs");
597 push (@torture_options, "--option=torture:progress=no") unless ($opt_verbose);
598 push (@torture_options, "--format=subunit");
599 push (@torture_options, "--option=torture:quick=yes") if ($opt_quick);
601 $ENV{TORTURE_OPTIONS} = join(' ', @torture_options);
602 print "OPTIONS $ENV{TORTURE_OPTIONS}\n";
604 my @todo = ();
606 my $testsdir = "$srcdir/selftest";
607 $ENV{SMB_CONF_PATH} = "$conffile";
608 $ENV{CONFIGURATION} = "--configfile=$conffile";
610 my %required_envs = ();
612 sub read_testlist($)
614 my ($filename) = @_;
616 my @ret = ();
617 open(IN, $filename) or die("Unable to open $filename: $!");
619 while (<IN>) {
620 if ($_ eq "-- TEST --\n") {
621 my $name = <IN>;
622 $name =~ s/\n//g;
623 my $env = <IN>;
624 $env =~ s/\n//g;
625 my $cmdline = <IN>;
626 $cmdline =~ s/\n//g;
627 if (not defined($tests) or $name =~ /$tests/) {
628 $required_envs{$env} = 1;
629 push (@ret, [$name, $env, $cmdline]);
631 } else {
632 print;
635 close(IN) or die("Error creating recipe");
636 return @ret;
639 if ($#testlists == -1) {
640 die("No testlists specified");
643 my @available = ();
644 foreach my $fn (@testlists) {
645 foreach (read_testlist($fn)) {
646 my $name = $$_[0];
647 next if (@includes and not find_in_list(\@includes, $name));
648 push (@available, $_);
652 my $msg_ops;
653 if ($opt_format eq "buildfarm") {
654 require output::buildfarm;
655 $msg_ops = new output::buildfarm($statistics);
656 } elsif ($opt_format eq "plain") {
657 require output::plain;
658 $msg_ops = new output::plain("$prefix/summary", $opt_verbose, $opt_immediate, $statistics, $#available+1);
659 } elsif ($opt_format eq "html") {
660 require output::html;
661 mkdir("test-results", 0777);
662 $msg_ops = new output::html("test-results", $statistics);
663 } else {
664 die("Invalid output format '$opt_format'");
668 foreach (@available) {
669 my $name = $$_[0];
670 my $skipreason = skip($name);
671 if ($skipreason) {
672 $msg_ops->skip_testsuite($name, $skipreason);
673 } else {
674 push(@todo, $_);
678 if ($#todo == -1) {
679 print STDERR "No tests to run\n";
680 exit(1);
683 my $suitestotal = $#todo + 1;
684 my $i = 0;
685 $| = 1;
687 my %running_envs = ();
689 my @exported_envvars = (
690 # domain stuff
691 "DOMAIN",
692 "REALM",
694 # domain controller stuff
695 "DC_SERVER",
696 "DC_SERVER_IP",
697 "DC_NETBIOSNAME",
698 "DC_NETBIOSALIAS",
700 # server stuff
701 "SERVER",
702 "SERVER_IP",
703 "NETBIOSNAME",
704 "NETBIOSALIAS",
706 # user stuff
707 "USERNAME",
708 "PASSWORD",
709 "DC_USERNAME",
710 "DC_PASSWORD",
712 # misc stuff
713 "KRB5_CONFIG",
714 "WINBINDD_SOCKET_DIR",
715 "WINBINDD_PRIV_PIPE_DIR"
718 $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
719 my $signame = shift;
720 teardown_env($_) foreach(keys %running_envs);
721 die("Received signal $signame");
724 sub setup_env($)
726 my ($envname) = @_;
728 my $testenv_vars;
729 if ($envname eq "none") {
730 $testenv_vars = {};
731 } elsif (defined($running_envs{$envname})) {
732 $testenv_vars = $running_envs{$envname};
733 if (not $target->check_env($testenv_vars)) {
734 $testenv_vars = undef;
736 } else {
737 $testenv_vars = $target->setup_env($envname, $prefix);
740 return undef unless defined($testenv_vars);
742 $running_envs{$envname} = $testenv_vars;
744 SocketWrapper::set_default_iface(6);
745 write_clientconf($conffile, $testenv_vars);
747 foreach (@exported_envvars) {
748 if (defined($testenv_vars->{$_})) {
749 $ENV{$_} = $testenv_vars->{$_};
750 } else {
751 delete $ENV{$_};
755 return $testenv_vars;
758 sub exported_envvars_str($)
760 my ($testenv_vars) = @_;
761 my $out = "";
763 foreach (@exported_envvars) {
764 next unless defined($testenv_vars->{$_});
765 $out .= $_."=".$testenv_vars->{$_}."\n";
768 return $out;
771 sub getlog_env($)
773 my ($envname) = @_;
774 return "" if ($envname eq "none");
775 return $target->getlog_env($running_envs{$envname});
778 sub check_env($)
780 my ($envname) = @_;
781 return 1 if ($envname eq "none");
782 return $target->check_env($running_envs{$envname});
785 sub teardown_env($)
787 my ($envname) = @_;
788 return if ($envname eq "none");
789 $target->teardown_env($running_envs{$envname});
790 delete $running_envs{$envname};
793 if ($opt_no_lazy_setup) {
794 setup_env($_) foreach (keys %required_envs);
797 if ($opt_testenv) {
798 my $testenv_name = $ENV{SELFTEST_TESTENV};
799 $testenv_name = $testenv_default unless defined($testenv_name);
801 my $testenv_vars = setup_env($testenv_name);
803 $ENV{PIDDIR} = $testenv_vars->{PIDDIR};
805 my $envvarstr = exported_envvars_str($testenv_vars);
807 my $term = ($ENV{TERM} or "xterm");
808 system("$term -e 'echo -e \"
809 Welcome to the Samba4 Test environment '$testenv_name'
811 This matches the client environment used in make test
812 server is pid `cat \$PIDDIR/samba.pid`
814 Some useful environment variables:
815 TORTURE_OPTIONS=\$TORTURE_OPTIONS
816 CONFIGURATION=\$CONFIGURATION
818 $envvarstr
819 \" && LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH} bash'");
820 teardown_env($testenv_name);
821 } else {
822 foreach (@todo) {
823 $i++;
824 my $cmd = $$_[2];
825 $cmd =~ s/([\(\)])/\\$1/g;
826 my $name = $$_[0];
827 my $envname = $$_[1];
829 my $envvars = setup_env($envname);
830 if (not defined($envvars)) {
831 $msg_ops->skip_testsuite($name, "unable to set up environment $envname");
832 next;
835 run_testsuite($envname, $name, $cmd, $i, $suitestotal,
836 $msg_ops);
838 if (defined($opt_analyse_cmd)) {
839 system("$opt_analyse_cmd \"$name\"");
842 teardown_env($envname) if ($opt_resetup_env);
846 print "\n";
848 teardown_env($_) foreach (keys %running_envs);
850 $target->stop();
852 $msg_ops->summary();
854 my $failed = 0;
856 # if there were any valgrind failures, show them
857 foreach (<$prefix/valgrind.log*>) {
858 next unless (-s $_);
859 system("grep DWARF2.CFI.reader $_ > /dev/null");
860 if ($? >> 8 == 0) {
861 print "VALGRIND FAILURE\n";
862 $failed++;
863 system("cat $_");
867 if ($opt_format eq "buildfarm") {
868 print "TEST STATUS: $statistics->{SUITES_FAIL}\n";
871 exit $statistics->{SUITES_FAIL};