diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2006-10-16 13:06:41 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:21:12 -0500 |
commit | 8773e743c518578584d07d35ffdafdd598af88b0 (patch) | |
tree | 89726232dd6ae9eca1c219e21729a9b2336ddaa9 /source4/torture/basic/attr.c | |
parent | 0f2347e417dec4a50f95d64353b260cd53a44a2b (diff) | |
download | samba-8773e743c518578584d07d35ffdafdd598af88b0.tar.gz samba-8773e743c518578584d07d35ffdafdd598af88b0.tar.bz2 samba-8773e743c518578584d07d35ffdafdd598af88b0.zip |
r19339: Merge my 4.0-unittest branch. This adds an API for more fine-grained
output in the testsuite rather than just True or False for a
set of tests.
The aim is to use this for:
* known failure lists (run all tests and detect tests that
started working or started failing). This
would allow us to get rid of the RPC-SAMBA3-* tests
* nicer torture output
* simplification of the testsuite system
* compatibility with other unit testing systems
* easier usage of smbtorture (being able to run one test
and automatically set up the environment for that)
This is still a work-in-progress; expect more updates over the next couple of
days.
(This used to be commit 0eb6097305776325c75081356309115f445a7218)
Diffstat (limited to 'source4/torture/basic/attr.c')
-rw-r--r-- | source4/torture/basic/attr.c | 66 |
1 files changed, 24 insertions, 42 deletions
diff --git a/source4/torture/basic/attr.c b/source4/torture/basic/attr.c index a98f815a92..8e1a53d7c0 100644 --- a/source4/torture/basic/attr.c +++ b/source4/torture/basic/attr.c @@ -87,22 +87,15 @@ static const struct trunc_open_results attr_results[] = { }; -BOOL torture_openattrtest(struct torture_context *torture) +BOOL torture_openattrtest(struct torture_context *tctx, + struct smbcli_state *cli1) { - struct smbcli_state *cli1; const char *fname = "\\openattr.file"; int fnum1; - BOOL correct = True; uint16_t attr; uint_t i, j, k, l; int failures = 0; - printf("starting open attr test\n"); - - if (!torture_open_connection(&cli1, 0)) { - return False; - } - for (k = 0, i = 0; i < sizeof(open_attrs_table)/sizeof(uint32_t); i++) { smbcli_setatr(cli1->tree, fname, 0, 0); smbcli_unlink(cli1->tree, fname); @@ -111,15 +104,13 @@ BOOL torture_openattrtest(struct torture_context *torture) open_attrs_table[i], NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); - if (fnum1 == -1) { - printf("open %d (1) of %s failed (%s)\n", i, fname, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open %d (1) of %s failed (%s)", i, + fname, smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("close %d (1) of %s failed (%s)\n", i, fname, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, + smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close %d (1) of %s failed (%s)", i, fname, + smbcli_errstr(cli1->tree))); for (j = 0; j < ARRAY_SIZE(open_attrs_table); j++) { fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, @@ -132,40 +123,37 @@ BOOL torture_openattrtest(struct torture_context *torture) if (fnum1 == -1) { for (l = 0; l < ARRAY_SIZE(attr_results); l++) { if (attr_results[l].num == k) { - printf("[%d] trunc open 0x%x -> 0x%x of %s failed - should have succeeded !(%s)\n", + torture_comment(tctx, "[%d] trunc open 0x%x -> 0x%x of %s failed - should have succeeded !(%s)\n", k, open_attrs_table[i], open_attrs_table[j], fname, smbcli_errstr(cli1->tree)); - correct = False; CHECK_MAX_FAILURES(error_exit); } } - if (!NT_STATUS_EQUAL(smbcli_nt_error(cli1->tree), NT_STATUS_ACCESS_DENIED)) { - printf("[%d] trunc open 0x%x -> 0x%x failed with wrong error code %s\n", + torture_assert_ntstatus_equal(tctx, + smbcli_nt_error(cli1->tree), NT_STATUS_ACCESS_DENIED, + talloc_asprintf(tctx, "[%d] trunc open 0x%x -> 0x%x failed with wrong error code %s", k, open_attrs_table[i], open_attrs_table[j], - smbcli_errstr(cli1->tree)); - correct = False; + smbcli_errstr(cli1->tree))); CHECK_MAX_FAILURES(error_exit); - } #if 0 - printf("[%d] trunc open 0x%x -> 0x%x failed\n", k, open_attrs_table[i], open_attrs_table[j]); + torture_comment(tctx, "[%d] trunc open 0x%x -> 0x%x failed\n", k, open_attrs_table[i], open_attrs_table[j]); #endif k++; continue; } - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("close %d (2) of %s failed (%s)\n", j, fname, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, + smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close %d (2) of %s failed (%s)", j, + fname, smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_getatr(cli1->tree, fname, &attr, NULL, NULL))) { - printf("getatr(2) failed (%s)\n", smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, + smbcli_getatr(cli1->tree, fname, &attr, NULL, NULL), + talloc_asprintf(tctx, "getatr(2) failed (%s)", smbcli_errstr(cli1->tree))); #if 0 - printf("[%d] getatr check [0x%x] trunc [0x%x] got attr 0x%x\n", + torture_comment(tctx, "[%d] getatr check [0x%x] trunc [0x%x] got attr 0x%x\n", k, open_attrs_table[i], open_attrs_table[j], attr ); #endif @@ -174,12 +162,11 @@ BOOL torture_openattrtest(struct torture_context *torture) if (attr != attr_results[l].result_attr || open_attrs_table[i] != attr_results[l].init_attr || open_attrs_table[j] != attr_results[l].trunc_attr) { - printf("[%d] getatr check failed. [0x%x] trunc [0x%x] got attr 0x%x, should be 0x%x\n", + torture_comment(tctx, "[%d] getatr check failed. [0x%x] trunc [0x%x] got attr 0x%x, should be 0x%x\n", k, open_attrs_table[i], open_attrs_table[j], (uint_t)attr, attr_results[l].result_attr); - correct = False; CHECK_MAX_FAILURES(error_exit); } break; @@ -192,11 +179,6 @@ error_exit: smbcli_setatr(cli1->tree, fname, 0, 0); smbcli_unlink(cli1->tree, fname); - printf("open attr test %s.\n", correct ? "passed" : "failed"); - - if (!torture_close_connection(cli1)) { - correct = False; - } - return correct; + return true; } |