------------------------------------------------------------ revno: 11293 revision-id: [EMAIL PROTECTED] parent: [EMAIL PROTECTED] committer: Jelmer Vernooij <[EMAIL PROTECTED]> branch nick: 4.0-perlselftest timestamp: Thu 2007-01-25 12:37:20 +0100 message: - Fix return code checking. - Parse subunit output. - Print failed test output at the end of test run. modified: .bzrignore svn-v2:[EMAIL PROTECTED] source/script/tests/selftest.pl svn-v2:[EMAIL PROTECTED] source/script/tests/test_nbt.sh svn-v2:[EMAIL PROTECTED] source/script/tests/tests_quick.sh svn-v2:[EMAIL PROTECTED] === modified file '.bzrignore' --- a/.bzrignore 2007-01-24 12:05:47 +0000 +++ b/.bzrignore 2007-01-25 11:37:20 +0000 @@ -162,3 +162,4 @@ source/st source/samba.info source/pidl/cover_db +source/dsdb/repl/drepl_service_proto.h
=== modified file 'source/script/tests/selftest.pl' --- a/source/script/tests/selftest.pl 2007-01-24 16:00:07 +0000 +++ b/source/script/tests/selftest.pl 2007-01-25 11:37:20 +0000 @@ -161,7 +161,6 @@ sub teststatus($$) { my ($name, $failed) = @_; - print "TEST STATUS: $failed failures\n"; if ($failed > 0) { print <<EOF ************************ @@ -173,19 +172,22 @@ exit $failed; } +my $suitesfailed = []; my $totalfailed = 0; +my $totalsuccesses = 0; +my $total = 0; my $start = time(); sub run_test_buildfarm($$$$) { - my ($name, $cmd, $i, $total) = @_; + my ($name, $cmd, $i, $suitestotal) = @_; print "--==--==--==--==--==--==--==--==--==--==--\n"; print "Running test $name (level 0 stdout)\n"; print "--==--==--==--==--==--==--==--==--==--==--\n"; system("date"); print "Testing $name"; - system($cmd); + my $ret = system($cmd); # print "SMBD is down! Skipping: $cmd\n"; # print "==========================================\n"; @@ -197,28 +199,51 @@ print "TEST PASSED: $name\n"; print "==========================================\n"; - my $ret = 0; - if ($ret != 0) { - $totalfailed++; - } + push(@$suitesfailed, $name) if ($ret != 0); } +my $test_output = {}; sub run_test_plain($$$$) { - my ($name, $cmd, $i, $total) = @_; + my ($name, $cmd, $i, $totalsuites) = @_; my $err = ""; - if ($totalfailed > 0) { $err = ", $totalfailed errors"; } - printf "[$i/$total in " . (time() - $start)."s$err] $name\n"; + if ($#$suitesfailed+1 > 0) { $err = ", ".($#$suitesfailed+1)." errors"; } + printf "[$i/$totalsuites in " . (time() - $start)."s$err] $name\n"; open(RESULT, "$cmd 2>/dev/null|"); - while (<RESULT>) { } - close(RESULT); - my $ret = 0; - if ($ret != 0) { - $totalfailed++; + my $open_tests = {}; + $test_output->{$name} = ""; + while (<RESULT>) { + if (/^test: ([^\n]+)/) { + $open_tests->{$1} = 1; + } elsif (/^success: ([^\[\n]+)/) { + delete $open_tests->{$1}; + $total++; + } elsif (/^failure: ([^\[\n]+)/) { + delete $open_tests->{$1}; + $totalfailed++; + } + $test_output->{$_}.=$_; + } + $test_output->{$name}.="COMMAND IS: $cmd\n"; + foreach (keys %$open_tests) { + print "$_ was started but never finished!\n"; + } + my $ret = close(RESULT); + if (not $ret) { + push(@$suitesfailed, $name); exit(1) if ($opt_one); } } +sub prepare_socket_wrapper($) +{ + my ($prefix) = @_; + my $socket_wrapper_dir = undef; + $socket_wrapper_dir = "$prefix/w"; + $ENV{SOCKET_WRAPPER_DIR} = $socket_wrapper_dir; + return $socket_wrapper_dir; +} + sub ShowHelp() { print "Samba test runner @@ -239,7 +264,7 @@ my $result = GetOptions ( 'help|h|?' => \$opt_help, - 'target' => \$opt_target, + 'target=s' => \$opt_target, 'socket-wrapper' => \$opt_socket_wrapper, 'quick' => \$opt_quick, 'one' => \$opt_one @@ -297,6 +322,8 @@ $ENV{PKG_CONFIG_PATH} = "$old_pwd/bin/pkgconfig:$ENV{PKG_CONFIG_PATH}"; $ENV{PATH} = "$old_pwd/bin:$ENV{PATH}"; +my @torture_options = (); + if ($opt_target eq "samba4") { print "PROVISIONING..."; open(IN, "$RealBin/mktestsetup.sh $prefix|") or die("Unable to setup"); @@ -320,17 +347,16 @@ die ("$ENV{WINTESTCONF} could not be read.") if (! -r $ENV{WINTESTCONF}); $ENV{WINTEST_DIR}="$ENV{SRCDIR}/script/tests/win"; +} elsif ($opt_target eq "none") { } else { die("unknown target `$opt_target'"); } -my $socket_wrapper_dir = undef; - +my $socket_wrapper_dir; if ( $opt_socket_wrapper) { - $socket_wrapper_dir = "$prefix/w"; - $ENV{SOCKET_WRAPPER_DIR} = $socket_wrapper_dir; - print "SOCKET_WRAPPER_DIR=$ENV{SOCKET_WRAPPER_DIR}\n"; + $socket_wrapper_dir = prepare_socket_wrapper($prefix); + print "SOCKET_WRAPPER_DIR=$socket_wrapper_dir\n"; } else { print "NOT USING SOCKET_WRAPPER\n"; } @@ -361,13 +387,14 @@ $ENV{SOCKET_WRAPPER_DEFAULT_IFACE} = 6; $ENV{TORTURE_INTERFACES} = '127.0.0.6/8,127.0.0.7/8,127.0.0.8/8,127.0.0.9/8,127.0.0.10/8,127.0.0.11/8'; -my @torture_options = (); push (@torture_options, "--option=interfaces=$ENV{TORTURE_INTERFACES}"); push (@torture_options, $ENV{CONFIGURATION}); # ensure any one smbtorture call doesn't run too long push (@torture_options, "--maximum-runtime=$torture_maxtime"); push (@torture_options, "--target=$opt_target"); push (@torture_options, "--option=torture:progress=no") if ($from_build_farm); +push (@torture_options, "--format=subunit"); +push (@torture_options, "--option=torture:quick=yes") if ($opt_quick); $ENV{TORTURE_OPTIONS} = join(' ', @torture_options); print "OPTIONS $ENV{TORTURE_OPTIONS}\n"; @@ -410,10 +437,10 @@ print; } } - close(IN); + close(IN) or die("Error creating recipe"); } -my $total = $#todo + 1; +my $suitestotal = $#todo + 1; my $i = 0; $| = 1; @@ -423,9 +450,9 @@ $cmd =~ s/([\(\)])/\\$1/g; my $name = $$_[0]; if ($from_build_farm) { - run_test_buildfarm($name, $cmd, $i, $total); + run_test_buildfarm($name, $cmd, $i, $suitestotal); } else { - run_test_plain($name, $cmd, $i, $total); + run_test_plain($name, $cmd, $i, $suitestotal); } } @@ -450,8 +477,24 @@ } my $end = time(); -print "DURATION: " . ($end-$start). " seconds\n"; -print "$totalfailed failures\n"; +my $duration = ($end-$start); +print "DURATION: $duration seconds\n"; +my $numfailed = $#$suitesfailed+1; +if ($numfailed == 0) { + print "ALL OK ($total tests in $suitestotal testsuites)\n"; +} else { + + unless ($from_build_farm) { + foreach (@$suitesfailed) { + print "================================================\n"; + print "FAIL: $_\n"; + print $test_output->{$_}; + print "\n"; + } + } + + print "$totalfailed failed tests in $numfailed testsuites\n"; +} # if there were any valgrind failures, show them foreach (<$prefix/valgrind.log*>) { @@ -464,6 +507,6 @@ } } -teststatus($Script, $failed); +teststatus($Script, $numfailed); -exit $failed; +exit $numfailed; === modified file 'source/script/tests/test_nbt.sh' --- a/source/script/tests/test_nbt.sh 2006-10-16 13:06:41 +0000 +++ b/source/script/tests/test_nbt.sh 2007-01-25 11:37:20 +0000 @@ -23,9 +23,7 @@ NBT_TESTS="NBT-REGISTER NBT-WINS" NBT_TESTS="$NBT_TESTS NBT-WINSREPLICATION" -# if [ "$TORTURE_QUICK"x != "yes"x ]; then -# NBT_TESTS="$NBT_TESTS NBT-WINSREPLICATION-OWNED" -# fi +# NBT_TESTS="$NBT_TESTS NBT-WINSREPLICATION-OWNED" NBT_TESTS="$NBT_TESTS NET-API-LOOKUP NET-API-LOOKUPHOST NET-API-LOOKUPPDC" for f in $NBT_TESTS; do === modified file 'source/script/tests/tests_quick.sh' --- a/source/script/tests/tests_quick.sh 2007-01-14 03:18:04 +0000 +++ b/source/script/tests/tests_quick.sh 2007-01-25 11:37:20 +0000 @@ -1,6 +1,4 @@ #!/bin/sh -TORTURE_OPTIONS="$TORTURE_OPTIONS --option=torture:quick=yes" -export TORTURE_OPTIONS TORTURE_QUICK="yes" export TORTURE_QUICK