------------------------------------------------------------ revno: 11300 revision-id: [EMAIL PROTECTED] parent: [EMAIL PROTECTED] committer: Jelmer Vernooij <[EMAIL PROTECTED]> branch nick: 4.0-perlselftest timestamp: Fri 2007-01-26 13:05:18 +0100 message: Improve output in selftest Run some more tests, add failing bits to knownfail file. modified: source/main.mk svn-v2:[EMAIL PROTECTED] source/samba4-knownfail svn-v2:[EMAIL PROTECTED] source/script/tests/selftest.pl svn-v2:[EMAIL PROTECTED] source/script/tests/test_posix.sh svn-v2:[EMAIL PROTECTED] source/torture/basic/delaywrite.c svn-v2:[EMAIL PROTECTED] source/torture/raw/oplock.c svn-v2:[EMAIL PROTECTED] source/torture/smbtorture.c svn-v2:[EMAIL PROTECTED] source/torture/ui.h svn-v2:[EMAIL PROTECTED] === modified file 'source/main.mk' --- a/source/main.mk 2007-01-26 09:43:56 +0000 +++ b/source/main.mk 2007-01-26 12:05:18 +0000 @@ -286,7 +286,7 @@ test: $(DEFAULT_TEST_TARGET) -SELFTEST = $(srcdir)/script/tests/selftest.pl --prefix=${selftest_prefix} --builddir=$(builddir) --srcdir=$(srcdir) +SELFTEST = $(srcdir)/script/tests/selftest.pl --prefix=${selftest_prefix} --builddir=$(builddir) --srcdir=$(srcdir) --expected-failures=samba4-knownfail test-swrap: all libraries $(SELFTEST) --socket-wrapper $(TESTS)
=== modified file 'source/samba4-knownfail' --- a/source/samba4-knownfail 2006-11-04 13:27:06 +0000 +++ b/source/samba4-knownfail 2007-01-26 12:05:18 +0000 @@ -1,3 +1,5 @@ -LOCAL-REGISTRY-* -LOCAL-RESOLVE-async -LOCAL-ICONV-next_codepoint() +LOCAL-REGISTRY/(nt4|ldb|dir) +LOCAL-RESOLVE/async +LOCAL-ICONV/next_codepoint() +BASE-DELAYWRITE/finfo update on close +RAW-OPLOCK/OPLOCK === modified file 'source/script/tests/selftest.pl' --- a/source/script/tests/selftest.pl 2007-01-26 09:43:56 +0000 +++ b/source/script/tests/selftest.pl 2007-01-26 12:05:18 +0000 @@ -159,10 +159,11 @@ 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"; + open STDIN, $test_fifo; + open STDOUT, ">$test_log"; + open STDERR, '>&STDOUT'; + my $ret = system("$valgrind $bindir/smbd --maximum-runtime=$max_time -s $conffile -M single -i --leak-report-full"); if ($? == -1) { - print LOG "Unable to start smbd: $ret: $!\n"; print "Unable to start smbd: $ret: $!\n"; exit 1; } @@ -171,16 +172,12 @@ 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"; @@ -189,13 +186,31 @@ } my $suitesfailed = []; -my $totalfailed = 0; -my $totalsuccesses = 0; -my $total = 0; -my $unexpected_success = 0; 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 $fullname = shift; + + foreach (@expected_failures) { + return 1 if $fullname =~ /^$_$/; + } + + return 0; +} + sub run_test_buildfarm($$$$) { my ($name, $cmd, $i, $suitestotal) = @_; @@ -228,39 +243,52 @@ if ($#$suitesfailed+1 > 0) { $err = ", ".($#$suitesfailed+1)." errors"; } printf "[$i/$totalsuites in " . (time() - $start)."s$err] $name\n"; open(RESULT, "$cmd 2>/dev/null|"); + my $expected_ret = 1; my $open_tests = {}; $test_output->{$name} = ""; while (<RESULT>) { - if (/^test: ([^\n]+)/) { + if (/^test: (.+)\n/) { $open_tests->{$1} = 1; - } elsif (/^success: ([^\[\n]+)/) { - delete $open_tests->{$1}; - if (grep(/^$name\/$1$/, @expected_failures)) { - $unexpected_success++; - } else { - $total++; - } - } elsif (/^failure: ([^\[\n]+)/) { - delete $open_tests->{$1}; - unless (grep(/^$name\/$1$/, @expected_failures)) { - $totalfailed++; - } else { - $total++; + } 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}++; } } $test_output->{$name}.=$_; } $test_output->{$name}.="COMMAND IS: $cmd\n"; foreach (keys %$open_tests) { - print "$_ was started but never finished!\n"; + $test_output->{$name}.="$_ was started but never finished!\n"; + $statistics->{TESTS_ERROR}++; } my $ret = close(RESULT); - if ($opt_immediate or (not $ret and $opt_one)) { + if ($ret != $expected_ret and ($opt_immediate or $opt_one)) { print "$test_output->{$name}\n"; } - if (not $ret) { + if ($ret != $expected_ret) { push(@$suitesfailed, $name); + $statistics->{SUITES_FAIL}++; exit(1) if ($opt_one); + } else { + $statistics->{SUITES_OK}++; } } @@ -282,15 +310,22 @@ 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 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 - --expected-failures=FILE specify list of tests that is guaranteed to fail - --srcdir=DIR source directory [.] - --builddir=DIR output directory [.] + --verbose, -v be verbose "; exit(0); } @@ -408,7 +443,7 @@ if (defined($opt_expected_failures)) { open(KNOWN, "<$opt_expected_failures") or die("unable to read known failures file: $!"); - while (<KNOWN>) { s/\n//g; push (@expected_failures, $_); } + while (<KNOWN>) { chomp; push (@expected_failures, $_); } close(KNOWN); } @@ -519,10 +554,10 @@ my $end = time(); my $duration = ($end-$start); -print "DURATION: $duration seconds\n"; my $numfailed = $#$suitesfailed+1; if ($numfailed == 0) { - print "ALL OK ($total tests in $suitestotal testsuites)\n"; + 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) { @@ -535,7 +570,7 @@ } } - print "FAILED ($totalfailed tests in $numfailed testsuites)\n"; + print "FAILED ($statistics->{TESTS_UNEXPECTED_FAIL} tests in $statistics->{SUITES_FAIL} testsuites)\n"; } else { print <<EOF ************************ @@ -545,6 +580,7 @@ ; } } +print "DURATION: $duration seconds\n"; # if there were any valgrind failures, show them foreach (<$prefix/valgrind.log*>) { === modified file 'source/script/tests/test_posix.sh' --- a/source/script/tests/test_posix.sh 2006-10-16 13:06:41 +0000 +++ b/source/script/tests/test_posix.sh 2007-01-26 12:05:18 +0000 @@ -31,7 +31,7 @@ base="$base BASE-MANGLE BASE-NEGNOWAIT BASE-NTDENY1" base="$base BASE-NTDENY2 BASE-OPEN BASE-OPENATTR BASE-PROPERTIES BASE-RENAME BASE-RW1" base="$base BASE-SECLEAK BASE-TCON BASE-TCONDEV BASE-TRANS2 BASE-UNLINK BASE-VUID" -base="$base BASE-XCOPY" +base="$base BASE-XCOPY BASE-DELAYWRITE" # # please don't remove tests here, when you want them to be skipped! @@ -42,6 +42,7 @@ raw="$raw RAW-IOCTL RAW-LOCK RAW-MKDIR RAW-MUX RAW-NOTIFY RAW-OPEN RAW-OPLOCK" raw="$raw RAW-QFILEINFO RAW-QFSINFO RAW-READ RAW-RENAME RAW-SEARCH RAW-SEEK" raw="$raw RAW-SFILEINFO RAW-SFILEINFO-BUG RAW-STREAMS RAW-UNLINK RAW-WRITE" +raw="$raw RAW-OPLOCK RAW-ACLS" smb2="SMB2-CONNECT SMB2-GETINFO SMB2-SETINFO SMB2-FIND" @@ -50,7 +51,7 @@ # # please add tests you want to be skipped here! # -skipped="BASE-CHARSET BASE-DEFER_OPEN BASE-DELAYWRITE RAW-COMPOSITE RAW-OPLOCK RAW-ACLS" +skipped="BASE-CHARSET BASE-DEFER_OPEN RAW-COMPOSITE" echo "WARNING: Skipping tests $skipped" === modified file 'source/torture/basic/delaywrite.c' --- a/source/torture/basic/delaywrite.c 2006-10-16 13:06:41 +0000 +++ b/source/torture/basic/delaywrite.c 2007-01-26 12:05:18 +0000 @@ -487,6 +487,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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; } === modified file 'source/torture/raw/oplock.c' --- a/source/torture/raw/oplock.c 2006-10-30 00:17:16 +0000 +++ b/source/torture/raw/oplock.c 2007-01-26 12:05:18 +0000 @@ -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 @@ /* 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 @@ 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 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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); === modified file 'source/torture/smbtorture.c' --- a/source/torture/smbtorture.c 2007-01-26 01:08:57 +0000 +++ b/source/torture/smbtorture.c 2007-01-26 12:05:18 +0000 @@ -337,7 +337,7 @@ break; } if (reason) - printf(" [ %s ]", reason); + printf(" [\n%s\n]", reason); printf("\n"); } === modified file 'source/torture/ui.h' --- a/source/torture/ui.h 2006-10-18 10:03:30 +0000 +++ b/source/torture/ui.h 2007-01-26 12:05:18 +0000 @@ -278,6 +278,10 @@ 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