tdb: fix locking error
[Samba/aatanasov.git] / selftest / selftest.pl
blobe0ea91d0f224058273afeb9cf7ea0bd6ce947d3d
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 my $tests = shift;
353 # quick hack to disable rpc validation when using valgrind - its way too slow
354 unless (defined($ENV{VALGRIND})) {
355 $ENV{VALIDATE} = "validate";
356 $ENV{MALLOC_CHECK_} = 2;
359 my $bindir = ($opt_bindir or "$builddir/bin");
360 my $bindir_abs = abs_path($bindir);
362 # Backwards compatibility:
363 if (defined($ENV{TEST_LDAP}) and $ENV{TEST_LDAP} eq "yes") {
364 if (defined($ENV{FEDORA_DS_ROOT})) {
365 $ldap = "fedora-ds";
366 } else {
367 $ldap = "openldap";
371 my $torture_maxtime = ($ENV{TORTURE_MAXTIME} or 1200);
372 if ($ldap) {
373 # LDAP is slow
374 $torture_maxtime *= 2;
377 $prefix =~ s+//+/+;
378 $prefix =~ s+/./+/+;
379 $prefix =~ s+/$++;
381 die("using an empty prefix isn't allowed") unless $prefix ne "";
383 #Ensure we have the test prefix around
384 mkdir($prefix, 0777) unless -d $prefix;
386 my $prefix_abs = abs_path($prefix);
387 my $srcdir_abs = abs_path($srcdir);
388 my $builddir_abs = abs_path($builddir);
390 die("using an empty absolute prefix isn't allowed") unless $prefix_abs ne "";
391 die("using '/' as absolute prefix isn't allowed") unless $prefix_abs ne "/";
393 $ENV{PREFIX} = $prefix;
394 $ENV{KRB5CCNAME} = "$prefix/krb5ticket";
395 $ENV{PREFIX_ABS} = $prefix_abs;
396 $ENV{SRCDIR} = $srcdir;
397 $ENV{SRCDIR_ABS} = $srcdir_abs;
398 $ENV{BUILDDIR} = $builddir;
399 $ENV{BUILDDIR_ABS} = $builddir_abs;
400 $ENV{EXEEXT} = $exeext;
402 my $tls_enabled = not $opt_quick;
403 $ENV{TLS_ENABLED} = ($tls_enabled?"yes":"no");
404 $ENV{LDB_MODULES_PATH} = "$bindir_abs/modules/ldb";
405 $ENV{LD_SAMBA_MODULE_PATH} = "$bindir_abs/modules";
406 sub prefix_pathvar($$)
408 my ($name, $newpath) = @_;
409 if (defined($ENV{$name})) {
410 $ENV{$name} = "$newpath:$ENV{$name}";
411 } else {
412 $ENV{$name} = $newpath;
415 prefix_pathvar("PKG_CONFIG_PATH", "$bindir_abs/pkgconfig");
416 prefix_pathvar("PYTHONPATH", "$bindir_abs/python");
418 if ($opt_socket_wrapper_keep_pcap) {
419 # Socket wrapper keep pcap implies socket wrapper pcap
420 $opt_socket_wrapper_pcap = 1;
423 if ($opt_socket_wrapper_pcap) {
424 # Socket wrapper pcap implies socket wrapper
425 $opt_socket_wrapper = 1;
428 my $socket_wrapper_dir;
429 if ($opt_socket_wrapper) {
430 $socket_wrapper_dir = SocketWrapper::setup_dir("$prefix/w", $opt_socket_wrapper_pcap);
431 print "SOCKET_WRAPPER_DIR=$socket_wrapper_dir\n";
432 } else {
433 unless ($< == 0) {
434 print "WARNING: Not using socket wrapper, but also not running as root. Will not be able to listen on proper ports\n";
438 my $target;
439 my $testenv_default = "none";
441 if ($opt_target eq "samba4") {
442 $testenv_default = "member";
443 require target::Samba4;
444 $target = new Samba4($bindir, $ldap, "$srcdir/setup", $exeext);
445 } elsif ($opt_target eq "samba3") {
446 if ($opt_socket_wrapper and `$bindir/smbd -b | grep SOCKET_WRAPPER` eq "") {
447 die("You must include --enable-socket-wrapper when compiling Samba in order to execute 'make test'. Exiting....");
449 $testenv_default = "member";
450 require target::Samba3;
451 $target = new Samba3($bindir);
452 } elsif ($opt_target eq "win") {
453 die("Windows tests will not run with socket wrapper enabled.")
454 if ($opt_socket_wrapper);
455 $testenv_default = "dc";
456 require target::Windows;
457 $target = new Windows();
458 } elsif ($opt_target eq "kvm") {
459 die("Kvm tests will not run with socket wrapper enabled.")
460 if ($opt_socket_wrapper);
461 require target::Kvm;
462 die("No image specified") unless ($opt_image);
463 $target = new Kvm($opt_image, undef);
467 # Start a Virtual Distributed Ethernet Switch
468 # Returns the pid of the switch.
470 sub start_vde_switch($)
472 my ($path) = @_;
474 system("vde_switch --pidfile $path/vde.pid --sock $path/vde.sock --daemon");
476 open(PID, "$path/vde.pid");
477 <PID> =~ /([0-9]+)/;
478 my $pid = $1;
479 close(PID);
481 return $pid;
484 # Stop a Virtual Distributed Ethernet Switch
485 sub stop_vde_switch($)
487 my ($pid) = @_;
488 kill 9, $pid;
491 sub read_test_regexes($)
493 my ($name) = @_;
494 my @ret = ();
495 open(LF, "<$name") or die("unable to read $name: $!");
496 while (<LF>) {
497 chomp;
498 next if (/^#/);
499 if (/^(.*?)([ \t]+)\#([\t ]*)(.*?)$/) {
500 push (@ret, [$1, $4]);
501 } else {
502 s/^(.*?)([ \t]+)\#([\t ]*)(.*?)$//;
503 push (@ret, [$_, undef]);
506 close(LF);
507 return @ret;
510 foreach (@opt_exclude) {
511 push (@excludes, read_test_regexes($_));
514 foreach (@opt_include) {
515 push (@includes, read_test_regexes($_));
518 my $interfaces = join(',', ("127.0.0.6/8",
519 "127.0.0.7/8",
520 "127.0.0.8/8",
521 "127.0.0.9/8",
522 "127.0.0.10/8",
523 "127.0.0.11/8"));
525 my $conffile = "$prefix_abs/client/client.conf";
526 $ENV{SMB_CONF_PATH} = $conffile;
528 sub write_clientconf($$)
530 my ($conffile, $vars) = @_;
532 mkdir("$prefix/client", 0777) unless -d "$prefix/client";
534 if ( -d "$prefix/client/private" ) {
535 unlink <$prefix/client/private/*>;
536 } else {
537 mkdir("$prefix/client/private", 0777);
540 if ( -d "$prefix/client/lock" ) {
541 unlink <$prefix/client/lockdir/*>;
542 } else {
543 mkdir("$prefix/client/lockdir", 0777);
546 open(CF, ">$conffile");
547 print CF "[global]\n";
548 if (defined($ENV{VALGRIND})) {
549 print CF "\ticonv:native = true\n";
550 } else {
551 print CF "\ticonv:native = false\n";
553 print CF "\tnetbios name = client\n";
554 if (defined($vars->{DOMAIN})) {
555 print CF "\tworkgroup = $vars->{DOMAIN}\n";
557 if (defined($vars->{REALM})) {
558 print CF "\trealm = $vars->{REALM}\n";
560 if ($opt_socket_wrapper) {
561 print CF "\tinterfaces = $interfaces\n";
563 print CF "
564 private dir = $prefix_abs/client/private
565 lock dir = $prefix_abs/client/lockdir
566 name resolve order = bcast
567 panic action = $RealBin/gdb_backtrace \%PID\% \%PROG\%
568 max xmit = 32K
569 notify:inotify = false
570 ldb:nosync = true
571 system:anonymous = true
572 client lanman auth = Yes
573 torture:basedir = $prefix_abs/client
574 #We don't want to pass our self-tests if the PAC code is wrong
575 gensec:require_pac = true
576 modules dir = $ENV{LD_SAMBA_MODULE_PATH}
578 close(CF);
581 my @todo = ();
583 my $testsdir = "$srcdir/selftest";
585 my %required_envs = ();
587 sub read_testlist($)
589 my ($filename) = @_;
591 my @ret = ();
592 open(IN, $filename) or die("Unable to open $filename: $!");
594 while (<IN>) {
595 if ($_ eq "-- TEST --\n") {
596 my $name = <IN>;
597 $name =~ s/\n//g;
598 my $env = <IN>;
599 $env =~ s/\n//g;
600 my $cmdline = <IN>;
601 $cmdline =~ s/\n//g;
602 if (not defined($tests) or $name =~ /$tests/) {
603 $required_envs{$env} = 1;
604 push (@ret, [$name, $env, $cmdline]);
606 } else {
607 print;
610 close(IN) or die("Error creating recipe");
611 return @ret;
614 if ($#testlists == -1) {
615 die("No testlists specified");
618 $ENV{SELFTEST_PREFIX} = "$prefix_abs";
619 if ($opt_socket_wrapper) {
620 $ENV{SELFTEST_INTERFACES} = $interfaces;
621 } else {
622 $ENV{SELFTEST_INTERFACES} = "";
624 if ($opt_verbose) {
625 $ENV{SELFTEST_VERBOSE} = "1";
626 } else {
627 $ENV{SELFTEST_VERBOSE} = "";
629 if ($opt_quick) {
630 $ENV{SELFTEST_QUICK} = "1";
631 } else {
632 $ENV{SELFTEST_QUICK} = "";
634 $ENV{SELFTEST_TARGET} = $opt_target;
635 $ENV{SELFTEST_MAXTIME} = $torture_maxtime;
637 my @available = ();
638 foreach my $fn (@testlists) {
639 foreach (read_testlist($fn)) {
640 my $name = $$_[0];
641 next if (@includes and not defined(find_in_list(\@includes, $name)));
642 push (@available, $_);
646 Subunit::testsuite_count($#available+1);
647 Subunit::report_time(time());
649 foreach (@available) {
650 my $name = $$_[0];
651 my $skipreason = skip($name);
652 if (defined($skipreason)) {
653 Subunit::skip_testsuite($name, $skipreason);
654 } else {
655 push(@todo, $_);
659 if ($#todo == -1) {
660 print STDERR "No tests to run\n";
661 exit(1);
664 my $suitestotal = $#todo + 1;
665 my $i = 0;
666 $| = 1;
668 my %running_envs = ();
670 sub get_running_env($)
672 my ($name) = @_;
674 my $envname = $name;
676 $envname =~ s/:.*//;
678 return $running_envs{$envname};
681 my @exported_envvars = (
682 # domain stuff
683 "DOMAIN",
684 "REALM",
686 # domain controller stuff
687 "DC_SERVER",
688 "DC_SERVER_IP",
689 "DC_NETBIOSNAME",
690 "DC_NETBIOSALIAS",
692 # server stuff
693 "SERVER",
694 "SERVER_IP",
695 "NETBIOSNAME",
696 "NETBIOSALIAS",
698 # user stuff
699 "USERNAME",
700 "PASSWORD",
701 "DC_USERNAME",
702 "DC_PASSWORD",
704 # misc stuff
705 "KRB5_CONFIG",
706 "WINBINDD_SOCKET_DIR",
707 "WINBINDD_PRIV_PIPE_DIR"
710 $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
711 my $signame = shift;
712 teardown_env($_) foreach(keys %running_envs);
713 die("Received signal $signame");
716 sub setup_env($)
718 my ($name) = @_;
720 my $testenv_vars = undef;
722 my $envname = $name;
723 my $option = $name;
725 $envname =~ s/:.*//;
726 $option =~ s/^[^:]*//;
727 $option =~ s/^://;
729 $option = "client" if $option eq "";
731 if ($envname eq "none") {
732 $testenv_vars = {};
733 } elsif (defined(get_running_env($envname))) {
734 $testenv_vars = get_running_env($envname);
735 if (not $target->check_env($testenv_vars)) {
736 $testenv_vars = undef;
738 } else {
739 $testenv_vars = $target->setup_env($envname, $prefix);
742 return undef unless defined($testenv_vars);
744 $running_envs{$envname} = $testenv_vars;
746 if ($option eq "local") {
747 SocketWrapper::set_default_iface($testenv_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
748 $ENV{SMB_CONF_PATH} = $testenv_vars->{SERVERCONFFILE};
749 } elsif ($option eq "client") {
750 SocketWrapper::set_default_iface(6);
751 write_clientconf($conffile, $testenv_vars);
752 $ENV{SMB_CONF_PATH} = $conffile;
753 } else {
754 die("Unknown option[$option] for envname[$envname]");
757 foreach (@exported_envvars) {
758 if (defined($testenv_vars->{$_})) {
759 $ENV{$_} = $testenv_vars->{$_};
760 } else {
761 delete $ENV{$_};
765 return $testenv_vars;
768 sub exported_envvars_str($)
770 my ($testenv_vars) = @_;
771 my $out = "";
773 foreach (@exported_envvars) {
774 next unless defined($testenv_vars->{$_});
775 $out .= $_."=".$testenv_vars->{$_}."\n";
778 return $out;
781 sub getlog_env($)
783 my ($envname) = @_;
784 return "" if ($envname eq "none");
785 return $target->getlog_env(get_running_env($envname));
788 sub check_env($)
790 my ($envname) = @_;
791 return 1 if ($envname eq "none");
792 return $target->check_env(get_running_env($envname));
795 sub teardown_env($)
797 my ($envname) = @_;
798 return if ($envname eq "none");
799 $target->teardown_env(get_running_env($envname));
800 delete $running_envs{$envname};
803 if ($opt_no_lazy_setup) {
804 setup_env($_) foreach (keys %required_envs);
807 if ($opt_testenv) {
808 my $testenv_name = $ENV{SELFTEST_TESTENV};
809 $testenv_name = $testenv_default unless defined($testenv_name);
811 my $testenv_vars = setup_env($testenv_name);
813 $ENV{PIDDIR} = $testenv_vars->{PIDDIR};
815 my $envvarstr = exported_envvars_str($testenv_vars);
817 my $term = ($ENV{TERM} or "xterm");
818 system("$term -e 'echo -e \"
819 Welcome to the Samba4 Test environment '$testenv_name'
821 This matches the client environment used in make test
822 server is pid `cat \$PIDDIR/samba.pid`
824 Some useful environment variables:
825 TORTURE_OPTIONS=\$TORTURE_OPTIONS
826 SMB_CONF_PATH=\$SMB_CONF_PATH
828 $envvarstr
829 \" && LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH} bash'");
830 teardown_env($testenv_name);
831 } else {
832 foreach (@todo) {
833 $i++;
834 my $cmd = $$_[2];
835 $cmd =~ s/([\(\)])/\\$1/g;
836 my $name = $$_[0];
837 my $envname = $$_[1];
839 my $envvars = setup_env($envname);
840 if (not defined($envvars)) {
841 Subunit::skip_testsuite($name,
842 "unable to set up environment $envname");
843 next;
846 run_testsuite($envname, $name, $cmd, $i, $suitestotal);
848 if (defined($opt_analyse_cmd)) {
849 system("$opt_analyse_cmd \"$name\"");
852 teardown_env($envname) if ($opt_resetup_env);
856 print "\n";
858 teardown_env($_) foreach (keys %running_envs);
860 $target->stop();
862 my $failed = 0;
864 # if there were any valgrind failures, show them
865 foreach (<$prefix/valgrind.log*>) {
866 next unless (-s $_);
867 system("grep DWARF2.CFI.reader $_ > /dev/null");
868 if ($? >> 8 == 0) {
869 print "VALGRIND FAILURE\n";
870 $failed++;
871 system("cat $_");
874 exit 0;