summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/build/smb_build/makefile.pm2
-rw-r--r--source4/lib/socket_wrapper/config.m46
-rw-r--r--source4/main.mk31
-rw-r--r--source4/samba4-knownfail8
-rw-r--r--source4/script/tests/Samba4.pm139
-rw-r--r--source4/script/tests/SocketWrapper.pm34
-rwxr-xr-x[-rw-r--r--]source4/script/tests/mk-fedora-ds.sh0
-rwxr-xr-x[-rw-r--r--]source4/script/tests/mk-keyblobs.sh0
-rwxr-xr-x[-rw-r--r--]source4/script/tests/mk-openldap.sh0
-rwxr-xr-x[-rw-r--r--]source4/script/tests/mktestsetup.sh.share_ldb0
-rwxr-xr-xsource4/script/tests/selftest.pl528
-rwxr-xr-xsource4/script/tests/selftest.sh290
-rwxr-xr-xsource4/script/tests/test_ejs.sh5
-rwxr-xr-xsource4/script/tests/test_ldap.sh5
-rwxr-xr-xsource4/script/tests/test_nbt.sh4
-rwxr-xr-xsource4/script/tests/testenv.pl32
-rwxr-xr-xsource4/script/tests/tests_net.sh2
-rwxr-xr-xsource4/script/tests/tests_quick.sh2
-rwxr-xr-x[-rw-r--r--]source4/script/tests/tests_xterm.sh0
-rw-r--r--source4/torture/basic/delaywrite.c30
-rw-r--r--source4/torture/raw/oplock.c159
-rw-r--r--source4/torture/smbtorture.c15
-rw-r--r--source4/torture/torture.c3
-rw-r--r--source4/torture/ui.c16
-rw-r--r--source4/torture/ui.h7
-rwxr-xr-xtestprogs/blackbox/test_ldb.sh2
26 files changed, 744 insertions, 576 deletions
diff --git a/source4/build/smb_build/makefile.pm b/source4/build/smb_build/makefile.pm
index d919f4dcbd..43391d8775 100644
--- a/source4/build/smb_build/makefile.pm
+++ b/source4/build/smb_build/makefile.pm
@@ -157,7 +157,7 @@ YAPP=$self->{config}->{YAPP}
GCOV=$self->{config}->{GCOV}
-DEFAULT_TEST_TARGET=$self->{config}->{DEFAULT_TEST_TARGET}
+DEFAULT_TEST_OPTIONS=$self->{config}->{DEFAULT_TEST_OPTIONS}
__EOD__
);
diff --git a/source4/lib/socket_wrapper/config.m4 b/source4/lib/socket_wrapper/config.m4
index dc4523a8cf..c830ac6305 100644
--- a/source4/lib/socket_wrapper/config.m4
+++ b/source4/lib/socket_wrapper/config.m4
@@ -1,7 +1,7 @@
AC_ARG_ENABLE(socket-wrapper,
[ --enable-socket-wrapper Turn on socket wrapper library (default=no)])
-DEFAULT_TEST_TARGET=test-noswrap
+DEFAULT_TEST_OPTIONS=
HAVE_SOCKET_WRAPPER=no
if eval "test x$developer = xyes"; then
@@ -10,9 +10,9 @@ fi
if eval "test x$enable_socket_wrapper = xyes"; then
AC_DEFINE(SOCKET_WRAPPER,1,[Use socket wrapper library])
- DEFAULT_TEST_TARGET=test-swrap
+ DEFAULT_TEST_OPTIONS=--socket-wrapper
HAVE_SOCKET_WRAPPER=yes
fi
-AC_SUBST(DEFAULT_TEST_TARGET)
+AC_SUBST(DEFAULT_TEST_OPTIONS)
AC_SUBST(HAVE_SOCKET_WRAPPER)
diff --git a/source4/main.mk b/source4/main.mk
index 4cfbf8a8fb..18ced055f5 100644
--- a/source4/main.mk
+++ b/source4/main.mk
@@ -282,49 +282,56 @@ realdistclean: distclean removebackup
-rm -f $(MANPAGES)
check:: test
-test: $(DEFAULT_TEST_TARGET)
-SELFTEST = builddir=$(builddir) srcdir=$(srcdir) \
- $(srcdir)/script/tests/selftest.sh ${selftest_prefix}
+SELFTEST = $(srcdir)/script/tests/selftest.pl --prefix=${selftest_prefix} --builddir=$(builddir) --srcdir=$(srcdir) --expected-failures=samba4-knownfail
+
+test: all libraries
+ $(SELFTEST) $(DEFAULT_TEST_OPTIONS) $(TESTS) --immediate
+
+testone: all libraries
+ $(SELFTEST) $(DEFAULT_TEST_OPTIONS) $(TESTS) --one
test-swrap: all libraries
- $(SELFTEST) all SOCKET_WRAPPER
+ $(SELFTEST) --socket-wrapper --immediate $(TESTS)
test-noswrap: all libraries
- $(SELFTEST) all
+ $(SELFTEST) --immediate $(TESTS)
+
+quicktestone: all
+ $(SELFTEST) --quick --socket-wrapper --one $(TESTS)
quicktest: all
- $(SELFTEST) quick SOCKET_WRAPPER
+ $(SELFTEST) --quick --socket-wrapper --immediate $(TESTS)
testenv: all libraries
- $(SELFTEST) xterm SOCKET_WRAPPER
+ $(srcdir)/script/tests/testenv.pl
valgrindtest: valgrindtest-quick
valgrindtest-quick: all
SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \
VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
- $(SELFTEST) quick SOCKET_WRAPPER
+ $(SELFTEST) --quick --immediate --socket-wrapper
valgrindtest-all: all libraries
SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \
VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
- $(SELFTEST) all SOCKET_WRAPPER
+ $(SELFTEST) --immediate --socket-wrapper
valgrindtest-env: all libraries
SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \
VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
- $(SELFTEST) xterm SOCKET_WRAPPER
+ $(srcdir)/script/tests/testenv.pl
gdbtest: gdbtest-quick
gdbtest-quick: all
SMBD_VALGRIND="xterm -n smbd -e gdb --args " \
- $(SELFTEST) quick SOCKET_WRAPPER
+ $(SELFTEST) --immediate --quick --socket-wrapper
gdbtest-all: all libraries
SMBD_VALGRIND="xterm -n smbd -e gdb --args " \
- $(SELFTEST) all SOCKET_WRAPPER
+ $(SELFTEST) --immediate --socket-wrapper
wintest: all
$(SELFTEST) win
diff --git a/source4/samba4-knownfail b/source4/samba4-knownfail
index 6229e3e33f..7431314823 100644
--- a/source4/samba4-knownfail
+++ b/source4/samba4-knownfail
@@ -1,3 +1,5 @@
-LOCAL-REGISTRY-*
-LOCAL-RESOLVE-async
-LOCAL-ICONV-next_codepoint()
+LOCAL-REGISTRY/(nt4|ldb|dir) # Not implemented yet
+LOCAL-RESOLVE/async
+LOCAL-ICONV/next_codepoint()
+BASE-DELAYWRITE/finfo update on close
+RAW-OPLOCK/OPLOCK
diff --git a/source4/script/tests/Samba4.pm b/source4/script/tests/Samba4.pm
new file mode 100644
index 0000000000..defca23d9f
--- /dev/null
+++ b/source4/script/tests/Samba4.pm
@@ -0,0 +1,139 @@
+#!/usr/bin/perl
+# Bootstrap Samba and run a number of tests against it.
+# Copyright (C) 2005-2007 Jelmer Vernooij <jelmer@samba.org>
+# Published under the GNU GPL, v3 or later.
+
+package Samba4;
+
+use Exporter;
+@ISA = qw(Exporter);
+@EXPORT_OK = qw(slapd_start slapd_stop smbd_check_or_start provision);
+
+use strict;
+use FindBin qw($RealBin);
+use POSIX;
+
+sub slapd_start($$)
+{
+ my ($conf, $uri) = @_;
+ if (defined($ENV{FEDORA_DS_PREFIX})) {
+ system("$ENV{FEDORA_DS_PREFIX}/lib/fedora-ds/ds_newinst.pl $ENV{FEDORA_DS_INF}") or die("Unable to provision fedora ds ldapd");
+ } else {
+ my $oldpath = $ENV{PATH};
+ $ENV{PATH} = "/usr/local/sbin:/usr/sbin:/sbin:$ENV{PATH}";
+ # running slapd in the background means it stays in the same process group, so it can be
+ # killed by timelimit
+ system("slapd -d0 -f $conf -h $uri &");
+ $ENV{PATH} = $oldpath;
+ }
+ return $? >> 8;
+}
+
+sub slapd_stop()
+{
+ if (defined($ENV{FEDORA_DS_PREFIX})) {
+ system("$ENV{LDAPDIR}/slapd-samba4/stop-slapd");
+ } else {
+ open(IN, "<$ENV{PIDDIR}/slapd.pid") or
+ die("unable to open slapd pid file");
+ kill 9, <IN>;
+ close(IN);
+ }
+}
+
+sub smbd_check_or_start($$$$$$)
+{
+ my ($bindir, $test_fifo, $test_log, $socket_wrapper_dir, $max_time, $conffile) = @_;
+ return 0 if ( -p $test_fifo );
+
+ warn("Not using socket wrapper, but also not running as root. Will not be able to listen on proper ports") unless
+ defined($socket_wrapper_dir) or $< == 0;
+
+ if (defined($socket_wrapper_dir)) {
+ if ( -d $socket_wrapper_dir ) {
+ unlink <$socket_wrapper_dir/*>;
+ } else {
+ mkdir($socket_wrapper_dir);
+ }
+ }
+
+ unlink($test_fifo);
+ POSIX::mkfifo($test_fifo, 0700);
+ unlink($test_log);
+
+ my $valgrind = "";
+ if (defined($ENV{SMBD_VALGRIND})) {
+ $valgrind = $ENV{SMBD_VALGRIND};
+ }
+
+ print "STARTING SMBD...";
+ my $pid = fork();
+ if ($pid == 0) {
+ open STDIN, $test_fifo;
+ open STDOUT, ">$test_log";
+ open STDERR, '>&STDOUT';
+ my $optarg = "";
+ if (defined($max_time)) {
+ $optarg = "--maximum-runtime=$max_time ";
+ }
+ my $ret = system("$valgrind $bindir/smbd $optarg -s $conffile -M single -i --leak-report-full");
+ if ($? == -1) {
+ print "Unable to start smbd: $ret: $!\n";
+ exit 1;
+ }
+ unlink($test_fifo);
+ unlink(<$socket_wrapper_dir/*>) if (defined($socket_wrapper_dir) and -d $socket_wrapper_dir);
+ my $exit = $? >> 8;
+ if ( $ret == 0 ) {
+ print "smbd exits with status $exit\n";
+ } elsif ( $ret & 127 ) {
+ print "smbd got signal ".($ret & 127)." and exits with $exit!\n";
+ } else {
+ $ret = $? >> 8;
+ print "smbd failed with status $exit!\n";
+ }
+ exit $exit;
+ }
+ print "DONE\n";
+
+ return $pid;
+}
+
+sub wait_for_start()
+{
+ # give time for nbt server to register its names
+ print "delaying for nbt name registration\n";
+ sleep(4);
+
+ # This will return quickly when things are up, but be slow if we
+ # need to wait for (eg) SSL init
+ system("bin/nmblookup $ENV{CONFIGURATION} $ENV{SERVER}");
+ system("bin/nmblookup $ENV{CONFIGURATION} -U $ENV{SERVER} $ENV{SERVER}");
+ system("bin/nmblookup $ENV{CONFIGURATION} $ENV{SERVER}");
+ system("bin/nmblookup $ENV{CONFIGURATION} -U $ENV{SERVER} $ENV{NETBIOSNAME}");
+ system("bin/nmblookup $ENV{CONFIGURATION} $ENV{NETBIOSNAME}");
+ system("bin/nmblookup $ENV{CONFIGURATION} -U $ENV{SERVER} $ENV{NETBIOSNAME}");
+}
+
+sub provision($)
+{
+ my ($prefix) = @_;
+ my %ret = ();
+ print "PROVISIONING...";
+ open(IN, "$RealBin/mktestsetup.sh $prefix|") or die("Unable to setup");
+ while (<IN>) {
+ die ("Error parsing `$_'") unless (/^([A-Z0-9a-z_]+)=(.*)$/);
+ $ret{$1} = $2;
+ }
+ close(IN);
+ return \%ret;
+}
+
+sub provision_ldap($$)
+{
+ my ($bindir, $setupdir) = @_;
+ system("$bindir/smbscript $setupdir/provision $ENV{PROVISION_OPTIONS} \"$ENV{PROVISION_ACI}\" --ldap-backend=$ENV{LDAPI}") or
+ die("LDAP PROVISIONING failed: $bindir/smbscript $setupdir/provision $ENV{PROVISION_OPTIONS} \"$ENV{PROVISION_ACI}\" --ldap-backend=$ENV{LDAPI}");
+}
+
+1;
diff --git a/source4/script/tests/SocketWrapper.pm b/source4/script/tests/SocketWrapper.pm
new file mode 100644
index 0000000000..c9edbcdf3d
--- /dev/null
+++ b/source4/script/tests/SocketWrapper.pm
@@ -0,0 +1,34 @@
+#!/usr/bin/perl
+# Bootstrap Samba and run a number of tests against it.
+# Copyright (C) 2005-2007 Jelmer Vernooij <jelmer@samba.org>
+# Published under the GNU GPL, v3 or later.
+
+package SocketWrapper;
+
+use Exporter;
+@ISA = qw(Exporter);
+@EXPORT_OK = qw(setup_dir setup_pcap set_default_iface);
+
+use strict;
+use FindBin qw($RealBin);
+
+sub setup_dir($)
+{
+ my ($dir) = @_;
+ $ENV{SOCKET_WRAPPER_DIR} = $dir;
+ return $dir;
+}
+
+sub setup_pcap($)
+{
+ my ($pcap_file) = @_;
+
+}
+
+sub set_default_iface($)
+{
+ my ($i) = @_;
+ $ENV{SOCKET_WRAPPER_DEFAULT_IFACE} = $i;
+}
+
+1;
diff --git a/source4/script/tests/mk-fedora-ds.sh b/source4/script/tests/mk-fedora-ds.sh
index 28b9fe29ab..28b9fe29ab 100644..100755
--- a/source4/script/tests/mk-fedora-ds.sh
+++ b/source4/script/tests/mk-fedora-ds.sh
diff --git a/source4/script/tests/mk-keyblobs.sh b/source4/script/tests/mk-keyblobs.sh
index d05f804fae..d05f804fae 100644..100755
--- a/source4/script/tests/mk-keyblobs.sh
+++ b/source4/script/tests/mk-keyblobs.sh
diff --git a/source4/script/tests/mk-openldap.sh b/source4/script/tests/mk-openldap.sh
index 0759532d3f..0759532d3f 100644..100755
--- a/source4/script/tests/mk-openldap.sh
+++ b/source4/script/tests/mk-openldap.sh
diff --git a/source4/script/tests/mktestsetup.sh.share_ldb b/source4/script/tests/mktestsetup.sh.share_ldb
index 8aa0a046ab..8aa0a046ab 100644..100755
--- a/source4/script/tests/mktestsetup.sh.share_ldb
+++ b/source4/script/tests/mktestsetup.sh.share_ldb
diff --git a/source4/script/tests/selftest.pl b/source4/script/tests/selftest.pl
index b14333e0b5..6c2ea6d0b1 100755
--- a/source4/script/tests/selftest.pl
+++ b/source4/script/tests/selftest.pl
@@ -2,6 +2,107 @@
# Bootstrap Samba and run a number of tests against it.
# Copyright (C) 2005-2007 Jelmer Vernooij <jelmer@samba.org>
# Published under the GNU GPL, v3 or later.
+
+=pod
+
+=head1 NAME
+
+selftest - Samba test runner
+
+=head1 SYNOPSIS
+
+selftest --help
+
+selftest [--srcdir=DIR] [--builddir=DIR] [--target=samba4|samba3|win] [--socket-wrapper] [--quick] [--one] [--prefix=prefix] [--immediate] [TESTS]
+
+=head1 DESCRIPTION
+
+A simple test runner. TESTS is a regular expression with tests to run.
+
+=head1 OPTIONS
+
+=over 4
+
+=item I<--help>
+
+Show list of available options.
+
+=item I<--srcdir=DIR>
+
+Source directory.
+
+=item I<--builddir=DIR>
+
+Build directory.
+
+=item I<--prefix=DIR>
+
+Change directory to run tests in. Default is 'st'.
+
+=item I<--immediate>
+
+Show errors as soon as they happen rather than at the end of the test run.
+
+=item I<--target samba4|samba3|win>
+
+Specify test target against which to run. Default is 'samba4'.
+
+=item I<--quick>
+
+Run only a limited number of tests. Intended to run in about 30 seconds on
+moderately recent systems.
+
+=item I<--socket-wrapper>
+
+Use socket wrapper library for communication with server. Only works
+when the server is running locally.
+
+Will prevent TCP and UDP ports being opened on the local host but
+(transparently) redirects these calls to use unix domain sockets.
+
+=item I<--expected-failures>
+
+Specify a file containing a list of tests that are expected to fail. Failures for
+these tests will be counted as successes, successes will be counted as failures.
+
+The format for the file is, one entry per line:
+
+TESTSUITE-NAME/TEST-NAME
+
+=item I<--one>
+
+Abort as soon as one test fails.
+
+=back
+
+=head1 ENVIRONMENT
+
+=over 4
+
+=item I<SMBD_VALGRIND>
+
+=item I<TORTURE_MAXTIME>
+
+=item I<VALGRIND>
+
+=item I<TEST_LDAP>
+
+=item I<TLS_ENABLED>
+
+=item I<srcdir>
+
+=back
+
+=head1 LICENSE
+
+selftest is licensed under the GNU General Public License L<http://www.gnu.org/licenses/gpl.html>.
+
+=head1 AUTHOR
+
+Jelmer Vernooij
+
+=cut
+
use strict;
use warnings;
@@ -10,86 +111,163 @@ use File::Spec;
use Getopt::Long;
use POSIX;
use Cwd;
+use lib "$RealBin";
+use Samba4;
+use SocketWrapper;
-sub slapd_start($$) {
- my ($conf, $uri) = @_;
- my $oldpath = $ENV{PATH};
- $ENV{PATH} = "/usr/local/sbin:/usr/sbin:/sbin:$ENV{PATH}";
- # running slapd in the background means it stays in the same process group, so it can be
- # killed by timelimit
- system("slapd -d0 -f $conf -h $uri &");
- $ENV{PATH} = $oldpath;
- return $? >> 8;
-}
+my $opt_help = 0;
+my $opt_target = "samba4";
+my $opt_quick = 0;
+my $opt_socket_wrapper = 0;
+my $opt_socket_wrapper_pcap = undef;
+my $opt_one = 0;
+my $opt_immediate = 0;
+my $opt_expected_failures = undef;
+my $opt_verbose = 0;
-sub smbd_check_or_start($$$$$$)
+my $srcdir = ".";
+my $builddir = ".";
+my $prefix = "st";
+
+my $suitesfailed = [];
+my $start = time();
+my @expected_failures = ();
+
+my $statistics = {
+ SUITES_FAIL => 0,
+ SUITES_OK => 0,
+
+ TESTS_UNEXPECTED_OK => 0,
+ TESTS_EXPECTED_OK => 0,
+ TESTS_UNEXPECTED_FAIL => 0,
+ TESTS_EXPECTED_FAIL => 0,
+ TESTS_ERROR => 0
+};
+
+sub expecting_failure($)
{
- my ($bindir, $test_fifo, $test_log, $socket_wrapper_dir, $max_time, $conffile) = @_;
- return 0 if ( -p $test_fifo );
+ my $fullname = shift;
- if (defined($socket_wrapper_dir)) {
- if ( -d $socket_wrapper_dir ) {
- unlink <$socket_wrapper_dir/*>;
- } else {
- mkdir($socket_wrapper_dir);
- }
+ foreach (@expected_failures) {
+ return 1 if $fullname =~ /^$_$/;
}
- unlink($test_fifo);
- system("mkfifo $test_fifo");
-
- unlink($test_log);
-
- my $valgrind = "";
- if (defined($ENV{SMBD_VALGRIND})) {
- $valgrind = $ENV{SMBD_VALGRIND};
- }
-
- print "STARTING SMBD...";
- my $pid = fork();
- if ($pid == 0) {
- my $ret = system("$valgrind $bindir/smbd --maximum-runtime=$max_time -s $conffile -M single -i --leak-report-full < $test_fifo > $test_log");
- open LOG, ">>$test_log";
- if ($? == -1) {
- print LOG "Unable to start smbd: $ret: $!\n";
- print "Unable to start smbd: $ret: $!\n";
- exit 1;
- }
- unlink($test_fifo);
- unlink(<$socket_wrapper_dir/*>) if (defined($socket_wrapper_dir) and -d $socket_wrapper_dir);
- my $exit = $? >> 8;
- if ( $ret == 0 ) {
- print "smbd exits with status $exit\n";
- print LOG "smbd exits with status $exit\n";
- } elsif ( $ret & 127 ) {
- print "smbd got signal ".($ret & 127)." and exits with $exit!\n";
- print LOG "smbd got signal".($ret & 127). " and exits with $exit!\n";
- } else {
- $ret = $? >> 8;
- print "smbd failed with status $exit!\n";
- print LOG "smbd failed with status $exit!\n";
+ return 0;
+}
+
+sub run_test_buildfarm($$$$)
+{
+ my ($name, $cmd, $i, $suitestotal) = @_;
+ print "--==--==--==--==--==--==--==--==--==--==--\n";
+ print "Running test $name (level 0 stdout)\n";
+ print "--==--==--==--==--==--==--==--==--==--==--\n";
+ system("date");
+
+ my $expected_ret = 1;
+ my $open_tests = {};
+ open(RESULT, "$cmd|");
+ while (<RESULT>) {
+ print;
+ if (/^test: (.+)\n/) {
+ $open_tests->{$1} = 1;
+ } elsif (/^(success|failure|skip|error): (.*?)( \[)?\n/) {
+ my $result = $1;
+ if ($1 eq "success") {
+ delete $open_tests->{$2};
+ if (expecting_failure("$name/$2")) {
+ $statistics->{TESTS_UNEXPECTED_OK}++;
+ } else {
+ $statistics->{TESTS_EXPECTED_OK}++;
+ }
+ } elsif ($1 eq "failure") {
+ delete $open_tests->{$2};
+ if (expecting_failure("$name/$2")) {
+ $statistics->{TESTS_EXPECTED_FAIL}++;
+ $expected_ret = 0;
+ } else {
+ $statistics->{TESTS_UNEXPECTED_FAIL}++;
+ }
+ } elsif ($1 eq "skip") {
+ delete $open_tests->{$2};
+ } elsif ($1 eq "error") {
+ $statistics->{TESTS_ERROR}++;
+ delete $open_tests->{$2};
+ }
}
- close(LOG);
- exit $exit;
}
- print "DONE\n";
+ print "COMMAND: $cmd\n";
+ foreach (keys %$open_tests) {
+ print "$_ was started but never finished!\n";
+ $statistics->{TESTS_ERROR}++;
+ }
+ my $ret = close(RESULT);
- return $pid;
+ print "==========================================\n";
+ if ($ret == $expected_ret) {
+ print "TEST PASSED: $name\n";
+ } else {
+ print "TEST FAILED: $name (status $ret)\n";
+ }
+ print "==========================================\n";
}
-sub teststatus($$) {
- my ($name, $failed) = @_;
-
- print "TEST STATUS: $failed failures\n";
- if ($failed > 0) {
-print <<EOF
-************************
-*** TESTSUITE FAILED ***
-************************
-EOF
-;
+my $test_output = {};
+sub run_test_plain($$$$)
+{
+ my ($name, $cmd, $i, $totalsuites) = @_;
+ my $err = "";
+ if ($#$suitesfailed+1 > 0) { $err = ", ".($#$suitesfailed+1)." errors"; }
+ printf "[$i/$totalsuites in " . (time() - $start)."s$err] $name\n";
+ open(RESULT, "$cmd 2>&1|");
+ my $expected_ret = 1;
+ my $open_tests = {};
+ $test_output->{$name} = "";
+ while (<RESULT>) {
+ $test_output->{$name}.=$_;
+ print if ($opt_verbose);
+ if (/^test: (.+)\n/) {
+ $open_tests->{$1} = 1;
+ } elsif (/^(success|failure|skip|error): (.*?)( \[)?\n/) {
+ my $result = $1;
+ if ($1 eq "success") {
+ delete $open_tests->{$2};
+ if (expecting_failure("$name/$2")) {
+ $statistics->{TESTS_UNEXPECTED_OK}++;
+ } else {
+ $statistics->{TESTS_EXPECTED_OK}++;
+ }
+ } elsif ($1 eq "failure") {
+ delete $open_tests->{$2};
+ if (expecting_failure("$name/$2")) {
+ $statistics->{TESTS_EXPECTED_FAIL}++;
+ $expected_ret = 0;
+ } else {
+ $statistics->{TESTS_UNEXPECTED_FAIL}++;
+ }
+ } elsif ($1 eq "skip") {
+ delete $open_tests->{$2};
+ } elsif ($1 eq "error") {
+ $statistics->{TESTS_ERROR}++;
+ delete $open_tests->{$2};
+ }
+ }
+ }
+ $test_output->{$name}.="COMMAND: $cmd\n";
+ foreach (keys %$open_tests) {
+ $test_output->{$name}.="$_ was started but never finished!\n";
+ $statistics->{TESTS_ERROR}++;
+ }
+ my $ret = close(RESULT);
+ if ($ret != $expected_ret and ($opt_immediate or $opt_one) and not $opt_verbose) {
+ print "$test_output->{$name}\n";
+ }
+ if ($ret != $expected_ret) {
+ push(@$suitesfailed, $name);
+ $statistics->{SUITES_FAIL}++;
+ exit(1) if ($opt_one);
+ } else {
+ $statistics->{SUITES_OK}++;
}
- exit $failed;
}
sub ShowHelp()
@@ -97,51 +275,60 @@ sub ShowHelp()
print "Samba test runner
Copyright (C) Jelmer Vernooij <jelmer\@samba.org>
-Usage: $Script PREFIX
+Usage: $Script [OPTIONS] PREFIX
Generic options:
--help this help page
+
+Paths:
+ --prefix=DIR prefix to run tests in [st]
+ --srcdir=DIR source directory [.]
+ --builddir=DIR output directory [.]
+
+Target Specific:
--target=samba4|samba3|win Samba version to target
+ --socket-wrapper-pcap=FILE save traffic to pcap file
--socket-wrapper enable socket wrapper
+ --expected-failures=FILE specify list of tests that is guaranteed to fail
+
+Behaviour:
--quick run quick overall test
--one abort when the first test fails
+ --immediate print test output for failed tests during run
+ --verbose be verbose
";
exit(0);
}
-my $opt_help = 0;
-my $opt_target = "samba4";
-my $opt_quick = 0;
-my $opt_socket_wrapper = 0;
-my $opt_one = 0;
-
my $result = GetOptions (
'help|h|?' => \$opt_help,
- 'target' => \$opt_target,
+ 'target=s' => \$opt_target,
+ 'prefix=s' => \$prefix,
'socket-wrapper' => \$opt_socket_wrapper,
+ 'socket-wrapper-pcap=s' => \$opt_socket_wrapper_pcap,
'quick' => \$opt_quick,
- 'one' => \$opt_one
+ 'one' => \$opt_one,
+ 'immediate' => \$opt_immediate,
+ 'expected-failures=s' => \$opt_expected_failures,
+ 'srcdir=s' => \$srcdir,
+ 'builddir=s' => \$builddir,
+ 'verbose' => \$opt_verbose
);
-if (not $result) {
- exit(1);
-}
+exit(1) if (not $result);
ShowHelp() if ($opt_help);
-ShowHelp() if ($#ARGV < 0);
-my $prefix = shift;
+my $tests = shift;
my $torture_maxtime = $ENV{TORTURE_MAXTIME};
unless (defined($torture_maxtime)) {
$torture_maxtime = 1200;
}
-# disable rpc validation when using valgrind - its way too slow
-my $valgrind = $ENV{VALGRIND};
-my $validate = undef;
-unless (defined($valgrind)) {
- $validate = "validate";
+# quick hack to disable rpc validation when using valgrind - its way too slow
+unless (defined($ENV{VALGRIND})) {
+ $ENV{VALIDATE} = "validate";
}
my $old_pwd = "$RealBin/../..";
@@ -150,10 +337,6 @@ my $ldap = (defined($ENV{TEST_LDAP}) and ($ENV{TEST_LDAP} eq "yes"))?1:0;
$prefix =~ s+//+/+;
$ENV{PREFIX} = $prefix;
-my $srcdir = "$RealBin/../..";
-if (defined($ENV{srcdir})) {
- $srcdir = $ENV{srcdir};
-}
$ENV{SRCDIR} = $srcdir;
my $bindir = "$srcdir/bin";
@@ -161,6 +344,8 @@ my $setupdir = "$srcdir/setup";
my $testsdir = "$srcdir/script/tests";
my $tls_enabled = not $opt_quick;
+my $from_build_farm = (defined($ENV{RUN_FROM_BUILD_FARM}) and
+ ($ENV{RUN_FROM_BUILD_FARM} eq "yes"));
$ENV{TLS_ENABLED} = ($tls_enabled?"yes":"no");
$ENV{LD_LDB_MODULE_PATH} = "$old_pwd/bin/modules/ldb";
@@ -173,14 +358,12 @@ if (defined($ENV{LD_LIBRARY_PATH})) {
$ENV{PKG_CONFIG_PATH} = "$old_pwd/bin/pkgconfig:$ENV{PKG_CONFIG_PATH}";
$ENV{PATH} = "$old_pwd/bin:$ENV{PATH}";
+my @torture_options = ();
+
+my $testenv_vars = {};
+
if ($opt_target eq "samba4") {
- print "PROVISIONING...";
- open(IN, "$RealBin/mktestsetup.sh $prefix|") or die("Unable to setup");
- while (<IN>) {
- next unless (/^([A-Z_]+)=(.*)$/);
- $ENV{$1} = $2;
- }
- close(IN);
+ $testenv_vars = Samba4::provision($prefix);
} elsif ($opt_target eq "win") {
die ("Windows tests will not run without root privileges.")
if (`whoami` ne "root");
@@ -196,77 +379,82 @@ if ($opt_target eq "samba4") {
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;
+foreach (keys %$testenv_vars) { $ENV{$_} = $testenv_vars->{$_}; }
+
+if ($opt_socket_wrapper_pcap) {
+ $ENV{SOCKET_WRAPPER_PCAP_FILE} = $opt_socket_wrapper_pcap;
+ # Socket wrapper pcap implies socket wrapper
+ $opt_socket_wrapper = 1;
+}
-if ( $opt_socket_wrapper)
+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";
-} else {
- print "NOT USING SOCKET_WRAPPER\n";
+ $socket_wrapper_dir = SocketWrapper::setup_dir("$prefix/w");
+ print "SOCKET_WRAPPER_DIR=$socket_wrapper_dir\n";
}
# Start slapd before smbd
if ($ldap) {
- slapd_start($ENV{SLAPD_CONF}, $ENV{LDAPI_ESCAPE}) or die("couldn't start slapd");
+ Samba4::slapd_start($ENV{SLAPD_CONF}, $ENV{LDAPI_ESCAPE}) or die("couldn't start slapd");
+
print "LDAP PROVISIONING...";
- system("$bindir/smbscript $setupdir/provision $ENV{PROVISION_OPTIONS} --ldap-backend=$ENV{LDAPI}") or
- die("LDAP PROVISIONING failed: $bindir/smbscript $setupdir/provision $ENV{PROVISION_OPTIONS} --ldap-backend=$ENV{LDAPI}");
+ Samba4::provision_ldap($bindir, $setupdir);
# LDAP is slow
$torture_maxtime *= 2;
}
+if (defined($opt_expected_failures)) {
+ open(KNOWN, "<$opt_expected_failures") or die("unable to read known failures file: $!");
+ while (<KNOWN>) {
+ chomp;
+ s/([ \t]+)\#(.*)$//;
+ push (@expected_failures, $_); }
+ close(KNOWN);
+}
+
my $test_fifo = "$prefix/smbd_test.fifo";
$ENV{SMBD_TEST_FIFO} = $test_fifo;
$ENV{SMBD_TEST_LOG} = "$prefix/smbd_test.log";
-$ENV{SOCKET_WRAPPER_DEFAULT_IFACE} = 1;
+SocketWrapper::set_default_iface(1);
my $max_time = 5400;
if (defined($ENV{SMBD_MAX_TIME})) {
$max_time = $ENV{SMBD_MAX_TIME};
}
-smbd_check_or_start($bindir, $test_fifo, $ENV{SMBD_TEST_LOG}, $socket_wrapper_dir, $max_time, $ENV{CONFFILE});
+Samba4::smbd_check_or_start($bindir, $test_fifo, $ENV{SMBD_TEST_LOG},
+ $socket_wrapper_dir, $max_time, $ENV{CONFFILE});
+
+SocketWrapper::set_default_iface(6);
-$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 $interfaces = join(',', ("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 = ("--option=interfaces=$ENV{TORTURE_INTERFACES} $ENV{CONFIGURATION}");
+push (@torture_options, "--option=interfaces=$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 (defined($ENV{RUN_FROM_BUILD_FARM}) and $ENV{RUN_FROM_BUILD_FARM} eq "yes");
+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";
-my $start = time();
-
open(DATA, ">$test_fifo");
-# give time for nbt server to register its names
-print "delaying for nbt name registration\n";
-sleep(4);
-
-# This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
-system("bin/nmblookup $ENV{CONFIGURATION} $ENV{SERVER}");
-system("bin/nmblookup $ENV{CONFIGURATION} -U $ENV{SERVER} $ENV{SERVER}");
-system("bin/nmblookup $ENV{CONFIGURATION} $ENV{SERVER}");
-system("bin/nmblookup $ENV{CONFIGURATION} -U $ENV{SERVER} $ENV{NETBIOSNAME}");
-system("bin/nmblookup $ENV{CONFIGURATION} $ENV{NETBIOSNAME}");
-system("bin/nmblookup $ENV{CONFIGURATION} -U $ENV{SERVER} $ENV{NETBIOSNAME}");
-
-# start off with 0 failures
-$ENV{failed} = 0;
-my $totalfailed = 0;
-
my @todo = ();
if ($opt_target eq "win") {
@@ -283,27 +471,35 @@ if ($opt_target eq "win") {
$name =~ s/\n//g;
my $cmdline = <IN>;
$cmdline =~ s/\n//g;
- push (@todo, [$name, $cmdline]);
+ push (@todo, [$name, $cmdline])
+ if (not defined($tests) or $name =~ /$tests/);
} else {
print;
}
}
- close(IN);
+ close(IN) or die("Error creating recipe");
}
-my $total = $#todo + 1;
+Samba4::wait_for_start();
+
+# start off with 0 failures
+$ENV{failed} = 0;
+
+my $suitestotal = $#todo + 1;
my $i = 0;
$| = 1;
+delete $ENV{DOMAIN};
+
foreach (@todo) {
- $i = $i + 1;
- my $err = "";
- if ($totalfailed > 0) { $err = ", $totalfailed errors"; }
- printf "[$i/$total in " . (time() - $start)."s$err] $$_[0]\n";
- my $ret = system("$$_[1] >/dev/null 2>/dev/null");
- if ($ret != 0) {
- $totalfailed++;
- exit(1) if ($opt_one);
+ $i++;
+ my $cmd = $$_[1];
+ $cmd =~ s/([\(\)])/\\$1/g;
+ my $name = $$_[0];
+ if ($from_build_farm) {
+ run_test_buildfarm($name, $cmd, $i, $suitestotal);
+ } else {
+ run_test_plain($name, $cmd, $i, $suitestotal);
}
}
@@ -311,6 +507,8 @@ print "\n";
close(DATA);
+sleep(2);
+
my $failed = $? >> 8;
if (-f "$ENV{PIDDIR}/smbd.pid" ) {
@@ -319,15 +517,37 @@ if (-f "$ENV{PIDDIR}/smbd.pid" ) {
close(IN);
}
-if ($ldap) {
- open(IN, "<$ENV{PIDDIR}/slapd.pid") or die("unable to open slapd pid file");
- kill 9, <IN>;
- close(IN);
-}
+Samba4::slapd_stop() if ($ldap);
-my $end=time();
-print "DURATION: " . ($end-$start). " seconds\n";
-print "$totalfailed failures\n";
+my $end = time();
+my $duration = ($end-$start);
+my $numfailed = $#$suitesfailed+1;
+if ($numfailed == 0) {
+ my $ok = $statistics->{TESTS_EXPECTED_OK} + $statistics->{TESTS_EXPECTED_FAIL};
+ print "ALL OK ($ok tests in $statistics->{SUITES_OK} testsuites)\n";
+} else {
+
+ unless ($from_build_farm) {
+ if (not $opt_immediate and not $opt_verbose) {
+ foreach (@$suitesfailed) {
+ print "===============================================================================\n";
+ print "FAIL: $_\n";
+ print $test_output->{$_};
+ print "\n";
+ }
+ }
+
+ print "FAILED ($statistics->{TESTS_UNEXPECTED_FAIL} failures and $statistics->{TESTS_ERROR} errors in $statistics->{SUITES_FAIL} testsuites)\n";
+ } else {
+ print <<EOF
+************************
+*** TESTSUITE FAILED ***
+************************
+EOF
+;
+ }
+}
+print "DURATION: $duration seconds\n";
# if there were any valgrind failures, show them
foreach (<$prefix/valgrind.log*>) {
@@ -340,6 +560,4 @@ foreach (<$prefix/valgrind.log*>) {
}
}
-teststatus($Script, $failed);
-
-exit $failed;
+exit $numfailed;
diff --git a/source4/script/tests/selftest.sh b/source4/script/tests/selftest.sh
deleted file mode 100755
index fa94412136..0000000000
--- a/source4/script/tests/selftest.sh
+++ /dev/null
@@ -1,290 +0,0 @@
-#!/bin/sh
-# Bootstrap Samba and run a number of tests against it.
-
-if [ $# -lt 1 ]
-then
- echo "$0 PREFIX TESTS"
- exit
-fi
-
-ARG0=$0
-ARG1=$1
-ARG2=$2
-ARG3=$3
-
-if [ -z "$TORTURE_MAXTIME" ]; then
- TORTURE_MAXTIME=1200
-fi
-
-# disable rpc validation when using valgrind - its way too slow
-if [ -z "$VALGRIND" ]; then
- VALIDATE="validate";
-else
- VALIDATE="";
-fi
-
-OLD_PWD=`pwd`
-PREFIX=$ARG1
-PREFIX=`echo $PREFIX | sed s+//+/+`
-export PREFIX
-
-# allow selection of the test lists
-TESTS=$ARG2
-
-if [ $TESTS = "all" ]; then
- TLS_ENABLED="yes"
-else
- TLS_ENABLED="no"
-fi
-export TLS_ENABLED
-
-LD_LDB_MODULE_PATH=$OLD_PWD/bin/modules/ldb
-export LD_LDB_MODULE_PATH
-
-LD_SAMBA_MODULE_PATH=$OLD_PWD/bin/modules
-export LD_SAMBA_MODULE_PATH
-
-LD_LIBRARY_PATH=$OLD_PWD/bin/shared:$LD_LIBRARY_PATH
-export LD_LIBRARY_PATH
-
-PKG_CONFIG_PATH=$OLD_PWD/bin/pkgconfig:$PKG_CONFIG_PATH
-export PKG_CONFIG_PATH
-
-incdir=`dirname $ARG0`
-echo -n "PROVISIONING..."
-eval `$incdir/mktestsetup.sh $PREFIX || exit 1`
-echo "DONE"
-
-export KRB5_CONFIG
-export PREFIX_ABS
-export TEST_DATA_PREFIX
-export CONFIGURATION
-export CONFFILE
-export PIDDIR
-export AUTH
-export SERVER
-export NETBIOSNAME
-
-PATH=bin:$PATH
-export PATH
-
-DO_SOCKET_WRAPPER=$ARG3
-if [ x"$DO_SOCKET_WRAPPER" = x"SOCKET_WRAPPER" ];then
- SOCKET_WRAPPER_DIR="$PREFIX/w"
- export SOCKET_WRAPPER_DIR
- echo "SOCKET_WRAPPER_DIR=$SOCKET_WRAPPER_DIR"
-else
- echo "NOT USING SOCKET_WRAPPER"
-fi
-
-incdir=`dirname $ARG0`
-. $incdir/test_functions.sh
-
-#Start slapd before smbd
-if [ x"$TEST_LDAP" = x"yes" ]; then
- if test -z "$FEDORA_DS_PREFIX"; then
- slapd_start || exit 1;
- else
- fedora_ds_start || exit 1;
- fi
- echo -n "LDAP PROVISIONING..."
- $srcdir/bin/smbscript $srcdir/setup/provision $PROVISION_OPTIONS "$PROVISION_ACI" --ldap-backend=$LDAP_URI || {
- echo "LDAP PROVISIONING failed: $srcdir/bin/smbscript $srcdir/setup/provision $PROVISION_OPTIONS $PROVISION_ACI --ldap-backend=$LDAP_URI"
- exit 1;
- }
- #LDAP is slow
- TORTURE_MAXTIME=`expr $TORTURE_MAXTIME '*' 2`
-fi
-
-SMBD_TEST_FIFO="$PREFIX/smbd_test.fifo"
-export SMBD_TEST_FIFO
-SMBD_TEST_LOG="$PREFIX/smbd_test.log"
-export SMBD_TEST_LOG
-
-SOCKET_WRAPPER_DEFAULT_IFACE=1
-export SOCKET_WRAPPER_DEFAULT_IFACE
-smbd_check_or_start
-
-SOCKET_WRAPPER_DEFAULT_IFACE=6
-export SOCKET_WRAPPER_DEFAULT_IFACE
-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'
-TORTURE_OPTIONS="--option=interfaces=$TORTURE_INTERFACES $CONFIGURATION"
-# ensure any one smbtorture call doesn't run too long
-TORTURE_OPTIONS="$TORTURE_OPTIONS --maximum-runtime=$TORTURE_MAXTIME"
-TORTURE_OPTIONS="$TORTURE_OPTIONS --target=samba4"
-export TORTURE_OPTIONS
-
-if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
- TORTURE_OPTIONS="$TORTURE_OPTIONS --option=torture:progress=no"
-fi
-
- runtest() {
- if [ -z "$PREFIX" ]; then
- PREFIX=test_prefix
- mkdir -p $PREFIX
- fi
- name=$1
- shift 1
- cmdline="$*"
-
- SMBD_IS_UP="no"
-
- shname=`echo $name | \
- sed -e 's%[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\-]%_%g'`
-
- UNIQUE_PID=`/bin/sh -c 'echo $$'`
- TEST_LOG="$PREFIX/test_log.${UNIQUE_PID}"
- TEST_PCAP="$PREFIX/test_${shname}_${UNIQUE_PID}.pcap"
- trap "rm -f $TEST_LOG $TEST_PCAP" EXIT
-
- if [ -n "$SMBD_TEST_LOG" -a -z "$smbd_log_size" ]; then
- smbd_log_size=`wc -l < $SMBD_TEST_LOG`;
- fi
-
- if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
- echo "--==--==--==--==--==--==--==--==--==--==--"
- echo "Running test $name (level 0 stdout)"
- echo "--==--==--==--==--==--==--==--==--==--==--"
- date
- echo "Testing $name"
- else
- nf="`expr $failed + $totalfailed`";
- if [ "$nf" = "0" ]; then
- echo "[$current/$total] Testing $name"
- else
- echo "[$current/$total, $nf failures] Testing $name"
- fi
- fi
-
- smbd_check_only && SMBD_IS_UP="yes"
- if [ x"$SMBD_IS_UP" != x"yes" ];then
- if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
- echo "SMBD is down! Skipping: $cmdline"
- echo "=========================================="
- echo "TEST SKIPPED: $name (reason SMBD is down)"
- echo "=========================================="
- else
- echo "TEST SKIPPED: $name (reason SMBD is down)"
- fi
- return 1
- fi
-
- if [ x"$MAKE_TEST_ENABLE_PCAP" = x"yes" ];then
- SOCKET_WRAPPER_PCAP_FILE=$TEST_PCAP
- export SOCKET_WRAPPER_PCAP_FILE
- fi
-
- ( $cmdline > $TEST_LOG 2>&1 )
- status=$?
- # show any additional output from smbd that has happened in this test
- smbd_have_test_log && {
- new_log_size=`wc -l < $SMBD_TEST_LOG`;
- test "$new_log_size" = "$smbd_log_size" || {
- echo "SMBD OUTPUT:";
- incr_log_size=`expr $new_log_size - $smbd_log_size`;
- tail -$incr_log_size $SMBD_TEST_LOG;
- smbd_log_size=$new_log_size;
- }
- }
- if [ x"$status" != x"0" ]; then
- echo "TEST OUTPUT:"
- cat $TEST_LOG;
- rm -f $TEST_LOG;
- if [ x"$MAKE_TEST_ENABLE_PCAP" = x"yes" ];then
- echo "TEST PCAP: $TEST_PCAP"
- fi
- if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
- echo "=========================================="
- echo "TEST FAILED: $name (status $status)"
- echo "=========================================="
- else
- echo "TEST FAILED: $cmdline (status $status)"
- fi
- trap "" EXIT
- return 1;
- fi
- rm -f $TEST_LOG;
- if [ x"$MAKE_TEST_KEEP_PCAP" = x"yes" ];then
- echo "TEST PCAP: $TEST_PCAP"
- else
- rm -f $TEST_PCAP;
- fi
- if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
- echo "ALL OK: $cmdline"
- echo "=========================================="
- echo "TEST PASSED: $name"
- echo "=========================================="
- fi
- trap "" EXIT
- return 0;
-}
-
-START=`date`
-(
- # give time for nbt server to register its names
- echo delaying for nbt name registration
- sleep 4
- # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
- bin/nmblookup $CONFIGURATION $SERVER
- bin/nmblookup $CONFIGURATION -U $SERVER $SERVER
- bin/nmblookup $CONFIGURATION $SERVER
- bin/nmblookup $CONFIGURATION -U $SERVER $NETBIOSNAME
- bin/nmblookup $CONFIGURATION $NETBIOSNAME
- bin/nmblookup $CONFIGURATION -U $SERVER $NETBIOSNAME
-
-# start off with 0 failures
-totalfailed=0
-export totalfailed
-
-. script/tests/tests_$TESTS.sh > $PREFIX/recipe
-total=`grep "TEST --" $PREFIX/recipe | wc -l`
-current=0
-cat $PREFIX/recipe | (
- while read LINE
- do
- if [ "$LINE" = "-- TEST --" ]; then
- read NAME
- read CMDLINE
- current=`expr $current + 1`
- runtest "$NAME" "$CMDLINE" || totalfailed=`expr $totalfailed + $?`
- else
- echo "$LINE"
- fi
- done
- exit $totalfailed
-)
-exit $?
-) 9>$SMBD_TEST_FIFO
-totalfailed=$?
-
-smbd_PID=`cat $PIDDIR/smbd.pid`
-waitforpid $smbd_PID 20 || {
- echo "smbd process $1 took more than 20 seconds to exit, killing"
- kill -9 $smbd_PID
-}
-
-if [ "$TEST_LDAP"x = "yesx" ]; then
- if test -z "$FEDORA_DS_PREFIX"; then
- kill `cat $PIDDIR/slapd.pid`
- else
- $LDAPDIR/slapd-samba4/stop-slapd
- fi
-fi
-
-END=`date`
-echo "START: $START ($ARG0)";
-echo "END: $END ($ARG0)";
-
-# if there were any valgrind failures, show them
-count=`find $PREFIX -name 'valgrind.log*' | wc -l`
-if [ "$count" != 0 ]; then
- for f in $PREFIX/valgrind.log*; do
- if [ -s $f ] && grep -v DWARF2.CFI.reader $f > /dev/null; then
- echo "VALGRIND FAILURE";
- totalfailed=`expr $totalfailed + 1`
- cat $f
- fi
- done
-fi
-
-teststatus $ARG0 $totalfailed
diff --git a/source4/script/tests/test_ejs.sh b/source4/script/tests/test_ejs.sh
index 6cd727e3e3..1ccbb323c0 100755
--- a/source4/script/tests/test_ejs.sh
+++ b/source4/script/tests/test_ejs.sh
@@ -24,16 +24,11 @@ PATH=bin:$PATH
export PATH
testit "base.js" $SCRIPTDIR/base.js $CONFIGURATION
-
testit "samr.js" "$SCRIPTDIR/samr.js" $CONFIGURATION ncalrpc: -U$USERNAME%$PASSWORD
testit "echo.js" "$SCRIPTDIR/echo.js" $CONFIGURATION ncalrpc: -U$USERNAME%$PASSWORD
-
testit "ejsnet.js" $SCRIPTDIR/ejsnet.js $CONFIGURATION -U$USERNAME%$PASSWORD $DOMAIN ejstestuser
-
testit "ldb.js" $SCRIPTDIR/ldb.js `pwd` $CONFIGURATION
-
testit "samba3sam.js" $SCRIPTDIR/samba3sam.js $CONFIGURATION `pwd` $DATADIR/samba3/
-
testit "winreg" scripting/bin/winreg $CONFIGURATION ncalrpc: 'HKLM' -U$USERNAME%$PASSWORD
testok $0 $failed
diff --git a/source4/script/tests/test_ldap.sh b/source4/script/tests/test_ldap.sh
index e50d062fca..9b25ca2803 100755
--- a/source4/script/tests/test_ldap.sh
+++ b/source4/script/tests/test_ldap.sh
@@ -15,7 +15,6 @@ PASSWORD="$3"
incdir=`dirname $0`
. $incdir/test_functions.sh
-
p=ldap
for options in "" "--option=socket:testnonblock=true" "-U$USERNAME%$PASSWORD --option=socket:testnonblock=true" "-U$USERNAME%$PASSWORD"; do
testit "TESTING PROTOCOL $p with options $options" ../testprogs/blackbox/test_ldb.sh $p $SERVER $options
@@ -37,11 +36,11 @@ done
test "$TORTURE_QUICK" = "yes" || {
LDBDIR=lib/ldb
export LDBDIR
- testit "ldb tests" $LDBDIR/tests/test-tdb.sh
+ testit "ldb" $LDBDIR/tests/test-tdb.sh
}
SCRIPTDIR=../testprogs/ejs
-testit "ejs ldap test" $SCRIPTDIR/ldap.js $CONFIGURATION $SERVER -U$USERNAME%$PASSWORD
+testit "ejs ldap" $SCRIPTDIR/ldap.js $CONFIGURATION $SERVER -U$USERNAME%$PASSWORD
testok $0 $failed
diff --git a/source4/script/tests/test_nbt.sh b/source4/script/tests/test_nbt.sh
index 6165e7c754..3cb8476b83 100755
--- a/source4/script/tests/test_nbt.sh
+++ b/source4/script/tests/test_nbt.sh
@@ -23,9 +23,7 @@ testit "nmblookup $SERVER" bin/nmblookup $TORTURE_OPTIONS $SERVER
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
diff --git a/source4/script/tests/testenv.pl b/source4/script/tests/testenv.pl
new file mode 100755
index 0000000000..b290aff542
--- /dev/null
+++ b/source4/script/tests/testenv.pl
@@ -0,0 +1,32 @@
+#!/usr/bin/perl
+
+use FindBin qw($RealBin);
+use lib "$RealBin";
+
+use Samba4;
+use SocketWrapper;
+
+my $vars = Samba4::provision("st");
+foreach (keys %$vars) { $ENV{$_} = $vars->{$_}; }
+SocketWrapper::set_default_iface(1);
+my $test_fifo = "st/smb_test.fifo";
+my $socket_wrapper_dir = SocketWrapper::setup_dir("$vars->{PREFIX_ABS}/w");
+Samba4::smbd_check_or_start("bin", $test_fifo, $ENV{SMBD_TEST_LOG}, $socket_wrapper_dir, undef, $ENV{CONFFILE});
+SocketWrapper::set_default_iface(6);
+my $interfaces = join(',', ("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"));
+
+push (@torture_options, "--option=interfaces=$interfaces",
+ $ENV{CONFIGURATION},
+ "--target=samba4");
+
+$ENV{TORTURE_OPTIONS} = join(' ', @torture_options);
+
+open(DATA, ">$test_fifo");
+Samba4::wait_for_start();
+system("xterm");
+close(DATA);
diff --git a/source4/script/tests/tests_net.sh b/source4/script/tests/tests_net.sh
deleted file mode 100755
index 2f9e57591b..0000000000
--- a/source4/script/tests/tests_net.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
- $SRCDIR/script/tests/test_net.sh $SERVER $USERNAME $PASSWORD $DOMAIN
diff --git a/source4/script/tests/tests_quick.sh b/source4/script/tests/tests_quick.sh
index b7f25fbb5e..87ecfd2cde 100755
--- a/source4/script/tests/tests_quick.sh
+++ b/source4/script/tests/tests_quick.sh
@@ -1,6 +1,4 @@
#!/bin/sh
-TORTURE_OPTIONS="$TORTURE_OPTIONS --option=torture:quick=yes"
-export TORTURE_OPTIONS
TORTURE_QUICK="yes"
export TORTURE_QUICK
diff --git a/source4/script/tests/tests_xterm.sh b/source4/script/tests/tests_xterm.sh
index c6a23316f7..c6a23316f7 100644..100755
--- a/source4/script/tests/tests_xterm.sh
+++ b/source4/script/tests/tests_xterm.sh
diff --git a/source4/torture/basic/delaywrite.c b/source4/torture/basic/delaywrite.c
index 4c2a511721..072f15c623 100644
--- a/source4/torture/basic/delaywrite.c
+++ b/source4/torture/basic/delaywrite.c
@@ -487,6 +487,7 @@ static BOOL test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum1 == -1) {
ret = False;
+ torture_result(tctx, TORTURE_FAIL, __location__": unable to open %s", fname);
goto done;
}
@@ -496,8 +497,8 @@ static BOOL test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
status = smb_raw_fileinfo(cli->tree, tctx, &finfo1);
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
ret = False;
+ torture_result(tctx, TORTURE_FAIL, __location__": fileinfo failed: %s", nt_errstr(status));
goto done;
}
@@ -506,16 +507,15 @@ static BOOL test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
written = smbcli_write(cli->tree, fnum1, 0, "x", 0, 1);
if (written != 1) {
- torture_comment(tctx, "(%s) written gave %d - should have been 1\n",
- __location__, (int)written);
+ torture_result(tctx, TORTURE_FAIL, __location__": written gave %d - should have been 1", (int)written);
ret = False;
goto done;
}
fnum2 = smbcli_open(cli2->tree, fname, O_RDWR, DENY_NONE);
if (fnum2 == -1) {
- torture_comment(tctx, "(%s) failed to open 2nd time - %s\n",
- __location__, smbcli_errstr(cli2->tree));
+ torture_result(tctx, TORTURE_FAIL, __location__": failed to open 2nd time - %s",
+ smbcli_errstr(cli2->tree));
ret = False;
goto done;
}
@@ -523,8 +523,8 @@ static BOOL test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
written = smbcli_write(cli2->tree, fnum2, 0, "x", 0, 1);
if (written != 1) {
- torture_comment(tctx, "(%s) written gave %d - should have been 1\n",
- __location__, (int)written);
+ torture_result(tctx, TORTURE_FAIL, __location__": written gave %d - should have been 1",
+ (int)written);
ret = False;
goto done;
}
@@ -535,30 +535,30 @@ static BOOL test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
status = smb_raw_pathinfo(cli2->tree, tctx, &finfo2);
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("(%s) fileinfo failed: %s\n",
- __location__, nt_errstr(status)));
+ torture_result(tctx, TORTURE_FAIL, __location__": fileinfo failed: %s",
+ nt_errstr(status));
ret = False;
goto done;
}
if (finfo1.basic_info.out.create_time !=
finfo2.basic_info.out.create_time) {
- torture_comment(tctx, "(%s) create_time changed\n", __location__);
+ torture_result(tctx, TORTURE_FAIL, __location__": create_time changed");
ret = False;
goto done;
}
if (finfo1.basic_info.out.access_time !=
finfo2.basic_info.out.access_time) {
- torture_comment(tctx, "(%s) access_time changed\n", __location__);
+ torture_result(tctx, TORTURE_FAIL, __location__": access_time changed");
ret = False;
goto done;
}
if (finfo1.basic_info.out.write_time !=
finfo2.basic_info.out.write_time) {
- torture_comment(tctx, "(%s) write_time changed\n", __location__);
- torture_comment(tctx, "write time conn 1 = %s, conn 2 = %s\n",
+ torture_result(tctx, TORTURE_FAIL, __location__": write_time changed:\n"
+ "write time conn 1 = %s, conn 2 = %s",
nt_time_string(tctx, finfo1.basic_info.out.write_time),
nt_time_string(tctx, finfo2.basic_info.out.write_time));
ret = False;
@@ -567,7 +567,7 @@ static BOOL test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
if (finfo1.basic_info.out.change_time !=
finfo2.basic_info.out.change_time) {
- torture_comment(tctx, "(%s) change_time changed\n", __location__);
+ torture_result(tctx, TORTURE_FAIL, __location__": change_time changed");
ret = False;
goto done;
}
@@ -587,7 +587,7 @@ static BOOL test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
status = smb_raw_pathinfo(cli->tree, tctx, &finfo2);
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
+ torture_result(tctx, TORTURE_FAIL, __location__": fileinfo failed: %s", nt_errstr(status));
ret = False;
goto done;
}
diff --git a/source4/torture/raw/oplock.c b/source4/torture/raw/oplock.c
index f2e894a6eb..1e677fad45 100644
--- a/source4/torture/raw/oplock.c
+++ b/source4/torture/raw/oplock.c
@@ -28,15 +28,15 @@
#define CHECK_VAL(v, correct) do { \
if ((v) != (correct)) { \
- printf("(%d) wrong value for %s got 0x%x - should be 0x%x\n", \
- __LINE__, #v, (int)v, (int)correct); \
+ torture_result(tctx, TORTURE_FAIL, __location__": wrong value for %s got 0x%x - should be 0x%x", \
+ #v, (int)v, (int)correct); \
ret = False; \
}} while (0)
-#define CHECK_STATUS(status, correct) do { \
+#define CHECK_STATUS(tctx, status, correct) do { \
if (!NT_STATUS_EQUAL(status, correct)) { \
- printf("(%d) Incorrect status %s - should be %s\n", \
- __LINE__, nt_errstr(status), nt_errstr(correct)); \
+ torture_result(tctx, TORTURE_FAIL, __location__": Incorrect status %s - should be %s", \
+ nt_errstr(status), nt_errstr(correct)); \
ret = False; \
goto done; \
}} while (0)
@@ -126,7 +126,8 @@ static BOOL oplock_handler_close(struct smbcli_transport *transport, uint16_t ti
/*
test oplock ops
*/
-static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TALLOC_CTX *mem_ctx)
+static BOOL test_oplock(struct torture_context *tctx,
+ struct smbcli_state *cli1, struct smbcli_state *cli2, TALLOC_CTX *mem_ctx)
{
const char *fname = BASEDIR "\\test_oplock.dat";
NTSTATUS status;
@@ -158,26 +159,26 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
io.ntcreatex.in.security_flags = 0;
io.ntcreatex.in.fname = fname;
- printf("open a file with a normal oplock\n");
+ torture_comment(tctx, "open a file with a normal oplock\n");
ZERO_STRUCT(break_info);
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK;
status = smb_raw_open(cli1->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, EXCLUSIVE_OPLOCK_RETURN);
- printf("a 2nd open should not cause a break\n");
+ torture_comment(tctx, "a 2nd open should not cause a break\n");
status = smb_raw_open(cli2->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION);
+ CHECK_STATUS(tctx, status, NT_STATUS_SHARING_VIOLATION);
CHECK_VAL(break_info.count, 0);
CHECK_VAL(break_info.failures, 0);
- printf("unlink it - should also be no break\n");
+ torture_comment(tctx, "unlink it - should also be no break\n");
unl.unlink.in.pattern = fname;
unl.unlink.in.attrib = 0;
status = smb_raw_unlink(cli2->tree, &unl);
- CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION);
+ CHECK_STATUS(tctx, status, NT_STATUS_SHARING_VIOLATION);
CHECK_VAL(break_info.count, 0);
CHECK_VAL(break_info.failures, 0);
@@ -186,35 +187,35 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
/*
with a batch oplock we get a break
*/
- printf("open with batch oplock\n");
+ torture_comment(tctx, "open with batch oplock\n");
ZERO_STRUCT(break_info);
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli1->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
- printf("unlink should generate a break\n");
+ torture_comment(tctx, "unlink should generate a break\n");
unl.unlink.in.pattern = fname;
unl.unlink.in.attrib = 0;
status = smb_raw_unlink(cli2->tree, &unl);
- CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION);
+ CHECK_STATUS(tctx, status, NT_STATUS_SHARING_VIOLATION);
CHECK_VAL(break_info.count, 1);
CHECK_VAL(break_info.fnum, fnum);
CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II);
CHECK_VAL(break_info.failures, 0);
- printf("2nd unlink should not generate a break\n");
+ torture_comment(tctx, "2nd unlink should not generate a break\n");
ZERO_STRUCT(break_info);
status = smb_raw_unlink(cli2->tree, &unl);
- CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION);
+ CHECK_STATUS(tctx, status, NT_STATUS_SHARING_VIOLATION);
CHECK_VAL(break_info.count, 0);
- printf("writing should generate a self break to none\n");
+ torture_comment(tctx, "writing should generate a self break to none\n");
smbcli_write(cli1->tree, fnum, 0, &c, 0, 1);
msleep(100);
smbcli_write(cli1->tree, fnum, 0, &c, 1, 1);
@@ -227,36 +228,36 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
smbcli_close(cli1->tree, fnum);
- printf("open with batch oplock\n");
+ torture_comment(tctx, "open with batch oplock\n");
ZERO_STRUCT(break_info);
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli1->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
- printf("unlink should generate a break, which we ack as break to none\n");
+ torture_comment(tctx, "unlink should generate a break, which we ack as break to none\n");
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_none, cli1->tree);
unl.unlink.in.pattern = fname;
unl.unlink.in.attrib = 0;
status = smb_raw_unlink(cli2->tree, &unl);
- CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION);
+ CHECK_STATUS(tctx, status, NT_STATUS_SHARING_VIOLATION);
CHECK_VAL(break_info.count, 1);
CHECK_VAL(break_info.fnum, fnum);
CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II);
CHECK_VAL(break_info.failures, 0);
- printf("2nd unlink should not generate a break\n");
+ torture_comment(tctx, "2nd unlink should not generate a break\n");
ZERO_STRUCT(break_info);
status = smb_raw_unlink(cli2->tree, &unl);
- CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION);
+ CHECK_STATUS(tctx, status, NT_STATUS_SHARING_VIOLATION);
CHECK_VAL(break_info.count, 0);
- printf("writing should not generate a break\n");
+ torture_comment(tctx, "writing should not generate a break\n");
smbcli_write(cli1->tree, fnum, 0, &c, 0, 1);
msleep(100);
smbcli_write(cli1->tree, fnum, 0, &c, 1, 1);
@@ -265,14 +266,14 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
smbcli_close(cli1->tree, fnum);
- printf("if we close on break then the unlink can succeed\n");
+ torture_comment(tctx, "if we close on break then the unlink can succeed\n");
ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_close, cli1->tree);
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli1->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
@@ -280,14 +281,14 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
unl.unlink.in.attrib = 0;
ZERO_STRUCT(break_info);
status = smb_raw_unlink(cli2->tree, &unl);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
CHECK_VAL(break_info.count, 1);
CHECK_VAL(break_info.fnum, fnum);
CHECK_VAL(break_info.level, 1);
CHECK_VAL(break_info.failures, 0);
- printf("a self read should not cause a break\n");
+ torture_comment(tctx, "a self read should not cause a break\n");
ZERO_STRUCT(break_info);
smbcli_close(cli1->tree, fnum);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
@@ -296,7 +297,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli1->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
@@ -306,11 +307,11 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
rd.read.in.offset = 0;
rd.read.in.remaining = 0;
status = smb_raw_read(cli1->tree, &rd);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
CHECK_VAL(break_info.count, 0);
CHECK_VAL(break_info.failures, 0);
- printf("a 2nd open should give a break\n");
+ torture_comment(tctx, "a 2nd open should give a break\n");
ZERO_STRUCT(break_info);
smbcli_close(cli1->tree, fnum);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
@@ -319,7 +320,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli1->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
@@ -327,7 +328,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED;
status = smb_raw_open(cli2->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION);
+ CHECK_STATUS(tctx, status, NT_STATUS_SHARING_VIOLATION);
CHECK_VAL(break_info.count, 1);
CHECK_VAL(break_info.fnum, fnum);
@@ -335,7 +336,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
CHECK_VAL(break_info.failures, 0);
- printf("a 2nd open should give a break to level II if the first open allowed shared read\n");
+ torture_comment(tctx, "a 2nd open should give a break to level II if the first open allowed shared read\n");
ZERO_STRUCT(break_info);
smbcli_close(cli1->tree, fnum);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
@@ -347,14 +348,14 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli1->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
ZERO_STRUCT(break_info);
status = smb_raw_open(cli2->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum2 = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN);
@@ -364,7 +365,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
CHECK_VAL(break_info.failures, 0);
ZERO_STRUCT(break_info);
- printf("write should trigger a break to none on both\n");
+ torture_comment(tctx, "write should trigger a break to none on both\n");
smbcli_write(cli1->tree, fnum, 0, &c, 0, 1);
msleep(100);
smbcli_write(cli1->tree, fnum, 0, &c, 1, 1);
@@ -376,7 +377,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
smbcli_close(cli1->tree, fnum);
smbcli_close(cli2->tree, fnum2);
- printf("a 2nd open should get an oplock when we close instead of ack\n");
+ torture_comment(tctx, "a 2nd open should get an oplock when we close instead of ack\n");
ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_close, cli1->tree);
@@ -386,7 +387,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli1->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum2 = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
@@ -396,7 +397,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli2->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
@@ -407,7 +408,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
smbcli_close(cli2->tree, fnum);
- printf("open with batch oplock\n");
+ torture_comment(tctx, "open with batch oplock\n");
ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
@@ -415,19 +416,19 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli1->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
ZERO_STRUCT(break_info);
- printf("second open with attributes only shouldn't cause oplock break\n");
+ torture_comment(tctx, "second open with attributes only shouldn't cause oplock break\n");
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
io.ntcreatex.in.access_mask = SEC_FILE_READ_ATTRIBUTE|SEC_FILE_WRITE_ATTRIBUTE|SEC_STD_SYNCHRONIZE;
status = smb_raw_open(cli2->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum2 = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, NO_OPLOCK_RETURN);
CHECK_VAL(break_info.count, 0);
@@ -437,7 +438,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
smbcli_close(cli2->tree, fnum2);
smbcli_unlink(cli1->tree, fname);
- printf("open with attributes only can create file\n");
+ torture_comment(tctx, "open with attributes only can create file\n");
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
NTCREATEX_FLAGS_REQUEST_OPLOCK |
@@ -445,11 +446,11 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
io.ntcreatex.in.access_mask = SEC_FILE_READ_ATTRIBUTE|SEC_FILE_WRITE_ATTRIBUTE|SEC_STD_SYNCHRONIZE;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
status = smb_raw_open(cli1->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
- printf("Subsequent normal open should break oplock on attribute only open to level II\n");
+ torture_comment(tctx, "Subsequent normal open should break oplock on attribute only open to level II\n");
ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
@@ -460,7 +461,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
status = smb_raw_open(cli2->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum2 = io.ntcreatex.out.file.fnum;
CHECK_VAL(break_info.count, 1);
CHECK_VAL(break_info.fnum, fnum);
@@ -469,7 +470,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN);
smbcli_close(cli2->tree, fnum2);
- printf("third oplocked open should grant level2 without break\n");
+ torture_comment(tctx, "third oplocked open should grant level2 without break\n");
ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_levelII, cli2->tree);
@@ -479,7 +480,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
status = smb_raw_open(cli2->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum2 = io.ntcreatex.out.file.fnum;
CHECK_VAL(break_info.count, 0);
CHECK_VAL(break_info.failures, 0);
@@ -487,7 +488,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
ZERO_STRUCT(break_info);
- printf("write should trigger a break to none on both\n");
+ torture_comment(tctx, "write should trigger a break to none on both\n");
smbcli_write(cli2->tree, fnum2, 0, &c, 0, 1);
/* Now the oplock break request comes in. But right now we can't
@@ -506,7 +507,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
- printf("Open with oplock after a on-oplock open should grant level2\n");
+ torture_comment(tctx, "Open with oplock after a on-oplock open should grant level2\n");
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED;
io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ|
@@ -514,7 +515,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
NTCREATEX_SHARE_ACCESS_DELETE;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
status = smb_raw_open(cli1->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(break_info.count, 0);
CHECK_VAL(break_info.failures, 0);
@@ -529,13 +530,13 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
NTCREATEX_SHARE_ACCESS_DELETE;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
status = smb_raw_open(cli2->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum2 = io.ntcreatex.out.file.fnum;
CHECK_VAL(break_info.count, 0);
CHECK_VAL(break_info.failures, 0);
CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN);
- printf("write should trigger a break to none\n");
+ torture_comment(tctx, "write should trigger a break to none\n");
{
union smb_write wr;
wr.write.level = RAW_WRITE_WRITE;
@@ -545,7 +546,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
wr.write.in.remaining = 0;
wr.write.in.data = (const uint8_t *)"x";
status = smb_raw_write(cli1->tree, &wr);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
}
/* Now the oplock break request comes in. But right now we can't
@@ -562,7 +563,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
wr.write.in.remaining = 0;
wr.write.in.data = (const uint8_t *)"x";
status = smb_raw_write(cli1->tree, &wr);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
}
CHECK_VAL(break_info.count, 1);
@@ -575,7 +576,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
smbcli_unlink(cli1->tree, fname);
/* Test if a set-eof on pathname breaks an exclusive oplock. */
- printf("Test if setpathinfo set EOF breaks oplocks.\n");
+ torture_comment(tctx, "Test if setpathinfo set EOF breaks oplocks.\n");
ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
@@ -589,7 +590,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
NTCREATEX_SHARE_ACCESS_DELETE;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
status = smb_raw_open(cli1->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(break_info.count, 0);
CHECK_VAL(break_info.failures, 0);
@@ -602,7 +603,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
status = smb_raw_setpathinfo(cli2->tree, &sfi);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
CHECK_VAL(break_info.count, 1);
CHECK_VAL(break_info.failures, 0);
CHECK_VAL(break_info.level, 0);
@@ -611,7 +612,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
smbcli_unlink(cli1->tree, fname);
/* Test if a set-allocation size on pathname breaks an exclusive oplock. */
- printf("Test if setpathinfo allocation size breaks oplocks.\n");
+ torture_comment(tctx, "Test if setpathinfo allocation size breaks oplocks.\n");
ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
@@ -625,7 +626,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
NTCREATEX_SHARE_ACCESS_DELETE;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
status = smb_raw_open(cli1->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(break_info.count, 0);
CHECK_VAL(break_info.failures, 0);
@@ -638,7 +639,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
status = smb_raw_setpathinfo(cli2->tree, &sfi);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
CHECK_VAL(break_info.count, 1);
CHECK_VAL(break_info.failures, 0);
CHECK_VAL(break_info.level, 0);
@@ -647,7 +648,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
smbcli_close(cli2->tree, fnum2);
smbcli_unlink(cli1->tree, fname);
- printf("open with batch oplock\n");
+ torture_comment(tctx, "open with batch oplock\n");
ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
@@ -656,13 +657,13 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
status = smb_raw_open(cli1->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
ZERO_STRUCT(break_info);
- printf("second open with attributes only and NTCREATEX_DISP_OVERWRITE dispostion causes oplock break\n");
+ torture_comment(tctx, "second open with attributes only and NTCREATEX_DISP_OVERWRITE dispostion causes oplock break\n");
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
NTCREATEX_FLAGS_REQUEST_OPLOCK |
@@ -670,7 +671,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
io.ntcreatex.in.access_mask = SEC_FILE_READ_ATTRIBUTE|SEC_FILE_WRITE_ATTRIBUTE|SEC_STD_SYNCHRONIZE;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OVERWRITE;
status = smb_raw_open(cli2->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum2 = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN);
CHECK_VAL(break_info.count, 1);
@@ -680,7 +681,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
smbcli_close(cli2->tree, fnum2);
smbcli_unlink(cli1->tree, fname);
- printf("open with batch oplock\n");
+ torture_comment(tctx, "open with batch oplock\n");
ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
@@ -689,13 +690,13 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
status = smb_raw_open(cli1->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
ZERO_STRUCT(break_info);
- printf("second open with attributes only and NTCREATEX_DISP_SUPERSEDE dispostion causes oplock break\n");
+ torture_comment(tctx, "second open with attributes only and NTCREATEX_DISP_SUPERSEDE dispostion causes oplock break\n");
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
NTCREATEX_FLAGS_REQUEST_OPLOCK |
@@ -703,7 +704,7 @@ static BOOL test_oplock(struct smbcli_state *cli1, struct smbcli_state *cli2, TA
io.ntcreatex.in.access_mask = SEC_FILE_READ_ATTRIBUTE|SEC_FILE_WRITE_ATTRIBUTE|SEC_STD_SYNCHRONIZE;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OVERWRITE;
status = smb_raw_open(cli2->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
fnum2 = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN);
CHECK_VAL(break_info.count, 1);
@@ -746,7 +747,7 @@ BOOL torture_raw_oplock(struct torture_context *torture)
mem_ctx = talloc_init("torture_raw_oplock");
- if (!test_oplock(cli1, cli2, mem_ctx)) {
+ if (!test_oplock(torture, cli1, cli2, mem_ctx)) {
ret = False;
}
@@ -776,7 +777,7 @@ BOOL torture_bench_oplock(struct torture_context *torture)
cli = talloc_array(mem_ctx, struct smbcli_state *, torture_nprocs);
- printf("Opening %d connections\n", torture_nprocs);
+ torture_comment(torture, "Opening %d connections\n", torture_nprocs);
for (i=0;i<torture_nprocs;i++) {
if (!torture_open_connection_ev(&cli[i], i, ev)) {
return False;
@@ -817,19 +818,19 @@ BOOL torture_bench_oplock(struct torture_context *torture)
This measures how fast we can pass on oplocks, and stresses
the oplock handling code
*/
- printf("Running for %d seconds\n", timelimit);
+ torture_comment(torture, "Running for %d seconds\n", timelimit);
while (timeval_elapsed(&tv) < timelimit) {
for (i=0;i<torture_nprocs;i++) {
NTSTATUS status;
status = smb_raw_open(cli[i]->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(torture, status, NT_STATUS_OK);
count++;
}
- printf("%.2f ops/second\r", count/timeval_elapsed(&tv));
+ torture_comment(torture, "%.2f ops/second\r", count/timeval_elapsed(&tv));
}
- printf("%.2f ops/second\n", count/timeval_elapsed(&tv));
+ torture_comment(torture, "%.2f ops/second\n", count/timeval_elapsed(&tv));
smb_raw_exit(cli[torture_nprocs-1]->session);
diff --git a/source4/torture/smbtorture.c b/source4/torture/smbtorture.c
index cc4c3e6b5b..5247abc14b 100644
--- a/source4/torture/smbtorture.c
+++ b/source4/torture/smbtorture.c
@@ -316,13 +316,25 @@ static void simple_comment (struct torture_context *test,
printf("%s", comment);
}
+static void simple_warning(struct torture_context *test,
+ const char *comment)
+{
+ fprintf(stderr, "WARNING: %s\n", comment);
+}
+
const static struct torture_ui_ops std_ui_ops = {
.comment = simple_comment,
+ .warning = simple_warning,
.suite_start = simple_suite_start,
.suite_finish = simple_suite_finish,
.test_result = simple_test_result
};
+static void subunit_init(struct torture_context *ctx)
+{
+ /* FIXME: register segv and bus handler */
+}
+
static void subunit_suite_start(struct torture_context *ctx,
struct torture_suite *suite)
{
@@ -354,7 +366,7 @@ static void subunit_test_result (struct torture_context *context,
break;
}
if (reason)
- printf(" [ %s ]", reason);
+ printf(" [\n%s\n]", reason);
printf("\n");
}
@@ -365,6 +377,7 @@ static void subunit_comment (struct torture_context *test,
}
const static struct torture_ui_ops subunit_ui_ops = {
+ .init = subunit_init,
.comment = subunit_comment,
.test_start = subunit_test_start,
.test_result = subunit_test_result,
diff --git a/source4/torture/torture.c b/source4/torture/torture.c
index e54efd72d0..4699df7d89 100644
--- a/source4/torture/torture.c
+++ b/source4/torture/torture.c
@@ -49,6 +49,9 @@ struct torture_context *torture_context_init(TALLOC_CTX *mem_ctx,
torture->ui_ops = ui_ops;
torture->returncode = true;
+ if (ui_ops->init)
+ ui_ops->init(torture);
+
return torture;
}
diff --git a/source4/torture/ui.c b/source4/torture/ui.c
index 6368d47991..d28c0e5bc2 100644
--- a/source4/torture/ui.c
+++ b/source4/torture/ui.c
@@ -40,6 +40,22 @@ void torture_comment(struct torture_context *context, const char *comment, ...)
talloc_free(tmp);
}
+void torture_warning(struct torture_context *context, const char *comment, ...)
+{
+ va_list ap;
+ char *tmp;
+
+ if (!context->ui_ops->warning)
+ return;
+
+ va_start(ap, comment);
+ tmp = talloc_vasprintf(context, comment, ap);
+
+ context->ui_ops->warning(context, tmp);
+
+ talloc_free(tmp);
+}
+
void torture_result(struct torture_context *context,
enum torture_result result, const char *fmt, ...)
{
diff --git a/source4/torture/ui.h b/source4/torture/ui.h
index 8c4d3b6729..329462ba28 100644
--- a/source4/torture/ui.h
+++ b/source4/torture/ui.h
@@ -40,7 +40,9 @@ enum torture_result {
*/
struct torture_ui_ops
{
+ void (*init) (struct torture_context *);
void (*comment) (struct torture_context *, const char *);
+ void (*warning) (struct torture_context *, const char *);
void (*suite_start) (struct torture_context *, struct torture_suite *);
void (*suite_finish) (struct torture_context *, struct torture_suite *);
void (*tcase_start) (struct torture_context *, struct torture_tcase *);
@@ -188,6 +190,7 @@ bool torture_run_test(struct torture_context *context,
struct torture_test *test);
void torture_comment(struct torture_context *test, const char *comment, ...) PRINTF_ATTRIBUTE(2,3);
+void torture_warning(struct torture_context *test, const char *comment, ...) PRINTF_ATTRIBUTE(2,3);
void torture_result(struct torture_context *test,
enum torture_result, const char *reason, ...) PRINTF_ATTRIBUTE(3,4);
@@ -263,6 +266,10 @@ void torture_result(struct torture_context *test,
torture_result(torture_ctx, TORTURE_FAIL, __location__": %s", cmt);\
return false; \
} while (0)
+#define torture_fail_goto(torture_ctx,label,cmt) do {\
+ torture_result(torture_ctx, TORTURE_FAIL, __location__": %s", cmt);\
+ goto label; \
+ } while (0)
#define torture_out stderr
diff --git a/testprogs/blackbox/test_ldb.sh b/testprogs/blackbox/test_ldb.sh
index 32e80e1995..2c2ac10fdb 100755
--- a/testprogs/blackbox/test_ldb.sh
+++ b/testprogs/blackbox/test_ldb.sh
@@ -21,8 +21,6 @@ check() {
return $status
}
-
-
check "RootDSE" bin/ldbsearch $CONFIGURATION $options --basedn='' -H $p://$SERVER -s base DUMMY=x dnsHostName highestCommittedUSN || failed=`expr $failed + 1`
echo "Getting defaultNamingContext"