1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

r21707: Finally merge my (long-living) perlselftest branch.

This changes the main selftest code to be in perl rather than in shell script.

The selftest script is now no longer a black box but a regular executable that takes
--help.

This adds the following features:

 * "make test TESTS=foo" will run only the tests that match the regex "foo"
 * ability to deal with expected failures. the suite will not warn about tests
   that fail and are known to fail, but will warn about other failing tests and
   tests that are succeeding tests but incorrectly marked as failing.
 * ability to print a summary with all failures at the end of the run

It also opens up the way to the following features, which I hope to implement later:
 * "environments", for example having a complete domains with DCs and domain members
 in a testenvironment
 * only set up smbd if necessary (not when running LOCAL tests, for example)
 * different mktestsetup scripts per target. except for the mktestsetup script, we can
   use the same infrastructure for samba 3 or windows.
(This used to be commit 38f867880b)
This commit is contained in:
Jelmer Vernooij 2007-03-05 21:28:55 +00:00 committed by Gerald (Jerry) Carter
parent d18afd6aee
commit 72d88d158a
26 changed files with 746 additions and 578 deletions

View File

@ -157,7 +157,7 @@ YAPP=$self->{config}->{YAPP}
GCOV=$self->{config}->{GCOV} GCOV=$self->{config}->{GCOV}
DEFAULT_TEST_TARGET=$self->{config}->{DEFAULT_TEST_TARGET} DEFAULT_TEST_OPTIONS=$self->{config}->{DEFAULT_TEST_OPTIONS}
__EOD__ __EOD__
); );

View File

@ -1,7 +1,7 @@
AC_ARG_ENABLE(socket-wrapper, AC_ARG_ENABLE(socket-wrapper,
[ --enable-socket-wrapper Turn on socket wrapper library (default=no)]) [ --enable-socket-wrapper Turn on socket wrapper library (default=no)])
DEFAULT_TEST_TARGET=test-noswrap DEFAULT_TEST_OPTIONS=
HAVE_SOCKET_WRAPPER=no HAVE_SOCKET_WRAPPER=no
if eval "test x$developer = xyes"; then if eval "test x$developer = xyes"; then
@ -10,9 +10,9 @@ fi
if eval "test x$enable_socket_wrapper = xyes"; then if eval "test x$enable_socket_wrapper = xyes"; then
AC_DEFINE(SOCKET_WRAPPER,1,[Use socket wrapper library]) AC_DEFINE(SOCKET_WRAPPER,1,[Use socket wrapper library])
DEFAULT_TEST_TARGET=test-swrap DEFAULT_TEST_OPTIONS=--socket-wrapper
HAVE_SOCKET_WRAPPER=yes HAVE_SOCKET_WRAPPER=yes
fi fi
AC_SUBST(DEFAULT_TEST_TARGET) AC_SUBST(DEFAULT_TEST_OPTIONS)
AC_SUBST(HAVE_SOCKET_WRAPPER) AC_SUBST(HAVE_SOCKET_WRAPPER)

View File

@ -282,49 +282,56 @@ realdistclean: distclean removebackup
-rm -f $(MANPAGES) -rm -f $(MANPAGES)
check:: test check:: test
test: $(DEFAULT_TEST_TARGET)
SELFTEST = builddir=$(builddir) srcdir=$(srcdir) \ SELFTEST = $(srcdir)/script/tests/selftest.pl --prefix=${selftest_prefix} --builddir=$(builddir) --srcdir=$(srcdir) --expected-failures=samba4-knownfail
$(srcdir)/script/tests/selftest.sh ${selftest_prefix}
test: all libraries
$(SELFTEST) $(DEFAULT_TEST_OPTIONS) $(TESTS) --immediate
testone: all libraries
$(SELFTEST) $(DEFAULT_TEST_OPTIONS) $(TESTS) --one
test-swrap: all libraries test-swrap: all libraries
$(SELFTEST) all SOCKET_WRAPPER $(SELFTEST) --socket-wrapper --immediate $(TESTS)
test-noswrap: all libraries test-noswrap: all libraries
$(SELFTEST) all $(SELFTEST) --immediate $(TESTS)
quicktestone: all
$(SELFTEST) --quick --socket-wrapper --one $(TESTS)
quicktest: all quicktest: all
$(SELFTEST) quick SOCKET_WRAPPER $(SELFTEST) --quick --socket-wrapper --immediate $(TESTS)
testenv: all libraries testenv: all libraries
$(SELFTEST) xterm SOCKET_WRAPPER $(srcdir)/script/tests/testenv.pl
valgrindtest: valgrindtest-quick valgrindtest: valgrindtest-quick
valgrindtest-quick: all valgrindtest-quick: all
SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \ 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" \ 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 valgrindtest-all: all libraries
SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \ 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" \ VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
$(SELFTEST) all SOCKET_WRAPPER $(SELFTEST) --immediate --socket-wrapper
valgrindtest-env: all libraries valgrindtest-env: all libraries
SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \ 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" \ 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: gdbtest-quick
gdbtest-quick: all gdbtest-quick: all
SMBD_VALGRIND="xterm -n smbd -e gdb --args " \ SMBD_VALGRIND="xterm -n smbd -e gdb --args " \
$(SELFTEST) quick SOCKET_WRAPPER $(SELFTEST) --immediate --quick --socket-wrapper
gdbtest-all: all libraries gdbtest-all: all libraries
SMBD_VALGRIND="xterm -n smbd -e gdb --args " \ SMBD_VALGRIND="xterm -n smbd -e gdb --args " \
$(SELFTEST) all SOCKET_WRAPPER $(SELFTEST) --immediate --socket-wrapper
wintest: all wintest: all
$(SELFTEST) win $(SELFTEST) win

View File

@ -1,3 +1,5 @@
LOCAL-REGISTRY-* LOCAL-REGISTRY/(nt4|ldb|dir) # Not implemented yet
LOCAL-RESOLVE-async LOCAL-RESOLVE/async
LOCAL-ICONV-next_codepoint() LOCAL-ICONV/next_codepoint()
BASE-DELAYWRITE/finfo update on close
RAW-OPLOCK/OPLOCK

View File

@ -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;

View File

@ -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;

0
source4/script/tests/mk-fedora-ds.sh Normal file → Executable file
View File

0
source4/script/tests/mk-keyblobs.sh Normal file → Executable file
View File

0
source4/script/tests/mk-openldap.sh Normal file → Executable file
View File

0
source4/script/tests/mktestsetup.sh.share_ldb Normal file → Executable file
View File

View File

@ -2,6 +2,107 @@
# Bootstrap Samba and run a number of tests against it. # Bootstrap Samba and run a number of tests against it.
# Copyright (C) 2005-2007 Jelmer Vernooij <jelmer@samba.org> # Copyright (C) 2005-2007 Jelmer Vernooij <jelmer@samba.org>
# Published under the GNU GPL, v3 or later. # 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 strict;
use warnings; use warnings;
@ -10,86 +111,163 @@ use File::Spec;
use Getopt::Long; use Getopt::Long;
use POSIX; use POSIX;
use Cwd; use Cwd;
use lib "$RealBin";
use Samba4;
use SocketWrapper;
sub slapd_start($$) { my $opt_help = 0;
my ($conf, $uri) = @_; my $opt_target = "samba4";
my $oldpath = $ENV{PATH}; my $opt_quick = 0;
$ENV{PATH} = "/usr/local/sbin:/usr/sbin:/sbin:$ENV{PATH}"; my $opt_socket_wrapper = 0;
# running slapd in the background means it stays in the same process group, so it can be my $opt_socket_wrapper_pcap = undef;
# killed by timelimit my $opt_one = 0;
system("slapd -d0 -f $conf -h $uri &"); my $opt_immediate = 0;
$ENV{PATH} = $oldpath; my $opt_expected_failures = undef;
return $? >> 8; 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) = @_; my $fullname = shift;
return 0 if ( -p $test_fifo );
if (defined($socket_wrapper_dir)) { foreach (@expected_failures) {
if ( -d $socket_wrapper_dir ) { return 1 if $fullname =~ /^$_$/;
unlink <$socket_wrapper_dir/*>;
} else {
mkdir($socket_wrapper_dir);
}
} }
unlink($test_fifo); return 0;
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";
}
close(LOG);
exit $exit;
}
print "DONE\n";
return $pid;
} }
sub teststatus($$) { sub run_test_buildfarm($$$$)
my ($name, $failed) = @_; {
my ($name, $cmd, $i, $suitestotal) = @_;
print "--==--==--==--==--==--==--==--==--==--==--\n";
print "Running test $name (level 0 stdout)\n";
print "--==--==--==--==--==--==--==--==--==--==--\n";
system("date");
print "TEST STATUS: $failed failures\n"; my $expected_ret = 1;
if ($failed > 0) { my $open_tests = {};
print <<EOF open(RESULT, "$cmd|");
************************ while (<RESULT>) {
*** TESTSUITE FAILED *** print;
************************ if (/^test: (.+)\n/) {
EOF $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};
}
}
}
print "COMMAND: $cmd\n";
foreach (keys %$open_tests) {
print "$_ was started but never finished!\n";
$statistics->{TESTS_ERROR}++;
}
my $ret = close(RESULT);
print "==========================================\n";
if ($ret == $expected_ret) {
print "TEST PASSED: $name\n";
} else {
print "TEST FAILED: $name (status $ret)\n";
}
print "==========================================\n";
}
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() sub ShowHelp()
@ -97,51 +275,60 @@ sub ShowHelp()
print "Samba test runner print "Samba test runner
Copyright (C) Jelmer Vernooij <jelmer\@samba.org> Copyright (C) Jelmer Vernooij <jelmer\@samba.org>
Usage: $Script PREFIX Usage: $Script [OPTIONS] PREFIX
Generic options: Generic options:
--help this help page --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 --target=samba4|samba3|win Samba version to target
--socket-wrapper-pcap=FILE save traffic to pcap file
--socket-wrapper enable socket wrapper --socket-wrapper enable socket wrapper
--expected-failures=FILE specify list of tests that is guaranteed to fail
Behaviour:
--quick run quick overall test --quick run quick overall test
--one abort when the first test fails --one abort when the first test fails
--immediate print test output for failed tests during run
--verbose be verbose
"; ";
exit(0); 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 ( my $result = GetOptions (
'help|h|?' => \$opt_help, 'help|h|?' => \$opt_help,
'target' => \$opt_target, 'target=s' => \$opt_target,
'prefix=s' => \$prefix,
'socket-wrapper' => \$opt_socket_wrapper, 'socket-wrapper' => \$opt_socket_wrapper,
'socket-wrapper-pcap=s' => \$opt_socket_wrapper_pcap,
'quick' => \$opt_quick, '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) if (not $result);
exit(1);
}
ShowHelp() if ($opt_help); ShowHelp() if ($opt_help);
ShowHelp() if ($#ARGV < 0);
my $prefix = shift; my $tests = shift;
my $torture_maxtime = $ENV{TORTURE_MAXTIME}; my $torture_maxtime = $ENV{TORTURE_MAXTIME};
unless (defined($torture_maxtime)) { unless (defined($torture_maxtime)) {
$torture_maxtime = 1200; $torture_maxtime = 1200;
} }
# disable rpc validation when using valgrind - its way too slow # quick hack to disable rpc validation when using valgrind - its way too slow
my $valgrind = $ENV{VALGRIND}; unless (defined($ENV{VALGRIND})) {
my $validate = undef; $ENV{VALIDATE} = "validate";
unless (defined($valgrind)) {
$validate = "validate";
} }
my $old_pwd = "$RealBin/../.."; my $old_pwd = "$RealBin/../..";
@ -150,10 +337,6 @@ my $ldap = (defined($ENV{TEST_LDAP}) and ($ENV{TEST_LDAP} eq "yes"))?1:0;
$prefix =~ s+//+/+; $prefix =~ s+//+/+;
$ENV{PREFIX} = $prefix; $ENV{PREFIX} = $prefix;
my $srcdir = "$RealBin/../..";
if (defined($ENV{srcdir})) {
$srcdir = $ENV{srcdir};
}
$ENV{SRCDIR} = $srcdir; $ENV{SRCDIR} = $srcdir;
my $bindir = "$srcdir/bin"; my $bindir = "$srcdir/bin";
@ -161,6 +344,8 @@ my $setupdir = "$srcdir/setup";
my $testsdir = "$srcdir/script/tests"; my $testsdir = "$srcdir/script/tests";
my $tls_enabled = not $opt_quick; 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{TLS_ENABLED} = ($tls_enabled?"yes":"no");
$ENV{LD_LDB_MODULE_PATH} = "$old_pwd/bin/modules/ldb"; $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{PKG_CONFIG_PATH} = "$old_pwd/bin/pkgconfig:$ENV{PKG_CONFIG_PATH}";
$ENV{PATH} = "$old_pwd/bin:$ENV{PATH}"; $ENV{PATH} = "$old_pwd/bin:$ENV{PATH}";
my @torture_options = ();
my $testenv_vars = {};
if ($opt_target eq "samba4") { if ($opt_target eq "samba4") {
print "PROVISIONING..."; $testenv_vars = Samba4::provision($prefix);
open(IN, "$RealBin/mktestsetup.sh $prefix|") or die("Unable to setup");
while (<IN>) {
next unless (/^([A-Z_]+)=(.*)$/);
$ENV{$1} = $2;
}
close(IN);
} elsif ($opt_target eq "win") { } elsif ($opt_target eq "win") {
die ("Windows tests will not run without root privileges.") die ("Windows tests will not run without root privileges.")
if (`whoami` ne "root"); if (`whoami` ne "root");
@ -196,77 +379,82 @@ if ($opt_target eq "samba4") {
die ("$ENV{WINTESTCONF} could not be read.") if (! -r $ENV{WINTESTCONF}); die ("$ENV{WINTESTCONF} could not be read.") if (! -r $ENV{WINTESTCONF});
$ENV{WINTEST_DIR}="$ENV{SRCDIR}/script/tests/win"; $ENV{WINTEST_DIR}="$ENV{SRCDIR}/script/tests/win";
} elsif ($opt_target eq "none") {
} else { } else {
die("unknown target `$opt_target'"); die("unknown target `$opt_target'");
} }
my $socket_wrapper_dir = undef; foreach (keys %$testenv_vars) { $ENV{$_} = $testenv_vars->{$_}; }
if ( $opt_socket_wrapper) if ($opt_socket_wrapper_pcap) {
$ENV{SOCKET_WRAPPER_PCAP_FILE} = $opt_socket_wrapper_pcap;
# Socket wrapper pcap implies socket wrapper
$opt_socket_wrapper = 1;
}
my $socket_wrapper_dir;
if ($opt_socket_wrapper)
{ {
$socket_wrapper_dir = "$prefix/w"; $socket_wrapper_dir = SocketWrapper::setup_dir("$prefix/w");
$ENV{SOCKET_WRAPPER_DIR} = $socket_wrapper_dir; print "SOCKET_WRAPPER_DIR=$socket_wrapper_dir\n";
print "SOCKET_WRAPPER_DIR=$ENV{SOCKET_WRAPPER_DIR}\n";
} else {
print "NOT USING SOCKET_WRAPPER\n";
} }
# Start slapd before smbd # Start slapd before smbd
if ($ldap) { 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..."; print "LDAP PROVISIONING...";
system("$bindir/smbscript $setupdir/provision $ENV{PROVISION_OPTIONS} --ldap-backend=$ENV{LDAPI}") or Samba4::provision_ldap($bindir, $setupdir);
die("LDAP PROVISIONING failed: $bindir/smbscript $setupdir/provision $ENV{PROVISION_OPTIONS} --ldap-backend=$ENV{LDAPI}");
# LDAP is slow # LDAP is slow
$torture_maxtime *= 2; $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"; my $test_fifo = "$prefix/smbd_test.fifo";
$ENV{SMBD_TEST_FIFO} = $test_fifo; $ENV{SMBD_TEST_FIFO} = $test_fifo;
$ENV{SMBD_TEST_LOG} = "$prefix/smbd_test.log"; $ENV{SMBD_TEST_LOG} = "$prefix/smbd_test.log";
$ENV{SOCKET_WRAPPER_DEFAULT_IFACE} = 1; SocketWrapper::set_default_iface(1);
my $max_time = 5400; my $max_time = 5400;
if (defined($ENV{SMBD_MAX_TIME})) { if (defined($ENV{SMBD_MAX_TIME})) {
$max_time = $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});
$ENV{SOCKET_WRAPPER_DEFAULT_IFACE} = 6; SocketWrapper::set_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 = ("--option=interfaces=$ENV{TORTURE_INTERFACES} $ENV{CONFIGURATION}"); 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");
push (@torture_options, $ENV{CONFIGURATION});
# ensure any one smbtorture call doesn't run too long # ensure any one smbtorture call doesn't run too long
push (@torture_options, "--maximum-runtime=$torture_maxtime"); push (@torture_options, "--maximum-runtime=$torture_maxtime");
push (@torture_options, "--target=$opt_target"); push (@torture_options, "--target=$opt_target");
push (@torture_options, "--option=torture:progress=no") push (@torture_options, "--option=torture:progress=no") if ($from_build_farm);
if (defined($ENV{RUN_FROM_BUILD_FARM}) and $ENV{RUN_FROM_BUILD_FARM} eq "yes"); push (@torture_options, "--format=subunit");
push (@torture_options, "--option=torture:quick=yes") if ($opt_quick);
$ENV{TORTURE_OPTIONS} = join(' ', @torture_options); $ENV{TORTURE_OPTIONS} = join(' ', @torture_options);
print "OPTIONS $ENV{TORTURE_OPTIONS}\n"; print "OPTIONS $ENV{TORTURE_OPTIONS}\n";
my $start = time();
open(DATA, ">$test_fifo"); 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 = (); my @todo = ();
if ($opt_target eq "win") { if ($opt_target eq "win") {
@ -283,27 +471,35 @@ if ($opt_target eq "win") {
$name =~ s/\n//g; $name =~ s/\n//g;
my $cmdline = <IN>; my $cmdline = <IN>;
$cmdline =~ s/\n//g; $cmdline =~ s/\n//g;
push (@todo, [$name, $cmdline]); push (@todo, [$name, $cmdline])
if (not defined($tests) or $name =~ /$tests/);
} else { } else {
print; 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; my $i = 0;
$| = 1; $| = 1;
delete $ENV{DOMAIN};
foreach (@todo) { foreach (@todo) {
$i = $i + 1; $i++;
my $err = ""; my $cmd = $$_[1];
if ($totalfailed > 0) { $err = ", $totalfailed errors"; } $cmd =~ s/([\(\)])/\\$1/g;
printf "[$i/$total in " . (time() - $start)."s$err] $$_[0]\n"; my $name = $$_[0];
my $ret = system("$$_[1] >/dev/null 2>/dev/null"); if ($from_build_farm) {
if ($ret != 0) { run_test_buildfarm($name, $cmd, $i, $suitestotal);
$totalfailed++; } else {
exit(1) if ($opt_one); run_test_plain($name, $cmd, $i, $suitestotal);
} }
} }
@ -311,6 +507,8 @@ print "\n";
close(DATA); close(DATA);
sleep(2);
my $failed = $? >> 8; my $failed = $? >> 8;
if (-f "$ENV{PIDDIR}/smbd.pid" ) { if (-f "$ENV{PIDDIR}/smbd.pid" ) {
@ -319,15 +517,37 @@ if (-f "$ENV{PIDDIR}/smbd.pid" ) {
close(IN); close(IN);
} }
if ($ldap) { Samba4::slapd_stop() if ($ldap);
open(IN, "<$ENV{PIDDIR}/slapd.pid") or die("unable to open slapd pid file");
kill 9, <IN>;
close(IN);
}
my $end=time(); my $end = time();
print "DURATION: " . ($end-$start). " seconds\n"; my $duration = ($end-$start);
print "$totalfailed failures\n"; 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 # if there were any valgrind failures, show them
foreach (<$prefix/valgrind.log*>) { foreach (<$prefix/valgrind.log*>) {
@ -340,6 +560,4 @@ foreach (<$prefix/valgrind.log*>) {
} }
} }
teststatus($Script, $failed); exit $numfailed;
exit $failed;

View File

@ -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

View File

@ -24,16 +24,11 @@ PATH=bin:$PATH
export PATH export PATH
testit "base.js" $SCRIPTDIR/base.js $CONFIGURATION testit "base.js" $SCRIPTDIR/base.js $CONFIGURATION
testit "samr.js" "$SCRIPTDIR/samr.js" $CONFIGURATION ncalrpc: -U$USERNAME%$PASSWORD testit "samr.js" "$SCRIPTDIR/samr.js" $CONFIGURATION ncalrpc: -U$USERNAME%$PASSWORD
testit "echo.js" "$SCRIPTDIR/echo.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 "ejsnet.js" $SCRIPTDIR/ejsnet.js $CONFIGURATION -U$USERNAME%$PASSWORD $DOMAIN ejstestuser
testit "ldb.js" $SCRIPTDIR/ldb.js `pwd` $CONFIGURATION testit "ldb.js" $SCRIPTDIR/ldb.js `pwd` $CONFIGURATION
testit "samba3sam.js" $SCRIPTDIR/samba3sam.js $CONFIGURATION `pwd` $DATADIR/samba3/ testit "samba3sam.js" $SCRIPTDIR/samba3sam.js $CONFIGURATION `pwd` $DATADIR/samba3/
testit "winreg" scripting/bin/winreg $CONFIGURATION ncalrpc: 'HKLM' -U$USERNAME%$PASSWORD testit "winreg" scripting/bin/winreg $CONFIGURATION ncalrpc: 'HKLM' -U$USERNAME%$PASSWORD
testok $0 $failed testok $0 $failed

View File

@ -15,7 +15,6 @@ PASSWORD="$3"
incdir=`dirname $0` incdir=`dirname $0`
. $incdir/test_functions.sh . $incdir/test_functions.sh
p=ldap p=ldap
for options in "" "--option=socket:testnonblock=true" "-U$USERNAME%$PASSWORD --option=socket:testnonblock=true" "-U$USERNAME%$PASSWORD"; do 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 testit "TESTING PROTOCOL $p with options $options" ../testprogs/blackbox/test_ldb.sh $p $SERVER $options
@ -37,11 +36,11 @@ done
test "$TORTURE_QUICK" = "yes" || { test "$TORTURE_QUICK" = "yes" || {
LDBDIR=lib/ldb LDBDIR=lib/ldb
export LDBDIR export LDBDIR
testit "ldb tests" $LDBDIR/tests/test-tdb.sh testit "ldb" $LDBDIR/tests/test-tdb.sh
} }
SCRIPTDIR=../testprogs/ejs 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 testok $0 $failed

View File

@ -23,9 +23,7 @@ testit "nmblookup $SERVER" bin/nmblookup $TORTURE_OPTIONS $SERVER
NBT_TESTS="NBT-REGISTER NBT-WINS" NBT_TESTS="NBT-REGISTER NBT-WINS"
NBT_TESTS="$NBT_TESTS NBT-WINSREPLICATION" NBT_TESTS="$NBT_TESTS NBT-WINSREPLICATION"
# if [ "$TORTURE_QUICK"x != "yes"x ]; then # NBT_TESTS="$NBT_TESTS NBT-WINSREPLICATION-OWNED"
# NBT_TESTS="$NBT_TESTS NBT-WINSREPLICATION-OWNED"
# fi
NBT_TESTS="$NBT_TESTS NET-API-LOOKUP NET-API-LOOKUPHOST NET-API-LOOKUPPDC" NBT_TESTS="$NBT_TESTS NET-API-LOOKUP NET-API-LOOKUPHOST NET-API-LOOKUPPDC"
for f in $NBT_TESTS; do for f in $NBT_TESTS; do

32
source4/script/tests/testenv.pl Executable file
View File

@ -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);

View File

@ -1,2 +0,0 @@
#!/bin/sh
$SRCDIR/script/tests/test_net.sh $SERVER $USERNAME $PASSWORD $DOMAIN

View File

@ -1,6 +1,4 @@
#!/bin/sh #!/bin/sh
TORTURE_OPTIONS="$TORTURE_OPTIONS --option=torture:quick=yes"
export TORTURE_OPTIONS
TORTURE_QUICK="yes" TORTURE_QUICK="yes"
export TORTURE_QUICK export TORTURE_QUICK

0
source4/script/tests/tests_xterm.sh Normal file → Executable file
View File

View File

@ -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); fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum1 == -1) { if (fnum1 == -1) {
ret = False; ret = False;
torture_result(tctx, TORTURE_FAIL, __location__": unable to open %s", fname);
goto done; 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); status = smb_raw_fileinfo(cli->tree, tctx, &finfo1);
if (!NT_STATUS_IS_OK(status)) { if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
ret = False; ret = False;
torture_result(tctx, TORTURE_FAIL, __location__": fileinfo failed: %s", nt_errstr(status));
goto done; 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); written = smbcli_write(cli->tree, fnum1, 0, "x", 0, 1);
if (written != 1) { if (written != 1) {
torture_comment(tctx, "(%s) written gave %d - should have been 1\n", torture_result(tctx, TORTURE_FAIL, __location__": written gave %d - should have been 1", (int)written);
__location__, (int)written);
ret = False; ret = False;
goto done; goto done;
} }
fnum2 = smbcli_open(cli2->tree, fname, O_RDWR, DENY_NONE); fnum2 = smbcli_open(cli2->tree, fname, O_RDWR, DENY_NONE);
if (fnum2 == -1) { if (fnum2 == -1) {
torture_comment(tctx, "(%s) failed to open 2nd time - %s\n", torture_result(tctx, TORTURE_FAIL, __location__": failed to open 2nd time - %s",
__location__, smbcli_errstr(cli2->tree)); smbcli_errstr(cli2->tree));
ret = False; ret = False;
goto done; 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); written = smbcli_write(cli2->tree, fnum2, 0, "x", 0, 1);
if (written != 1) { if (written != 1) {
torture_comment(tctx, "(%s) written gave %d - should have been 1\n", torture_result(tctx, TORTURE_FAIL, __location__": written gave %d - should have been 1",
__location__, (int)written); (int)written);
ret = False; ret = False;
goto done; 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); status = smb_raw_pathinfo(cli2->tree, tctx, &finfo2);
if (!NT_STATUS_IS_OK(status)) { if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("(%s) fileinfo failed: %s\n", torture_result(tctx, TORTURE_FAIL, __location__": fileinfo failed: %s",
__location__, nt_errstr(status))); nt_errstr(status));
ret = False; ret = False;
goto done; goto done;
} }
if (finfo1.basic_info.out.create_time != if (finfo1.basic_info.out.create_time !=
finfo2.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; ret = False;
goto done; goto done;
} }
if (finfo1.basic_info.out.access_time != if (finfo1.basic_info.out.access_time !=
finfo2.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; ret = False;
goto done; goto done;
} }
if (finfo1.basic_info.out.write_time != if (finfo1.basic_info.out.write_time !=
finfo2.basic_info.out.write_time) { finfo2.basic_info.out.write_time) {
torture_comment(tctx, "(%s) write_time changed\n", __location__); torture_result(tctx, TORTURE_FAIL, __location__": write_time changed:\n"
torture_comment(tctx, "write time conn 1 = %s, conn 2 = %s\n", "write time conn 1 = %s, conn 2 = %s",
nt_time_string(tctx, finfo1.basic_info.out.write_time), nt_time_string(tctx, finfo1.basic_info.out.write_time),
nt_time_string(tctx, finfo2.basic_info.out.write_time)); nt_time_string(tctx, finfo2.basic_info.out.write_time));
ret = False; 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 != if (finfo1.basic_info.out.change_time !=
finfo2.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; ret = False;
goto done; 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); status = smb_raw_pathinfo(cli->tree, tctx, &finfo2);
if (!NT_STATUS_IS_OK(status)) { 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; ret = False;
goto done; goto done;
} }

View File

@ -28,15 +28,15 @@
#define CHECK_VAL(v, correct) do { \ #define CHECK_VAL(v, correct) do { \
if ((v) != (correct)) { \ if ((v) != (correct)) { \
printf("(%d) wrong value for %s got 0x%x - should be 0x%x\n", \ torture_result(tctx, TORTURE_FAIL, __location__": wrong value for %s got 0x%x - should be 0x%x", \
__LINE__, #v, (int)v, (int)correct); \ #v, (int)v, (int)correct); \
ret = False; \ ret = False; \
}} while (0) }} while (0)
#define CHECK_STATUS(status, correct) do { \ #define CHECK_STATUS(tctx, status, correct) do { \
if (!NT_STATUS_EQUAL(status, correct)) { \ if (!NT_STATUS_EQUAL(status, correct)) { \
printf("(%d) Incorrect status %s - should be %s\n", \ torture_result(tctx, TORTURE_FAIL, __location__": Incorrect status %s - should be %s", \
__LINE__, nt_errstr(status), nt_errstr(correct)); \ nt_errstr(status), nt_errstr(correct)); \
ret = False; \ ret = False; \
goto done; \ goto done; \
}} while (0) }} while (0)
@ -126,7 +126,8 @@ static BOOL oplock_handler_close(struct smbcli_transport *transport, uint16_t ti
/* /*
test oplock ops 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"; const char *fname = BASEDIR "\\test_oplock.dat";
NTSTATUS status; 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.security_flags = 0;
io.ntcreatex.in.fname = fname; 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); ZERO_STRUCT(break_info);
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK; io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK;
status = smb_raw_open(cli1->tree, mem_ctx, &io); 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; fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, EXCLUSIVE_OPLOCK_RETURN); 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); 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.count, 0);
CHECK_VAL(break_info.failures, 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.pattern = fname;
unl.unlink.in.attrib = 0; unl.unlink.in.attrib = 0;
status = smb_raw_unlink(cli2->tree, &unl); 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.count, 0);
CHECK_VAL(break_info.failures, 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 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); ZERO_STRUCT(break_info);
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
NTCREATEX_FLAGS_REQUEST_OPLOCK | NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli1->tree, mem_ctx, &io); 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; fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN); 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.pattern = fname;
unl.unlink.in.attrib = 0; unl.unlink.in.attrib = 0;
status = smb_raw_unlink(cli2->tree, &unl); 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.count, 1);
CHECK_VAL(break_info.fnum, fnum); CHECK_VAL(break_info.fnum, fnum);
CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II); CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II);
CHECK_VAL(break_info.failures, 0); 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); ZERO_STRUCT(break_info);
status = smb_raw_unlink(cli2->tree, &unl); 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.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); smbcli_write(cli1->tree, fnum, 0, &c, 0, 1);
msleep(100); msleep(100);
smbcli_write(cli1->tree, fnum, 0, &c, 1, 1); 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); smbcli_close(cli1->tree, fnum);
printf("open with batch oplock\n"); torture_comment(tctx, "open with batch oplock\n");
ZERO_STRUCT(break_info); ZERO_STRUCT(break_info);
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
NTCREATEX_FLAGS_REQUEST_OPLOCK | NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli1->tree, mem_ctx, &io); 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; fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN); 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); smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_none, cli1->tree);
unl.unlink.in.pattern = fname; unl.unlink.in.pattern = fname;
unl.unlink.in.attrib = 0; unl.unlink.in.attrib = 0;
status = smb_raw_unlink(cli2->tree, &unl); 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.count, 1);
CHECK_VAL(break_info.fnum, fnum); CHECK_VAL(break_info.fnum, fnum);
CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II); CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II);
CHECK_VAL(break_info.failures, 0); 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); ZERO_STRUCT(break_info);
status = smb_raw_unlink(cli2->tree, &unl); 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.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); smbcli_write(cli1->tree, fnum, 0, &c, 0, 1);
msleep(100); msleep(100);
smbcli_write(cli1->tree, fnum, 0, &c, 1, 1); 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); 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); ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_close, cli1->tree); smbcli_oplock_handler(cli1->transport, oplock_handler_close, cli1->tree);
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
NTCREATEX_FLAGS_REQUEST_OPLOCK | NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli1->tree, mem_ctx, &io); 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; fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN); 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; unl.unlink.in.attrib = 0;
ZERO_STRUCT(break_info); ZERO_STRUCT(break_info);
status = smb_raw_unlink(cli2->tree, &unl); 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.count, 1);
CHECK_VAL(break_info.fnum, fnum); CHECK_VAL(break_info.fnum, fnum);
CHECK_VAL(break_info.level, 1); CHECK_VAL(break_info.level, 1);
CHECK_VAL(break_info.failures, 0); 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); ZERO_STRUCT(break_info);
smbcli_close(cli1->tree, fnum); smbcli_close(cli1->tree, fnum);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); 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_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli1->tree, mem_ctx, &io); 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; fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN); 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.offset = 0;
rd.read.in.remaining = 0; rd.read.in.remaining = 0;
status = smb_raw_read(cli1->tree, &rd); 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.count, 0);
CHECK_VAL(break_info.failures, 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); ZERO_STRUCT(break_info);
smbcli_close(cli1->tree, fnum); smbcli_close(cli1->tree, fnum);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); 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_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli1->tree, mem_ctx, &io); 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; fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN); 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; io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED;
status = smb_raw_open(cli2->tree, mem_ctx, &io); 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.count, 1);
CHECK_VAL(break_info.fnum, fnum); 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); 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); ZERO_STRUCT(break_info);
smbcli_close(cli1->tree, fnum); smbcli_close(cli1->tree, fnum);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); 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_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli1->tree, mem_ctx, &io); 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; fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN); CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
ZERO_STRUCT(break_info); ZERO_STRUCT(break_info);
status = smb_raw_open(cli2->tree, mem_ctx, &io); 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; fnum2 = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN); 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); CHECK_VAL(break_info.failures, 0);
ZERO_STRUCT(break_info); 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); smbcli_write(cli1->tree, fnum, 0, &c, 0, 1);
msleep(100); msleep(100);
smbcli_write(cli1->tree, fnum, 0, &c, 1, 1); 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(cli1->tree, fnum);
smbcli_close(cli2->tree, fnum2); 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); ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_close, cli1->tree); 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_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli1->tree, mem_ctx, &io); 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; fnum2 = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN); 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_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli2->tree, mem_ctx, &io); 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; fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN); 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); smbcli_close(cli2->tree, fnum);
printf("open with batch oplock\n"); torture_comment(tctx, "open with batch oplock\n");
ZERO_STRUCT(break_info); ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); 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_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli1->tree, mem_ctx, &io); 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; fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN); CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
ZERO_STRUCT(break_info); 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 | io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
NTCREATEX_FLAGS_REQUEST_OPLOCK | NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
io.ntcreatex.in.access_mask = SEC_FILE_READ_ATTRIBUTE|SEC_FILE_WRITE_ATTRIBUTE|SEC_STD_SYNCHRONIZE; 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); 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; fnum2 = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, NO_OPLOCK_RETURN); CHECK_VAL(io.ntcreatex.out.oplock_level, NO_OPLOCK_RETURN);
CHECK_VAL(break_info.count, 0); 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_close(cli2->tree, fnum2);
smbcli_unlink(cli1->tree, fname); 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 | io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
NTCREATEX_FLAGS_REQUEST_OPLOCK | 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.access_mask = SEC_FILE_READ_ATTRIBUTE|SEC_FILE_WRITE_ATTRIBUTE|SEC_STD_SYNCHRONIZE;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
status = smb_raw_open(cli1->tree, mem_ctx, &io); 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; fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN); 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); ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); 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.access_mask = SEC_RIGHTS_FILE_ALL;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
status = smb_raw_open(cli2->tree, mem_ctx, &io); 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; fnum2 = io.ntcreatex.out.file.fnum;
CHECK_VAL(break_info.count, 1); CHECK_VAL(break_info.count, 1);
CHECK_VAL(break_info.fnum, fnum); 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); CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN);
smbcli_close(cli2->tree, fnum2); 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); ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_levelII, cli2->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.access_mask = SEC_RIGHTS_FILE_ALL;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
status = smb_raw_open(cli2->tree, mem_ctx, &io); 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; fnum2 = io.ntcreatex.out.file.fnum;
CHECK_VAL(break_info.count, 0); CHECK_VAL(break_info.count, 0);
CHECK_VAL(break_info.failures, 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); 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); smbcli_write(cli2->tree, fnum2, 0, &c, 0, 1);
/* Now the oplock break request comes in. But right now we can't /* 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); ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); 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.flags = NTCREATEX_FLAGS_EXTENDED;
io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ| 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; NTCREATEX_SHARE_ACCESS_DELETE;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
status = smb_raw_open(cli1->tree, mem_ctx, &io); 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; fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(break_info.count, 0); CHECK_VAL(break_info.count, 0);
CHECK_VAL(break_info.failures, 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; NTCREATEX_SHARE_ACCESS_DELETE;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
status = smb_raw_open(cli2->tree, mem_ctx, &io); 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; fnum2 = io.ntcreatex.out.file.fnum;
CHECK_VAL(break_info.count, 0); CHECK_VAL(break_info.count, 0);
CHECK_VAL(break_info.failures, 0); CHECK_VAL(break_info.failures, 0);
CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN); 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; union smb_write wr;
wr.write.level = RAW_WRITE_WRITE; 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.remaining = 0;
wr.write.in.data = (const uint8_t *)"x"; wr.write.in.data = (const uint8_t *)"x";
status = smb_raw_write(cli1->tree, &wr); 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 /* 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.remaining = 0;
wr.write.in.data = (const uint8_t *)"x"; wr.write.in.data = (const uint8_t *)"x";
status = smb_raw_write(cli1->tree, &wr); 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); 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); smbcli_unlink(cli1->tree, fname);
/* Test if a set-eof on pathname breaks an exclusive oplock. */ /* 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); ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); 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; NTCREATEX_SHARE_ACCESS_DELETE;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
status = smb_raw_open(cli1->tree, mem_ctx, &io); 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; fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(break_info.count, 0); CHECK_VAL(break_info.count, 0);
CHECK_VAL(break_info.failures, 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); 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.count, 1);
CHECK_VAL(break_info.failures, 0); CHECK_VAL(break_info.failures, 0);
CHECK_VAL(break_info.level, 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); smbcli_unlink(cli1->tree, fname);
/* Test if a set-allocation size on pathname breaks an exclusive oplock. */ /* 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); ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); 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; NTCREATEX_SHARE_ACCESS_DELETE;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
status = smb_raw_open(cli1->tree, mem_ctx, &io); 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; fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(break_info.count, 0); CHECK_VAL(break_info.count, 0);
CHECK_VAL(break_info.failures, 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); 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.count, 1);
CHECK_VAL(break_info.failures, 0); CHECK_VAL(break_info.failures, 0);
CHECK_VAL(break_info.level, 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_close(cli2->tree, fnum2);
smbcli_unlink(cli1->tree, fname); smbcli_unlink(cli1->tree, fname);
printf("open with batch oplock\n"); torture_comment(tctx, "open with batch oplock\n");
ZERO_STRUCT(break_info); ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); 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; NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
status = smb_raw_open(cli1->tree, mem_ctx, &io); 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; fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN); CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
ZERO_STRUCT(break_info); 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 | io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
NTCREATEX_FLAGS_REQUEST_OPLOCK | 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.access_mask = SEC_FILE_READ_ATTRIBUTE|SEC_FILE_WRITE_ATTRIBUTE|SEC_STD_SYNCHRONIZE;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OVERWRITE; io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OVERWRITE;
status = smb_raw_open(cli2->tree, mem_ctx, &io); 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; fnum2 = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN); CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN);
CHECK_VAL(break_info.count, 1); 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_close(cli2->tree, fnum2);
smbcli_unlink(cli1->tree, fname); smbcli_unlink(cli1->tree, fname);
printf("open with batch oplock\n"); torture_comment(tctx, "open with batch oplock\n");
ZERO_STRUCT(break_info); ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree); 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; NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
status = smb_raw_open(cli1->tree, mem_ctx, &io); 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; fnum = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN); CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
ZERO_STRUCT(break_info); 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 | io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
NTCREATEX_FLAGS_REQUEST_OPLOCK | 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.access_mask = SEC_FILE_READ_ATTRIBUTE|SEC_FILE_WRITE_ATTRIBUTE|SEC_STD_SYNCHRONIZE;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OVERWRITE; io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OVERWRITE;
status = smb_raw_open(cli2->tree, mem_ctx, &io); 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; fnum2 = io.ntcreatex.out.file.fnum;
CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN); CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN);
CHECK_VAL(break_info.count, 1); 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"); mem_ctx = talloc_init("torture_raw_oplock");
if (!test_oplock(cli1, cli2, mem_ctx)) { if (!test_oplock(torture, cli1, cli2, mem_ctx)) {
ret = False; ret = False;
} }
@ -776,7 +777,7 @@ BOOL torture_bench_oplock(struct torture_context *torture)
cli = talloc_array(mem_ctx, struct smbcli_state *, torture_nprocs); 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++) { for (i=0;i<torture_nprocs;i++) {
if (!torture_open_connection_ev(&cli[i], i, ev)) { if (!torture_open_connection_ev(&cli[i], i, ev)) {
return False; 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 This measures how fast we can pass on oplocks, and stresses
the oplock handling code 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) { while (timeval_elapsed(&tv) < timelimit) {
for (i=0;i<torture_nprocs;i++) { for (i=0;i<torture_nprocs;i++) {
NTSTATUS status; NTSTATUS status;
status = smb_raw_open(cli[i]->tree, mem_ctx, &io); status = smb_raw_open(cli[i]->tree, mem_ctx, &io);
CHECK_STATUS(status, NT_STATUS_OK); CHECK_STATUS(torture, status, NT_STATUS_OK);
count++; 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); smb_raw_exit(cli[torture_nprocs-1]->session);

View File

@ -316,13 +316,25 @@ static void simple_comment (struct torture_context *test,
printf("%s", comment); 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 = { const static struct torture_ui_ops std_ui_ops = {
.comment = simple_comment, .comment = simple_comment,
.warning = simple_warning,
.suite_start = simple_suite_start, .suite_start = simple_suite_start,
.suite_finish = simple_suite_finish, .suite_finish = simple_suite_finish,
.test_result = simple_test_result .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, static void subunit_suite_start(struct torture_context *ctx,
struct torture_suite *suite) struct torture_suite *suite)
{ {
@ -354,7 +366,7 @@ static void subunit_test_result (struct torture_context *context,
break; break;
} }
if (reason) if (reason)
printf(" [ %s ]", reason); printf(" [\n%s\n]", reason);
printf("\n"); printf("\n");
} }
@ -365,6 +377,7 @@ static void subunit_comment (struct torture_context *test,
} }
const static struct torture_ui_ops subunit_ui_ops = { const static struct torture_ui_ops subunit_ui_ops = {
.init = subunit_init,
.comment = subunit_comment, .comment = subunit_comment,
.test_start = subunit_test_start, .test_start = subunit_test_start,
.test_result = subunit_test_result, .test_result = subunit_test_result,

View File

@ -49,6 +49,9 @@ struct torture_context *torture_context_init(TALLOC_CTX *mem_ctx,
torture->ui_ops = ui_ops; torture->ui_ops = ui_ops;
torture->returncode = true; torture->returncode = true;
if (ui_ops->init)
ui_ops->init(torture);
return torture; return torture;
} }

View File

@ -40,6 +40,22 @@ void torture_comment(struct torture_context *context, const char *comment, ...)
talloc_free(tmp); 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, void torture_result(struct torture_context *context,
enum torture_result result, const char *fmt, ...) enum torture_result result, const char *fmt, ...)
{ {

View File

@ -40,7 +40,9 @@ enum torture_result {
*/ */
struct torture_ui_ops struct torture_ui_ops
{ {
void (*init) (struct torture_context *);
void (*comment) (struct torture_context *, const char *); 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_start) (struct torture_context *, struct torture_suite *);
void (*suite_finish) (struct torture_context *, struct torture_suite *); void (*suite_finish) (struct torture_context *, struct torture_suite *);
void (*tcase_start) (struct torture_context *, struct torture_tcase *); 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); struct torture_test *test);
void torture_comment(struct torture_context *test, const char *comment, ...) PRINTF_ATTRIBUTE(2,3); 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, void torture_result(struct torture_context *test,
enum torture_result, const char *reason, ...) PRINTF_ATTRIBUTE(3,4); 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);\ torture_result(torture_ctx, TORTURE_FAIL, __location__": %s", cmt);\
return false; \ return false; \
} while (0) } 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 #define torture_out stderr

View File

@ -21,8 +21,6 @@ check() {
return $status return $status
} }
check "RootDSE" bin/ldbsearch $CONFIGURATION $options --basedn='' -H $p://$SERVER -s base DUMMY=x dnsHostName highestCommittedUSN || failed=`expr $failed + 1` check "RootDSE" bin/ldbsearch $CONFIGURATION $options --basedn='' -H $p://$SERVER -s base DUMMY=x dnsHostName highestCommittedUSN || failed=`expr $failed + 1`
echo "Getting defaultNamingContext" echo "Getting defaultNamingContext"