From 919aa6b27e5fe49b70c814210aa026c19be66e8a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 28 Aug 2007 12:54:27 +0000 Subject: r24735: Use torture API in more places. (This used to be commit 1319d88c099496be29dd9214fa2492c81e848369) --- source4/torture/raw/unlink.c | 46 ++++++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 27 deletions(-) (limited to 'source4/torture/raw/unlink.c') diff --git a/source4/torture/raw/unlink.c b/source4/torture/raw/unlink.c index 3e4580d2d3..c307b14e08 100644 --- a/source4/torture/raw/unlink.c +++ b/source4/torture/raw/unlink.c @@ -37,7 +37,7 @@ /* test unlink ops */ -static BOOL test_unlink(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_unlink(struct torture_context *tctx, struct smbcli_state *cli) { union smb_unlink io; NTSTATUS status; @@ -199,7 +199,8 @@ done: /* test delete on close */ -static BOOL test_delete_on_close(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_delete_on_close(struct torture_context *tctx, + struct smbcli_state *cli) { union smb_open op; union smb_unlink io; @@ -224,7 +225,7 @@ static BOOL test_delete_on_close(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); printf("Testing with delete_on_close 0\n"); - fnum = create_complex_file(cli, mem_ctx, fname); + fnum = create_complex_file(cli, tctx, fname); sfinfo.disposition_info.level = RAW_SFILEINFO_DISPOSITION_INFO; sfinfo.disposition_info.in.file.fnum = fnum; @@ -238,7 +239,7 @@ static BOOL test_delete_on_close(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) CHECK_STATUS(status, NT_STATUS_OK); printf("Testing with delete_on_close 1\n"); - fnum = create_complex_file(cli, mem_ctx, fname); + fnum = create_complex_file(cli, tctx, fname); sfinfo.disposition_info.in.file.fnum = fnum; sfinfo.disposition_info.in.delete_on_close = 1; status = smb_raw_setfileinfo(cli->tree, &sfinfo); @@ -290,7 +291,7 @@ static BOOL test_delete_on_close(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) status = create_directory_handle(cli->tree, dname, &fnum); CHECK_STATUS(status, NT_STATUS_OK); - fnum2 = create_complex_file(cli, mem_ctx, inside); + fnum2 = create_complex_file(cli, tctx, inside); sfinfo.disposition_info.in.file.fnum = fnum; sfinfo.disposition_info.in.delete_on_close = 1; @@ -321,7 +322,7 @@ static BOOL test_delete_on_close(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) CHECK_STATUS(status, NT_STATUS_OK); smbcli_close(cli->tree, fnum); - fnum2 = create_complex_file(cli, mem_ctx, inside); + fnum2 = create_complex_file(cli, tctx, inside); smbcli_close(cli->tree, fnum2); op.generic.level = RAW_OPEN_NTCREATEX; @@ -337,7 +338,7 @@ static BOOL test_delete_on_close(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) op.ntcreatex.in.security_flags = 0; op.ntcreatex.in.fname = dname; - status = smb_raw_open(cli->tree, mem_ctx, &op); + status = smb_raw_open(cli->tree, tctx, &op); CHECK_STATUS(status, NT_STATUS_OK); fnum = op.ntcreatex.out.file.fnum; @@ -353,7 +354,7 @@ static BOOL test_delete_on_close(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) CHECK_STATUS(status, NT_STATUS_OK); smbcli_close(cli->tree, fnum); - fnum2 = create_complex_file(cli, mem_ctx, inside); + fnum2 = create_complex_file(cli, tctx, inside); smbcli_close(cli->tree, fnum2); op.generic.level = RAW_OPEN_NTCREATEX; @@ -369,7 +370,7 @@ static BOOL test_delete_on_close(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) op.ntcreatex.in.security_flags = 0; op.ntcreatex.in.fname = dname; - status = smb_raw_open(cli->tree, mem_ctx, &op); + status = smb_raw_open(cli->tree, tctx, &op); CHECK_STATUS(status, NT_STATUS_OK); fnum2 = op.ntcreatex.out.file.fnum; @@ -386,7 +387,7 @@ static BOOL test_delete_on_close(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) smbcli_close(cli->tree, fnum); - fnum = create_complex_file(cli, mem_ctx, inside); + fnum = create_complex_file(cli, tctx, inside); smbcli_close(cli->tree, fnum); /* we have a dir with a file in it, no handles open */ @@ -404,13 +405,13 @@ static BOOL test_delete_on_close(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) op.ntcreatex.in.security_flags = 0; op.ntcreatex.in.fname = dname; - status = smb_raw_open(cli->tree, mem_ctx, &op); + status = smb_raw_open(cli->tree, tctx, &op); CHECK_STATUS(status, NT_STATUS_OK); fnum = op.ntcreatex.out.file.fnum; /* open without delete on close */ op.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY; - status = smb_raw_open(cli->tree, mem_ctx, &op); + status = smb_raw_open(cli->tree, tctx, &op); CHECK_STATUS(status, NT_STATUS_OK); fnum2 = op.ntcreatex.out.file.fnum; @@ -436,22 +437,13 @@ done: /* basic testing of unlink calls */ -BOOL torture_raw_unlink(struct torture_context *torture) +struct torture_suite *torture_raw_unlink(TALLOC_CTX *mem_ctx) { - struct smbcli_state *cli; - BOOL ret = True; - TALLOC_CTX *mem_ctx; - - if (!torture_open_connection(&cli, 0)) { - return False; - } - - mem_ctx = talloc_init("torture_raw_unlink"); + struct torture_suite *suite = torture_suite_create(mem_ctx, + "UNLINK"); - ret &= test_unlink(cli, mem_ctx); - ret &= test_delete_on_close(cli, mem_ctx); + torture_suite_add_1smb_test(suite, "unlink", test_unlink); + torture_suite_add_1smb_test(suite, "delete_on_close", test_delete_on_close); - torture_close_connection(cli); - talloc_free(mem_ctx); - return ret; + return suite; } -- cgit