diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2007-08-28 12:54:27 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 15:03:00 -0500 |
commit | 919aa6b27e5fe49b70c814210aa026c19be66e8a (patch) | |
tree | 4f1cff79459133a014a32e3f42fa787c7d83de67 /source4/torture/raw | |
parent | b42691ee167415c7dc89d50b4ba18909bacd40c1 (diff) | |
download | samba-919aa6b27e5fe49b70c814210aa026c19be66e8a.tar.gz samba-919aa6b27e5fe49b70c814210aa026c19be66e8a.tar.bz2 samba-919aa6b27e5fe49b70c814210aa026c19be66e8a.zip |
r24735: Use torture API in more places.
(This used to be commit 1319d88c099496be29dd9214fa2492c81e848369)
Diffstat (limited to 'source4/torture/raw')
-rw-r--r-- | source4/torture/raw/acls.c | 28 | ||||
-rw-r--r-- | source4/torture/raw/chkpath.c | 21 | ||||
-rw-r--r-- | source4/torture/raw/close.c | 45 | ||||
-rw-r--r-- | source4/torture/raw/composite.c | 23 | ||||
-rw-r--r-- | source4/torture/raw/context.c | 35 | ||||
-rw-r--r-- | source4/torture/raw/eas.c | 16 | ||||
-rw-r--r-- | source4/torture/raw/ioctl.c | 24 | ||||
-rw-r--r-- | source4/torture/raw/lock.c | 56 | ||||
-rw-r--r-- | source4/torture/raw/mkdir.c | 19 | ||||
-rw-r--r-- | source4/torture/raw/mux.c | 30 | ||||
-rw-r--r-- | source4/torture/raw/notify.c | 44 | ||||
-rw-r--r-- | source4/torture/raw/open.c | 38 | ||||
-rw-r--r-- | source4/torture/raw/oplock.c | 4 | ||||
-rw-r--r-- | source4/torture/raw/qfileinfo.c | 48 | ||||
-rw-r--r-- | source4/torture/raw/qfsinfo.c | 19 | ||||
-rw-r--r-- | source4/torture/raw/raw.c | 53 | ||||
-rw-r--r-- | source4/torture/raw/read.c | 56 | ||||
-rw-r--r-- | source4/torture/raw/rename.c | 55 | ||||
-rw-r--r-- | source4/torture/raw/search.c | 151 | ||||
-rw-r--r-- | source4/torture/raw/seek.c | 18 | ||||
-rw-r--r-- | source4/torture/raw/setfileinfo.c | 78 | ||||
-rw-r--r-- | source4/torture/raw/streams.c | 15 | ||||
-rw-r--r-- | source4/torture/raw/unlink.c | 46 | ||||
-rw-r--r-- | source4/torture/raw/write.c | 48 |
24 files changed, 366 insertions, 604 deletions
diff --git a/source4/torture/raw/acls.c b/source4/torture/raw/acls.c index bad98178d7..c22c9be7de 100644 --- a/source4/torture/raw/acls.c +++ b/source4/torture/raw/acls.c @@ -1726,35 +1726,25 @@ done: /* basic testing of security descriptor calls */ -BOOL torture_raw_acls(struct torture_context *torture) +bool torture_raw_acls(struct torture_context *tctx, struct smbcli_state *cli) { - 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_acls"); if (!torture_setup_dir(cli, BASEDIR)) { return False; } - ret &= test_sd(cli, mem_ctx); - ret &= test_nttrans_create(cli, mem_ctx); - ret &= test_creator_sid(cli, mem_ctx); - ret &= test_generic_bits(cli, mem_ctx); - ret &= test_owner_bits(cli, mem_ctx); - ret &= test_inheritance(cli, mem_ctx); - ret &= test_inheritance_dynamic(cli, mem_ctx); - ret &= test_sd_get_set(cli, mem_ctx); + ret &= test_sd(cli, tctx); + ret &= test_nttrans_create(cli, tctx); + ret &= test_creator_sid(cli, tctx); + ret &= test_generic_bits(cli, tctx); + ret &= test_owner_bits(cli, tctx); + ret &= test_inheritance(cli, tctx); + ret &= test_inheritance_dynamic(cli, tctx); + ret &= test_sd_get_set(cli, tctx); smb_raw_exit(cli->session); smbcli_deltree(cli->tree, BASEDIR); - torture_close_connection(cli); - talloc_free(mem_ctx); return ret; } diff --git a/source4/torture/raw/chkpath.c b/source4/torture/raw/chkpath.c index 9914fdacca..a56afee546 100644 --- a/source4/torture/raw/chkpath.c +++ b/source4/torture/raw/chkpath.c @@ -214,18 +214,11 @@ done: /* basic testing of chkpath calls */ -BOOL torture_raw_chkpath(struct torture_context *torture) +bool torture_raw_chkpath(struct torture_context *torture, + struct smbcli_state *cli) { - struct smbcli_state *cli; - BOOL ret = True; + bool ret = true; int fnum; - TALLOC_CTX *mem_ctx; - - if (!torture_open_connection(&cli, 0)) { - return False; - } - - mem_ctx = talloc_init("torture_raw_chkpath"); if (!torture_setup_dir(cli, BASEDIR)) { return False; @@ -246,23 +239,19 @@ BOOL torture_raw_chkpath(struct torture_context *torture) return False; } - fnum = create_complex_file(cli, mem_ctx, BASEDIR "\\nt\\V S\\VB98\\vb6.exe"); + fnum = create_complex_file(cli, torture, BASEDIR "\\nt\\V S\\VB98\\vb6.exe"); if (fnum == -1) { printf("failed to open \\nt\\V S\\VB98\\vb6.exe - %s\n", smbcli_errstr(cli->tree)); ret = False; goto done; } - if (!test_chkpath(cli, mem_ctx)) { - ret = False; - } + ret &= test_chkpath(cli, torture); done: smb_raw_exit(cli->session); smbcli_deltree(cli->tree, BASEDIR); - torture_close_connection(cli); - talloc_free(mem_ctx); return ret; } diff --git a/source4/torture/raw/close.c b/source4/torture/raw/close.c index 6af234e4b4..34ac2f0db8 100644 --- a/source4/torture/raw/close.c +++ b/source4/torture/raw/close.c @@ -24,14 +24,13 @@ #include "libcli/libcli.h" #include "torture/util.h" - -/* basic testing of all RAW_CLOSE_* calls +/** + * basic testing of all RAW_CLOSE_* calls */ -BOOL torture_raw_close(struct torture_context *torture) +bool torture_raw_close(struct torture_context *torture, + struct smbcli_state *cli) { - struct smbcli_state *cli; - BOOL ret = True; - TALLOC_CTX *mem_ctx; + bool ret = true; union smb_close io; union smb_flush io_flush; int fnum; @@ -40,17 +39,11 @@ BOOL torture_raw_close(struct torture_context *torture) union smb_fileinfo finfo, finfo2; NTSTATUS status; - if (!torture_open_connection(&cli, 0)) { - return False; - } - - mem_ctx = talloc_init("torture_raw_close"); - #define REOPEN do { \ - fnum = create_complex_file(cli, mem_ctx, fname); \ + fnum = create_complex_file(cli, torture, fname); \ if (fnum == -1) { \ printf("(%d) Failed to create %s\n", __LINE__, fname); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -58,7 +51,7 @@ BOOL torture_raw_close(struct torture_context *torture) if (!NT_STATUS_EQUAL(status, correct)) { \ printf("(%d) Incorrect status %s - should be %s\n", \ __LINE__, nt_errstr(status), nt_errstr(correct)); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -78,15 +71,15 @@ BOOL torture_raw_close(struct torture_context *torture) /* the file should have the write time set */ finfo.generic.level = RAW_FILEINFO_ALL_INFO; finfo.generic.in.file.path = fname; - status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo); + status = smb_raw_pathinfo(cli->tree, torture, &finfo); CHECK_STATUS(status, NT_STATUS_OK); if (basetime != nt_time_to_unix(finfo.all_info.out.write_time)) { printf("Incorrect write time on file - %s - %s\n", - timestring(mem_ctx, basetime), - nt_time_string(mem_ctx, finfo.all_info.out.write_time)); - dump_all_info(mem_ctx, &finfo); - ret = False; + timestring(torture, basetime), + nt_time_string(torture, finfo.all_info.out.write_time)); + dump_all_info(torture, &finfo); + ret = false; } printf("testing other times\n"); @@ -99,7 +92,7 @@ BOOL torture_raw_close(struct torture_context *torture) nt_time_equal(&finfo.all_info.out.write_time, &finfo.all_info.out.change_time)) { printf("Incorrect times after close - only write time should be set\n"); - dump_all_info(mem_ctx, &finfo); + dump_all_info(torture, &finfo); if (!torture_setting_bool(torture, "samba3", false)) { /* @@ -117,7 +110,7 @@ BOOL torture_raw_close(struct torture_context *torture) finfo2.generic.level = RAW_FILEINFO_ALL_INFO; finfo2.generic.in.file.path = fname; - status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo2); + status = smb_raw_pathinfo(cli->tree, torture, &finfo2); CHECK_STATUS(status, NT_STATUS_OK); io.close.level = RAW_CLOSE_CLOSE; @@ -129,14 +122,14 @@ BOOL torture_raw_close(struct torture_context *torture) /* the file should have the write time set equal to access time */ finfo.generic.level = RAW_FILEINFO_ALL_INFO; finfo.generic.in.file.path = fname; - status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo); + status = smb_raw_pathinfo(cli->tree, torture, &finfo); CHECK_STATUS(status, NT_STATUS_OK); if (!nt_time_equal(&finfo.all_info.out.write_time, &finfo2.all_info.out.write_time)) { printf("Incorrect write time on file - 0 time should be ignored\n"); - dump_all_info(mem_ctx, &finfo); - ret = False; + dump_all_info(torture, &finfo); + ret = false; } printf("testing splclose\n"); @@ -179,7 +172,5 @@ BOOL torture_raw_close(struct torture_context *torture) done: smbcli_close(cli->tree, fnum); smbcli_unlink(cli->tree, fname); - torture_close_connection(cli); - talloc_free(mem_ctx); return ret; } diff --git a/source4/torture/raw/composite.c b/source4/torture/raw/composite.c index 0b7644dd03..374ff3cb98 100644 --- a/source4/torture/raw/composite.c +++ b/source4/torture/raw/composite.c @@ -399,31 +399,22 @@ static BOOL test_fsinfo(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) /* basic testing of libcli composite calls */ -BOOL torture_raw_composite(struct torture_context *torture) +bool torture_raw_composite(struct torture_context *tctx, + struct smbcli_state *cli) { - 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_composite"); + bool ret = true; if (!torture_setup_dir(cli, BASEDIR)) { return False; } - ret &= test_fetchfile(cli, mem_ctx); - ret &= test_loadfile(cli, mem_ctx); - ret &= test_appendacl(cli, mem_ctx); - ret &= test_fsinfo(cli, mem_ctx); + ret &= test_fetchfile(cli, tctx); + ret &= test_loadfile(cli, tctx); + ret &= test_appendacl(cli, tctx); + ret &= test_fsinfo(cli, tctx); smb_raw_exit(cli->session); smbcli_deltree(cli->tree, BASEDIR); - torture_close_connection(cli); - talloc_free(mem_ctx); return ret; } diff --git a/source4/torture/raw/context.c b/source4/torture/raw/context.c index 8f3695d0dc..df7f5f3851 100644 --- a/source4/torture/raw/context.c +++ b/source4/torture/raw/context.c @@ -865,45 +865,36 @@ done: /* basic testing of session/tree context calls */ -static BOOL torture_raw_context_int(void) +static bool torture_raw_context_int(struct torture_context *tctx, + struct smbcli_state *cli) { - 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_context"); - - ret &= test_session(cli, mem_ctx); - ret &= test_tree(cli, mem_ctx); - ret &= test_tree_ulogoff(cli, mem_ctx); - ret &= test_pid_exit_only_sees_open(cli, mem_ctx); - ret &= test_pid_2sess(cli, mem_ctx); - ret &= test_pid_2tcon(cli, mem_ctx); + ret &= test_session(cli, tctx); + ret &= test_tree(cli, tctx); + ret &= test_tree_ulogoff(cli, tctx); + ret &= test_pid_exit_only_sees_open(cli, tctx); + ret &= test_pid_2sess(cli, tctx); + ret &= test_pid_2tcon(cli, tctx); smb_raw_exit(cli->session); smbcli_deltree(cli->tree, BASEDIR); - torture_close_connection(cli); - talloc_free(mem_ctx); - return ret; } /* basic testing of session/tree context calls */ -BOOL torture_raw_context(struct torture_context *torture) +bool torture_raw_context(struct torture_context *torture, + struct smbcli_state *cli) { - BOOL ret = True; + bool ret = true; if (lp_use_spnego()) { - ret &= torture_raw_context_int(); + ret &= torture_raw_context_int(torture, cli); lp_set_cmdline("use spnego", "False"); } - ret &= torture_raw_context_int(); + ret &= torture_raw_context_int(torture, cli); return ret; } diff --git a/source4/torture/raw/eas.c b/source4/torture/raw/eas.c index 226c4f6052..7e9c742943 100644 --- a/source4/torture/raw/eas.c +++ b/source4/torture/raw/eas.c @@ -444,29 +444,19 @@ done: /* basic testing of EA calls */ -BOOL torture_raw_eas(struct torture_context *torture) +bool torture_raw_eas(struct torture_context *torture, struct smbcli_state *cli) { - 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_eas"); if (!torture_setup_dir(cli, BASEDIR)) { return False; } - ret &= test_eas(cli, mem_ctx); - ret &= test_nttrans_create(cli, mem_ctx); + ret &= test_eas(cli, torture); + ret &= test_nttrans_create(cli, torture); smb_raw_exit(cli->session); - torture_close_connection(cli); - talloc_free(mem_ctx); return ret; } diff --git a/source4/torture/raw/ioctl.c b/source4/torture/raw/ioctl.c index 9208d9fa44..8e98822e11 100644 --- a/source4/torture/raw/ioctl.c +++ b/source4/torture/raw/ioctl.c @@ -151,34 +151,20 @@ done: /* basic testing of some ioctl calls */ -BOOL torture_raw_ioctl(struct torture_context *torture) +bool torture_raw_ioctl(struct torture_context *torture, + struct smbcli_state *cli) { - 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_ioctl"); + bool ret = true; if (!torture_setup_dir(cli, BASEDIR)) { return False; } - if (!test_ioctl(cli, mem_ctx)) { - ret = False; - } - - if (!test_fsctl(cli, mem_ctx)) { - ret = False; - } + ret &= test_ioctl(cli, torture); + ret &= test_fsctl(cli, torture); smb_raw_exit(cli->session); smbcli_deltree(cli->tree, BASEDIR); - torture_close_connection(cli); - talloc_free(mem_ctx); return ret; } diff --git a/source4/torture/raw/lock.c b/source4/torture/raw/lock.c index cfedb4444b..533974c9a9 100644 --- a/source4/torture/raw/lock.c +++ b/source4/torture/raw/lock.c @@ -42,7 +42,7 @@ /* test SMBlock and SMBunlock ops */ -static BOOL test_lock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_lock(struct torture_context *tctx, struct smbcli_state *cli) { union smb_lock io; NTSTATUS status; @@ -177,7 +177,7 @@ done: /* test locking&X ops */ -static BOOL test_lockx(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_lockx(struct torture_context *tctx, struct smbcli_state *cli) { union smb_lock io; struct smb_lock_entry lock[1]; @@ -356,7 +356,8 @@ done: /* test high pid */ -static BOOL test_pidhigh(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_pidhigh(struct torture_context *tctx, + struct smbcli_state *cli) { union smb_lock io; struct smb_lock_entry lock[1]; @@ -437,7 +438,8 @@ done: /* test locking&X async operation */ -static BOOL test_async(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_async(struct torture_context *tctx, + struct smbcli_state *cli) { struct smbcli_session *session; struct smb_composite_sesssetup setup; @@ -586,7 +588,7 @@ static BOOL test_async(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) } printf("create a new sessions\n"); - session = smbcli_session_init(cli->transport, mem_ctx, False); + session = smbcli_session_init(cli->transport, tctx, False); setup.in.sesskey = cli->transport->negotiate.sesskey; setup.in.capabilities = cli->transport->negotiate.capabilities; setup.in.workgroup = lp_workgroup(); @@ -598,13 +600,13 @@ static BOOL test_async(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) printf("create new tree context\n"); share = lp_parm_string(-1, "torture", "share"); host = lp_parm_string(-1, "torture", "host"); - tree = smbcli_tree_init(session, mem_ctx, False); + tree = smbcli_tree_init(session, tctx, False); tcon.generic.level = RAW_TCON_TCONX; tcon.tconx.in.flags = 0; tcon.tconx.in.password = data_blob(NULL, 0); - tcon.tconx.in.path = talloc_asprintf(mem_ctx, "\\\\%s\\%s", host, share); + tcon.tconx.in.path = talloc_asprintf(tctx, "\\\\%s\\%s", host, share); tcon.tconx.in.device = "A:"; - status = smb_raw_tcon(tree, mem_ctx, &tcon); + status = smb_raw_tcon(tree, tctx, &tcon); CHECK_STATUS(status, NT_STATUS_OK); tree->tid = tcon.tconx.out.tid; @@ -769,7 +771,8 @@ done: /* test NT_STATUS_LOCK_NOT_GRANTED vs. NT_STATUS_FILE_LOCK_CONFLICT */ -static BOOL test_errorcode(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_errorcode(struct torture_context *tctx, + struct smbcli_state *cli) { union smb_lock io; union smb_open op; @@ -812,11 +815,11 @@ next_run: op.openx.in.size = 0; op.openx.in.timeout = 0; - 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.openx.out.file.fnum; - 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.openx.out.file.fnum; @@ -1250,7 +1253,8 @@ done: /* test LOCKING_ANDX_CHANGE_LOCKTYPE */ -static BOOL test_changetype(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_changetype(struct torture_context *tctx, + struct smbcli_state *cli) { union smb_lock io; struct smb_lock_entry lock[2]; @@ -1315,26 +1319,16 @@ done: /* basic testing of lock calls */ -BOOL torture_raw_lock(struct torture_context *torture) +struct torture_suite *torture_raw_lock(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_lock"); + struct torture_suite *suite = torture_suite_create(mem_ctx, "LOCK"); - ret &= test_lockx(cli, mem_ctx); - ret &= test_lock(cli, mem_ctx); - ret &= test_pidhigh(cli, mem_ctx); - ret &= test_async(cli, mem_ctx); - ret &= test_errorcode(cli, mem_ctx); - ret &= test_changetype(cli, mem_ctx); + torture_suite_add_1smb_test(suite, "lockx", test_lockx); + torture_suite_add_1smb_test(suite, "lock", test_lock); + torture_suite_add_1smb_test(suite, "pidhigh", test_pidhigh); + torture_suite_add_1smb_test(suite, "async", test_async); + torture_suite_add_1smb_test(suite, "errorcode", test_errorcode); + torture_suite_add_1smb_test(suite, "changetype", test_changetype); - torture_close_connection(cli); - talloc_free(mem_ctx); - return ret; + return suite; } diff --git a/source4/torture/raw/mkdir.c b/source4/torture/raw/mkdir.c index 2485fb61e8..0e2fd1afe0 100644 --- a/source4/torture/raw/mkdir.c +++ b/source4/torture/raw/mkdir.c @@ -160,23 +160,14 @@ done: /* basic testing of all RAW_MKDIR_* calls */ -BOOL torture_raw_mkdir(struct torture_context *torture) +BOOL torture_raw_mkdir(struct torture_context *torture, + struct smbcli_state *cli) { - 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_mkdir"); + bool ret = true; - if (!test_mkdir(cli, mem_ctx)) { - ret = False; + if (!test_mkdir(cli, torture)) { + ret = false; } - torture_close_connection(cli); - talloc_free(mem_ctx); return ret; } diff --git a/source4/torture/raw/mux.c b/source4/torture/raw/mux.c index d61d037239..b67d756ed9 100644 --- a/source4/torture/raw/mux.c +++ b/source4/torture/raw/mux.c @@ -342,37 +342,19 @@ done: /* basic testing of multiplexing notify */ -BOOL torture_raw_mux(struct torture_context *torture) +bool torture_raw_mux(struct torture_context *torture, struct smbcli_state *cli) { - struct smbcli_state *cli; - BOOL ret = True; - TALLOC_CTX *mem_ctx; + bool ret = true; - if (!torture_open_connection(&cli, 0)) { - return False; - } - - mem_ctx = talloc_init("torture_raw_mux"); - if (!torture_setup_dir(cli, BASEDIR)) { - return False; - } - - if (!test_mux_open(cli, mem_ctx)) { - ret = False; - } - - if (!test_mux_write(cli, mem_ctx)) { - ret = False; + return false; } - if (!test_mux_lock(cli, mem_ctx)) { - ret = False; - } + ret &= test_mux_open(cli, torture); + ret &= test_mux_write(cli, torture); + ret &= test_mux_lock(cli, torture); smb_raw_exit(cli->session); smbcli_deltree(cli->tree, BASEDIR); - torture_close_connection(cli); - talloc_free(mem_ctx); return ret; } diff --git a/source4/torture/raw/notify.c b/source4/torture/raw/notify.c index 5be1b612d3..1540a4a2dd 100644 --- a/source4/torture/raw/notify.c +++ b/source4/torture/raw/notify.c @@ -1283,41 +1283,29 @@ done: /* basic testing of change notify */ -BOOL torture_raw_notify(struct torture_context *torture) +bool torture_raw_notify(struct torture_context *torture, + struct smbcli_state *cli, + struct smbcli_state *cli2) { - struct smbcli_state *cli, *cli2; - BOOL ret = True; - TALLOC_CTX *mem_ctx; + bool ret = true; - if (!torture_open_connection(&cli, 0)) { - return False; - } - if (!torture_open_connection(&cli2, 0)) { - return False; - } - - mem_ctx = talloc_init("torture_raw_notify"); - if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } - ret &= test_notify_dir(cli, cli2, mem_ctx); - ret &= test_notify_mask(cli, mem_ctx); - ret &= test_notify_recursive(cli, mem_ctx); - ret &= test_notify_mask_change(cli, mem_ctx); - ret &= test_notify_file(cli, mem_ctx); - ret &= test_notify_tdis(mem_ctx); - ret &= test_notify_exit(mem_ctx); - ret &= test_notify_ulogoff(mem_ctx); - ret &= test_notify_tcp_dis(mem_ctx); - ret &= test_notify_double(cli, mem_ctx); - ret &= test_notify_tree(cli, mem_ctx); + ret &= test_notify_dir(cli, cli2, torture); + ret &= test_notify_mask(cli, torture); + ret &= test_notify_recursive(cli, torture); + ret &= test_notify_mask_change(cli, torture); + ret &= test_notify_file(cli, torture); + ret &= test_notify_tdis(torture); + ret &= test_notify_exit(torture); + ret &= test_notify_ulogoff(torture); + ret &= test_notify_tcp_dis(torture); + ret &= test_notify_double(cli, torture); + ret &= test_notify_tree(cli, torture); smb_raw_exit(cli->session); smbcli_deltree(cli->tree, BASEDIR); - torture_close_connection(cli); - torture_close_connection(cli2); - talloc_free(mem_ctx); return ret; } diff --git a/source4/torture/raw/open.c b/source4/torture/raw/open.c index 4a4b97f531..f8fa4ff8fe 100644 --- a/source4/torture/raw/open.c +++ b/source4/torture/raw/open.c @@ -1459,39 +1459,29 @@ static BOOL test_raw_open_multi(void) /* basic testing of all RAW_OPEN_* calls */ -BOOL torture_raw_open(struct torture_context *torture) +bool torture_raw_open(struct torture_context *torture, struct smbcli_state *cli) { - 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_open"); + bool ret = true; if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } - ret &= test_ntcreatex_brlocked(cli, mem_ctx); - ret &= test_open(cli, mem_ctx); + ret &= test_ntcreatex_brlocked(cli, torture); + ret &= test_open(cli, torture); ret &= test_raw_open_multi(); - ret &= test_openx(cli, mem_ctx); - ret &= test_ntcreatex(cli, mem_ctx); - ret &= test_nttrans_create(cli, mem_ctx); - ret &= test_t2open(cli, mem_ctx); - ret &= test_mknew(cli, mem_ctx); - ret &= test_create(cli, mem_ctx); - ret &= test_ctemp(cli, mem_ctx); - ret &= test_chained(cli, mem_ctx); - ret &= test_no_leading_slash(cli, mem_ctx); + ret &= test_openx(cli, torture); + ret &= test_ntcreatex(cli, torture); + ret &= test_nttrans_create(cli, torture); + ret &= test_t2open(cli, torture); + ret &= test_mknew(cli, torture); + ret &= test_create(cli, torture); + ret &= test_ctemp(cli, torture); + ret &= test_chained(cli, torture); + ret &= test_no_leading_slash(cli, torture); smb_raw_exit(cli->session); smbcli_deltree(cli->tree, BASEDIR); - torture_close_connection(cli); - talloc_free(mem_ctx); return ret; } diff --git a/source4/torture/raw/oplock.c b/source4/torture/raw/oplock.c index 1d6b22244a..f1779ad9cf 100644 --- a/source4/torture/raw/oplock.c +++ b/source4/torture/raw/oplock.c @@ -1282,9 +1282,9 @@ done: /* basic testing of oplocks */ -struct torture_suite *torture_raw_oplock(void) +struct torture_suite *torture_raw_oplock(TALLOC_CTX *mem_ctx) { - struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "OPLOCK"); + struct torture_suite *suite = torture_suite_create(mem_ctx, "OPLOCK"); torture_suite_add_2smb_test(suite, "NORMAL", test_raw_oplock_normal); torture_suite_add_2smb_test(suite, "BATCH1", test_raw_oplock_batch1); diff --git a/source4/torture/raw/qfileinfo.c b/source4/torture/raw/qfileinfo.c index 6bcfdcfe09..8cb80cecc1 100644 --- a/source4/torture/raw/qfileinfo.c +++ b/source4/torture/raw/qfileinfo.c @@ -222,9 +222,11 @@ static union smb_fileinfo *fname_find(bool is_ipc, const char *name) for each call we test that it succeeds, and where possible test for consistency between the calls. */ -static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture, TALLOC_CTX *mem_ctx, - struct smbcli_tree *tree, int fnum, const char *fname, - bool is_ipc) +static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture, + TALLOC_CTX *mem_ctx, + struct smbcli_tree *tree, + int fnum, const char *fname, + bool is_ipc) { int i; BOOL ret = True; @@ -816,56 +818,38 @@ done: for each call we test that it succeeds, and where possible test for consistency between the calls. */ -BOOL torture_raw_qfileinfo(struct torture_context *torture) +bool torture_raw_qfileinfo(struct torture_context *torture, + struct smbcli_state *cli) { - struct smbcli_state *cli; - BOOL ret = True; - TALLOC_CTX *mem_ctx; int fnum; + bool ret; const char *fname = "\\torture_qfileinfo.txt"; - if (!torture_open_connection(&cli, 0)) { - return False; - } - - mem_ctx = talloc_init("torture_qfileinfo"); - - fnum = create_complex_file(cli, mem_ctx, fname); + fnum = create_complex_file(cli, torture, fname); if (fnum == -1) { printf("ERROR: open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree)); - ret = False; - goto done; + return false; } - ret = torture_raw_qfileinfo_internals(torture, mem_ctx, cli->tree, fnum, fname, False /* is_ipc */); + ret = torture_raw_qfileinfo_internals(torture, torture, cli->tree, fnum, fname, False /* is_ipc */); smbcli_close(cli->tree, fnum); smbcli_unlink(cli->tree, fname); -done: - torture_close_connection(cli); - talloc_free(mem_ctx); return ret; } -BOOL torture_raw_qfileinfo_pipe(struct torture_context *torture) +bool torture_raw_qfileinfo_pipe(struct torture_context *torture, + struct smbcli_state *cli) { - TALLOC_CTX *mem_ctx; - BOOL ret = True; + bool ret = true; int fnum; const char *fname = "\\lsass"; - struct smbcli_state *cli; struct dcerpc_pipe *p; struct smbcli_tree *ipc_tree; NTSTATUS status; - if (!torture_open_connection(&cli, 0)) { - return False; - } - - mem_ctx = talloc_init("torture_qfileinfo_pipe"); - - if (!(p = dcerpc_pipe_init(mem_ctx, + if (!(p = dcerpc_pipe_init(torture, cli->tree->session->transport->socket->event.ctx))) { return False; } @@ -881,7 +865,7 @@ BOOL torture_raw_qfileinfo_pipe(struct torture_context *torture) ipc_tree = dcerpc_smb_tree(p->conn); fnum = dcerpc_smb_fnum(p->conn); - ret = torture_raw_qfileinfo_internals(torture, mem_ctx, ipc_tree, fnum, fname, True /* is_ipc */); + ret = torture_raw_qfileinfo_internals(torture, torture, ipc_tree, fnum, fname, True /* is_ipc */); talloc_free(p); return ret; diff --git a/source4/torture/raw/qfsinfo.c b/source4/torture/raw/qfsinfo.c index 982f348cd5..dc09e55b63 100644 --- a/source4/torture/raw/qfsinfo.c +++ b/source4/torture/raw/qfsinfo.c @@ -120,26 +120,19 @@ static union smb_fsinfo *find(const char *name) Some of the consistency tests assume that the target filesystem is quiescent, which is sometimes hard to achieve */ -BOOL torture_raw_qfsinfo(struct torture_context *torture) +bool torture_raw_qfsinfo(struct torture_context *torture, + struct smbcli_state *cli) { - struct smbcli_state *cli; int i; BOOL ret = True; int count; union smb_fsinfo *s1, *s2; - TALLOC_CTX *mem_ctx; - if (!torture_open_connection(&cli, 0)) { - return False; - } - - mem_ctx = talloc_init("torture_qfsinfo"); - /* scan all the levels, pulling the results */ for (i=0; levels[i].name; i++) { printf("Running level %s\n", levels[i].name); levels[i].fsinfo.generic.level = levels[i].level; - levels[i].status = smb_raw_fsinfo(cli->tree, mem_ctx, &levels[i].fsinfo); + levels[i].status = smb_raw_fsinfo(cli->tree, torture, &levels[i].fsinfo); } /* check for completely broken levels */ @@ -158,11 +151,10 @@ BOOL torture_raw_qfsinfo(struct torture_context *torture) } if (count != 0) { - ret = False; printf("%d levels failed\n", count); if (count > 13) { printf("too many level failures - giving up\n"); - goto done; + return False; } } @@ -303,8 +295,5 @@ BOOL torture_raw_qfsinfo(struct torture_context *torture) STR_CHECK("ATTRIBUTE_INFO", attribute_info, fs_type, STR_UNICODE); STR_CHECK("ATTRIBUTE_INFORMATION", attribute_info, fs_type, STR_UNICODE); -done: - torture_close_connection(cli); - talloc_free(mem_ctx); return ret; } diff --git a/source4/torture/raw/raw.c b/source4/torture/raw/raw.c index 67d79ef78c..85db92661b 100644 --- a/source4/torture/raw/raw.c +++ b/source4/torture/raw/raw.c @@ -21,6 +21,7 @@ #include "torture/torture.h" #include "libcli/raw/libcliraw.h" #include "torture/raw/proto.h" +#include "torture/util.h" NTSTATUS torture_raw_init(void) { @@ -31,33 +32,33 @@ NTSTATUS torture_raw_init(void) torture_suite_add_simple_test(suite, "BENCH-OPLOCK", torture_bench_oplock); torture_suite_add_simple_test(suite, "BENCH-LOCK", torture_bench_lock); torture_suite_add_simple_test(suite, "BENCH-OPEN", torture_bench_open); - torture_suite_add_simple_test(suite, "QFSINFO", torture_raw_qfsinfo); - torture_suite_add_simple_test(suite, "QFILEINFO", torture_raw_qfileinfo); - torture_suite_add_simple_test(suite, "QFILEINFO-IPC", torture_raw_qfileinfo_pipe); - torture_suite_add_simple_test(suite, "SFILEINFO", torture_raw_sfileinfo); - torture_suite_add_simple_test(suite, "SFILEINFO-BUG", torture_raw_sfileinfo_bug); - torture_suite_add_simple_test(suite, "SFILEINFO-RENAME", + torture_suite_add_1smb_test(suite, "QFSINFO", torture_raw_qfsinfo); + torture_suite_add_1smb_test(suite, "QFILEINFO", torture_raw_qfileinfo); + torture_suite_add_1smb_test(suite, "QFILEINFO-IPC", torture_raw_qfileinfo_pipe); + torture_suite_add_1smb_test(suite, "SFILEINFO", torture_raw_sfileinfo); + torture_suite_add_1smb_test(suite, "SFILEINFO-BUG", torture_raw_sfileinfo_bug); + torture_suite_add_1smb_test(suite, "SFILEINFO-RENAME", torture_raw_sfileinfo_rename); - torture_suite_add_simple_test(suite, "SEARCH", torture_raw_search); - torture_suite_add_simple_test(suite, "CLOSE", torture_raw_close); - torture_suite_add_simple_test(suite, "OPEN", torture_raw_open); - torture_suite_add_simple_test(suite, "MKDIR", torture_raw_mkdir); - torture_suite_add_suite(suite, torture_raw_oplock()); - torture_suite_add_simple_test(suite, "NOTIFY", torture_raw_notify); - torture_suite_add_simple_test(suite, "MUX", torture_raw_mux); - torture_suite_add_simple_test(suite, "IOCTL", torture_raw_ioctl); - torture_suite_add_simple_test(suite, "CHKPATH", torture_raw_chkpath); - torture_suite_add_simple_test(suite, "UNLINK", torture_raw_unlink); - torture_suite_add_simple_test(suite, "READ", torture_raw_read); - torture_suite_add_simple_test(suite, "WRITE", torture_raw_write); - torture_suite_add_simple_test(suite, "LOCK", torture_raw_lock); - torture_suite_add_simple_test(suite, "CONTEXT", torture_raw_context); - torture_suite_add_simple_test(suite, "RENAME", torture_raw_rename); - torture_suite_add_simple_test(suite, "SEEK", torture_raw_seek); - torture_suite_add_simple_test(suite, "EAS", torture_raw_eas); - torture_suite_add_simple_test(suite, "STREAMS", torture_raw_streams); - torture_suite_add_simple_test(suite, "ACLS", torture_raw_acls); - torture_suite_add_simple_test(suite, "COMPOSITE", torture_raw_composite); + torture_suite_add_suite(suite, torture_raw_search(suite)); + torture_suite_add_1smb_test(suite, "CLOSE", torture_raw_close); + torture_suite_add_1smb_test(suite, "OPEN", torture_raw_open); + torture_suite_add_1smb_test(suite, "MKDIR", torture_raw_mkdir); + torture_suite_add_suite(suite, torture_raw_oplock(suite)); + torture_suite_add_2smb_test(suite, "NOTIFY", torture_raw_notify); + torture_suite_add_1smb_test(suite, "MUX", torture_raw_mux); + torture_suite_add_1smb_test(suite, "IOCTL", torture_raw_ioctl); + torture_suite_add_1smb_test(suite, "CHKPATH", torture_raw_chkpath); + torture_suite_add_suite(suite, torture_raw_unlink(suite)); + torture_suite_add_suite(suite, torture_raw_read(suite)); + torture_suite_add_suite(suite, torture_raw_write(suite)); + torture_suite_add_suite(suite, torture_raw_lock(suite)); + torture_suite_add_1smb_test(suite, "CONTEXT", torture_raw_context); + torture_suite_add_suite(suite, torture_raw_rename(suite)); + torture_suite_add_1smb_test(suite, "SEEK", torture_raw_seek); + torture_suite_add_1smb_test(suite, "EAS", torture_raw_eas); + torture_suite_add_1smb_test(suite, "STREAMS", torture_raw_streams); + torture_suite_add_1smb_test(suite, "ACLS", torture_raw_acls); + torture_suite_add_1smb_test(suite, "COMPOSITE", torture_raw_composite); torture_suite_add_simple_test(suite, "SAMBA3HIDE", torture_samba3_hide); torture_suite_add_simple_test(suite, "SAMBA3CLOSEERR", torture_samba3_closeerr); torture_suite_add_simple_test(suite, "SAMBA3CHECKFSP", torture_samba3_checkfsp); diff --git a/source4/torture/raw/read.c b/source4/torture/raw/read.c index 95e9d891d9..f1048f25ac 100644 --- a/source4/torture/raw/read.c +++ b/source4/torture/raw/read.c @@ -81,7 +81,7 @@ static BOOL check_buffer(uint8_t *buf, uint_t seed, int len, int line) /* test read ops */ -static BOOL test_read(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_read(struct torture_context *tctx, struct smbcli_state *cli) { union smb_read io; NTSTATUS status; @@ -93,7 +93,7 @@ static BOOL test_read(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) const char *test_data = "TEST DATA"; uint_t seed = time(NULL); - buf = talloc_zero_size(mem_ctx, maxsize); + buf = talloc_zero_size(tctx, maxsize); if (!torture_setup_dir(cli, BASEDIR)) { return False; @@ -207,7 +207,8 @@ done: /* test lockread ops */ -static BOOL test_lockread(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_lockread(struct torture_context *tctx, + struct smbcli_state *cli) { union smb_read io; NTSTATUS status; @@ -219,7 +220,7 @@ static BOOL test_lockread(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) const char *test_data = "TEST DATA"; uint_t seed = time(NULL); - buf = talloc_zero_size(mem_ctx, maxsize); + buf = talloc_zero_size(tctx, maxsize); if (!torture_setup_dir(cli, BASEDIR)) { return False; @@ -352,7 +353,7 @@ done: /* test readx ops */ -static BOOL test_readx(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_readx(struct torture_context *tctx, struct smbcli_state *cli) { union smb_read io; NTSTATUS status; @@ -364,7 +365,7 @@ static BOOL test_readx(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) const char *test_data = "TEST DATA"; uint_t seed = time(NULL); - buf = talloc_zero_size(mem_ctx, maxsize); + buf = talloc_zero_size(tctx, maxsize); if (!torture_setup_dir(cli, BASEDIR)) { return False; @@ -590,7 +591,8 @@ done: /* test readbraw ops */ -static BOOL test_readbraw(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_readbraw(struct torture_context *tctx, + struct smbcli_state *cli) { union smb_read io; NTSTATUS status; @@ -602,7 +604,7 @@ static BOOL test_readbraw(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) const char *test_data = "TEST DATA"; uint_t seed = time(NULL); - buf = talloc_zero_size(mem_ctx, maxsize); + buf = talloc_zero_size(tctx, maxsize); if (!torture_setup_dir(cli, BASEDIR)) { return False; @@ -762,7 +764,8 @@ done: /* test read for execute */ -static BOOL test_read_for_execute(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_read_for_execute(struct torture_context *tctx, + struct smbcli_state *cli) { union smb_open op; union smb_write wr; @@ -775,7 +778,7 @@ static BOOL test_read_for_execute(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) const char *fname = BASEDIR "\\test.txt"; const uint8_t data[] = "TEST DATA"; - buf = talloc_zero_size(mem_ctx, maxsize); + buf = talloc_zero_size(tctx, maxsize); if (!torture_setup_dir(cli, BASEDIR)) { return False; @@ -795,7 +798,7 @@ static BOOL test_read_for_execute(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) op.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; op.ntcreatex.in.security_flags = 0; op.ntcreatex.in.fname = fname; - 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; @@ -826,7 +829,7 @@ static BOOL test_read_for_execute(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) op.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; op.ntcreatex.in.security_flags = 0; op.ntcreatex.in.fname = fname; - 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; @@ -873,7 +876,7 @@ static BOOL test_read_for_execute(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) op.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; op.ntcreatex.in.security_flags = 0; op.ntcreatex.in.fname = fname; - 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; @@ -917,25 +920,16 @@ done: /* basic testing of read calls */ -BOOL torture_raw_read(struct torture_context *torture) +struct torture_suite *torture_raw_read(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_read"); + struct torture_suite *suite = torture_suite_create(mem_ctx, "READ"); - ret &= test_read(cli, mem_ctx); - ret &= test_readx(cli, mem_ctx); - ret &= test_lockread(cli, mem_ctx); - ret &= test_readbraw(cli, mem_ctx); - ret &= test_read_for_execute(cli, mem_ctx); + torture_suite_add_1smb_test(suite, "read", test_read); + torture_suite_add_1smb_test(suite, "readx", test_readx); + torture_suite_add_1smb_test(suite, "lockread", test_lockread); + torture_suite_add_1smb_test(suite, "readbraw", test_readbraw); + torture_suite_add_1smb_test(suite, "read for execute", + test_read_for_execute); - torture_close_connection(cli); - talloc_free(mem_ctx); - return ret; + return suite; } diff --git a/source4/torture/raw/rename.c b/source4/torture/raw/rename.c index 6b1eb4392a..05a5320859 100644 --- a/source4/torture/raw/rename.c +++ b/source4/torture/raw/rename.c @@ -43,7 +43,8 @@ /* test SMBmv ops */ -static BOOL test_mv(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_mv(struct torture_context *tctx, + struct smbcli_state *cli) { union smb_rename io; NTSTATUS status; @@ -78,7 +79,7 @@ static BOOL test_mv(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) op.ntcreatex.in.security_flags = 0; op.ntcreatex.in.fname = fname1; - 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; @@ -98,7 +99,7 @@ static BOOL test_mv(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) NTCREATEX_SHARE_ACCESS_DELETE | NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; - 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; @@ -119,7 +120,7 @@ static BOOL test_mv(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) finfo.generic.level = RAW_FILEINFO_ALL_INFO; finfo.all_info.in.file.path = fname1; - status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo); + status = smb_raw_pathinfo(cli->tree, tctx, &finfo); CHECK_STATUS(status, NT_STATUS_OK); if (strcmp(finfo.all_info.out.fname.s, Fname1) != 0) { printf("(%s) Incorrect filename [%s] after case-changing " @@ -191,7 +192,8 @@ done: /* test SMBntrename ops */ -static BOOL test_ntrename(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_ntrename(struct torture_context *tctx, + struct smbcli_state *cli) { union smb_rename io; NTSTATUS status; @@ -209,7 +211,7 @@ static BOOL test_ntrename(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) printf("Trying simple rename\n"); - fnum = create_complex_file(cli, mem_ctx, fname1); + fnum = create_complex_file(cli, tctx, fname1); io.generic.level = RAW_RENAME_NTRENAME; io.ntrename.in.old_name = fname1; @@ -269,13 +271,13 @@ static BOOL test_ntrename(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) finfo.generic.level = RAW_FILEINFO_ALL_INFO; finfo.generic.in.file.path = fname2; - status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo); + status = smb_raw_pathinfo(cli->tree, tctx, &finfo); CHECK_STATUS(status, NT_STATUS_OK); CHECK_VALUE(finfo.all_info.out.nlink, 2); CHECK_VALUE(finfo.all_info.out.attrib, FILE_ATTRIBUTE_SYSTEM); finfo.generic.in.file.path = fname1; - status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo); + status = smb_raw_pathinfo(cli->tree, tctx, &finfo); CHECK_STATUS(status, NT_STATUS_OK); CHECK_VALUE(finfo.all_info.out.nlink, 2); CHECK_VALUE(finfo.all_info.out.attrib, FILE_ATTRIBUTE_SYSTEM); @@ -285,7 +287,7 @@ static BOOL test_ntrename(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) smbcli_unlink(cli->tree, fname2); finfo.generic.in.file.path = fname1; - status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo); + status = smb_raw_pathinfo(cli->tree, tctx, &finfo); CHECK_STATUS(status, NT_STATUS_OK); CHECK_VALUE(finfo.all_info.out.nlink, 1); CHECK_VALUE(finfo.all_info.out.attrib, FILE_ATTRIBUTE_NORMAL); @@ -300,14 +302,14 @@ static BOOL test_ntrename(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) finfo.generic.level = RAW_FILEINFO_ALL_INFO; finfo.generic.in.file.path = fname1; - status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo); + status = smb_raw_pathinfo(cli->tree, tctx, &finfo); CHECK_STATUS(status, NT_STATUS_OK); CHECK_VALUE(finfo.all_info.out.nlink, 1); CHECK_VALUE(finfo.all_info.out.attrib, FILE_ATTRIBUTE_NORMAL); finfo.generic.level = RAW_FILEINFO_ALL_INFO; finfo.generic.in.file.path = fname2; - status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo); + status = smb_raw_pathinfo(cli->tree, tctx, &finfo); CHECK_STATUS(status, NT_STATUS_OK); CHECK_VALUE(finfo.all_info.out.nlink, 1); CHECK_VALUE(finfo.all_info.out.attrib, FILE_ATTRIBUTE_NORMAL); @@ -316,13 +318,13 @@ static BOOL test_ntrename(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) finfo.generic.level = RAW_FILEINFO_ALL_INFO; finfo.generic.in.file.path = fname2; - status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo); + status = smb_raw_pathinfo(cli->tree, tctx, &finfo); CHECK_STATUS(status, NT_STATUS_OK); CHECK_VALUE(finfo.all_info.out.nlink, 1); CHECK_VALUE(finfo.all_info.out.attrib, FILE_ATTRIBUTE_NORMAL); finfo.generic.in.file.path = fname1; - status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo); + status = smb_raw_pathinfo(cli->tree, tctx, &finfo); CHECK_STATUS(status, NT_STATUS_OK); CHECK_VALUE(finfo.all_info.out.nlink, 1); CHECK_VALUE(finfo.all_info.out.attrib, FILE_ATTRIBUTE_SYSTEM); @@ -332,7 +334,7 @@ static BOOL test_ntrename(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) smbcli_unlink(cli->tree, fname2); finfo.generic.in.file.path = fname1; - status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo); + status = smb_raw_pathinfo(cli->tree, tctx, &finfo); CHECK_STATUS(status, NT_STATUS_OK); CHECK_VALUE(finfo.all_info.out.nlink, 1); @@ -436,27 +438,12 @@ done: /* basic testing of rename calls */ -BOOL torture_raw_rename(struct torture_context *torture) +struct torture_suite *torture_raw_rename(TALLOC_CTX *mem_ctx) { - struct smbcli_state *cli; - BOOL ret = True; - TALLOC_CTX *mem_ctx; + struct torture_suite *suite = torture_suite_create(mem_ctx, "RENAME"); - if (!torture_open_connection(&cli, 0)) { - return False; - } + torture_suite_add_1smb_test(suite, "mv", test_mv); + torture_suite_add_1smb_test(suite, "ntrename", test_ntrename); - mem_ctx = talloc_init("torture_raw_rename"); - - if (!test_mv(cli, mem_ctx)) { - ret = False; - } - - if (!test_ntrename(cli, mem_ctx)) { - ret = False; - } - - torture_close_connection(cli); - talloc_free(mem_ctx); - return ret; + return suite; } diff --git a/source4/torture/raw/search.c b/source4/torture/raw/search.c index cd79b4dd3b..986da474d0 100644 --- a/source4/torture/raw/search.c +++ b/source4/torture/raw/search.c @@ -43,7 +43,7 @@ static BOOL single_search_callback(void *private, const union smb_search_data *f do a single file (non-wildcard) search */ _PUBLIC_ NTSTATUS torture_single_search(struct smbcli_state *cli, - TALLOC_CTX *mem_ctx, + TALLOC_CTX *tctx, const char *pattern, enum smb_search_level level, enum smb_search_data_level data_level, @@ -79,7 +79,7 @@ _PUBLIC_ NTSTATUS torture_single_search(struct smbcli_state *cli, return NT_STATUS_INVALID_LEVEL; } - status = smb_raw_search_first(cli->tree, mem_ctx, + status = smb_raw_search_first(cli->tree, tctx, &io, (void *)data, single_search_callback); if (NT_STATUS_IS_OK(status) && level == RAW_SEARCH_FFIRST) { @@ -231,7 +231,8 @@ static union smb_search_data *find(const char *name) /* basic testing of all RAW_SEARCH_* calls using a single file */ -static BOOL test_one_file(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static BOOL test_one_file(struct torture_context *tctx, + struct smbcli_state *cli) { BOOL ret = True; int fnum; @@ -244,7 +245,7 @@ static BOOL test_one_file(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) printf("Testing one file searches\n"); - fnum = create_complex_file(cli, mem_ctx, fname); + fnum = create_complex_file(cli, tctx, fname); if (fnum == -1) { printf("ERROR: open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree)); ret = False; @@ -258,7 +259,7 @@ static BOOL test_one_file(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) printf("testing %s\n", levels[i].name); - levels[i].status = torture_single_search(cli, mem_ctx, fname, + levels[i].status = torture_single_search(cli, tctx, fname, levels[i].level, levels[i].data_level, 0, @@ -279,7 +280,7 @@ static BOOL test_one_file(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) continue; } - status = torture_single_search(cli, mem_ctx, fname2, + status = torture_single_search(cli, tctx, fname2, levels[i].level, levels[i].data_level, 0, @@ -303,7 +304,7 @@ static BOOL test_one_file(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) /* get the all_info file into to check against */ all_info.generic.level = RAW_FILEINFO_ALL_INFO; all_info.generic.in.file.path = fname; - status = smb_raw_pathinfo(cli->tree, mem_ctx, &all_info); + status = smb_raw_pathinfo(cli->tree, tctx, &all_info); if (!NT_STATUS_IS_OK(status)) { printf("RAW_FILEINFO_ALL_INFO failed - %s\n", nt_errstr(status)); ret = False; @@ -312,7 +313,7 @@ static BOOL test_one_file(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) alt_info.generic.level = RAW_FILEINFO_ALT_NAME_INFO; alt_info.generic.in.file.path = fname; - status = smb_raw_pathinfo(cli->tree, mem_ctx, &alt_info); + status = smb_raw_pathinfo(cli->tree, tctx, &alt_info); if (!NT_STATUS_IS_OK(status)) { printf("RAW_FILEINFO_ALT_NAME_INFO failed - %s\n", nt_errstr(status)); ret = False; @@ -321,7 +322,7 @@ static BOOL test_one_file(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) internal_info.generic.level = RAW_FILEINFO_INTERNAL_INFORMATION; internal_info.generic.in.file.path = fname; - status = smb_raw_pathinfo(cli->tree, mem_ctx, &internal_info); + status = smb_raw_pathinfo(cli->tree, tctx, &internal_info); if (!NT_STATUS_IS_OK(status)) { printf("RAW_FILEINFO_INTERNAL_INFORMATION failed - %s\n", nt_errstr(status)); ret = False; @@ -330,7 +331,7 @@ static BOOL test_one_file(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) name_info.generic.level = RAW_FILEINFO_NAME_INFO; name_info.generic.in.file.path = fname; - status = smb_raw_pathinfo(cli->tree, mem_ctx, &name_info); + status = smb_raw_pathinfo(cli->tree, tctx, &name_info); if (!NT_STATUS_IS_OK(status)) { printf("RAW_FILEINFO_NAME_INFO failed - %s\n", nt_errstr(status)); ret = False; @@ -355,8 +356,8 @@ static BOOL test_one_file(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) if (s->sname1.field1 != (~1 & nt_time_to_unix(v.sname2.out.field2))) { \ printf("(%s) %s/%s [%s] != %s/%s [%s]\n", \ __location__, \ - #sname1, #field1, timestring(mem_ctx, s->sname1.field1), \ - #sname2, #field2, nt_time_string(mem_ctx, v.sname2.out.field2)); \ + #sname1, #field1, timestring(tctx, s->sname1.field1), \ + #sname2, #field2, nt_time_string(tctx, v.sname2.out.field2)); \ ret = False; \ } \ }} while (0) @@ -367,8 +368,8 @@ static BOOL test_one_file(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) if (s->sname1.field1 != v.sname2.out.field2) { \ printf("(%s) %s/%s [%s] != %s/%s [%s]\n", \ __location__, \ - #sname1, #field1, nt_time_string(mem_ctx, s->sname1.field1), \ - #sname2, #field2, nt_time_string(mem_ctx, v.sname2.out.field2)); \ + #sname1, #field1, nt_time_string(tctx, s->sname1.field1), \ + #sname2, #field2, nt_time_string(tctx, v.sname2.out.field2)); \ ret = False; \ } \ }} while (0) @@ -518,7 +519,7 @@ done: struct multiple_result { - TALLOC_CTX *mem_ctx; + TALLOC_CTX *tctx; int count; union smb_search_data *list; }; @@ -532,7 +533,7 @@ static BOOL multiple_search_callback(void *private, const union smb_search_data data->count++; - data->list = talloc_realloc(data->mem_ctx, + data->list = talloc_realloc(data->tctx, data->list, union smb_search_data, data->count); @@ -548,7 +549,7 @@ enum continue_type {CONT_FLAGS, CONT_NAME, CONT_RESUME_KEY}; do a single file (non-wildcard) search */ static NTSTATUS multiple_search(struct smbcli_state *cli, - TALLOC_CTX *mem_ctx, + TALLOC_CTX *tctx, const char *pattern, enum smb_search_data_level data_level, enum continue_type cont_type, @@ -580,7 +581,7 @@ static NTSTATUS multiple_search(struct smbcli_state *cli, } } - status = smb_raw_search_first(cli->tree, mem_ctx, + status = smb_raw_search_first(cli->tree, tctx, &io, data, multiple_search_callback); @@ -621,7 +622,7 @@ static NTSTATUS multiple_search(struct smbcli_state *cli, } } - status = smb_raw_search_next(cli->tree, mem_ctx, + status = smb_raw_search_next(cli->tree, tctx, &io2, data, multiple_search_callback); if (!NT_STATUS_IS_OK(status)) { break; @@ -686,7 +687,8 @@ static int search_compare(union smb_search_data *d1, union smb_search_data *d2) /* basic testing of search calls using many files */ -static BOOL test_many_files(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_many_files(struct torture_context *tctx, + struct smbcli_state *cli) { const int num_files = 700; int i, fnum, t; @@ -745,11 +747,11 @@ static BOOL test_many_files(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) for (t=0;t<ARRAY_SIZE(search_types);t++) { ZERO_STRUCT(result); - result.mem_ctx = talloc_new(mem_ctx); + result.tctx = talloc_new(tctx); printf("Continue %s via %s\n", search_types[t].name, search_types[t].cont_name); - status = multiple_search(cli, mem_ctx, BASEDIR "\\*.*", + status = multiple_search(cli, tctx, BASEDIR "\\*.*", search_types[t].data_level, search_types[t].cont_type, &result); @@ -785,7 +787,7 @@ static BOOL test_many_files(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) } talloc_free(fname); } - talloc_free(result.mem_ctx); + talloc_free(result.tctx); } done: @@ -831,7 +833,8 @@ static BOOL check_result(struct multiple_result *result, const char *name, BOOL /* test what happens when the directory is modified during a search */ -static BOOL test_modify_search(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_modify_search(struct torture_context *tctx, + struct smbcli_state *cli) { const int num_files = 20; int i, fnum; @@ -863,7 +866,7 @@ static BOOL test_modify_search(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) printf("pulling the first file\n"); ZERO_STRUCT(result); - result.mem_ctx = talloc_new(mem_ctx); + result.tctx = talloc_new(tctx); io.t2ffirst.level = RAW_SEARCH_TRANS2; io.t2ffirst.data_level = RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO; @@ -873,7 +876,7 @@ static BOOL test_modify_search(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) io.t2ffirst.in.storage_type = 0; io.t2ffirst.in.pattern = BASEDIR "\\*.*"; - status = smb_raw_search_first(cli->tree, mem_ctx, + status = smb_raw_search_first(cli->tree, tctx, &io, &result, multiple_search_callback); CHECK_STATUS(status, NT_STATUS_OK); CHECK_VALUE(result.count, 1); @@ -887,7 +890,7 @@ static BOOL test_modify_search(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) io2.t2fnext.in.flags = 0; io2.t2fnext.in.last_name = result.list[result.count-1].both_directory_info.name.s; - status = smb_raw_search_next(cli->tree, mem_ctx, + status = smb_raw_search_next(cli->tree, tctx, &io2, &result, multiple_search_callback); CHECK_STATUS(status, NT_STATUS_OK); CHECK_VALUE(result.count, 2); @@ -897,7 +900,7 @@ static BOOL test_modify_search(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) printf("Changing attributes and deleting\n"); smbcli_open(cli->tree, BASEDIR "\\T003-03.txt.2", O_CREAT|O_RDWR, DENY_NONE); smbcli_open(cli->tree, BASEDIR "\\T013-13.txt.2", O_CREAT|O_RDWR, DENY_NONE); - fnum = create_complex_file(cli, mem_ctx, BASEDIR "\\T013-13.txt.3"); + fnum = create_complex_file(cli, tctx, BASEDIR "\\T013-13.txt.3"); smbcli_unlink(cli->tree, BASEDIR "\\T014-14.txt"); torture_set_file_attribute(cli->tree, BASEDIR "\\T015-15.txt", FILE_ATTRIBUTE_HIDDEN); torture_set_file_attribute(cli->tree, BASEDIR "\\T016-16.txt", FILE_ATTRIBUTE_NORMAL); @@ -917,7 +920,7 @@ static BOOL test_modify_search(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) io2.t2fnext.in.flags = 0; io2.t2fnext.in.last_name = "."; - status = smb_raw_search_next(cli->tree, mem_ctx, + status = smb_raw_search_next(cli->tree, tctx, &io2, &result, multiple_search_callback); CHECK_STATUS(status, NT_STATUS_OK); CHECK_VALUE(result.count, 20); @@ -937,7 +940,7 @@ static BOOL test_modify_search(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) for (i=0;i<result.count;i++) { printf("%s %s (0x%x)\n", result.list[i].both_directory_info.name.s, - attrib_string(mem_ctx, result.list[i].both_directory_info.attrib), + attrib_string(tctx, result.list[i].both_directory_info.attrib), result.list[i].both_directory_info.attrib); } } @@ -953,7 +956,7 @@ done: /* testing if directories always come back sorted */ -static BOOL test_sorted(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_sorted(struct torture_context *tctx, struct smbcli_state *cli) { const int num_files = 700; int i, fnum; @@ -969,7 +972,7 @@ static BOOL test_sorted(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) printf("Creating %d files\n", num_files); for (i=0;i<num_files;i++) { - fname = talloc_asprintf(cli, BASEDIR "\\%s.txt", generate_random_str_list(mem_ctx, 10, "abcdefgh")); + fname = talloc_asprintf(cli, BASEDIR "\\%s.txt", generate_random_str_list(tctx, 10, "abcdefgh")); fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE); if (fnum == -1) { printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree)); @@ -982,9 +985,9 @@ static BOOL test_sorted(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) ZERO_STRUCT(result); - result.mem_ctx = mem_ctx; + result.tctx = tctx; - status = multiple_search(cli, mem_ctx, BASEDIR "\\*.*", + status = multiple_search(cli, tctx, BASEDIR "\\*.*", RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO, CONT_NAME, &result); CHECK_STATUS(status, NT_STATUS_OK); @@ -1016,7 +1019,8 @@ done: /* basic testing of many old style search calls using separate dirs */ -static BOOL test_many_dirs(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_many_dirs(struct torture_context *tctx, + struct smbcli_state *cli) { const int num_dirs = 20; int i, fnum, n; @@ -1057,9 +1061,9 @@ static BOOL test_many_dirs(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) talloc_free(dname); } - file = talloc_zero_array(mem_ctx, union smb_search_data, num_dirs); - file2 = talloc_zero_array(mem_ctx, union smb_search_data, num_dirs); - file3 = talloc_zero_array(mem_ctx, union smb_search_data, num_dirs); + file = talloc_zero_array(tctx, union smb_search_data, num_dirs); + file2 = talloc_zero_array(tctx, union smb_search_data, num_dirs); + file3 = talloc_zero_array(tctx, union smb_search_data, num_dirs); printf("Search first on %d dirs\n", num_dirs); @@ -1069,12 +1073,12 @@ static BOOL test_many_dirs(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) io.search_first.data_level = RAW_SEARCH_DATA_SEARCH; io.search_first.in.max_count = 1; io.search_first.in.search_attrib = 0; - io.search_first.in.pattern = talloc_asprintf(mem_ctx, BASEDIR "\\d%d\\*.txt", i); - fname = talloc_asprintf(mem_ctx, "f%d-", i); + io.search_first.in.pattern = talloc_asprintf(tctx, BASEDIR "\\d%d\\*.txt", i); + fname = talloc_asprintf(tctx, "f%d-", i); io.search_first.out.count = 0; - status = smb_raw_search_first(cli->tree, mem_ctx, + status = smb_raw_search_first(cli->tree, tctx, &io, (void *)&file[i], single_search_callback); if (io.search_first.out.count != 1) { printf("(%s) search first gave %d entries for dir %d - %s\n", @@ -1103,11 +1107,11 @@ static BOOL test_many_dirs(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) io2.search_next.in.max_count = 1; io2.search_next.in.search_attrib = 0; io2.search_next.in.id = file[i].search.id; - fname = talloc_asprintf(mem_ctx, "f%d-", i); + fname = talloc_asprintf(tctx, "f%d-", i); io2.search_next.out.count = 0; - status = smb_raw_search_next(cli->tree, mem_ctx, + status = smb_raw_search_next(cli->tree, tctx, &io2, (void *)&file2[i], single_search_callback); if (io2.search_next.out.count != 1) { printf("(%s) search next gave %d entries for dir %d - %s\n", @@ -1137,10 +1141,10 @@ static BOOL test_many_dirs(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) io2.search_next.in.max_count = 1; io2.search_next.in.search_attrib = 0; io2.search_next.in.id = file[i].search.id; - fname = talloc_asprintf(mem_ctx, "f%d-", i); + fname = talloc_asprintf(tctx, "f%d-", i); io2.search_next.out.count = 0; - status = smb_raw_search_next(cli->tree, mem_ctx, + status = smb_raw_search_next(cli->tree, tctx, &io2, (void *)&file3[i], single_search_callback); if (io2.search_next.out.count != 1) { printf("(%s) search next gave %d entries for dir %d - %s\n", @@ -1179,7 +1183,8 @@ done: /* testing of OS/2 style delete */ -static BOOL test_os2_delete(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_os2_delete(struct torture_context *tctx, + struct smbcli_state *cli) { const int num_files = 700; const int delete_count = 4; @@ -1212,7 +1217,7 @@ static BOOL test_os2_delete(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) ZERO_STRUCT(result); - result.mem_ctx = mem_ctx; + result.tctx = tctx; io.t2ffirst.level = RAW_SEARCH_TRANS2; io.t2ffirst.data_level = RAW_SEARCH_DATA_EA_SIZE; @@ -1222,7 +1227,7 @@ static BOOL test_os2_delete(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) io.t2ffirst.in.storage_type = 0; io.t2ffirst.in.pattern = BASEDIR "\\*"; - status = smb_raw_search_first(cli->tree, mem_ctx, + status = smb_raw_search_first(cli->tree, tctx, &io, &result, multiple_search_callback); CHECK_STATUS(status, NT_STATUS_OK); @@ -1244,9 +1249,9 @@ static BOOL test_os2_delete(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) do { ZERO_STRUCT(result); - result.mem_ctx = mem_ctx; + result.tctx = tctx; - status = smb_raw_search_next(cli->tree, mem_ctx, + status = smb_raw_search_next(cli->tree, tctx, &io2, &result, multiple_search_callback); if (!NT_STATUS_IS_OK(status)) { break; @@ -1290,7 +1295,8 @@ static int ealist_cmp(union smb_search_data *r1, union smb_search_data *r2) /* testing of the rather strange ea_list level */ -static BOOL test_ea_list(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_ea_list(struct torture_context *tctx, + struct smbcli_state *cli) { int fnum; BOOL ret = True; @@ -1318,7 +1324,7 @@ static BOOL test_ea_list(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) setfile.generic.level = RAW_SFILEINFO_EA_SET; setfile.generic.in.file.path = BASEDIR "\\file2.txt"; setfile.ea_set.in.num_eas = 2; - setfile.ea_set.in.eas = talloc_array(mem_ctx, struct ea_struct, 2); + setfile.ea_set.in.eas = talloc_array(tctx, struct ea_struct, 2); setfile.ea_set.in.eas[0].flags = 0; setfile.ea_set.in.eas[0].name.s = "EA ONE"; setfile.ea_set.in.eas[0].value = data_blob_string_const("VALUE 1"); @@ -1334,7 +1340,7 @@ static BOOL test_ea_list(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) CHECK_STATUS(status, NT_STATUS_OK); ZERO_STRUCT(result); - result.mem_ctx = mem_ctx; + result.tctx = tctx; io.t2ffirst.level = RAW_SEARCH_TRANS2; io.t2ffirst.data_level = RAW_SEARCH_DATA_EA_LIST; @@ -1344,11 +1350,11 @@ static BOOL test_ea_list(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) io.t2ffirst.in.storage_type = 0; io.t2ffirst.in.pattern = BASEDIR "\\*"; io.t2ffirst.in.num_names = 2; - io.t2ffirst.in.ea_names = talloc_array(mem_ctx, struct ea_name, 2); + io.t2ffirst.in.ea_names = talloc_array(tctx, struct ea_name, 2); io.t2ffirst.in.ea_names[0].name.s = "SECOND EA"; io.t2ffirst.in.ea_names[1].name.s = "THIRD EA"; - status = smb_raw_search_first(cli->tree, mem_ctx, + status = smb_raw_search_first(cli->tree, tctx, &io, &result, multiple_search_callback); CHECK_STATUS(status, NT_STATUS_OK); CHECK_VALUE(result.count, 2); @@ -1361,11 +1367,11 @@ static BOOL test_ea_list(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) nxt.t2fnext.in.flags = FLAG_TRANS2_FIND_REQUIRE_RESUME | FLAG_TRANS2_FIND_CONTINUE; nxt.t2fnext.in.last_name = result.list[1].ea_list.name.s; nxt.t2fnext.in.num_names = 2; - nxt.t2fnext.in.ea_names = talloc_array(mem_ctx, struct ea_name, 2); + nxt.t2fnext.in.ea_names = talloc_array(tctx, struct ea_name, 2); nxt.t2fnext.in.ea_names[0].name.s = "SECOND EA"; nxt.t2fnext.in.ea_names[1].name.s = "THIRD EA"; - status = smb_raw_search_next(cli->tree, mem_ctx, + status = smb_raw_search_next(cli->tree, tctx, &nxt, &result, multiple_search_callback); CHECK_STATUS(status, NT_STATUS_OK); @@ -1408,28 +1414,17 @@ done: /* basic testing of all RAW_SEARCH_* calls using a single file */ -BOOL torture_raw_search(struct torture_context *torture) +struct torture_suite *torture_raw_search(TALLOC_CTX *mem_ctx) { - struct smbcli_state *cli; - BOOL ret = True; - TALLOC_CTX *mem_ctx; - - if (!torture_open_connection(&cli, 0)) { - return False; - } + struct torture_suite *suite = torture_suite_create(mem_ctx, "SEARCH"); - mem_ctx = talloc_init("torture_search"); + torture_suite_add_1smb_test(suite, "one file", test_one_file); + torture_suite_add_1smb_test(suite, "many files", test_many_files); + torture_suite_add_1smb_test(suite, "sorted", test_sorted); + torture_suite_add_1smb_test(suite, "modify search", test_modify_search); + torture_suite_add_1smb_test(suite, "many dirs", test_many_dirs); + torture_suite_add_1smb_test(suite, "os2 delete", test_os2_delete); + torture_suite_add_1smb_test(suite, "ea list", test_ea_list); - ret &= test_one_file(cli, mem_ctx); - ret &= test_many_files(cli, mem_ctx); - ret &= test_sorted(cli, mem_ctx); - ret &= test_modify_search(cli, mem_ctx); - ret &= test_many_dirs(cli, mem_ctx); - ret &= test_os2_delete(cli, mem_ctx); - ret &= test_ea_list(cli, mem_ctx); - - torture_close_connection(cli); - talloc_free(mem_ctx); - - return ret; + return suite; } diff --git a/source4/torture/raw/seek.c b/source4/torture/raw/seek.c index f9b072b3de..f5413d8b1d 100644 --- a/source4/torture/raw/seek.c +++ b/source4/torture/raw/seek.c @@ -233,23 +233,11 @@ done: /* basic testing of seek calls */ -BOOL torture_raw_seek(struct torture_context *torture) +bool torture_raw_seek(struct torture_context *torture, struct smbcli_state *cli) { - struct smbcli_state *cli; - BOOL ret = True; - TALLOC_CTX *mem_ctx; - - if (!torture_open_connection(&cli, 0)) { - return False; - } + bool ret = true; - mem_ctx = talloc_init("torture_raw_seek"); - - if (!test_seek(cli, mem_ctx)) { - ret = False; - } + ret &= test_seek(cli, torture); - torture_close_connection(cli); - talloc_free(mem_ctx); return ret; } diff --git a/source4/torture/raw/setfileinfo.c b/source4/torture/raw/setfileinfo.c index d30637bce8..b06a04753f 100644 --- a/source4/torture/raw/setfileinfo.c +++ b/source4/torture/raw/setfileinfo.c @@ -30,11 +30,10 @@ for each call we test that it succeeds, and where possible test for consistency between the calls. */ -BOOL torture_raw_sfileinfo(struct torture_context *torture) +bool torture_raw_sfileinfo(struct torture_context *torture, + struct smbcli_state *cli) { - struct smbcli_state *cli; BOOL ret = True; - TALLOC_CTX *mem_ctx; int fnum_saved, d_fnum, fnum2, fnum = -1; char *fnum_fname; char *fnum_fname_new; @@ -53,19 +52,13 @@ BOOL torture_raw_sfileinfo(struct torture_context *torture) asprintf(&fnum_fname, BASEDIR "\\fnum_test_%d.txt", n); asprintf(&fnum_fname_new, BASEDIR "\\fnum_test_new_%d.txt", n); - if (!torture_open_connection(&cli, 0)) { - return False; - } - - mem_ctx = talloc_init("torture_sfileinfo"); - if (!torture_setup_dir(cli, BASEDIR)) { return False; } #define RECREATE_FILE(fname) do { \ if (fnum != -1) smbcli_close(cli->tree, fnum); \ - fnum = create_complex_file(cli, mem_ctx, fname); \ + fnum = create_complex_file(cli, torture, fname); \ if (fnum == -1) { \ printf("(%s) ERROR: open of %s failed (%s)\n", \ __location__, fname, smbcli_errstr(cli->tree)); \ @@ -94,7 +87,7 @@ BOOL torture_raw_sfileinfo(struct torture_context *torture) } \ finfo1.generic.level = RAW_FILEINFO_ALL_INFO; \ finfo1.generic.in.file.fnum = fnum; \ - status2 = smb_raw_fileinfo(cli->tree, mem_ctx, &finfo1); \ + status2 = smb_raw_fileinfo(cli->tree, torture, &finfo1); \ if (!NT_STATUS_IS_OK(status2)) { \ printf("(%s) %s pathinfo - %s\n", __location__, #call, nt_errstr(status)); \ ret = False; \ @@ -117,10 +110,10 @@ BOOL torture_raw_sfileinfo(struct torture_context *torture) } \ finfo1.generic.level = RAW_FILEINFO_ALL_INFO; \ finfo1.generic.in.file.path = path_fname; \ - status2 = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo1); \ + status2 = smb_raw_pathinfo(cli->tree, torture, &finfo1); \ if (NT_STATUS_EQUAL(status2, NT_STATUS_OBJECT_NAME_NOT_FOUND)) { \ finfo1.generic.in.file.path = path_fname_new; \ - status2 = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo1); \ + status2 = smb_raw_pathinfo(cli->tree, torture, &finfo1); \ } \ if (!NT_STATUS_IS_OK(status2)) { \ printf("(%s) %s pathinfo - %s\n", __location__, #call, nt_errstr(status2)); \ @@ -132,13 +125,13 @@ BOOL torture_raw_sfileinfo(struct torture_context *torture) finfo2.generic.level = RAW_FILEINFO_ ## call; \ if (check_fnum) { \ finfo2.generic.in.file.fnum = fnum; \ - status2 = smb_raw_fileinfo(cli->tree, mem_ctx, &finfo2); \ + status2 = smb_raw_fileinfo(cli->tree, torture, &finfo2); \ } else { \ finfo2.generic.in.file.path = path_fname; \ - status2 = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo2); \ + status2 = smb_raw_pathinfo(cli->tree, torture, &finfo2); \ if (NT_STATUS_EQUAL(status2, NT_STATUS_OBJECT_NAME_NOT_FOUND)) { \ finfo2.generic.in.file.path = path_fname_new; \ - status2 = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo2); \ + status2 = smb_raw_pathinfo(cli->tree, torture, &finfo2); \ } \ } \ if (!NT_STATUS_IS_OK(status2)) { \ @@ -153,7 +146,7 @@ BOOL torture_raw_sfileinfo(struct torture_context *torture) printf("(%s) %s - %s/%s should be 0x%x - 0x%x\n", __location__, \ call_name, #stype, #field, \ (uint_t)value, (uint_t)finfo2.stype.out.field); \ - dump_all_info(mem_ctx, &finfo1); \ + dump_all_info(torture, &finfo1); \ ret = False; \ }} while (0) @@ -164,9 +157,9 @@ BOOL torture_raw_sfileinfo(struct torture_context *torture) call_name, #stype, #field, \ (uint_t)value, \ (uint_t)nt_time_to_unix(finfo2.stype.out.field)); \ - printf("\t%s", timestring(mem_ctx, value)); \ - printf("\t%s\n", nt_time_string(mem_ctx, finfo2.stype.out.field)); \ - dump_all_info(mem_ctx, &finfo1); \ + printf("\t%s", timestring(torture, value)); \ + printf("\t%s\n", nt_time_string(torture, finfo2.stype.out.field)); \ + dump_all_info(torture, &finfo1); \ ret = False; \ }} while (0) @@ -177,7 +170,7 @@ BOOL torture_raw_sfileinfo(struct torture_context *torture) call_name, #stype, #field, \ value, \ finfo2.stype.out.field); \ - dump_all_info(mem_ctx, &finfo1); \ + dump_all_info(torture, &finfo1); \ ret = False; \ }} while (0) @@ -444,19 +437,16 @@ done: printf("Failed to delete %s - %s\n", path_fname, smbcli_errstr(cli->tree)); } - torture_close_connection(cli); - talloc_free(mem_ctx); return ret; } /* * basic testing of all RAW_SFILEINFO_RENAME call */ -BOOL torture_raw_sfileinfo_rename(struct torture_context *torture) +bool torture_raw_sfileinfo_rename(struct torture_context *torture, + struct smbcli_state *cli) { - struct smbcli_state *cli; BOOL ret = True; - TALLOC_CTX *mem_ctx; int fnum_saved, d_fnum, fnum2, fnum = -1; char *fnum_fname; char *fnum_fname_new; @@ -474,12 +464,6 @@ BOOL torture_raw_sfileinfo_rename(struct torture_context *torture) asprintf(&fnum_fname, BASEDIR "\\fnum_test_%d.txt", n); asprintf(&fnum_fname_new, BASEDIR "\\fnum_test_new_%d.txt", n); - if (!torture_open_connection(&cli, 0)) { - return False; - } - - mem_ctx = talloc_init("torture_sfileinfo"); - if (!torture_setup_dir(cli, BASEDIR)) { return False; } @@ -488,8 +472,8 @@ BOOL torture_raw_sfileinfo_rename(struct torture_context *torture) ZERO_STRUCT(sfinfo); - smbcli_close(cli->tree, create_complex_file(cli, mem_ctx, fnum_fname_new)); - smbcli_close(cli->tree, create_complex_file(cli, mem_ctx, path_fname_new)); + smbcli_close(cli->tree, create_complex_file(cli, torture, fnum_fname_new)); + smbcli_close(cli->tree, create_complex_file(cli, torture, path_fname_new)); sfinfo.rename_information.in.overwrite = 0; sfinfo.rename_information.in.root_fid = 0; @@ -509,7 +493,7 @@ BOOL torture_raw_sfileinfo_rename(struct torture_context *torture) CHECK_STR(NAME_INFO, name_info, fname.s, fnum_fname_new); printf("Trying rename with dest file open\n"); - fnum2 = create_complex_file(cli, mem_ctx, fnum_fname); + fnum2 = create_complex_file(cli, torture, fnum_fname); sfinfo.rename_information.in.new_name = fnum_fname+strlen(BASEDIR)+1; sfinfo.rename_information.in.overwrite = 1; CHECK_CALL_FNUM(RENAME_INFORMATION, NT_STATUS_ACCESS_DENIED); @@ -536,7 +520,7 @@ BOOL torture_raw_sfileinfo_rename(struct torture_context *torture) CHECK_CALL_FNUM(RENAME_INFORMATION, NT_STATUS_OK); CHECK_STR(NAME_INFO, name_info, fname.s, fnum_fname); - fnum2 = create_complex_file(cli, mem_ctx, fnum_fname); + fnum2 = create_complex_file(cli, torture, fnum_fname); sfinfo.rename_information.in.new_name = fnum_fname_new+strlen(BASEDIR)+1; sfinfo.rename_information.in.overwrite = 0; CHECK_CALL_FNUM(RENAME_INFORMATION, NT_STATUS_OK); @@ -579,35 +563,25 @@ done: printf("Failed to delete %s - %s\n", path_fname, smbcli_errstr(cli->tree)); } - torture_close_connection(cli); - talloc_free(mem_ctx); return ret; } /* look for the w2k3 setpathinfo STANDARD bug */ -BOOL torture_raw_sfileinfo_bug(struct torture_context *torture) +bool torture_raw_sfileinfo_bug(struct torture_context *torture, + struct smbcli_state *cli) { - struct smbcli_state *cli; - TALLOC_CTX *mem_ctx; const char *fname = "\\bug3.txt"; union smb_setfileinfo sfinfo; NTSTATUS status; int fnum; - if (!torture_setting_bool(torture, "dangerous", False)) { - printf("torture_raw_sfileinfo_bug disabled - enable dangerous tests to use\n"); - return True; - } - - if (!torture_open_connection(&cli, 0)) { - return False; - } - - mem_ctx = talloc_init("torture_sfileinfo"); + if (!torture_setting_bool(torture, "dangerous", false)) + torture_skip(torture, + "torture_raw_sfileinfo_bug disabled - enable dangerous tests to use\n"); - fnum = create_complex_file(cli, mem_ctx, fname); + fnum = create_complex_file(cli, torture, fname); smbcli_close(cli->tree, fnum); sfinfo.generic.level = RAW_SFILEINFO_STANDARD; diff --git a/source4/torture/raw/streams.c b/source4/torture/raw/streams.c index b52d84f772..24428efcf7 100644 --- a/source4/torture/raw/streams.c +++ b/source4/torture/raw/streams.c @@ -213,28 +213,19 @@ done: /* basic testing of streams calls */ -BOOL torture_raw_streams(struct torture_context *torture) +bool torture_raw_streams(struct torture_context *torture, + struct smbcli_state *cli) { - 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_streams"); if (!torture_setup_dir(cli, BASEDIR)) { return False; } - ret &= test_stream_io(cli, mem_ctx); + ret &= test_stream_io(cli, torture); smb_raw_exit(cli->session); smbcli_deltree(cli->tree, BASEDIR); - torture_close_connection(cli); - talloc_free(mem_ctx); return ret; } 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; } diff --git a/source4/torture/raw/write.c b/source4/torture/raw/write.c index 9b043bfe2c..75d275fc3c 100644 --- a/source4/torture/raw/write.c +++ b/source4/torture/raw/write.c @@ -51,12 +51,12 @@ #define CHECK_ALL_INFO(v, field) do { \ finfo.all_info.level = RAW_FILEINFO_ALL_INFO; \ finfo.all_info.in.file.path = fname; \ - status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo); \ + status = smb_raw_pathinfo(cli->tree, tctx, &finfo); \ CHECK_STATUS(status, NT_STATUS_OK); \ if ((v) != finfo.all_info.out.field) { \ printf("(%s) wrong value for field %s %.0f - %.0f\n", \ __location__, #field, (double)v, (double)finfo.all_info.out.field); \ - dump_all_info(mem_ctx, &finfo); \ + dump_all_info(tctx, &finfo); \ ret = False; \ }} while (0) @@ -95,7 +95,8 @@ static BOOL check_buffer(uint8_t *buf, uint_t seed, int len, const char *locatio /* test write ops */ -static BOOL test_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_write(struct torture_context *tctx, + struct smbcli_state *cli) { union smb_write io; NTSTATUS status; @@ -107,7 +108,7 @@ static BOOL test_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) uint_t seed = time(NULL); union smb_fileinfo finfo; - buf = talloc_zero_size(mem_ctx, maxsize); + buf = talloc_zero_size(tctx, maxsize); if (!torture_setup_dir(cli, BASEDIR)) { return False; @@ -222,7 +223,8 @@ done: /* test writex ops */ -static BOOL test_writex(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_writex(struct torture_context *tctx, + struct smbcli_state *cli) { union smb_write io; NTSTATUS status; @@ -240,7 +242,7 @@ static BOOL test_writex(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) printf("dangerous not set - limiting range of test to 2^%d\n", max_bits); } - buf = talloc_zero_size(mem_ctx, maxsize); + buf = talloc_zero_size(tctx, maxsize); if (!torture_setup_dir(cli, BASEDIR)) { return False; @@ -409,7 +411,8 @@ done: /* test write unlock ops */ -static BOOL test_writeunlock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_writeunlock(struct torture_context *tctx, + struct smbcli_state *cli) { union smb_write io; NTSTATUS status; @@ -421,7 +424,7 @@ static BOOL test_writeunlock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) uint_t seed = time(NULL); union smb_fileinfo finfo; - buf = talloc_zero_size(mem_ctx, maxsize); + buf = talloc_zero_size(tctx, maxsize); if (!torture_setup_dir(cli, BASEDIR)) { return False; @@ -551,7 +554,8 @@ done: /* test write close ops */ -static BOOL test_writeclose(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_writeclose(struct torture_context *tctx, + struct smbcli_state *cli) { union smb_write io; NTSTATUS status; @@ -563,7 +567,7 @@ static BOOL test_writeclose(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) uint_t seed = time(NULL); union smb_fileinfo finfo; - buf = talloc_zero_size(mem_ctx, maxsize); + buf = talloc_zero_size(tctx, maxsize); if (!torture_setup_dir(cli, BASEDIR)) { return False; @@ -706,24 +710,14 @@ done: /* basic testing of write calls */ -BOOL torture_raw_write(struct torture_context *torture) +struct torture_suite *torture_raw_write(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_write"); + struct torture_suite *suite = torture_suite_create(mem_ctx, "WRITE"); - ret &= test_write(cli, mem_ctx); - ret &= test_writeunlock(cli, mem_ctx); - ret &= test_writeclose(cli, mem_ctx); - ret &= test_writex(cli, mem_ctx); + torture_suite_add_1smb_test(suite, "write", test_write); + torture_suite_add_1smb_test(suite, "write unlock", test_writeunlock); + torture_suite_add_1smb_test(suite, "write close", test_writeclose); + torture_suite_add_1smb_test(suite, "writex", test_writex); - torture_close_connection(cli); - talloc_free(mem_ctx); - return ret; + return suite; } |