summaryrefslogtreecommitdiff
path: root/source4/torture/basic/unlink.c
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2006-10-16 13:06:41 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:21:12 -0500
commit8773e743c518578584d07d35ffdafdd598af88b0 (patch)
tree89726232dd6ae9eca1c219e21729a9b2336ddaa9 /source4/torture/basic/unlink.c
parent0f2347e417dec4a50f95d64353b260cd53a44a2b (diff)
downloadsamba-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/unlink.c')
-rw-r--r--source4/torture/basic/unlink.c60
1 files changed, 19 insertions, 41 deletions
diff --git a/source4/torture/basic/unlink.c b/source4/torture/basic/unlink.c
index b64c52e110..a8469e4bf6 100644
--- a/source4/torture/basic/unlink.c
+++ b/source4/torture/basic/unlink.c
@@ -34,49 +34,36 @@
1) the server does not allow an unlink on a file that is open
*/
-BOOL torture_unlinktest(struct torture_context *torture)
+BOOL torture_unlinktest(struct torture_context *tctx, struct smbcli_state *cli)
{
- struct smbcli_state *cli;
const char *fname = BASEDIR "\\unlink.tst";
int fnum;
BOOL correct = True;
union smb_open io;
NTSTATUS status;
- if (!torture_open_connection(&cli, 0)) {
- return False;
- }
-
- printf("starting unlink test\n");
-
- if (!torture_setup_dir(cli, BASEDIR)) {
- return False;
- }
+ torture_assert(tctx, torture_setup_dir(cli, BASEDIR),
+ talloc_asprintf(tctx, "Failed setting up %s", BASEDIR));
cli->session->pid = 1;
- printf("Opening a file\n");
+ torture_comment(tctx, "Opening a file\n");
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
- if (fnum == -1) {
- printf("open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
- return False;
- }
-
- printf("Unlinking a open file\n");
-
- if (NT_STATUS_IS_OK(smbcli_unlink(cli->tree, fname))) {
- printf("(%s) error: server allowed unlink on an open file\n", __location__);
- correct = False;
- } else {
- correct = check_error(__location__, cli, ERRDOS, ERRbadshare,
+ torture_assert(tctx, fnum != -1, talloc_asprintf(tctx, "open of %s failed (%s)", fname, smbcli_errstr(cli->tree)));
+
+ torture_comment(tctx, "Unlinking a open file\n");
+
+ torture_assert(tctx, !NT_STATUS_IS_OK(smbcli_unlink(cli->tree, fname)),
+ "server allowed unlink on an open file");
+
+ correct = check_error(__location__, cli, ERRDOS, ERRbadshare,
NT_STATUS_SHARING_VIOLATION);
- }
smbcli_close(cli->tree, fnum);
smbcli_unlink(cli->tree, fname);
- printf("testing unlink after ntcreatex with DELETE access\n");
+ torture_comment(tctx, "testing unlink after ntcreatex with DELETE access\n");
io.ntcreatex.level = RAW_OPEN_NTCREATEX;
io.ntcreatex.in.root_fid = 0;
@@ -92,23 +79,14 @@ BOOL torture_unlinktest(struct torture_context *torture)
io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
status = smb_raw_open(cli->tree, cli, &io);
- if (!NT_STATUS_IS_OK(status)) {
- printf("(%s) failed to open %s\n", __location__, fname);
- }
- if (NT_STATUS_IS_OK(smbcli_unlink(cli->tree, fname))) {
- printf("(%s) error: server allowed unlink on an open file\n", __location__);
- correct = False;
- } else {
- correct = check_error(__location__, cli, ERRDOS, ERRbadshare,
- NT_STATUS_SHARING_VIOLATION);
- }
+ torture_assert_ntstatus_ok(tctx, status, talloc_asprintf(tctx, "failed to open %s", fname));
- if (!torture_close_connection(cli)) {
- correct = False;
- }
+ torture_assert(tctx, !NT_STATUS_IS_OK(smbcli_unlink(cli->tree, fname)),
+ "server allowed unlink on an open file");
+
+ correct = check_error(__location__, cli, ERRDOS, ERRbadshare,
+ NT_STATUS_SHARING_VIOLATION);
- printf("unlink test finished\n");
-
return correct;
}