summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-04-25 10:04:20 +0100
committerJelmer Vernooij <jelmer@samba.org>2008-04-25 10:04:20 +0100
commitcc9c4aaa8d02c4c31c9e9a4bb53e5941683fcc31 (patch)
treed0b116699dee35372ed335834989e1c885e8f94a /source4/torture
parentd1432d617e6ed04c33ca214d7f3b0099bdf53065 (diff)
parent240d959005f5fd80a38b3734b39dd5d6e425a566 (diff)
downloadsamba-cc9c4aaa8d02c4c31c9e9a4bb53e5941683fcc31.tar.gz
samba-cc9c4aaa8d02c4c31c9e9a4bb53e5941683fcc31.tar.bz2
samba-cc9c4aaa8d02c4c31c9e9a4bb53e5941683fcc31.zip
Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into v4-0-gmake3
Conflicts: source/Makefile source/auth/config.mk source/auth/gensec/config.mk source/build/m4/public.m4 source/build/make/python.mk source/build/make/rules.mk source/build/smb_build/header.pm source/build/smb_build/main.pl source/build/smb_build/makefile.pm source/dsdb/config.mk source/dsdb/samdb/ldb_modules/config.mk source/kdc/config.mk source/lib/events/config.mk source/lib/events/events.c source/lib/ldb/config.mk source/lib/nss_wrapper/config.mk source/lib/policy/config.mk source/lib/util/config.mk source/libcli/smb2/config.mk source/libnet/config.mk source/librpc/config.mk source/nbt_server/config.mk source/ntptr/ntptr_base.c source/ntvfs/posix/config.mk source/ntvfs/sysdep/config.mk source/param/config.mk source/rpc_server/config.mk source/rpc_server/service_rpc.c source/scripting/ejs/config.mk source/scripting/python/config.mk source/smb_server/config.mk source/smbd/server.c source/torture/config.mk source/torture/smb2/config.mk source/wrepl_server/config.mk (This used to be commit 13bbd420681519894a4036729c43273912c9b402)
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/auth/ntlmssp.c10
-rw-r--r--source4/torture/basic/base.c5
-rw-r--r--source4/torture/basic/delaywrite.c278
-rw-r--r--source4/torture/config.mk42
-rw-r--r--source4/torture/gentest.c47
-rw-r--r--source4/torture/ldap/cldap.c8
-rw-r--r--source4/torture/ldap/cldapbench.c6
-rw-r--r--source4/torture/ldap/common.c2
-rw-r--r--source4/torture/ldap/schema.c2
-rw-r--r--source4/torture/ldap/uptodatevector.c2
-rw-r--r--source4/torture/libnet/domain.c4
-rw-r--r--source4/torture/libnet/libnet_BecomeDC.c48
-rw-r--r--source4/torture/libnet/libnet_domain.c15
-rw-r--r--source4/torture/libnet/libnet_group.c6
-rw-r--r--source4/torture/libnet/libnet_lookup.c8
-rw-r--r--source4/torture/libnet/libnet_rpc.c2
-rw-r--r--source4/torture/libnet/libnet_share.c4
-rw-r--r--source4/torture/libnet/libnet_user.c16
-rw-r--r--source4/torture/local/dbspeed.c2
-rw-r--r--source4/torture/local/torture.c41
-rw-r--r--source4/torture/locktest.c26
-rw-r--r--source4/torture/locktest2.c26
-rw-r--r--source4/torture/masktest.c9
-rw-r--r--source4/torture/nbt/browse.c2
-rw-r--r--source4/torture/nbt/dgram.c12
-rw-r--r--source4/torture/nbt/nbt.c2
-rw-r--r--source4/torture/nbt/query.c2
-rw-r--r--source4/torture/nbt/register.c4
-rw-r--r--source4/torture/nbt/wins.c2
-rw-r--r--source4/torture/nbt/winsbench.c2
-rw-r--r--source4/torture/nbt/winsreplication.c18
-rw-r--r--source4/torture/ndr/netlogon.c12
-rw-r--r--source4/torture/raw/composite.c4
-rw-r--r--source4/torture/raw/lockbench.c9
-rw-r--r--source4/torture/raw/lookuprate.c320
-rw-r--r--source4/torture/raw/offline.c13
-rw-r--r--source4/torture/raw/open.c10
-rw-r--r--source4/torture/raw/openbench.c9
-rw-r--r--source4/torture/raw/oplock.c3
-rw-r--r--source4/torture/raw/raw.c2
-rw-r--r--source4/torture/raw/samba3hide.c2
-rw-r--r--source4/torture/raw/samba3misc.c2
-rw-r--r--source4/torture/rpc/async_bind.c7
-rw-r--r--source4/torture/rpc/dfs.c8
-rw-r--r--source4/torture/rpc/dssync.c10
-rw-r--r--source4/torture/rpc/join.c4
-rw-r--r--source4/torture/rpc/rpc.c8
-rw-r--r--source4/torture/rpc/samba3rpc.c24
-rw-r--r--source4/torture/rpc/samlogon.c2
-rw-r--r--source4/torture/rpc/samsync.c4
-rw-r--r--source4/torture/rpc/schannel.c16
-rw-r--r--source4/torture/rpc/session_key.c6
-rw-r--r--source4/torture/rpc/testjoin.c12
-rw-r--r--source4/torture/smb2/config.mk4
-rw-r--r--source4/torture/smb2/oplocks.c178
-rw-r--r--source4/torture/smb2/persistent_handles.c184
-rw-r--r--source4/torture/smb2/scan.c4
-rw-r--r--source4/torture/smb2/smb2.c63
-rw-r--r--source4/torture/smb2/util.c2
-rw-r--r--source4/torture/smbtorture.c4
-rw-r--r--source4/torture/ui.c9
-rw-r--r--source4/torture/ui.h11
-rw-r--r--source4/torture/unix/unix_info2.c4
-rw-r--r--source4/torture/unix/whoami.c2
-rw-r--r--source4/torture/util.h22
-rw-r--r--source4/torture/util_provision.c126
-rw-r--r--source4/torture/util_smb.c3
-rw-r--r--source4/torture/winbind/struct_based.c26
68 files changed, 1241 insertions, 541 deletions
diff --git a/source4/torture/auth/ntlmssp.c b/source4/torture/auth/ntlmssp.c
index 9366de986a..739a048d29 100644
--- a/source4/torture/auth/ntlmssp.c
+++ b/source4/torture/auth/ntlmssp.c
@@ -33,7 +33,8 @@ static bool torture_ntlmssp_self_check(struct torture_context *tctx)
TALLOC_CTX *mem_ctx = tctx;
torture_assert_ntstatus_ok(tctx,
- gensec_client_start(mem_ctx, &gensec_security, NULL, tctx->lp_ctx),
+ gensec_client_start(mem_ctx, &gensec_security,
+ tctx->ev, tctx->lp_ctx),
"gensec client start");
gensec_set_credentials(gensec_security, cmdline_credentials);
@@ -69,7 +70,7 @@ static bool torture_ntlmssp_self_check(struct torture_context *tctx)
torture_assert_int_equal(tctx, sig.length, expected_sig.length, "Wrong sig length");
- torture_assert(tctx, 0 == memcmp(sig.data, expected_sig.data, sig.length),
+ torture_assert_mem_equal(tctx, sig.data, expected_sig.data, sig.length,
"data mismatch");
torture_assert_ntstatus_equal(tctx,
@@ -87,7 +88,8 @@ static bool torture_ntlmssp_self_check(struct torture_context *tctx)
talloc_free(gensec_security);
torture_assert_ntstatus_ok(tctx,
- gensec_client_start(mem_ctx, &gensec_security, NULL, tctx->lp_ctx),
+ gensec_client_start(mem_ctx, &gensec_security,
+ tctx->ev, tctx->lp_ctx),
"Failed to start GENSEC for NTLMSSP");
gensec_set_credentials(gensec_security, cmdline_credentials);
@@ -123,7 +125,7 @@ static bool torture_ntlmssp_self_check(struct torture_context *tctx)
torture_assert_int_equal(tctx, sig.length, expected_sig.length, "Wrong sig length");
- torture_assert(tctx, 0 == memcmp(sig.data+8, expected_sig.data+8, sig.length-8),
+ torture_assert_mem_equal(tctx, sig.data+8, expected_sig.data+8, sig.length-8,
"data mismatch");
torture_assert_ntstatus_equal(tctx,
diff --git a/source4/torture/basic/base.c b/source4/torture/basic/base.c
index ac71d14116..966d436935 100644
--- a/source4/torture/basic/base.c
+++ b/source4/torture/basic/base.c
@@ -55,7 +55,8 @@ static struct smbcli_state *open_nbt_connection(struct torture_context *tctx)
lp_smbcli_options(tctx->lp_ctx, &options);
- if (!smbcli_socket_connect(cli, host, lp_smb_ports(tctx->lp_ctx), lp_resolve_context(tctx->lp_ctx), &options)) {
+ if (!smbcli_socket_connect(cli, host, lp_smb_ports(tctx->lp_ctx), tctx->ev,
+ lp_resolve_context(tctx->lp_ctx), &options)) {
torture_comment(tctx, "Failed to connect with %s\n", host);
goto failed;
}
@@ -590,7 +591,7 @@ static bool rw_torture2(struct torture_context *tctx,
break;
}
- torture_assert(tctx, memcmp(buf_rd, buf, buf_size) == 0,
+ torture_assert_mem_equal(tctx, buf_rd, buf, buf_size,
"read/write compare failed\n");
}
diff --git a/source4/torture/basic/delaywrite.c b/source4/torture/basic/delaywrite.c
index e3d63c09ec..84adfef61a 100644
--- a/source4/torture/basic/delaywrite.c
+++ b/source4/torture/basic/delaywrite.c
@@ -40,7 +40,12 @@ static bool test_delayed_write_update(struct torture_context *tctx, struct smbcl
int fnum1 = -1;
bool ret = true;
ssize_t written;
- time_t t;
+ struct timeval start;
+ struct timeval end;
+ int used_delay = torture_setting_int(tctx, "writetimeupdatedelay", 2000000);
+ int normal_delay = 2000000;
+ double sec = ((double)used_delay) / ((double)normal_delay);
+ int msec = 1000 * sec;
if (!torture_setup_dir(cli, BASEDIR)) {
return false;
@@ -68,7 +73,7 @@ static bool test_delayed_write_update(struct torture_context *tctx, struct smbcl
/* 3 second delay to ensure we get past any 2 second time
granularity (older systems may have that) */
- sleep(3);
+ msleep(3 * msec);
written = smbcli_write(cli->tree, fnum1, 0, "x", 0, 1);
@@ -78,9 +83,9 @@ static bool test_delayed_write_update(struct torture_context *tctx, struct smbcl
return false;
}
- t = time(NULL);
-
- while (time(NULL) < t+120) {
+ start = timeval_current();
+ end = timeval_add(&start, (120*sec), 0);
+ while (!timeval_expired(&end)) {
status = smb_raw_fileinfo(cli->tree, tctx, &finfo2);
if (!NT_STATUS_IS_OK(status)) {
@@ -91,20 +96,22 @@ static bool test_delayed_write_update(struct torture_context *tctx, struct smbcl
torture_comment(tctx, "write time %s\n",
nt_time_string(tctx, finfo2.basic_info.out.write_time));
if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) {
- int diff = time(NULL) - t;
- if (diff < 2) {
- torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
- diff);
+ double diff = timeval_elapsed(&start);
+ if (diff < (2 * sec * 0.75)) { /* 0.75 to cope with vmware timing */
+ torture_comment(tctx, "Server updated write_time after %.2f seconds"
+ "(1 sec == %.2f)(wrong!)\n",
+ diff, sec);
ret = false;
break;
}
- torture_comment(tctx, "Server updated write_time after %d seconds (correct)\n",
- diff);
+ torture_comment(tctx, "Server updated write_time after %.2f seconds"
+ "(1 sec == %.2f)(correct)\n",
+ diff, sec);
break;
}
- sleep(1);
fflush(stdout);
+ msleep(1 * msec);
}
if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) {
@@ -135,7 +142,12 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
int fnum2 = -1;
bool ret = true;
ssize_t written;
- time_t t;
+ struct timeval start;
+ struct timeval end;
+ int used_delay = torture_setting_int(tctx, "writetimeupdatedelay", 2000000);
+ int normal_delay = 2000000;
+ double sec = ((double)used_delay) / ((double)normal_delay);
+ int msec = 1000 * sec;
union smb_flush flsh;
if (!torture_setup_dir(cli, BASEDIR)) {
@@ -164,7 +176,7 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
/* 3 second delay to ensure we get past any 2 second time
granularity (older systems may have that) */
- sleep(3);
+ msleep(3 * msec);
{
/* Try using setfileinfo instead of write to update write time. */
@@ -251,12 +263,11 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
return false;
}
- t = time(NULL);
-
/* Once the time was set using setfileinfo then it stays set - writes
don't have any effect. But make sure. */
-
- while (time(NULL) < t+15) {
+ start = timeval_current();
+ end = timeval_add(&start, (15*sec), 0);
+ while (!timeval_expired(&end)) {
status = smb_raw_fileinfo(cli->tree, tctx, &finfo2);
if (!NT_STATUS_IS_OK(status)) {
@@ -267,13 +278,15 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
torture_comment(tctx, "write time %s\n",
nt_time_string(tctx, finfo2.basic_info.out.write_time));
if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) {
- torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
- (int)(time(NULL) - t));
+ double diff = timeval_elapsed(&start);
+ torture_comment(tctx, "Server updated write_time after %.2f seconds"
+ "(1sec == %.2f) (wrong!)\n",
+ diff, sec);
ret = false;
break;
}
- sleep(1);
fflush(stdout);
+ msleep(1 * msec);
}
if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) {
@@ -339,12 +352,11 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
ret = false;
}
- t = time(NULL);
-
/* Once the time was set using setfileinfo then it stays set - writes
don't have any effect. But make sure. */
-
- while (time(NULL) < t+15) {
+ start = timeval_current();
+ end = timeval_add(&start, (15*sec), 0);
+ while (!timeval_expired(&end)) {
status = smb_raw_fileinfo(cli->tree, tctx, &finfo2);
if (!NT_STATUS_IS_OK(status)) {
@@ -355,13 +367,15 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
torture_comment(tctx, "write time %s\n",
nt_time_string(tctx, finfo2.basic_info.out.write_time));
if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) {
- torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
- (int)(time(NULL) - t));
+ double diff = timeval_elapsed(&start);
+ torture_comment(tctx, "Server updated write_time after %.2f seconds "
+ "(1sec == %.2f) (wrong!)\n",
+ diff, sec);
ret = false;
break;
}
- sleep(1);
fflush(stdout);
+ msleep(1 * msec);
}
if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) {
@@ -393,7 +407,7 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
torture_comment(tctx, "Second open initial write time %s\n",
nt_time_string(tctx, finfo1.basic_info.out.write_time));
- sleep(10);
+ msleep(10 * msec);
torture_comment(tctx, "Doing a 10 byte write to extend the file to see if this changes the last write time.\n");
written = smbcli_write(cli->tree, fnum1, 0, "0123456789", 31, 10);
@@ -420,11 +434,10 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
ret = false;
}
- t = time(NULL);
-
/* Now the write time should be updated again */
-
- while (time(NULL) < t+15) {
+ start = timeval_current();
+ end = timeval_add(&start, (15*sec), 0);
+ while (!timeval_expired(&end)) {
status = smb_raw_fileinfo(cli->tree, tctx, &finfo2);
if (!NT_STATUS_IS_OK(status)) {
@@ -435,20 +448,22 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
torture_comment(tctx, "write time %s\n",
nt_time_string(tctx, finfo2.basic_info.out.write_time));
if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) {
- int diff = time(NULL) - t;
- if (diff < 2) {
- torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
- diff);
+ double diff = timeval_elapsed(&start);
+ if (diff < (2 * sec * 0.75)) { /* 0.75 to cope with vmware timing */
+ torture_comment(tctx, "Server updated write_time after %.2f seconds"
+ "(1sec == %.2f) (wrong!)\n",
+ diff, sec);
ret = false;
break;
}
- torture_comment(tctx, "Server updated write_time after %d seconds (correct)\n",
- diff);
+ torture_comment(tctx, "Server updated write_time after %.2f seconds"
+ "(1sec == %.2f) (correct)\n",
+ diff, sec);
break;
}
- sleep(1);
fflush(stdout);
+ msleep(1*msec);
}
if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) {
@@ -490,6 +505,10 @@ static bool test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
int fnum2;
bool ret = true;
ssize_t written;
+ int used_delay = torture_setting_int(tctx, "writetimeupdatedelay", 2000000);
+ int normal_delay = 2000000;
+ double sec = ((double)used_delay) / ((double)normal_delay);
+ int msec = 1000 * sec;
if (!torture_setup_dir(cli, BASEDIR)) {
return false;
@@ -513,7 +532,7 @@ static bool test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
goto done;
}
- msleep(1000);
+ msleep(1 * msec);
written = smbcli_write(cli->tree, fnum1, 0, "x", 0, 1);
@@ -613,12 +632,23 @@ static bool test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
}
#define COMPARE_WRITE_TIME_CMP(given, correct, cmp) do { \
+ uint64_t r = 10*1000*1000; \
NTTIME g = (given).basic_info.out.write_time; \
+ NTTIME gr = (g / r) * r; \
NTTIME c = (correct).basic_info.out.write_time; \
- if (g cmp c) { \
- torture_result(tctx, TORTURE_FAIL, __location__": wrong write_time (%s)%s %s (%s)%s", \
- #given, nt_time_string(tctx, g), \
- #cmp, #correct, nt_time_string(tctx, c)); \
+ NTTIME cr = (c / r) * r; \
+ bool strict = torture_setting_bool(tctx, "strict mode", false); \
+ bool err = false; \
+ if (strict && (g cmp c)) { \
+ err = true; \
+ } else if (gr cmp cr) { \
+ /* handle filesystem without high resolution timestamps */ \
+ err = true; \
+ } \
+ if (err) { \
+ torture_result(tctx, TORTURE_FAIL, __location__": wrong write_time (%s)%s(%llu) %s (%s)%s(%llu)", \
+ #given, nt_time_string(tctx, g), (unsigned long long)g, \
+ #cmp, #correct, nt_time_string(tctx, c), (unsigned long long)c); \
ret = false; \
goto done; \
} \
@@ -724,7 +754,12 @@ static bool test_delayed_write_update3(struct torture_context *tctx,
int fnum1 = -1;
bool ret = true;
ssize_t written;
- time_t t;
+ struct timeval start;
+ struct timeval end;
+ int used_delay = torture_setting_int(tctx, "writetimeupdatedelay", 2000000);
+ int normal_delay = 2000000;
+ double sec = ((double)used_delay) / ((double)normal_delay);
+ int msec = 1000 * sec;
if (!torture_setup_dir(cli, BASEDIR)) {
return false;
@@ -760,8 +795,9 @@ static bool test_delayed_write_update3(struct torture_context *tctx,
* calcuated from the first write
* (but expect upto 5 seconds extra time for a busy server)
*/
- t = time(NULL);
- while (time(NULL) < t+7) {
+ start = timeval_current();
+ end = timeval_add(&start, 7 * sec, 0);
+ while (!timeval_expired(&end)) {
/* do a write */
torture_comment(tctx, "Do a write on the file handle\n");
written = smbcli_write(cli->tree, fnum1, 0, "x", 0, 1);
@@ -774,26 +810,29 @@ static bool test_delayed_write_update3(struct torture_context *tctx,
GET_INFO_FILE(finfo1);
if (finfo1.basic_info.out.write_time > finfo0.basic_info.out.write_time) {
- int diff = time(NULL) - t;
- if (diff < 2) {
- torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
- diff);
+ double diff = timeval_elapsed(&start);
+ if (diff < (2 * sec * 0.75)) { /* 0.75 to cope with vmware timing */
+ torture_comment(tctx, "Server updated write_time after %.2f seconds "
+ "(1sec == %.2f) (wrong!)\n",
+ diff, sec);
ret = false;
break;
}
- torture_comment(tctx, "Server updated write_time after %d seconds (correct)\n",
- diff);
+ torture_comment(tctx, "Server updated write_time after %.2f seconds "
+ "(1sec == %.2f) (correct)\n",
+ diff, sec);
break;
}
- msleep(500);
+ msleep(0.5 * msec);
}
GET_INFO_BOTH(finfo1,pinfo1);
/* sure any further write doesn't update the write time */
- t = time(NULL);
- while (time(NULL) < t+15) {
+ start = timeval_current();
+ end = timeval_add(&start, 15 * sec, 0);
+ while (!timeval_expired(&end)) {
/* do a write */
torture_comment(tctx, "Do a write on the file handle\n");
written = smbcli_write(cli->tree, fnum1, 0, "x", 0, 1);
@@ -806,12 +845,14 @@ static bool test_delayed_write_update3(struct torture_context *tctx,
GET_INFO_BOTH(finfo2,pinfo2);
if (finfo2.basic_info.out.write_time > finfo1.basic_info.out.write_time) {
- torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
- (int)(time(NULL) - t));
+ double diff = timeval_elapsed(&start);
+ torture_comment(tctx, "Server updated write_time after %.2f seconds "
+ "(1sec == %.2f) (wrong!)\n",
+ diff, sec);
ret = false;
break;
}
- msleep(2000);
+ msleep(2 * msec);
}
GET_INFO_BOTH(finfo2,pinfo2);
@@ -821,7 +862,7 @@ static bool test_delayed_write_update3(struct torture_context *tctx,
}
/* sleep */
- msleep(5000);
+ msleep(5 * msec);
GET_INFO_BOTH(finfo3,pinfo3);
COMPARE_WRITE_TIME_EQUAL(finfo3, finfo2);
@@ -860,7 +901,12 @@ static bool test_delayed_write_update4(struct torture_context *tctx,
int fnum1 = -1;
bool ret = true;
ssize_t written;
- time_t t;
+ struct timeval start;
+ struct timeval end;
+ int used_delay = torture_setting_int(tctx, "writetimeupdatedelay", 2000000);
+ int normal_delay = 2000000;
+ double sec = ((double)used_delay) / ((double)normal_delay);
+ int msec = 1000 * sec;
if (!torture_setup_dir(cli, BASEDIR)) {
return false;
@@ -892,7 +938,7 @@ static bool test_delayed_write_update4(struct torture_context *tctx,
GET_INFO_BOTH(finfo0,pinfo0);
/* sleep a bit */
- msleep(5000);
+ msleep(5 * msec);
/* do a write */
torture_comment(tctx, "Do a write on the file handle\n");
@@ -911,32 +957,36 @@ static bool test_delayed_write_update4(struct torture_context *tctx,
* calcuated from the first write
* (but expect upto 3 seconds extra time for a busy server)
*/
- t = time(NULL);
- while (time(NULL) < t+5) {
+ start = timeval_current();
+ end = timeval_add(&start, 5 * sec, 0);
+ while (!timeval_expired(&end)) {
/* get the times after the first write */
GET_INFO_FILE(finfo1);
if (finfo1.basic_info.out.write_time > finfo0.basic_info.out.write_time) {
- int diff = time(NULL) - t;
- if (diff < 2) {
- torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
- diff);
+ double diff = timeval_elapsed(&start);
+ if (diff < (2 * sec * 0.75)) { /* 0.75 to cope with vmware timing */
+ torture_comment(tctx, "Server updated write_time after %.2f seconds "
+ "(1sec == %.2f) (wrong!)\n",
+ diff, sec);
ret = false;
break;
}
- torture_comment(tctx, "Server updated write_time after %d seconds (correct)\n",
- diff);
+ torture_comment(tctx, "Server updated write_time after %.2f seconds "
+ "(1sec == %.2f) (correct)\n",
+ diff, sec);
break;
}
- msleep(500);
+ msleep(0.5 * msec);
}
GET_INFO_BOTH(finfo1,pinfo1);
/* sure any further write doesn't update the write time */
- t = time(NULL);
- while (time(NULL) < t+15) {
+ start = timeval_current();
+ end = timeval_add(&start, 15 * sec, 0);
+ while (!timeval_expired(&end)) {
/* do a write */
torture_comment(tctx, "Do a write on the file handle\n");
written = smbcli_write(cli->tree, fnum1, 0, "x", 0, 1);
@@ -949,12 +999,14 @@ static bool test_delayed_write_update4(struct torture_context *tctx,
GET_INFO_BOTH(finfo2,pinfo2);
if (finfo2.basic_info.out.write_time > finfo1.basic_info.out.write_time) {
- torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
- (int)(time(NULL) - t));
+ double diff = timeval_elapsed(&start);
+ torture_comment(tctx, "Server updated write_time after %.2f seconds "
+ "(1sec == %.2f) (wrong!)\n",
+ diff, sec);
ret = false;
break;
}
- msleep(2000);
+ msleep(2 * msec);
}
GET_INFO_BOTH(finfo2,pinfo2);
@@ -964,7 +1016,7 @@ static bool test_delayed_write_update4(struct torture_context *tctx,
}
/* sleep */
- msleep(5000);
+ msleep(5 * msec);
GET_INFO_BOTH(finfo3,pinfo3);
COMPARE_WRITE_TIME_EQUAL(finfo3, finfo2);
@@ -1003,7 +1055,12 @@ static bool test_delayed_write_update5(struct torture_context *tctx,
int fnum1 = -1;
bool ret = true;
ssize_t written;
- time_t t;
+ struct timeval start;
+ struct timeval end;
+ int used_delay = torture_setting_int(tctx, "writetimeupdatedelay", 2000000);
+ int normal_delay = 2000000;
+ double sec = ((double)used_delay) / ((double)normal_delay);
+ int msec = 1000 * sec;
if (!torture_setup_dir(cli, BASEDIR)) {
return false;
@@ -1059,19 +1116,22 @@ static bool test_delayed_write_update5(struct torture_context *tctx,
COMPARE_WRITE_TIME_LESS(finfo2, finfo1);
/* make sure the 2 second delay from the first write are canceled */
- t = time(NULL);
- while (time(NULL) < t+15) {
+ start = timeval_current();
+ end = timeval_add(&start, 15 * sec, 0);
+ while (!timeval_expired(&end)) {
/* get the times after the first write */
GET_INFO_BOTH(finfo3,pinfo3);
if (finfo3.basic_info.out.write_time > finfo2.basic_info.out.write_time) {
- torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
- (int)(time(NULL) - t));
+ double diff = timeval_elapsed(&start);
+ torture_comment(tctx, "Server updated write_time after %.2f seconds "
+ "(1sec == %.2f) (wrong!)\n",
+ diff, sec);
ret = false;
break;
}
- msleep(2000);
+ msleep(2 * msec);
}
GET_INFO_BOTH(finfo3,pinfo3);
@@ -1081,8 +1141,9 @@ static bool test_delayed_write_update5(struct torture_context *tctx,
}
/* sure any further write doesn't update the write time */
- t = time(NULL);
- while (time(NULL) < t+15) {
+ start = timeval_current();
+ end = timeval_add(&start, 15 * sec, 0);
+ while (!timeval_expired(&end)) {
/* do a write */
torture_comment(tctx, "Do a write on the file handle\n");
written = smbcli_write(cli->tree, fnum1, 0, "x", 0, 1);
@@ -1095,12 +1156,14 @@ static bool test_delayed_write_update5(struct torture_context *tctx,
GET_INFO_BOTH(finfo4,pinfo4);
if (finfo4.basic_info.out.write_time > finfo3.basic_info.out.write_time) {
- torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
- (int)(time(NULL) - t));
+ double diff = timeval_elapsed(&start);
+ torture_comment(tctx, "Server updated write_time after %.2f seconds "
+ "(1sec == %.2f) (wrong!)\n",
+ diff, sec);
ret = false;
break;
}
- msleep(2000);
+ msleep(2 * msec);
}
GET_INFO_BOTH(finfo4,pinfo4);
@@ -1110,7 +1173,7 @@ static bool test_delayed_write_update5(struct torture_context *tctx,
}
/* sleep */
- msleep(5000);
+ msleep(5 * msec);
GET_INFO_BOTH(finfo5,pinfo5);
COMPARE_WRITE_TIME_EQUAL(finfo5, finfo4);
@@ -1149,7 +1212,12 @@ static bool test_delayed_write_update6(struct torture_context *tctx,
int fnum2 = -1;
bool ret = true;
ssize_t written;
- time_t t;
+ struct timeval start;
+ struct timeval end;
+ int used_delay = torture_setting_int(tctx, "writetimeupdatedelay", 2000000);
+ int normal_delay = 2000000;
+ double sec = ((double)used_delay) / ((double)normal_delay);
+ int msec = 1000 * sec;
bool first = true;
if (!torture_setup_dir(cli, BASEDIR)) {
@@ -1217,19 +1285,22 @@ again:
COMPARE_WRITE_TIME_LESS(finfo2, finfo1);
/* make sure the 2 second delay from the first write are canceled */
- t = time(NULL);
- while (time(NULL) < t+15) {
+ start = timeval_current();
+ end = timeval_add(&start, 15 * sec, 0);
+ while (!timeval_expired(&end)) {
/* get the times after the first write */
GET_INFO_BOTH(finfo3,pinfo3);
if (finfo3.basic_info.out.write_time > finfo2.basic_info.out.write_time) {
- torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
- (int)(time(NULL) - t));
+ double diff = timeval_elapsed(&start);
+ torture_comment(tctx, "Server updated write_time after %.2f seconds "
+ "(1sec == %.2f) (wrong!)\n",
+ diff, sec);
ret = false;
break;
}
- msleep(2000);
+ msleep(2 * msec);
}
GET_INFO_BOTH(finfo3,pinfo3);
@@ -1239,8 +1310,9 @@ again:
}
/* sure any further write doesn't update the write time */
- t = time(NULL);
- while (time(NULL) < t+15) {
+ start = timeval_current();
+ end = timeval_add(&start, 15 * sec, 0);
+ while (!timeval_expired(&end)) {
/* do a write */
torture_comment(tctx, "Do a write on the file handle\n");
written = smbcli_write(cli->tree, fnum1, 0, "x", 0, 1);
@@ -1253,12 +1325,14 @@ again:
GET_INFO_BOTH(finfo4,pinfo4);
if (finfo4.basic_info.out.write_time > finfo3.basic_info.out.write_time) {
- torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
- (int)(time(NULL) - t));
+ double diff = timeval_elapsed(&start);
+ torture_comment(tctx, "Server updated write_time after %.2f seconds "
+ "(1sec == %.2f) (wrong!)\n",
+ diff, sec);
ret = false;
break;
}
- msleep(2000);
+ msleep(2 * msec);
}
GET_INFO_BOTH(finfo4,pinfo4);
@@ -1268,7 +1342,7 @@ again:
}
/* sleep */
- msleep(5000);
+ msleep(5 * msec);
GET_INFO_BOTH(finfo5,pinfo5);
COMPARE_WRITE_TIME_EQUAL(finfo5, finfo4);
diff --git a/source4/torture/config.mk b/source4/torture/config.mk
index 7209838d33..1565797609 100644
--- a/source4/torture/config.mk
+++ b/source4/torture/config.mk
@@ -13,10 +13,10 @@ torture_OBJ_FILES = $(addprefix torture/, torture.o ui.o)
PUBLIC_HEADERS += torture/torture.h torture/ui.h
[SUBSYSTEM::TORTURE_UTIL]
-PRIVATE_DEPENDENCIES = LIBCLI_RAW LIBPYTHON smbcalls
+PRIVATE_DEPENDENCIES = LIBCLI_RAW LIBPYTHON smbcalls PROVISION
PUBLIC_DEPENDENCIES = POPT_CREDENTIALS
-TORTURE_UTIL_OBJ_FILES = $(addprefix torture/, util_smb.o util_provision.o)
+TORTURE_UTIL_OBJ_FILES = $(addprefix torture/, util_smb.o)
#################################
# Start SUBSYSTEM TORTURE_BASIC
@@ -86,6 +86,7 @@ TORTURE_RAW_OBJ_FILES = $(addprefix torture/raw/, \
lock.o \
pingpong.o \
lockbench.o \
+ lookuprate.o \
openbench.o \
rename.o \
eas.o \
@@ -313,31 +314,34 @@ locktest_OBJ_FILES = torture/locktest.o
MANPAGES += torture/man/locktest.1
-COV_TARGET = test
+GCOV=0
+
+ifeq ($(MAKECMDGOALS),gcov)
+GCOV=1
+endif
+
+ifeq ($(MAKECMDGOALS),lcov)
+GCOV=1
+endif
+
+ifeq ($(MAKECMDGOALS),testcov-html)
+GCOV=1
+endif
-COV_VARS = \
- CFLAGS="$(CFLAGS) --coverage" \
- LDFLAGS="$(LDFLAGS) --coverage"
+ifeq ($(GCOV),1)
+CFLAGS += --coverage
+LDFLAGS += --coverage
+endif
-test_cov:
- -$(MAKE) $(COV_TARGET) $(COV_VARS)
+COV_TARGET = test
-gcov: test_cov
+gcov: test
for I in $(sort $(dir $(ALL_OBJS))); \
do $(GCOV) -p -o $$I $$I/*.c; \
done
-lcov-split:
- rm -f samba.info
- @$(MAKE) $(COV_TARGET) $(COV_VARS) \
- TEST_OPTIONS="--analyse-cmd=\"lcov --base-directory `pwd` --directory . --capture --output-file samba.info -t\""
- -rm heimdal/lib/*/{lex,parse}.{gcda,gcno}
- -rm lib/policy/*/{lex,parse}.{gcda,gcno}
- genhtml -o coverage samba.info
-
-lcov: test_cov
+lcov: test
-rm heimdal/lib/*/{lex,parse}.{gcda,gcno}
- -rm lib/policy/*/{lex,parse}.{gcda,gcno}
lcov --base-directory `pwd` --directory . --capture --output-file samba.info
genhtml -o coverage samba.info
diff --git a/source4/torture/gentest.c b/source4/torture/gentest.c
index d5fc855f17..ae18fe809c 100644
--- a/source4/torture/gentest.c
+++ b/source4/torture/gentest.c
@@ -19,6 +19,7 @@
#include "includes.h"
#include "lib/cmdline/popt_common.h"
+#include "lib/events/events.h"
#include "system/time.h"
#include "system/filesys.h"
#include "libcli/raw/request.h"
@@ -36,18 +37,18 @@
/* global options */
static struct gentest_options {
- bool showall;
- bool analyze;
- bool analyze_always;
- bool analyze_continuous;
+ int showall;
+ int analyze;
+ int analyze_always;
+ int analyze_continuous;
uint_t max_open_handles;
uint_t seed;
uint_t numops;
- bool use_oplocks;
+ int use_oplocks;
char **ignore_patterns;
const char *seeds_file;
- bool use_preset_seeds;
- bool fast_reconnect;
+ int use_preset_seeds;
+ int fast_reconnect;
} options;
/* mapping between open handles on the server and local handles */
@@ -154,7 +155,8 @@ static bool connect_servers_fast(void)
/*****************************************************
connect to the servers
*******************************************************/
-static bool connect_servers(struct loadparm_context *lp_ctx)
+static bool connect_servers(struct event_context *ev,
+ struct loadparm_context *lp_ctx)
{
int i, j;
@@ -193,7 +195,7 @@ static bool connect_servers(struct loadparm_context *lp_ctx)
servers[i].share_name, NULL,
servers[i].credentials,
lp_resolve_context(lp_ctx),
- NULL, &smb_options);
+ ev, &smb_options);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to connect to \\\\%s\\%s - %s\n",
servers[i].server_name, servers[i].share_name,
@@ -1937,11 +1939,11 @@ static struct {
run the test with the current set of op_parms parameters
return the number of operations that completed successfully
*/
-static int run_test(struct loadparm_context *lp_ctx)
+static int run_test(struct event_context *ev, struct loadparm_context *lp_ctx)
{
int op, i;
- if (!connect_servers(lp_ctx)) {
+ if (!connect_servers(ev, lp_ctx)) {
printf("Failed to connect to servers\n");
exit(1);
}
@@ -2018,7 +2020,8 @@ static int run_test(struct loadparm_context *lp_ctx)
perform a backtracking analysis of the minimal set of operations
to generate an error
*/
-static void backtrack_analyze(struct loadparm_context *lp_ctx)
+static void backtrack_analyze(struct event_context *ev,
+ struct loadparm_context *lp_ctx)
{
int chunk, ret;
@@ -2039,7 +2042,7 @@ static void backtrack_analyze(struct loadparm_context *lp_ctx)
}
printf("Testing %d ops with %d-%d disabled\n",
options.numops, base, max-1);
- ret = run_test(lp_ctx);
+ ret = run_test(ev, lp_ctx);
printf("Completed %d of %d ops\n", ret, options.numops);
for (i=base;i<max; i++) {
op_parms[i].disabled = false;
@@ -2071,7 +2074,7 @@ static void backtrack_analyze(struct loadparm_context *lp_ctx)
} while (chunk > 0);
printf("Reduced to %d ops\n", options.numops);
- ret = run_test(lp_ctx);
+ ret = run_test(ev, lp_ctx);
if (ret != options.numops - 1) {
printf("Inconsistent result? ret=%d numops=%d\n", ret, options.numops);
}
@@ -2080,7 +2083,8 @@ static void backtrack_analyze(struct loadparm_context *lp_ctx)
/*
start the main gentest process
*/
-static bool start_gentest(struct loadparm_context *lp_ctx)
+static bool start_gentest(struct event_context *ev,
+ struct loadparm_context *lp_ctx)
{
int op;
int ret;
@@ -2116,15 +2120,15 @@ static bool start_gentest(struct loadparm_context *lp_ctx)
}
}
- ret = run_test(lp_ctx);
+ ret = run_test(ev, lp_ctx);
if (ret != options.numops && options.analyze) {
options.numops = ret+1;
- backtrack_analyze(lp_ctx);
+ backtrack_analyze(ev, lp_ctx);
} else if (options.analyze_always) {
- backtrack_analyze(lp_ctx);
+ backtrack_analyze(ev, lp_ctx);
} else if (options.analyze_continuous) {
- while (run_test(lp_ctx) == options.numops) ;
+ while (run_test(ev, lp_ctx) == options.numops) ;
}
return ret == options.numops;
@@ -2171,6 +2175,7 @@ static bool split_unc_name(const char *unc, char **server, char **share)
int i, username_count=0;
bool ret;
char *ignore_file=NULL;
+ struct event_context *ev;
struct loadparm_context *lp_ctx;
poptContext pc;
int argc_new;
@@ -2278,9 +2283,11 @@ static bool split_unc_name(const char *unc, char **server, char **share)
printf("seed=%u\n", options.seed);
+ ev = event_context_init(talloc_autofree_context());
+
gensec_init(lp_ctx);
- ret = start_gentest(lp_ctx);
+ ret = start_gentest(ev, lp_ctx);
if (ret) {
printf("gentest completed - no errors\n");
diff --git a/source4/torture/ldap/cldap.c b/source4/torture/ldap/cldap.c
index dbe9d2f9a4..ca4d9b7705 100644
--- a/source4/torture/ldap/cldap.c
+++ b/source4/torture/ldap/cldap.c
@@ -38,13 +38,15 @@
*/
static bool test_cldap_netlogon(struct torture_context *tctx, const char *dest)
{
- struct cldap_socket *cldap = cldap_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ struct cldap_socket *cldap;
NTSTATUS status;
struct cldap_netlogon search, empty_search;
union nbt_cldap_netlogon n1;
struct GUID guid;
int i;
+ cldap = cldap_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
+
ZERO_STRUCT(search);
search.in.dest_address = dest;
search.in.dest_port = lp_cldap_port(tctx->lp_ctx);
@@ -244,13 +246,15 @@ static void cldap_dump_results(struct cldap_search *search)
*/
static bool test_cldap_generic(struct torture_context *tctx, const char *dest)
{
- struct cldap_socket *cldap = cldap_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ struct cldap_socket *cldap;
NTSTATUS status;
struct cldap_search search;
const char *attrs1[] = { "currentTime", "highestCommittedUSN", NULL };
const char *attrs2[] = { "currentTime", "highestCommittedUSN", "netlogon", NULL };
const char *attrs3[] = { "netlogon", NULL };
+ cldap = cldap_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
+
ZERO_STRUCT(search);
search.in.dest_address = dest;
search.in.dest_port = lp_cldap_port(tctx->lp_ctx);
diff --git a/source4/torture/ldap/cldapbench.c b/source4/torture/ldap/cldapbench.c
index 83e505e164..df2a5b0551 100644
--- a/source4/torture/ldap/cldapbench.c
+++ b/source4/torture/ldap/cldapbench.c
@@ -51,7 +51,7 @@ static void request_handler(struct cldap_request *req)
*/
static bool bench_cldap(struct torture_context *tctx, const char *address)
{
- struct cldap_socket *cldap = cldap_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ struct cldap_socket *cldap;
int num_sent=0;
struct timeval tv = timeval_current();
bool ret = true;
@@ -59,6 +59,8 @@ static bool bench_cldap(struct torture_context *tctx, const char *address)
struct cldap_netlogon search;
struct bench_state *state;
+ cldap = cldap_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
+
state = talloc_zero(tctx, struct bench_state);
ZERO_STRUCT(search);
@@ -116,7 +118,7 @@ bool torture_bench_cldap(struct torture_context *torture)
make_nbt_name_server(&name, torture_setting_string(torture, "host", NULL));
/* do an initial name resolution to find its IP */
- status = resolve_name(lp_resolve_context(torture->lp_ctx), &name, torture, &address, event_context_find(torture));
+ status = resolve_name(lp_resolve_context(torture->lp_ctx), &name, torture, &address, torture->ev);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to resolve %s - %s\n",
name.name, nt_errstr(status));
diff --git a/source4/torture/ldap/common.c b/source4/torture/ldap/common.c
index 65b02ed5e8..5913163822 100644
--- a/source4/torture/ldap/common.c
+++ b/source4/torture/ldap/common.c
@@ -65,7 +65,7 @@ NTSTATUS torture_ldap_connection(struct torture_context *tctx,
return NT_STATUS_INVALID_PARAMETER;
}
- *conn = ldap4_new_connection(tctx, tctx->lp_ctx, NULL);
+ *conn = ldap4_new_connection(tctx, tctx->lp_ctx, tctx->ev);
status = ldap_connect(*conn, url);
if (!NT_STATUS_IS_OK(status)) {
diff --git a/source4/torture/ldap/schema.c b/source4/torture/ldap/schema.c
index 4cfce11eb5..8437e7f79d 100644
--- a/source4/torture/ldap/schema.c
+++ b/source4/torture/ldap/schema.c
@@ -376,7 +376,7 @@ bool torture_ldap_schema(struct torture_context *torture)
url = talloc_asprintf(torture, "ldap://%s/", host);
- ldb = ldb_wrap_connect(torture, torture->lp_ctx, url,
+ ldb = ldb_wrap_connect(torture, torture->ev, torture->lp_ctx, url,
NULL,
cmdline_credentials,
0, NULL);
diff --git a/source4/torture/ldap/uptodatevector.c b/source4/torture/ldap/uptodatevector.c
index cec330b2f6..87b7e09e13 100644
--- a/source4/torture/ldap/uptodatevector.c
+++ b/source4/torture/ldap/uptodatevector.c
@@ -162,7 +162,7 @@ bool torture_ldap_uptodatevector(struct torture_context *torture)
url = talloc_asprintf(torture, "ldap://%s/", host);
if (!url) goto failed;
- ldb = ldb_wrap_connect(torture, torture->lp_ctx, url,
+ ldb = ldb_wrap_connect(torture, torture->ev, torture->lp_ctx, url,
NULL,
cmdline_credentials,
0, NULL);
diff --git a/source4/torture/libnet/domain.c b/source4/torture/libnet/domain.c
index ff1fbcab78..ab7846e5e1 100644
--- a/source4/torture/libnet/domain.c
+++ b/source4/torture/libnet/domain.c
@@ -74,7 +74,6 @@ bool torture_domainopen(struct torture_context *torture)
{
NTSTATUS status;
struct libnet_context *net_ctx;
- struct event_context *evt_ctx;
TALLOC_CTX *mem_ctx;
bool ret = true;
struct policy_handle h;
@@ -82,8 +81,7 @@ bool torture_domainopen(struct torture_context *torture)
mem_ctx = talloc_init("test_domain_open");
- evt_ctx = event_context_find(torture);
- net_ctx = libnet_context_init(evt_ctx, torture->lp_ctx);
+ net_ctx = libnet_context_init(torture->ev, torture->lp_ctx);
status = torture_rpc_connection(torture,
&net_ctx->samr.pipe,
diff --git a/source4/torture/libnet/libnet_BecomeDC.c b/source4/torture/libnet/libnet_BecomeDC.c
index 3f8edd40e8..bc92b4ebc2 100644
--- a/source4/torture/libnet/libnet_BecomeDC.c
+++ b/source4/torture/libnet/libnet_BecomeDC.c
@@ -38,6 +38,7 @@
#include "auth/auth.h"
#include "param/param.h"
#include "torture/util.h"
+#include "param/provision.h"
struct test_become_dc_state {
struct libnet_context *ctx;
@@ -66,16 +67,9 @@ static NTSTATUS test_become_dc_prepare_db(void *private_data,
{
struct test_become_dc_state *s = talloc_get_type(private_data, struct test_become_dc_state);
struct provision_settings settings;
+ struct provision_result result;
NTSTATUS status;
- bool ok;
- struct loadparm_context *lp_ctx = loadparm_init(s);
- char *smbconf;
-
- if (!lp_ctx) {
- return NT_STATUS_NO_MEMORY;
- }
- settings.dns_name = p->dest_dsa->dns_name;
settings.site_name = p->dest_dsa->site_name;
settings.root_dn_str = p->forest->root_dn_str;
settings.domain_dn_str = p->domain->dn_str;
@@ -84,40 +78,14 @@ static NTSTATUS test_become_dc_prepare_db(void *private_data,
settings.netbios_name = p->dest_dsa->netbios_name;
settings.realm = torture_join_dom_dns_name(s->tj);
settings.domain = torture_join_dom_netbios_name(s->tj);
+ settings.server_dn_str = torture_join_server_dn_str(s->tj);
settings.machine_password = cli_credentials_get_password(s->machine_account);
settings.targetdir = s->targetdir;
- status = provision_bare(s, s->lp_ctx, &settings);
+ status = provision_bare(s, s->lp_ctx, &settings, &result);
- smbconf = talloc_asprintf(lp_ctx, "%s/%s", s->targetdir, "/etc/smb.conf");
-
- ok = lp_load(lp_ctx, smbconf);
- if (!ok) {
- DEBUG(0,("Failed load freshly generated smb.conf '%s'\n", smbconf));
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- s->ldb = ldb_wrap_connect(s, lp_ctx, lp_sam_url(lp_ctx),
- system_session(s, lp_ctx),
- NULL, 0, NULL);
- if (!s->ldb) {
- DEBUG(0,("Failed to open '%s'\n", lp_sam_url(lp_ctx)));
- return NT_STATUS_INTERNAL_DB_ERROR;
- }
-
- ok = samdb_set_ntds_invocation_id(s->ldb, &p->dest_dsa->invocation_id);
- if (!ok) {
- DEBUG(0,("Failed to set cached ntds invocationId\n"));
- return NT_STATUS_FOOBAR;
- }
- ok = samdb_set_ntds_objectGUID(s->ldb, &p->dest_dsa->ntds_guid);
- if (!ok) {
- DEBUG(0,("Failed to set cached ntds objectGUID\n"));
- return NT_STATUS_FOOBAR;
- }
-
- s->lp_ctx = lp_ctx;
-
+ s->ldb = result.samdb;
+ s->lp_ctx = result.lp_ctx;
return NT_STATUS_OK;
@@ -354,7 +322,7 @@ static NTSTATUS test_apply_schema(struct test_become_dc_state *s,
sam_ldb_path = talloc_asprintf(s, "%s/%s", s->targetdir, "private/sam.ldb");
DEBUG(0,("Reopen the SAM LDB with system credentials and a already stored schema: %s\n", sam_ldb_path));
- s->ldb = ldb_wrap_connect(s, s->tctx->lp_ctx, sam_ldb_path,
+ s->ldb = ldb_wrap_connect(s, s->tctx->ev, s->tctx->lp_ctx, sam_ldb_path,
system_session(s, s->tctx->lp_ctx),
NULL, 0, NULL);
if (!s->ldb) {
@@ -686,7 +654,7 @@ bool torture_net_become_dc(struct torture_context *torture)
sam_ldb_path = talloc_asprintf(s, "%s/%s", s->targetdir, "private/sam.ldb");
DEBUG(0,("Reopen the SAM LDB with system credentials and all replicated data: %s\n", sam_ldb_path));
- s->ldb = ldb_wrap_connect(s, s->lp_ctx, sam_ldb_path,
+ s->ldb = ldb_wrap_connect(s, s->tctx->ev, s->lp_ctx, sam_ldb_path,
system_session(s, s->lp_ctx),
NULL, 0, NULL);
if (!s->ldb) {
diff --git a/source4/torture/libnet/libnet_domain.c b/source4/torture/libnet/libnet_domain.c
index 3c8d574f0e..7d5be368c2 100644
--- a/source4/torture/libnet/libnet_domain.c
+++ b/source4/torture/libnet/libnet_domain.c
@@ -136,7 +136,7 @@ bool torture_domain_open_lsa(struct torture_context *torture)
of specific server name. */
domain_name = lp_workgroup(torture->lp_ctx);
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
if (ctx == NULL) {
d_printf("failed to create libnet context\n");
return false;
@@ -190,7 +190,7 @@ bool torture_domain_close_lsa(struct torture_context *torture)
return false;
}
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
if (ctx == NULL) {
d_printf("failed to create libnet context\n");
ret = false;
@@ -201,7 +201,7 @@ bool torture_domain_close_lsa(struct torture_context *torture)
mem_ctx = talloc_init("torture_domain_close_lsa");
status = dcerpc_pipe_connect_b(mem_ctx, &p, binding, &ndr_table_lsarpc,
- cmdline_credentials, NULL, torture->lp_ctx);
+ cmdline_credentials, torture->ev, torture->lp_ctx);
if (!NT_STATUS_IS_OK(status)) {
d_printf("failed to connect to server: %s\n", nt_errstr(status));
ret = false;
@@ -245,7 +245,6 @@ bool torture_domain_open_samr(struct torture_context *torture)
{
NTSTATUS status;
struct libnet_context *ctx;
- struct event_context *evt_ctx=NULL;
TALLOC_CTX *mem_ctx;
struct policy_handle domain_handle, handle;
struct libnet_DomainOpen io;
@@ -255,7 +254,7 @@ bool torture_domain_open_samr(struct torture_context *torture)
mem_ctx = talloc_init("test_domainopen_lsa");
- ctx = libnet_context_init(evt_ctx, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
ctx->cred = cmdline_credentials;
/* we're accessing domain controller so the domain name should be
@@ -320,7 +319,7 @@ bool torture_domain_close_samr(struct torture_context *torture)
return false;
}
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
if (ctx == NULL) {
d_printf("failed to create libnet context\n");
ret = false;
@@ -331,7 +330,7 @@ bool torture_domain_close_samr(struct torture_context *torture)
mem_ctx = talloc_init("torture_domain_close_samr");
status = dcerpc_pipe_connect_b(mem_ctx, &p, binding, &ndr_table_samr,
- ctx->cred, NULL, torture->lp_ctx);
+ ctx->cred, torture->ev, torture->lp_ctx);
if (!NT_STATUS_IS_OK(status)) {
d_printf("failed to connect to server: %s\n", nt_errstr(status));
ret = false;
@@ -388,7 +387,7 @@ bool torture_domain_list(struct torture_context *torture)
return false;
}
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
if (ctx == NULL) {
d_printf("failed to create libnet context\n");
ret = false;
diff --git a/source4/torture/libnet/libnet_group.c b/source4/torture/libnet/libnet_group.c
index cabccdbe66..12b8167a86 100644
--- a/source4/torture/libnet/libnet_group.c
+++ b/source4/torture/libnet/libnet_group.c
@@ -235,7 +235,7 @@ bool torture_groupinfo_api(struct torture_context *torture)
prep_mem_ctx = talloc_init("prepare torture group info");
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
ctx->cred = cmdline_credentials;
status = torture_rpc_connection(torture,
@@ -300,7 +300,7 @@ bool torture_grouplist(struct torture_context *torture)
struct libnet_GroupList req;
int i;
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
ctx->cred = cmdline_credentials;
domain_name.string = lp_workgroup(torture->lp_ctx);
@@ -361,7 +361,7 @@ bool torture_creategroup(struct torture_context *torture)
mem_ctx = talloc_init("test_creategroup");
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
ctx->cred = cmdline_credentials;
req.in.group_name = TEST_GROUPNAME;
diff --git a/source4/torture/libnet/libnet_lookup.c b/source4/torture/libnet/libnet_lookup.c
index 9167d1de3e..b25b51b7d9 100644
--- a/source4/torture/libnet/libnet_lookup.c
+++ b/source4/torture/libnet/libnet_lookup.c
@@ -40,7 +40,7 @@ bool torture_lookup(struct torture_context *torture)
mem_ctx = talloc_init("test_lookup");
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
ctx->cred = cmdline_credentials;
lookup.in.hostname = torture_setting_string(torture, "host", NULL);
@@ -84,7 +84,7 @@ bool torture_lookup_host(struct torture_context *torture)
mem_ctx = talloc_init("test_lookup_host");
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
ctx->cred = cmdline_credentials;
lookup.in.hostname = torture_setting_string(torture, "host", NULL);
@@ -127,7 +127,7 @@ bool torture_lookup_pdc(struct torture_context *torture)
mem_ctx = talloc_init("test_lookup_pdc");
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
ctx->cred = cmdline_credentials;
talloc_steal(ctx, mem_ctx);
@@ -171,7 +171,7 @@ bool torture_lookup_sam_name(struct torture_context *torture)
struct libnet_context *ctx;
struct libnet_LookupName r;
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
ctx->cred = cmdline_credentials;
mem_ctx = talloc_init("torture lookup sam name");
diff --git a/source4/torture/libnet/libnet_rpc.c b/source4/torture/libnet/libnet_rpc.c
index 282837d3fe..f25c1ecc48 100644
--- a/source4/torture/libnet/libnet_rpc.c
+++ b/source4/torture/libnet/libnet_rpc.c
@@ -89,7 +89,7 @@ static bool torture_rpc_connect(struct torture_context *torture,
{
struct libnet_context *ctx;
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
ctx->cred = cmdline_credentials;
d_printf("Testing connection to LSA interface\n");
diff --git a/source4/torture/libnet/libnet_share.c b/source4/torture/libnet/libnet_share.c
index eb1edff18d..6bc5be40a6 100644
--- a/source4/torture/libnet/libnet_share.c
+++ b/source4/torture/libnet/libnet_share.c
@@ -131,7 +131,7 @@ bool torture_listshares(struct torture_context *torture)
goto done;
}
- libnetctx = libnet_context_init(NULL, torture->lp_ctx);
+ libnetctx = libnet_context_init(torture->ev, torture->lp_ctx);
if (!libnetctx) {
printf("Couldn't allocate libnet context\n");
ret = false;
@@ -210,7 +210,7 @@ bool torture_delshare(struct torture_context *torture)
status = torture_rpc_binding(torture, &binding);
torture_assert_ntstatus_ok(torture, status, "Failed to get binding");
- libnetctx = libnet_context_init(NULL, torture->lp_ctx);
+ libnetctx = libnet_context_init(torture->ev, torture->lp_ctx);
libnetctx->cred = cmdline_credentials;
status = torture_rpc_connection(torture,
diff --git a/source4/torture/libnet/libnet_user.c b/source4/torture/libnet/libnet_user.c
index 5446087034..6d3e682976 100644
--- a/source4/torture/libnet/libnet_user.c
+++ b/source4/torture/libnet/libnet_user.c
@@ -241,7 +241,7 @@ bool torture_createuser(struct torture_context *torture)
mem_ctx = talloc_init("test_createuser");
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
ctx->cred = cmdline_credentials;
req.in.user_name = TEST_USERNAME;
@@ -287,7 +287,7 @@ bool torture_deleteuser(struct torture_context *torture)
prep_mem_ctx = talloc_init("prepare test_deleteuser");
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
ctx->cred = cmdline_credentials;
req.in.user_name = TEST_USERNAME;
@@ -482,7 +482,7 @@ bool torture_modifyuser(struct torture_context *torture)
prep_mem_ctx = talloc_init("prepare test_deleteuser");
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
ctx->cred = cmdline_credentials;
status = torture_rpc_connection(torture,
@@ -530,7 +530,8 @@ bool torture_modifyuser(struct torture_context *torture)
ZERO_STRUCT(user_req);
user_req.in.domain_name = lp_workgroup(torture->lp_ctx);
- user_req.in.user_name = name;
+ user_req.in.data.user_name = name;
+ user_req.in.level = USER_INFO_BY_NAME;
status = libnet_UserInfo(ctx, torture, &user_req);
if (!NT_STATUS_IS_OK(status)) {
@@ -616,7 +617,7 @@ bool torture_userinfo_api(struct torture_context *torture)
prep_mem_ctx = talloc_init("prepare torture user info");
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
ctx->cred = cmdline_credentials;
status = torture_rpc_connection(torture,
@@ -642,7 +643,8 @@ bool torture_userinfo_api(struct torture_context *torture)
ZERO_STRUCT(req);
req.in.domain_name = domain_name.string;
- req.in.user_name = name;
+ req.in.data.user_name = name;
+ req.in.level = USER_INFO_BY_NAME;
status = libnet_UserInfo(ctx, mem_ctx, &req);
if (!NT_STATUS_IS_OK(status)) {
@@ -681,7 +683,7 @@ bool torture_userlist(struct torture_context *torture)
struct libnet_UserList req;
int i;
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
ctx->cred = cmdline_credentials;
domain_name.string = lp_workgroup(torture->lp_ctx);
diff --git a/source4/torture/local/dbspeed.c b/source4/torture/local/dbspeed.c
index 34083cd204..bf88c00e35 100644
--- a/source4/torture/local/dbspeed.c
+++ b/source4/torture/local/dbspeed.c
@@ -176,7 +176,7 @@ static bool test_ldb_speed(struct torture_context *torture, const void *_data)
torture_comment(torture, "Testing ldb speed for sidmap\n");
- ldb = ldb_wrap_connect(tmp_ctx, torture->lp_ctx, "tdb://test.ldb",
+ ldb = ldb_wrap_connect(tmp_ctx, torture->ev, torture->lp_ctx, "tdb://test.ldb",
NULL, NULL, LDB_FLG_NOSYNC, NULL);
if (!ldb) {
unlink("./test.ldb");
diff --git a/source4/torture/local/torture.c b/source4/torture/local/torture.c
index bb6e21ed4f..7935f6cc35 100644
--- a/source4/torture/local/torture.c
+++ b/source4/torture/local/torture.c
@@ -25,6 +25,7 @@
#include "lib/events/events.h"
#include "libcli/raw/libcliraw.h"
#include "torture/util.h"
+#include "param/provision.h"
static bool test_tempdir(struct torture_context *tctx)
{
@@ -42,30 +43,34 @@ static bool test_tempdir(struct torture_context *tctx)
static bool test_provision(struct torture_context *tctx)
{
NTSTATUS status;
- struct provision_settings settings;
- char *location = NULL;
- torture_assert_ntstatus_ok(tctx, torture_temp_dir(tctx, "torture_provision", &location),
+ struct provision_settings *settings = talloc_zero(tctx, struct provision_settings);
+ struct provision_result result;
+ char *targetdir = NULL;
+
+ torture_assert_ntstatus_ok(tctx, torture_temp_dir(tctx, "torture_provision", &targetdir),
"torture_temp_dir should return NT_STATUS_OK" );
+ settings->targetdir = talloc_steal(settings, targetdir);
- settings.dns_name = "example.com";
- settings.site_name = "SOME-SITE-NAME";
- settings.root_dn_str = "DC=EXAMPLE,DC=COM";
- settings.domain_dn_str = "DC=EXAMPLE,DC=COM";
- settings.config_dn_str = NULL;
- settings.schema_dn_str = NULL;
- settings.invocation_id = NULL;
- settings.netbios_name = "FOO";
- settings.realm = "EXAMPLE.COM";
- settings.domain = "EXAMPLE";
- settings.ntds_guid = NULL;
- settings.ntds_dn_str = NULL;
- settings.machine_password = "geheim";
- settings.targetdir = location;
+ settings->site_name = "SOME-SITE-NAME";
+ settings->root_dn_str = "DC=EXAMPLE,DC=COM";
+ settings->domain_dn_str = "DC=EXAMPLE,DC=COM";
+ settings->config_dn_str = NULL;
+ settings->schema_dn_str = NULL;
+ settings->invocation_id = NULL;
+ settings->netbios_name = "FOO";
+ settings->realm = "EXAMPLE.COM";
+ settings->domain = "EXAMPLE";
+ settings->netbios_name = "torture";
+ settings->ntds_dn_str = NULL;
+ settings->machine_password = "geheim";
- status = provision_bare(tctx, tctx->lp_ctx, &settings);
+ status = provision_bare(settings, tctx->lp_ctx, settings, &result);
torture_assert_ntstatus_ok(tctx, status, "provision");
+ torture_assert_str_equal(tctx, result.domaindn, "DC=EXAMPLE,DC=COM",
+ "domaindn incorrect");
+
return true;
}
diff --git a/source4/torture/locktest.c b/source4/torture/locktest.c
index 618568acf9..8959232edb 100644
--- a/source4/torture/locktest.c
+++ b/source4/torture/locktest.c
@@ -19,6 +19,7 @@
#include "includes.h"
#include "lib/cmdline/popt_common.h"
+#include "lib/events/events.h"
#include "system/filesys.h"
#include "system/time.h"
#include "pstring.h"
@@ -107,7 +108,8 @@ static struct record *recorded;
/*****************************************************
return a connection to a server
*******************************************************/
-static struct smbcli_state *connect_one(struct loadparm_context *lp_ctx,
+static struct smbcli_state *connect_one(struct event_context *ev,
+ struct loadparm_context *lp_ctx,
char *share, int snum, int conn)
{
struct smbcli_state *c;
@@ -162,7 +164,7 @@ static struct smbcli_state *connect_one(struct loadparm_context *lp_ctx,
share, NULL,
servers[snum],
lp_resolve_context(lp_ctx),
- NULL, &options);
+ ev, &options);
if (!NT_STATUS_IS_OK(status)) {
sleep(2);
}
@@ -176,7 +178,8 @@ static struct smbcli_state *connect_one(struct loadparm_context *lp_ctx,
}
-static void reconnect(struct loadparm_context *lp_ctx,
+static void reconnect(struct event_context *ev,
+ struct loadparm_context *lp_ctx,
struct smbcli_state *cli[NSERVERS][NCONNECTIONS], int fnum[NSERVERS][NCONNECTIONS][NFILES],
char *share[NSERVERS])
{
@@ -193,7 +196,7 @@ static void reconnect(struct loadparm_context *lp_ctx,
}
talloc_free(cli[server][conn]);
}
- cli[server][conn] = connect_one(lp_ctx, share[server],
+ cli[server][conn] = connect_one(ev, lp_ctx, share[server],
server, conn);
if (!cli[server][conn]) {
DEBUG(0,("Failed to connect to %s\n", share[server]));
@@ -396,7 +399,9 @@ static int retest(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
we then do random locking ops in tamdem on the 4 fnums from each
server and ensure that the results match
*/
-static int test_locks(struct loadparm_context *lp_ctx, char *share[NSERVERS])
+static int test_locks(struct event_context *ev,
+ struct loadparm_context *lp_ctx,
+ char *share[NSERVERS])
{
struct smbcli_state *cli[NSERVERS][NCONNECTIONS];
int fnum[NSERVERS][NCONNECTIONS][NFILES];
@@ -447,7 +452,7 @@ static int test_locks(struct loadparm_context *lp_ctx, char *share[NSERVERS])
#endif
}
- reconnect(lp_ctx, cli, fnum, share);
+ reconnect(ev, lp_ctx, cli, fnum, share);
open_files(cli, fnum);
n = retest(cli, fnum, numops);
@@ -465,7 +470,7 @@ static int test_locks(struct loadparm_context *lp_ctx, char *share[NSERVERS])
n1 = n;
close_files(cli, fnum);
- reconnect(lp_ctx, cli, fnum, share);
+ reconnect(ev, lp_ctx, cli, fnum, share);
open_files(cli, fnum);
for (i=0;i<n-skip;i+=skip) {
@@ -503,7 +508,7 @@ static int test_locks(struct loadparm_context *lp_ctx, char *share[NSERVERS])
}
close_files(cli, fnum);
- reconnect(lp_ctx, cli, fnum, share);
+ reconnect(ev, lp_ctx, cli, fnum, share);
open_files(cli, fnum);
showall = true;
n1 = retest(cli, fnum, n);
@@ -543,6 +548,7 @@ static void usage(poptContext pc)
int opt;
int seed, server;
int username_count=0;
+ struct event_context *ev;
struct loadparm_context *lp_ctx;
poptContext pc;
int argc_new, i;
@@ -631,12 +637,14 @@ static void usage(poptContext pc)
servers[1] = servers[0];
}
+ ev = event_context_init(talloc_autofree_context());
+
gensec_init(lp_ctx);
DEBUG(0,("seed=%u base=%d range=%d min_length=%d\n",
seed, lock_base, lock_range, min_length));
srandom(seed);
- return test_locks(lp_ctx, share);
+ return test_locks(ev, lp_ctx, share);
}
diff --git a/source4/torture/locktest2.c b/source4/torture/locktest2.c
index 0fe3725385..1784a0a729 100644
--- a/source4/torture/locktest2.c
+++ b/source4/torture/locktest2.c
@@ -19,6 +19,7 @@
#include "includes.h"
#include "system/passwd.h"
+#include "lib/events/events.h"
static fstring password;
static fstring username;
@@ -137,7 +138,8 @@ static bool try_unlock(struct smbcli_state *c, int fstype,
return a connection to a server
*******************************************************/
static struct smbcli_state *connect_one(char *share, const char **ports,
- struct smb_options *options)
+ struct smb_options *optionsi,
+ struct event_context *ev)
{
struct smbcli_state *c;
char *server_n;
@@ -165,7 +167,7 @@ static struct smbcli_state *connect_one(char *share, const char **ports,
nt_status = smbcli_full_connection(NULL,
&c, myname, server_n, ports, share, NULL,
- username, lp_workgroup(), password, NULL,
+ username, lp_workgroup(), password, ev,
options);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0, ("smbcli_full_connection failed with error %s\n", nt_errstr(nt_status)));
@@ -183,6 +185,7 @@ static void reconnect(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
int fnum[NSERVERS][NUMFSTYPES][NCONNECTIONS][NFILES],
const char **ports,
struct smbcli_options *options,
+ struct event_context *ev,
char *share1, char *share2)
{
int server, conn, f, fstype;
@@ -201,7 +204,7 @@ static void reconnect(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
smbcli_ulogoff(cli[server][conn]);
talloc_free(cli[server][conn]);
}
- cli[server][conn] = connect_one(share[server], ports, options);
+ cli[server][conn] = connect_one(share[server], ports, options, ev);
if (!cli[server][conn]) {
DEBUG(0,("Failed to connect to %s\n", share[server]));
exit(1);
@@ -347,7 +350,11 @@ static int retest(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
we then do random locking ops in tamdem on the 4 fnums from each
server and ensure that the results match
*/
-static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath2, const char **ports, struct smbcli_options *options)
+static void test_locks(char *share1, char *share2,
+ char *nfspath1, char *nfspath2,
+ const char **ports,
+ struct smbcli_options *options,
+ struct event_context *ev)
{
struct smbcli_state *cli[NSERVERS][NCONNECTIONS];
char *nfs[NSERVERS];
@@ -376,7 +383,7 @@ static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath
recorded[n].needed = true;
}
- reconnect(cli, nfs, fnum, ports, options, share1, share2);
+ reconnect(cli, nfs, fnum, ports, options, ev, share1, share2);
open_files(cli, nfs, fnum);
n = retest(cli, nfs, fnum, numops);
@@ -387,7 +394,7 @@ static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath
n1 = n;
close_files(cli, nfs, fnum);
- reconnect(cli, nfs, fnum, ports, options, share1, share2);
+ reconnect(cli, nfs, fnum, ports, options, ev, share1, share2);
open_files(cli, nfs, fnum);
for (i=0;i<n-1;i++) {
@@ -414,7 +421,7 @@ static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath
}
close_files(cli, nfs, fnum);
- reconnect(cli, nfs, fnum, ports, options, share1, share2);
+ reconnect(cli, nfs, fnum, ports, options, ev, share1, share2);
open_files(cli, nfs, fnum);
showall = true;
n1 = retest(cli, nfs, fnum, n);
@@ -466,6 +473,7 @@ static void usage(void)
char *p;
int seed;
struct loadparm_context *lp_ctx;
+ struct event_context *ev;
setlinebuf(stdout);
@@ -542,10 +550,12 @@ static void usage(void)
DEBUG(0,("seed=%u\n", seed));
srandom(seed);
+ ev = event_context_init(talloc_autofree_context());
+
locking_init(1);
lp_smbcli_options(lp_ctx, &options);
test_locks(share1, share2, nfspath1, nfspath2, lp_smb_ports(lp_ctx),
- &options);
+ &options, ev);
return(0);
}
diff --git a/source4/torture/masktest.c b/source4/torture/masktest.c
index ac7029aa50..39b1296dbe 100644
--- a/source4/torture/masktest.c
+++ b/source4/torture/masktest.c
@@ -30,6 +30,7 @@
#include "param/param.h"
#include "dynconfig.h"
#include "libcli/resolve/resolve.h"
+#include "lib/events/events.h"
static bool showall = false;
static bool old_list = false;
@@ -73,6 +74,7 @@ static char *reg_test(struct smbcli_state *cli, char *pattern, char *long_name,
return a connection to a server
*******************************************************/
static struct smbcli_state *connect_one(struct resolve_context *resolve_ctx,
+ struct event_context *ev,
char *share, const char **ports,
struct smbcli_options *options)
{
@@ -92,7 +94,7 @@ static struct smbcli_state *connect_one(struct resolve_context *resolve_ctx,
server,
ports,
share, NULL,
- cmdline_credentials, resolve_ctx, NULL,
+ cmdline_credentials, resolve_ctx, ev,
options);
if (!NT_STATUS_IS_OK(status)) {
@@ -291,6 +293,7 @@ static void usage(poptContext pc)
struct smbcli_state *cli;
int opt;
int seed;
+ struct event_context *ev;
struct loadparm_context *lp_ctx;
struct smbcli_options options;
poptContext pc;
@@ -352,11 +355,13 @@ static void usage(poptContext pc)
lp_ctx = cmdline_lp_ctx;
+ ev = event_context_init(talloc_autofree_context());
+
gensec_init(lp_ctx);
lp_smbcli_options(lp_ctx, &options);
- cli = connect_one(lp_resolve_context(lp_ctx), share,
+ cli = connect_one(lp_resolve_context(lp_ctx), ev, share,
lp_smb_ports(lp_ctx), &options);
if (!cli) {
DEBUG(0,("Failed to connect to %s\n", share));
diff --git a/source4/torture/nbt/browse.c b/source4/torture/nbt/browse.c
index e609e72055..a0e7b7d9ca 100644
--- a/source4/torture/nbt/browse.c
+++ b/source4/torture/nbt/browse.c
@@ -40,7 +40,7 @@ bool torture_nbt_browse(struct torture_context *torture)
name.scope = NULL;
/* do an initial name resolution to find its IP */
- status = resolve_name(&name, mem_ctx, &address, NULL);
+ status = resolve_name(&name, mem_ctx, &address, torture->ev);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to resolve %s - %s\n",
name.name, nt_errstr(status));
diff --git a/source4/torture/nbt/dgram.c b/source4/torture/nbt/dgram.c
index e1680877e8..a3585896eb 100644
--- a/source4/torture/nbt/dgram.c
+++ b/source4/torture/nbt/dgram.c
@@ -64,7 +64,7 @@ static void netlogon_handler(struct dgram_mailslot_handler *dgmslot,
static bool nbt_test_netlogon(struct torture_context *tctx)
{
struct dgram_mailslot_handler *dgmslot;
- struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, NULL,
+ struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, tctx->ev,
lp_iconv_convenience(tctx->lp_ctx));
struct socket_address *dest;
const char *myaddress;
@@ -87,7 +87,7 @@ static bool nbt_test_netlogon(struct torture_context *tctx)
/* do an initial name resolution to find its IP */
torture_assert_ntstatus_ok(tctx,
- resolve_name(lp_resolve_context(tctx->lp_ctx), &name, tctx, &address, event_context_find(tctx)),
+ resolve_name(lp_resolve_context(tctx->lp_ctx), &name, tctx, &address, tctx->ev),
talloc_asprintf(tctx, "Failed to resolve %s", name.name));
load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces);
@@ -147,7 +147,7 @@ static bool nbt_test_netlogon(struct torture_context *tctx)
static bool nbt_test_netlogon2(struct torture_context *tctx)
{
struct dgram_mailslot_handler *dgmslot;
- struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, NULL,
+ struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, tctx->ev,
lp_iconv_convenience(tctx->lp_ctx));
struct socket_address *dest;
const char *myaddress;
@@ -170,7 +170,7 @@ static bool nbt_test_netlogon2(struct torture_context *tctx)
/* do an initial name resolution to find its IP */
torture_assert_ntstatus_ok(tctx,
- resolve_name(lp_resolve_context(tctx->lp_ctx), &name, tctx, &address, event_context_find(tctx)),
+ resolve_name(lp_resolve_context(tctx->lp_ctx), &name, tctx, &address, tctx->ev),
talloc_asprintf(tctx, "Failed to resolve %s", name.name));
load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces);
@@ -257,7 +257,7 @@ static void ntlogon_handler(struct dgram_mailslot_handler *dgmslot,
static bool nbt_test_ntlogon(struct torture_context *tctx)
{
struct dgram_mailslot_handler *dgmslot;
- struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, NULL,
+ struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, tctx->ev,
lp_iconv_convenience(tctx->lp_ctx));
struct socket_address *dest;
struct test_join *join_ctx;
@@ -283,7 +283,7 @@ static bool nbt_test_ntlogon(struct torture_context *tctx)
/* do an initial name resolution to find its IP */
torture_assert_ntstatus_ok(tctx,
- resolve_name(lp_resolve_context(tctx->lp_ctx), &name, tctx, &address, event_context_find(tctx)),
+ resolve_name(lp_resolve_context(tctx->lp_ctx), &name, tctx, &address, tctx->ev),
talloc_asprintf(tctx, "Failed to resolve %s", name.name));
load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces);
diff --git a/source4/torture/nbt/nbt.c b/source4/torture/nbt/nbt.c
index 6cb9507398..d27a26eb30 100644
--- a/source4/torture/nbt/nbt.c
+++ b/source4/torture/nbt/nbt.c
@@ -34,7 +34,7 @@ bool torture_nbt_get_name(struct torture_context *tctx,
/* do an initial name resolution to find its IP */
torture_assert_ntstatus_ok(tctx,
- resolve_name(lp_resolve_context(tctx->lp_ctx), name, tctx, address, NULL),
+ resolve_name(lp_resolve_context(tctx->lp_ctx), name, tctx, address, tctx->ev),
talloc_asprintf(tctx,
"Failed to resolve %s", name->name));
diff --git a/source4/torture/nbt/query.c b/source4/torture/nbt/query.c
index 1ba6172e5c..3f3a15cca5 100644
--- a/source4/torture/nbt/query.c
+++ b/source4/torture/nbt/query.c
@@ -47,7 +47,7 @@ static void increment_handler(struct nbt_name_request *req)
*/
static bool bench_namequery(struct torture_context *tctx)
{
- struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL,
+ struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, tctx->ev,
lp_iconv_convenience(tctx->lp_ctx));
int num_sent=0;
struct result_struct *result;
diff --git a/source4/torture/nbt/register.c b/source4/torture/nbt/register.c
index b9f06c479d..a8681f828f 100644
--- a/source4/torture/nbt/register.c
+++ b/source4/torture/nbt/register.c
@@ -44,7 +44,7 @@ static bool nbt_register_own(struct torture_context *tctx)
{
struct nbt_name_register io;
NTSTATUS status;
- struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL,
+ struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, tctx->ev,
lp_iconv_convenience(tctx->lp_ctx));
struct socket_address *socket_address;
struct nbt_name name;
@@ -114,7 +114,7 @@ static bool nbt_refresh_own(struct torture_context *tctx)
{
struct nbt_name_refresh io;
NTSTATUS status;
- struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL,
+ struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, tctx->ev,
lp_iconv_convenience(tctx->lp_ctx));
const char *myaddress;
struct socket_address *socket_address;
diff --git a/source4/torture/nbt/wins.c b/source4/torture/nbt/wins.c
index 059b2dc919..ae20de6e2f 100644
--- a/source4/torture/nbt/wins.c
+++ b/source4/torture/nbt/wins.c
@@ -53,7 +53,7 @@ static bool nbt_test_wins_name(struct torture_context *tctx, const char *address
struct nbt_name_refresh_wins refresh;
struct nbt_name_release release;
NTSTATUS status;
- struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
const char *myaddress;
struct socket_address *socket_address;
struct interface *ifaces;
diff --git a/source4/torture/nbt/winsbench.c b/source4/torture/nbt/winsbench.c
index ea4abaf21b..a0d90fb653 100644
--- a/source4/torture/nbt/winsbench.c
+++ b/source4/torture/nbt/winsbench.c
@@ -225,7 +225,7 @@ static void generate_request(struct nbt_name_socket *nbtsock, struct wins_state
*/
static bool bench_wins(struct torture_context *tctx)
{
- struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
int num_sent=0;
struct timeval tv = timeval_current();
bool ret = true;
diff --git a/source4/torture/nbt/winsreplication.c b/source4/torture/nbt/winsreplication.c
index 470eee8310..ee7a1510d5 100644
--- a/source4/torture/nbt/winsreplication.c
+++ b/source4/torture/nbt/winsreplication.c
@@ -103,8 +103,8 @@ static bool test_assoc_ctx1(struct torture_context *tctx)
torture_comment(tctx, "Test if assoc_ctx is only valid on the conection it was created on\n");
- wrepl_socket1 = wrepl_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
- wrepl_socket2 = wrepl_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ wrepl_socket1 = wrepl_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
+ wrepl_socket2 = wrepl_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
torture_comment(tctx, "Setup 2 wrepl connections\n");
status = wrepl_connect(wrepl_socket1, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, address), address);
@@ -186,7 +186,7 @@ static bool test_assoc_ctx2(struct torture_context *tctx)
torture_comment(tctx, "Test if we always get back the same assoc_ctx\n");
- wrepl_socket = wrepl_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ wrepl_socket = wrepl_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
torture_comment(tctx, "Setup wrepl connections\n");
status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, address), address);
@@ -255,7 +255,7 @@ static bool test_wins_replication(struct torture_context *tctx)
torture_comment(tctx, "Test one pull replication cycle\n");
- wrepl_socket = wrepl_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ wrepl_socket = wrepl_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
torture_comment(tctx, "Setup wrepl connections\n");
status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, address), address);
@@ -553,7 +553,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
if (!ctx) return NULL;
ctx->address = address;
- ctx->pull = wrepl_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ ctx->pull = wrepl_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
if (!ctx->pull) return NULL;
torture_comment(tctx, "Setup wrepl conflict pull connection\n");
@@ -610,7 +610,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
talloc_free(pull_table.out.partners);
- ctx->nbtsock = nbt_name_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ ctx->nbtsock = nbt_name_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
if (!ctx->nbtsock) return NULL;
load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces);
@@ -628,7 +628,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
status = socket_listen(ctx->nbtsock->sock, ctx->myaddr, 0, 0);
if (!NT_STATUS_IS_OK(status)) return NULL;
- ctx->nbtsock_srv = nbt_name_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ ctx->nbtsock_srv = nbt_name_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
if (!ctx->nbtsock_srv) return NULL;
/* Make a port 137 version of ctx->myaddr */
@@ -645,7 +645,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
}
if (ctx->myaddr2 && ctx->nbtsock_srv) {
- ctx->nbtsock2 = nbt_name_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ ctx->nbtsock2 = nbt_name_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
if (!ctx->nbtsock2) return NULL;
status = socket_listen(ctx->nbtsock2->sock, ctx->myaddr2, 0, 0);
@@ -722,7 +722,7 @@ static bool test_wrepl_update_one(struct torture_context *tctx,
uint32_t assoc_ctx;
NTSTATUS status;
- wrepl_socket = wrepl_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ wrepl_socket = wrepl_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, ctx->address), ctx->address);
CHECK_STATUS(tctx, status, NT_STATUS_OK);
diff --git a/source4/torture/ndr/netlogon.c b/source4/torture/ndr/netlogon.c
index 2f01a9d009..a5221f71e9 100644
--- a/source4/torture/ndr/netlogon.c
+++ b/source4/torture/ndr/netlogon.c
@@ -46,7 +46,7 @@ static bool netrserverauthenticate3_in_check(struct torture_context *tctx,
torture_assert_int_equal(tctx, r->in.secure_channel_type, 2, "secure channel type");
torture_assert_str_equal(tctx, r->in.computer_name, "NATIVE-2K", "computer name");
torture_assert_int_equal(tctx, *r->in.negotiate_flags, 0x6007ffff, "negotiate flags");
- torture_assert(tctx, memcmp(cred_expected, r->in.credentials->data, 8) == 0, "credentials");
+ torture_assert_mem_equal(tctx, cred_expected, r->in.credentials->data, 8, "credentials");
return true;
}
@@ -59,7 +59,7 @@ static bool netrserverauthenticate3_out_check(struct torture_context *tctx,
struct netr_ServerAuthenticate3 *r)
{
uint8_t cred_expected[8] = { 0x22, 0x0c, 0x86, 0x8a, 0xe9, 0x92, 0x93, 0xc9 };
- torture_assert(tctx, memcmp(cred_expected, r->out.credentials->data, 8) == 0, "credentials");
+ torture_assert_mem_equal(tctx, cred_expected, r->out.credentials->data, 8, "credentials");
torture_assert_int_equal(tctx, *r->out.negotiate_flags, 0x6007ffff, "negotiate flags");
torture_assert_int_equal(tctx, *r->out.rid, 0x454, "rid");
torture_assert_ntstatus_ok(tctx, r->out.result, "return code");
@@ -80,12 +80,12 @@ static const uint8_t netrserverreqchallenge_in_data[] = {
};
static bool netrserverreqchallenge_in_check(struct torture_context *tctx,
- struct netr_ServerReqChallenge *r)
+ struct netr_ServerReqChallenge *r)
{
uint8_t cred_expected[8] = { 0xa3, 0x2c, 0xa2, 0x95, 0x40, 0xcc, 0xb7, 0xbb };
torture_assert_str_equal(tctx, r->in.server_name, "\\\\NATIVE-DC.NATIVE.BASE", "server name");
torture_assert_str_equal(tctx, r->in.computer_name, "NATIVE-2K", "account name");
- torture_assert(tctx, memcmp(cred_expected, r->in.credentials->data, 8) == 0, "credentials");
+ torture_assert_mem_equal(tctx, cred_expected, r->in.credentials->data, 8, "credentials");
return true;
}
@@ -95,10 +95,10 @@ static const uint8_t netrserverreqchallenge_out_data[] = {
};
static bool netrserverreqchallenge_out_check(struct torture_context *tctx,
- struct netr_ServerReqChallenge *r)
+ struct netr_ServerReqChallenge *r)
{
uint8_t cred_expected[8] = { 0x22, 0xfc, 0xc1, 0x17, 0xc0, 0xae, 0x27, 0x8e };
- torture_assert(tctx, memcmp(cred_expected, r->out.credentials->data, 8) == 0, "credentials");
+ torture_assert_mem_equal(tctx, cred_expected, r->out.credentials->data, 8, "credentials");
torture_assert_ntstatus_ok(tctx, r->out.result, "return code");
return true;
diff --git a/source4/torture/raw/composite.c b/source4/torture/raw/composite.c
index 1f31fbc515..d73ac1327e 100644
--- a/source4/torture/raw/composite.c
+++ b/source4/torture/raw/composite.c
@@ -296,7 +296,7 @@ static bool test_appendacl(struct smbcli_state *cli, struct torture_context *tct
c[i]->async.private_data = count;
}
- event_ctx = talloc_reference(tctx, cli->tree->session->transport->socket->event.ctx);
+ event_ctx = tctx->ev;
printf("waiting for completion\n");
while (*count != num_ops) {
event_loop_once(event_ctx);
@@ -354,7 +354,7 @@ static bool test_fsinfo(struct smbcli_state *cli, struct torture_context *tctx)
printf("testing parallel queryfsinfo [Object ID] with %d ops\n", torture_numops);
- event_ctx = talloc_reference(tctx, cli->tree->session->transport->socket->event.ctx);
+ event_ctx = tctx->ev;
c = talloc_array(tctx, struct composite_context *, torture_numops);
for (i=0; i<torture_numops; i++) {
diff --git a/source4/torture/raw/lockbench.c b/source4/torture/raw/lockbench.c
index 86030c538a..21541d003b 100644
--- a/source4/torture/raw/lockbench.c
+++ b/source4/torture/raw/lockbench.c
@@ -316,7 +316,6 @@ bool torture_bench_lock(struct torture_context *torture)
int i;
int timelimit = torture_setting_int(torture, "timelimit", 10);
struct timeval tv;
- struct event_context *ev = event_context_find(mem_ctx);
struct benchlock_state *state;
int total = 0, minops=0;
struct smbcli_state *cli;
@@ -333,8 +332,8 @@ bool torture_bench_lock(struct torture_context *torture)
state[i].tctx = torture;
state[i].mem_ctx = talloc_new(state);
state[i].client_num = i;
- state[i].ev = ev;
- if (!torture_open_connection_ev(&cli, i, torture, ev)) {
+ state[i].ev = torture->ev;
+ if (!torture_open_connection_ev(&cli, i, torture, torture->ev)) {
return false;
}
talloc_steal(mem_ctx, state);
@@ -375,12 +374,12 @@ bool torture_bench_lock(struct torture_context *torture)
tv = timeval_current();
if (progress) {
- event_add_timed(ev, state, timeval_current_ofs(1, 0), report_rate, state);
+ event_add_timed(torture->ev, state, timeval_current_ofs(1, 0), report_rate, state);
}
printf("Running for %d seconds\n", timelimit);
while (timeval_elapsed(&tv) < timelimit) {
- event_loop_once(ev);
+ event_loop_once(torture->ev);
if (lock_failed) {
DEBUG(0,("locking failed\n"));
diff --git a/source4/torture/raw/lookuprate.c b/source4/torture/raw/lookuprate.c
new file mode 100644
index 0000000000..0e8f002efb
--- /dev/null
+++ b/source4/torture/raw/lookuprate.c
@@ -0,0 +1,320 @@
+/*
+ File lookup rate test.
+
+ Copyright (C) James Peach 2006
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "param/param.h"
+#include "system/filesys.h"
+#include "torture/torture.h"
+#include "torture/basic/proto.h"
+#include "libcli/libcli.h"
+#include "torture/util.h"
+#include "lib/cmdline/popt_common.h"
+#include "auth/credentials/credentials.h"
+
+#define BASEDIR "\\lookuprate"
+#define MISSINGNAME BASEDIR "\\foo"
+
+#define FUZZ_PERCENT 10
+
+#define usec_to_sec(s) ((s) / 1000000)
+#define sec_to_usec(s) ((s) * 1000000)
+
+struct rate_record
+{
+ unsigned dirent_count;
+ unsigned querypath_persec;
+ unsigned findfirst_persec;
+};
+
+static struct rate_record records[] =
+{
+ { 0, 0, 0 }, /* Base (optimal) lookup rate. */
+ { 100, 0, 0},
+ { 1000, 0, 0},
+ { 10000, 0, 0},
+ { 100000, 0, 0}
+};
+
+typedef NTSTATUS lookup_function(struct smbcli_tree *tree, const char * path);
+
+/* Test whether rhs is within fuzz% of lhs. */
+static bool fuzzily_equal(unsigned lhs, unsigned rhs, int percent)
+{
+ double fuzz = (double)lhs * (double)percent/100.0;
+
+ if (((double)rhs >= ((double)lhs - fuzz)) &&
+ ((double)rhs <= ((double)lhs + fuzz))) {
+ return true;
+ }
+
+ return false;
+
+}
+
+static NTSTATUS fill_directory(struct smbcli_tree *tree,
+ const char * path, unsigned count)
+{
+ NTSTATUS status;
+ char *fname = NULL;
+ unsigned i;
+ unsigned current;
+
+ struct timeval start;
+ struct timeval now;
+
+ status = smbcli_mkdir(tree, path);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ printf("filling directory %s with %u files... ", path, count);
+ fflush(stdout);
+
+ current = random();
+ start = timeval_current();
+
+ for (i = 0; i < count; ++i) {
+ int fnum;
+
+ ++current;
+ fname = talloc_asprintf(NULL, "%s\\fill%u",
+ path, current);
+
+ fnum = smbcli_open(tree, fname, O_RDONLY|O_CREAT,
+ OPENX_MODE_DENY_NONE);
+ if (fnum < 0) {
+ talloc_free(fname);
+ return smbcli_nt_error(tree);
+ }
+
+ smbcli_close(tree, fnum);
+ talloc_free(fname);
+ }
+
+ if (count) {
+ double rate;
+ now = timeval_current();
+ rate = (double)count / usec_to_sec((double)usec_time_diff(&now, &start));
+ printf("%u/sec\n", (unsigned)rate);
+ } else {
+ printf("done\n");
+ }
+
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS squash_lookup_error(NTSTATUS status)
+{
+ if (NT_STATUS_IS_OK(status)) {
+ return NT_STATUS_OK;
+ }
+
+ /* We don't care if the file isn't there. */
+ if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_PATH_NOT_FOUND)) {
+ return NT_STATUS_OK;
+ }
+
+ if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
+ return NT_STATUS_OK;
+ }
+
+ if (NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_FILE)) {
+ return NT_STATUS_OK;
+ }
+
+ return status;
+}
+
+/* Look up a pathname using TRANS2_QUERY_PATH_INFORMATION. */
+static NTSTATUS querypath_lookup(struct smbcli_tree *tree, const char * path)
+{
+ NTSTATUS status;
+ time_t ftimes[3];
+ size_t fsize;
+ uint16_t fmode;
+
+ status = smbcli_qpathinfo(tree, path, &ftimes[0], &ftimes[1], &ftimes[2],
+ &fsize, &fmode);
+
+ return squash_lookup_error(status);
+}
+
+/* Look up a pathname using TRANS2_FIND_FIRST2. */
+static NTSTATUS findfirst_lookup(struct smbcli_tree *tree, const char * path)
+{
+ NTSTATUS status = NT_STATUS_OK;
+
+ if (smbcli_list(tree, path, 0, NULL, NULL) < 0) {
+ status = smbcli_nt_error(tree);
+ }
+
+ return squash_lookup_error(status);
+}
+
+static NTSTATUS lookup_rate_convert(struct smbcli_tree *tree,
+ lookup_function lookup, const char * path, unsigned * rate)
+{
+ NTSTATUS status;
+
+ struct timeval start;
+ struct timeval now;
+ unsigned count = 0;
+ int64_t elapsed = 0;
+
+#define LOOKUP_PERIOD_SEC (2)
+
+ start = timeval_current();
+ while (elapsed < sec_to_usec(LOOKUP_PERIOD_SEC)) {
+
+ status = lookup(tree, path);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ ++count;
+ now = timeval_current();
+ elapsed = usec_time_diff(&now, &start);
+ }
+
+#undef LOOKUP_PERIOD_SEC
+
+ *rate = (unsigned)((double)count / (double)usec_to_sec(elapsed));
+ return NT_STATUS_OK;
+}
+
+static bool remove_working_directory(struct smbcli_tree *tree,
+ const char * path)
+{
+ int tries;
+
+ /* Using smbcli_deltree to delete a very large number of files
+ * doesn't work against all servers. Work around this by
+ * retrying.
+ */
+ for (tries = 0; tries < 5; ) {
+ int ret;
+
+ ret = smbcli_deltree(tree, BASEDIR);
+ if (ret == -1) {
+ tries++;
+ printf("(%s) failed to deltree %s: %s\n",
+ __location__, BASEDIR,
+ smbcli_errstr(tree));
+ continue;
+ }
+
+ return true;
+ }
+
+ return false;
+
+}
+
+/* Verify that looking up a file name takes constant time.
+ *
+ * This test samples the lookup rate for a non-existant filename in a
+ * directory, while varying the number of files in the directory. The
+ * lookup rate should continue to approximate the lookup rate for the
+ * empty directory case.
+ */
+bool torture_bench_lookup(struct torture_context *torture)
+{
+ NTSTATUS status;
+ bool result = false;
+
+ int i, tries;
+ struct smbcli_state *cli = NULL;
+
+ if (!torture_open_connection(&cli, torture, 0)) {
+ goto done;
+ }
+
+ remove_working_directory(cli->tree, BASEDIR);
+
+ for (i = 0; i < ARRAY_SIZE(records); ++i) {
+ printf("testing lookup rate with %u directory entries\n",
+ records[i].dirent_count);
+
+ status = fill_directory(cli->tree, BASEDIR,
+ records[i].dirent_count);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("failed to fill directory: %s\n", nt_errstr(status));
+ goto done;
+ }
+
+ status = lookup_rate_convert(cli->tree, querypath_lookup,
+ MISSINGNAME, &records[i].querypath_persec);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("querypathinfo of %s failed: %s\n",
+ MISSINGNAME, nt_errstr(status));
+ goto done;
+ }
+
+ status = lookup_rate_convert(cli->tree, findfirst_lookup,
+ MISSINGNAME, &records[i].findfirst_persec);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("findfirst of %s failed: %s\n",
+ MISSINGNAME, nt_errstr(status));
+ goto done;
+ }
+
+ printf("entries = %u, querypath = %u/sec, findfirst = %u/sec\n",
+ records[i].dirent_count,
+ records[i].querypath_persec,
+ records[i].findfirst_persec);
+
+ if (!remove_working_directory(cli->tree, BASEDIR)) {
+ goto done;
+ }
+ }
+
+ /* Ok. We have run all our tests. Walk through the records we
+ * accumulated and figure out whether the lookups took constant
+ * time of not.
+ */
+ for (i = 0; i < ARRAY_SIZE(records); ++i) {
+ if (!fuzzily_equal(records[0].querypath_persec,
+ records[i].querypath_persec,
+ FUZZ_PERCENT)) {
+ printf("querypath rate for %d entries differed by "
+ "more than %d%% from base rate\n",
+ records[i].dirent_count, FUZZ_PERCENT);
+ result = false;
+ }
+
+ if (!fuzzily_equal(records[0].findfirst_persec,
+ records[i].findfirst_persec,
+ FUZZ_PERCENT)) {
+ printf("findfirst rate for %d entries differed by "
+ "more than %d%% from base rate\n",
+ records[i].dirent_count, FUZZ_PERCENT);
+ result = false;
+ }
+ }
+
+done:
+ if (cli) {
+ remove_working_directory(cli->tree, BASEDIR);
+ talloc_free(cli);
+ }
+
+ return result;
+}
+
+/* vim: set sts=8 sw=8 : */
diff --git a/source4/torture/raw/offline.c b/source4/torture/raw/offline.c
index 1340692faa..9c66c3be9c 100644
--- a/source4/torture/raw/offline.c
+++ b/source4/torture/raw/offline.c
@@ -389,7 +389,6 @@ bool torture_test_offline(struct torture_context *torture)
int i;
int timelimit = torture_setting_int(torture, "timelimit", 10);
struct timeval tv;
- struct event_context *ev = event_context_find(mem_ctx);
struct offline_state *state;
struct smbcli_state *cli;
bool progress;
@@ -404,8 +403,8 @@ bool torture_test_offline(struct torture_context *torture)
for (i=0;i<nconnections;i++) {
state[i].tctx = torture;
state[i].mem_ctx = talloc_new(state);
- state[i].ev = ev;
- if (!torture_open_connection_ev(&cli, i, torture, ev)) {
+ state[i].ev = torture->ev;
+ if (!torture_open_connection_ev(&cli, i, torture, torture->ev)) {
return false;
}
state[i].tree = cli->tree;
@@ -418,7 +417,7 @@ bool torture_test_offline(struct torture_context *torture)
for (i=nconnections;i<numstates;i++) {
state[i].tctx = torture;
state[i].mem_ctx = talloc_new(state);
- state[i].ev = ev;
+ state[i].ev = torture->ev;
state[i].tree = state[i % nconnections].tree;
state[i].client = i;
}
@@ -468,12 +467,12 @@ bool torture_test_offline(struct torture_context *torture)
tv = timeval_current();
if (progress) {
- event_add_timed(ev, state, timeval_current_ofs(1, 0), report_rate, state);
+ event_add_timed(torture->ev, state, timeval_current_ofs(1, 0), report_rate, state);
}
printf("Running for %d seconds\n", timelimit);
while (timeval_elapsed(&tv) < timelimit) {
- event_loop_once(ev);
+ event_loop_once(torture->ev);
if (test_failed) {
DEBUG(0,("test failed\n"));
@@ -487,7 +486,7 @@ bool torture_test_offline(struct torture_context *torture)
while (state[i].loadfile ||
state[i].savefile ||
state[i].req) {
- event_loop_once(ev);
+ event_loop_once(torture->ev);
}
}
diff --git a/source4/torture/raw/open.c b/source4/torture/raw/open.c
index d28a8bd14e..c6ba0d2571 100644
--- a/source4/torture/raw/open.c
+++ b/source4/torture/raw/open.c
@@ -1350,21 +1350,19 @@ static bool test_raw_open_multi(struct torture_context *tctx)
const char *host = torture_setting_string(tctx, "host", NULL);
const char *share = torture_setting_string(tctx, "share", NULL);
int i, num_files = 3;
- struct event_context *ev;
int num_ok = 0;
int num_collision = 0;
- ev = cli_credentials_get_event_context(cmdline_credentials);
clients = talloc_array(mem_ctx, struct smbcli_state *, num_files);
requests = talloc_array(mem_ctx, struct smbcli_request *, num_files);
ios = talloc_array(mem_ctx, union smb_open, num_files);
- if ((ev == NULL) || (clients == NULL) || (requests == NULL) ||
+ if ((tctx->ev == NULL) || (clients == NULL) || (requests == NULL) ||
(ios == NULL)) {
DEBUG(0, ("talloc failed\n"));
return false;
}
- if (!torture_open_connection_share(mem_ctx, &cli, tctx, host, share, ev)) {
+ if (!torture_open_connection_share(mem_ctx, &cli, tctx, host, share, tctx->ev)) {
return false;
}
@@ -1372,7 +1370,7 @@ static bool test_raw_open_multi(struct torture_context *tctx)
for (i=0; i<num_files; i++) {
if (!torture_open_connection_share(mem_ctx, &(clients[i]),
- tctx, host, share, ev)) {
+ tctx, host, share, tctx->ev)) {
DEBUG(0, ("Could not open %d'th connection\n", i));
return false;
}
@@ -1441,7 +1439,7 @@ static bool test_raw_open_multi(struct torture_context *tctx)
break;
}
- if (event_loop_once(ev) != 0) {
+ if (event_loop_once(tctx->ev) != 0) {
DEBUG(0, ("event_loop_once failed\n"));
return false;
}
diff --git a/source4/torture/raw/openbench.c b/source4/torture/raw/openbench.c
index a5b1434a47..26b862c33f 100644
--- a/source4/torture/raw/openbench.c
+++ b/source4/torture/raw/openbench.c
@@ -369,7 +369,6 @@ bool torture_bench_open(struct torture_context *torture)
int i;
int timelimit = torture_setting_int(torture, "timelimit", 10);
struct timeval tv;
- struct event_context *ev = event_context_find(mem_ctx);
struct benchopen_state *state;
int total = 0;
int total_retries = 0;
@@ -387,8 +386,8 @@ bool torture_bench_open(struct torture_context *torture)
state[i].tctx = torture;
state[i].mem_ctx = talloc_new(state);
state[i].client_num = i;
- state[i].ev = ev;
- if (!torture_open_connection_ev(&state[i].cli, i, torture, ev)) {
+ state[i].ev = torture->ev;
+ if (!torture_open_connection_ev(&state[i].cli, i, torture, torture->ev)) {
return false;
}
talloc_steal(mem_ctx, state);
@@ -428,13 +427,13 @@ bool torture_bench_open(struct torture_context *torture)
tv = timeval_current();
if (progress) {
- report_te = event_add_timed(ev, state, timeval_current_ofs(1, 0),
+ report_te = event_add_timed(torture->ev, state, timeval_current_ofs(1, 0),
report_rate, state);
}
printf("Running for %d seconds\n", timelimit);
while (timeval_elapsed(&tv) < timelimit) {
- event_loop_once(ev);
+ event_loop_once(torture->ev);
if (open_failed) {
DEBUG(0,("open failed\n"));
diff --git a/source4/torture/raw/oplock.c b/source4/torture/raw/oplock.c
index 1927a0f027..fd8d292980 100644
--- a/source4/torture/raw/oplock.c
+++ b/source4/torture/raw/oplock.c
@@ -2841,13 +2841,12 @@ bool torture_bench_oplock(struct torture_context *torture)
int timelimit = torture_setting_int(torture, "timelimit", 10);
union smb_open io;
struct timeval tv;
- struct event_context *ev = event_context_find(mem_ctx);
cli = talloc_array(mem_ctx, struct smbcli_state *, torture_nprocs);
torture_comment(torture, "Opening %d connections\n", torture_nprocs);
for (i=0;i<torture_nprocs;i++) {
- if (!torture_open_connection_ev(&cli[i], i, torture, ev)) {
+ if (!torture_open_connection_ev(&cli[i], i, torture, torture->ev)) {
return false;
}
talloc_steal(mem_ctx, cli[i]);
diff --git a/source4/torture/raw/raw.c b/source4/torture/raw/raw.c
index bb3dde728f..262ed1384b 100644
--- a/source4/torture/raw/raw.c
+++ b/source4/torture/raw/raw.c
@@ -33,6 +33,8 @@ NTSTATUS torture_raw_init(void)
torture_suite_add_simple_test(suite, "PING-PONG", torture_ping_pong);
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, "BENCH-LOOKUP",
+ torture_bench_lookup);
torture_suite_add_simple_test(suite, "OFFLINE", torture_test_offline);
torture_suite_add_1smb_test(suite, "QFSINFO", torture_raw_qfsinfo);
torture_suite_add_1smb_test(suite, "QFILEINFO", torture_raw_qfileinfo);
diff --git a/source4/torture/raw/samba3hide.c b/source4/torture/raw/samba3hide.c
index 814b5f57f4..1f1501045c 100644
--- a/source4/torture/raw/samba3hide.c
+++ b/source4/torture/raw/samba3hide.c
@@ -136,7 +136,7 @@ bool torture_samba3_hide(struct torture_context *torture)
if (!torture_open_connection_share(
torture, &cli, torture, torture_setting_string(torture, "host", NULL),
- torture_setting_string(torture, "share", NULL), NULL)) {
+ torture_setting_string(torture, "share", NULL), torture->ev)) {
d_printf("torture_open_connection_share failed\n");
return false;
}
diff --git a/source4/torture/raw/samba3misc.c b/source4/torture/raw/samba3misc.c
index 15a7f6c4a3..27b4d42dd8 100644
--- a/source4/torture/raw/samba3misc.c
+++ b/source4/torture/raw/samba3misc.c
@@ -56,7 +56,7 @@ bool torture_samba3_checkfsp(struct torture_context *torture)
if (!torture_open_connection_share(
torture, &cli, torture, torture_setting_string(torture, "host", NULL),
- torture_setting_string(torture, "share", NULL), NULL)) {
+ torture_setting_string(torture, "share", NULL), torture->ev)) {
d_printf("torture_open_connection_share failed\n");
ret = false;
goto done;
diff --git a/source4/torture/rpc/async_bind.c b/source4/torture/rpc/async_bind.c
index 1ca3c62df0..0ebbef1ce6 100644
--- a/source4/torture/rpc/async_bind.c
+++ b/source4/torture/rpc/async_bind.c
@@ -39,7 +39,6 @@ bool torture_async_bind(struct torture_context *torture)
{
NTSTATUS status;
TALLOC_CTX *mem_ctx;
- struct event_context *evt_ctx;
int i;
const char *binding_string;
struct cli_credentials *creds;
@@ -70,15 +69,11 @@ bool torture_async_bind(struct torture_context *torture)
/* credentials */
creds = cmdline_credentials;
- /* event context */
- evt_ctx = cli_credentials_get_event_context(creds);
- if (evt_ctx == NULL) return false;
-
/* send bind requests */
for (i = 0; i < torture_numasync; i++) {
table[i] = &ndr_table_lsarpc;
bind_req[i] = dcerpc_pipe_connect_send(mem_ctx, binding_string,
- table[i], creds, evt_ctx, torture->lp_ctx);
+ table[i], creds, torture->ev, torture->lp_ctx);
}
/* recv bind requests */
diff --git a/source4/torture/rpc/dfs.c b/source4/torture/rpc/dfs.c
index 9cfdd80578..1c81766ebe 100644
--- a/source4/torture/rpc/dfs.c
+++ b/source4/torture/rpc/dfs.c
@@ -56,7 +56,7 @@ static bool test_NetShareAdd(TALLOC_CTX *mem_ctx,
printf("Creating share %s\n", sharename);
- if (!(libnetctx = libnet_context_init(NULL, tctx->lp_ctx))) {
+ if (!(libnetctx = libnet_context_init(tctx->ev, tctx->lp_ctx))) {
return false;
}
@@ -96,7 +96,7 @@ static bool test_NetShareDel(TALLOC_CTX *mem_ctx,
printf("Deleting share %s\n", sharename);
- if (!(libnetctx = libnet_context_init(NULL, tctx->lp_ctx))) {
+ if (!(libnetctx = libnet_context_init(tctx->ev, tctx->lp_ctx))) {
return false;
}
@@ -124,7 +124,7 @@ static bool test_CreateDir(TALLOC_CTX *mem_ctx,
{
printf("Creating directory %s\n", dir);
- if (!torture_open_connection_share(mem_ctx, cli, tctx, host, share, NULL)) {
+ if (!torture_open_connection_share(mem_ctx, cli, tctx, host, share, tctx->ev)) {
return false;
}
@@ -494,7 +494,7 @@ static void test_cleanup_stdroot(struct dcerpc_pipe *p,
test_RemoveStdRoot(p, mem_ctx, host, sharename);
test_NetShareDel(mem_ctx, tctx, host, sharename);
- torture_open_connection_share(mem_ctx, &cli, tctx, host, "C$", NULL);
+ torture_open_connection_share(mem_ctx, &cli, tctx, host, "C$", tctx->ev);
test_DeleteDir(cli, dir);
torture_close_connection(cli);
}
diff --git a/source4/torture/rpc/dssync.c b/source4/torture/rpc/dssync.c
index b28e429a75..00617f4072 100644
--- a/source4/torture/rpc/dssync.c
+++ b/source4/torture/rpc/dssync.c
@@ -178,12 +178,11 @@ static bool _test_DsBind(struct torture_context *tctx,
{
NTSTATUS status;
bool ret = true;
- struct event_context *event = NULL;
status = dcerpc_pipe_connect_b(ctx,
&b->pipe, ctx->drsuapi_binding,
&ndr_table_drsuapi,
- credentials, event, tctx->lp_ctx);
+ credentials, tctx->ev, tctx->lp_ctx);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to connect to server as a BDC: %s\n", nt_errstr(status));
@@ -254,10 +253,11 @@ static bool test_GetInfo(struct torture_context *tctx, struct DsSyncTest *ctx)
struct drsuapi_DsCrackNames r;
struct drsuapi_DsNameString names[1];
bool ret = true;
-
- struct cldap_socket *cldap = cldap_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ struct cldap_socket *cldap;
struct cldap_netlogon search;
-
+
+ cldap = cldap_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
+
r.in.bind_handle = &ctx->admin.drsuapi.bind_handle;
r.in.level = 1;
r.in.req.req1.codepage = 1252; /* western european */
diff --git a/source4/torture/rpc/join.c b/source4/torture/rpc/join.c
index 849b9fd1e9..cd5eb32fa8 100644
--- a/source4/torture/rpc/join.c
+++ b/source4/torture/rpc/join.c
@@ -39,7 +39,7 @@ bool torture_rpc_join(struct torture_context *torture)
"IPC$", NULL,
machine_account,
lp_resolve_context(torture->lp_ctx),
- NULL, &options);
+ torture->ev, &options);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("%s failed to connect to IPC$ with workstation credentials\n",
TORTURE_NETBIOS_NAME));
@@ -65,7 +65,7 @@ bool torture_rpc_join(struct torture_context *torture)
"IPC$", NULL,
machine_account,
lp_resolve_context(torture->lp_ctx),
- NULL, &options);
+ torture->ev, &options);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("%s failed to connect to IPC$ with workstation credentials\n",
TORTURE_NETBIOS_NAME));
diff --git a/source4/torture/rpc/rpc.c b/source4/torture/rpc/rpc.c
index 6e38d0465a..7c8e78b160 100644
--- a/source4/torture/rpc/rpc.c
+++ b/source4/torture/rpc/rpc.c
@@ -83,7 +83,7 @@ _PUBLIC_ NTSTATUS torture_rpc_connection(struct torture_context *tctx,
status = dcerpc_pipe_connect_b(tctx,
p, binding, table,
- cmdline_credentials, NULL, tctx->lp_ctx);
+ cmdline_credentials, tctx->ev, tctx->lp_ctx);
if (NT_STATUS_IS_ERR(status)) {
printf("Failed to connect to remote server: %s %s\n",
@@ -113,7 +113,7 @@ NTSTATUS torture_rpc_connection_transport(struct torture_context *tctx,
binding->assoc_group_id = assoc_group_id;
status = dcerpc_pipe_connect_b(tctx, p, binding, table,
- cmdline_credentials, NULL, tctx->lp_ctx);
+ cmdline_credentials, tctx->ev, tctx->lp_ctx);
if (NT_STATUS_IS_ERR(status)) {
*p = NULL;
@@ -147,7 +147,7 @@ static bool torture_rpc_setup_machine(struct torture_context *tctx,
&(tcase_data->pipe),
binding,
tcase->table,
- tcase_data->credentials, NULL, tctx->lp_ctx);
+ tcase_data->credentials, tctx->ev, tctx->lp_ctx);
torture_assert_ntstatus_ok(tctx, status, "Error connecting to server");
@@ -205,7 +205,7 @@ static bool torture_rpc_setup_anonymous(struct torture_context *tctx,
&(tcase_data->pipe),
binding,
tcase->table,
- tcase_data->credentials, NULL, tctx->lp_ctx);
+ tcase_data->credentials, tctx->ev, tctx->lp_ctx);
torture_assert_ntstatus_ok(tctx, status, "Error connecting to server");
diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c
index 8eb1f54b4f..1103acaefa 100644
--- a/source4/torture/rpc/samba3rpc.c
+++ b/source4/torture/rpc/samba3rpc.c
@@ -89,7 +89,7 @@ bool torture_bind_authcontext(struct torture_context *torture)
lp_smb_ports(torture->lp_ctx),
"IPC$", NULL, cmdline_credentials,
lp_resolve_context(torture->lp_ctx),
- NULL, &options);
+ torture->ev, &options);
if (!NT_STATUS_IS_OK(status)) {
d_printf("smbcli_full_connection failed: %s\n",
nt_errstr(status));
@@ -303,7 +303,7 @@ bool torture_bind_samba3(struct torture_context *torture)
lp_smb_ports(torture->lp_ctx),
"IPC$", NULL, cmdline_credentials,
lp_resolve_context(torture->lp_ctx),
- NULL, &options);
+ torture->ev, &options);
if (!NT_STATUS_IS_OK(status)) {
d_printf("smbcli_full_connection failed: %s\n",
nt_errstr(status));
@@ -1220,7 +1220,7 @@ bool torture_netlogon_samba3(struct torture_context *torture)
lp_smb_ports(torture->lp_ctx),
"IPC$", NULL, anon_creds,
lp_resolve_context(torture->lp_ctx),
- NULL, &options);
+ torture->ev, &options);
if (!NT_STATUS_IS_OK(status)) {
d_printf("smbcli_full_connection failed: %s\n",
nt_errstr(status));
@@ -1307,7 +1307,7 @@ static bool test_join3(struct torture_context *tctx,
lp_smb_ports(tctx->lp_ctx),
"IPC$", NULL, smb_creds,
lp_resolve_context(tctx->lp_ctx),
- NULL, &options);
+ tctx->ev, &options);
if (!NT_STATUS_IS_OK(status)) {
d_printf("smbcli_full_connection failed: %s\n",
nt_errstr(status));
@@ -1682,7 +1682,7 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture)
lp_smb_ports(torture->lp_ctx),
"IPC$", NULL, cmdline_credentials,
lp_resolve_context(torture->lp_ctx),
- NULL, &options);
+ torture->ev, &options);
if (!NT_STATUS_IS_OK(status)) {
d_printf("(%s) smbcli_full_connection failed: %s\n",
__location__, nt_errstr(status));
@@ -1709,7 +1709,7 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture)
lp_smb_ports(torture->lp_ctx),
"IPC$", NULL, anon_creds,
lp_resolve_context(torture->lp_ctx),
- NULL, &options);
+ torture->ev, &options);
if (!NT_STATUS_IS_OK(status)) {
d_printf("(%s) anon smbcli_full_connection failed: %s\n",
__location__, nt_errstr(status));
@@ -1924,7 +1924,7 @@ bool torture_samba3_rpc_srvsvc(struct torture_context *torture)
if (!(torture_open_connection_share(
mem_ctx, &cli, torture, torture_setting_string(torture, "host", NULL),
- "IPC$", NULL))) {
+ "IPC$", torture->ev))) {
talloc_free(mem_ctx);
return false;
}
@@ -1986,7 +1986,7 @@ bool torture_samba3_rpc_randomauth2(struct torture_context *torture)
if (!(torture_open_connection_share(
mem_ctx, &cli,
torture, torture_setting_string(torture, "host", NULL),
- "IPC$", NULL))) {
+ "IPC$", torture->ev))) {
d_printf("IPC$ connection failed\n");
goto done;
}
@@ -2281,7 +2281,7 @@ bool torture_samba3_rpc_sharesec(struct torture_context *torture)
if (!(torture_open_connection_share(
mem_ctx, &cli, torture, torture_setting_string(torture, "host", NULL),
- "IPC$", NULL))) {
+ "IPC$", torture->ev))) {
d_printf("IPC$ connection failed\n");
talloc_free(mem_ctx);
return false;
@@ -2329,7 +2329,7 @@ bool torture_samba3_rpc_lsa(struct torture_context *torture)
if (!(torture_open_connection_share(
mem_ctx, &cli, torture, torture_setting_string(torture, "host", NULL),
- "IPC$", NULL))) {
+ "IPC$", torture->ev))) {
d_printf("IPC$ connection failed\n");
talloc_free(mem_ctx);
return false;
@@ -2611,7 +2611,7 @@ bool torture_samba3_rpc_spoolss(struct torture_context *torture)
if (!(torture_open_connection_share(
mem_ctx, &cli, torture, torture_setting_string(torture, "host", NULL),
- "IPC$", NULL))) {
+ "IPC$", torture->ev))) {
d_printf("IPC$ connection failed\n");
talloc_free(mem_ctx);
return false;
@@ -2797,7 +2797,7 @@ bool torture_samba3_rpc_wkssvc(struct torture_context *torture)
if (!(torture_open_connection_share(
mem_ctx, &cli, torture, torture_setting_string(torture, "host", NULL),
- "IPC$", NULL))) {
+ "IPC$", torture->ev))) {
d_printf("IPC$ connection failed\n");
talloc_free(mem_ctx);
return false;
diff --git a/source4/torture/rpc/samlogon.c b/source4/torture/rpc/samlogon.c
index 24b2511bc7..ab3283a952 100644
--- a/source4/torture/rpc/samlogon.c
+++ b/source4/torture/rpc/samlogon.c
@@ -1602,7 +1602,7 @@ bool torture_rpc_samlogon(struct torture_context *torture)
status = dcerpc_pipe_connect_b(mem_ctx, &p, b,
&ndr_table_netlogon,
- machine_credentials, NULL, torture->lp_ctx);
+ machine_credentials, torture->ev, torture->lp_ctx);
if (!NT_STATUS_IS_OK(status)) {
d_printf("RPC pipe connect as domain member failed: %s\n", nt_errstr(status));
diff --git a/source4/torture/rpc/samsync.c b/source4/torture/rpc/samsync.c
index 3b152d92aa..9705f7b0de 100644
--- a/source4/torture/rpc/samsync.c
+++ b/source4/torture/rpc/samsync.c
@@ -1560,7 +1560,7 @@ bool torture_rpc_samsync(struct torture_context *torture)
status = dcerpc_pipe_connect_b(samsync_state,
&samsync_state->p, b,
&ndr_table_netlogon,
- credentials, NULL, torture->lp_ctx);
+ credentials, torture->ev, torture->lp_ctx);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to connect to server as a BDC: %s\n", nt_errstr(status));
@@ -1598,7 +1598,7 @@ bool torture_rpc_samsync(struct torture_context *torture)
&samsync_state->p_netlogon_wksta,
b_netlogon_wksta,
&ndr_table_netlogon,
- credentials_wksta, NULL, torture->lp_ctx);
+ credentials_wksta, torture->ev, torture->lp_ctx);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to connect to server as a Workstation: %s\n", nt_errstr(status));
diff --git a/source4/torture/rpc/schannel.c b/source4/torture/rpc/schannel.c
index 19b871f9c0..c89b71baaf 100644
--- a/source4/torture/rpc/schannel.c
+++ b/source4/torture/rpc/schannel.c
@@ -258,7 +258,7 @@ static bool test_schannel(struct torture_context *tctx,
b->flags |= dcerpc_flags;
status = dcerpc_pipe_connect_b(tctx, &p, b, &ndr_table_samr,
- credentials, NULL, tctx->lp_ctx);
+ credentials, tctx->ev, tctx->lp_ctx);
torture_assert_ntstatus_ok(tctx, status,
"Failed to connect with schannel");
@@ -270,7 +270,7 @@ static bool test_schannel(struct torture_context *tctx,
* the second */
/* Swap the binding details from SAMR to NETLOGON */
- status = dcerpc_epm_map_binding(tctx, b, &ndr_table_netlogon, NULL, tctx->lp_ctx);
+ status = dcerpc_epm_map_binding(tctx, b, &ndr_table_netlogon, tctx->ev, tctx->lp_ctx);
torture_assert_ntstatus_ok(tctx, status, "epm map");
status = dcerpc_secondary_connection(p, &p_netlogon,
@@ -296,7 +296,7 @@ static bool test_schannel(struct torture_context *tctx,
"Failed to process schannel secured NETLOGON EX ops");
/* Swap the binding details from SAMR to LSARPC */
- status = dcerpc_epm_map_binding(tctx, b, &ndr_table_lsarpc, NULL, tctx->lp_ctx);
+ status = dcerpc_epm_map_binding(tctx, b, &ndr_table_lsarpc, tctx->ev, tctx->lp_ctx);
torture_assert_ntstatus_ok(tctx, status, "epm map");
status = dcerpc_secondary_connection(p, &p_lsa,
@@ -328,7 +328,7 @@ static bool test_schannel(struct torture_context *tctx,
b->flags |= dcerpc_flags;
status = dcerpc_pipe_connect_b(tctx, &p_samr2, b, &ndr_table_samr,
- credentials, NULL, tctx->lp_ctx);
+ credentials, tctx->ev, tctx->lp_ctx);
torture_assert_ntstatus_ok(tctx, status,
"Failed to connect with schannel");
@@ -337,7 +337,7 @@ static bool test_schannel(struct torture_context *tctx,
"Failed to process schannel secured SAMR ops (on fresh connection)");
/* Swap the binding details from SAMR to NETLOGON */
- status = dcerpc_epm_map_binding(tctx, b, &ndr_table_netlogon, NULL, tctx->lp_ctx);
+ status = dcerpc_epm_map_binding(tctx, b, &ndr_table_netlogon, tctx->ev, tctx->lp_ctx);
torture_assert_ntstatus_ok(tctx, status, "epm");
status = dcerpc_secondary_connection(p_samr2, &p_netlogon2,
@@ -370,7 +370,7 @@ static bool test_schannel(struct torture_context *tctx,
b->flags &= ~DCERPC_AUTH_OPTIONS;
status = dcerpc_pipe_connect_b(tctx, &p_netlogon3, b, &ndr_table_netlogon,
- credentials, NULL, tctx->lp_ctx);
+ credentials, tctx->ev, tctx->lp_ctx);
torture_assert_ntstatus_ok(tctx, status, "Failed to connect without schannel");
torture_assert(tctx, !test_netlogon_ex_ops(p_netlogon3, tctx, credentials, creds),
@@ -453,12 +453,12 @@ bool torture_rpc_schannel2(struct torture_context *torture)
printf("Opening first connection\n");
status = dcerpc_pipe_connect_b(torture, &p1, b, &ndr_table_netlogon,
- credentials1, NULL, torture->lp_ctx);
+ credentials1, torture->ev, torture->lp_ctx);
torture_assert_ntstatus_ok(torture, status, "Failed to connect with schannel");
torture_comment(torture, "Opening second connection\n");
status = dcerpc_pipe_connect_b(torture, &p2, b, &ndr_table_netlogon,
- credentials2, NULL, torture->lp_ctx);
+ credentials2, torture->ev, torture->lp_ctx);
torture_assert_ntstatus_ok(torture, status, "Failed to connect with schannel");
credentials1->netlogon_creds = NULL;
diff --git a/source4/torture/rpc/session_key.c b/source4/torture/rpc/session_key.c
index fcb828ddb2..0df7e576ee 100644
--- a/source4/torture/rpc/session_key.c
+++ b/source4/torture/rpc/session_key.c
@@ -158,7 +158,11 @@ static bool test_secrets(struct torture_context *torture, const void *_data)
binding->flags |= settings->bindoptions;
torture_assert_ntstatus_ok(torture,
- dcerpc_pipe_connect_b(torture, &p, binding, &ndr_table_lsarpc, cmdline_credentials, NULL, torture->lp_ctx),
+ dcerpc_pipe_connect_b(torture, &p, binding,
+ &ndr_table_lsarpc,
+ cmdline_credentials,
+ torture->ev,
+ torture->lp_ctx),
"connect");
if (!test_lsa_OpenPolicy2(p, torture, &handle)) {
diff --git a/source4/torture/rpc/testjoin.c b/source4/torture/rpc/testjoin.c
index 02f04946d6..100e7cead2 100644
--- a/source4/torture/rpc/testjoin.c
+++ b/source4/torture/rpc/testjoin.c
@@ -311,7 +311,7 @@ _PUBLIC_ struct test_join *torture_join_domain(struct torture_context *tctx,
struct samr_SetUserInfo s;
union samr_UserInfo u;
- tj = talloc(NULL, struct test_join);
+ tj = talloc(tctx, struct test_join);
if (!tj) return NULL;
libnet_r = talloc(tj, struct libnet_JoinDomain);
@@ -320,7 +320,7 @@ _PUBLIC_ struct test_join *torture_join_domain(struct torture_context *tctx,
return NULL;
}
- libnet_ctx = libnet_context_init(NULL, tctx->lp_ctx);
+ libnet_ctx = libnet_context_init(tctx->ev, tctx->lp_ctx);
if (!libnet_ctx) {
talloc_free(tj);
return NULL;
@@ -553,6 +553,14 @@ const char *torture_join_dom_dns_name(struct test_join *join)
return join->dom_dns_name;
}
+const char *torture_join_server_dn_str(struct test_join *join)
+{
+ if (join->libnet_r) {
+ return join->libnet_r->out.server_dn_str;
+ }
+ return NULL;
+}
+
#if 0 /* Left as the documentation of the join process, but see new implementation in libnet_become_dc.c */
struct test_join_ads_dc {
diff --git a/source4/torture/smb2/config.mk b/source4/torture/smb2/config.mk
index 379632f0e7..f3318bb736 100644
--- a/source4/torture/smb2/config.mk
+++ b/source4/torture/smb2/config.mk
@@ -20,5 +20,7 @@ TORTURE_SMB2_OBJ_FILES = $(addprefix torture/smb2/, \
find.o \
lock.o \
notify.o \
- smb2.o)
+ smb2.o \
+ persistent_handles.o \
+ oplocks.o)
diff --git a/source4/torture/smb2/oplocks.c b/source4/torture/smb2/oplocks.c
new file mode 100644
index 0000000000..b0a1b31d1f
--- /dev/null
+++ b/source4/torture/smb2/oplocks.c
@@ -0,0 +1,178 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ test suite for SMB2 oplocks
+
+ Copyright (C) Stefan Metzmacher 2008
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "librpc/gen_ndr/security.h"
+#include "libcli/smb2/smb2.h"
+#include "libcli/smb2/smb2_calls.h"
+#include "torture/torture.h"
+#include "torture/smb2/proto.h"
+#include "param/param.h"
+
+#define CHECK_VAL(v, correct) do { \
+ if ((v) != (correct)) { \
+ torture_result(tctx, TORTURE_FAIL, "(%s): wrong value for %s got 0x%x - should be 0x%x\n", \
+ __location__, #v, (int)v, (int)correct); \
+ ret = false; \
+ }} while (0)
+
+#define CHECK_STATUS(status, correct) do { \
+ if (!NT_STATUS_EQUAL(status, correct)) { \
+ torture_result(tctx, TORTURE_FAIL, __location__": Incorrect status %s - should be %s", \
+ nt_errstr(status), nt_errstr(correct)); \
+ ret = false; \
+ goto done; \
+ }} while (0)
+
+static struct {
+ struct smb2_handle handle;
+ uint8_t level;
+ struct smb2_break br;
+ int count;
+ int failures;
+} break_info;
+
+static void torture_oplock_break_callback(struct smb2_request *req)
+{
+ NTSTATUS status;
+ struct smb2_break br;
+
+ ZERO_STRUCT(br);
+ status = smb2_break_recv(req, &break_info.br);
+ if (!NT_STATUS_IS_OK(status)) {
+ break_info.failures++;
+ }
+
+ return;
+}
+
+/* a oplock break request handler */
+static bool torture_oplock_handler(struct smb2_transport *transport,
+ const struct smb2_handle *handle,
+ uint8_t level, void *private_data)
+{
+ struct smb2_tree *tree = private_data;
+ const char *name;
+ struct smb2_request *req;
+
+ break_info.handle = *handle;
+ break_info.level = level;
+ break_info.count++;
+
+ switch (level) {
+ case SMB2_OPLOCK_LEVEL_II:
+ name = "level II";
+ break;
+ case SMB2_OPLOCK_LEVEL_NONE:
+ name = "none";
+ break;
+ default:
+ name = "unknown";
+ break_info.failures++;
+ }
+ printf("Acking to %s [0x%02X] in oplock handler\n",
+ name, level);
+
+ ZERO_STRUCT(break_info.br);
+ break_info.br.in.file.handle = *handle;
+ break_info.br.in.oplock_level = level;
+ break_info.br.in.reserved = 0;
+ break_info.br.in.reserved2 = 0;
+
+ req = smb2_break_send(tree, &break_info.br);
+ req->async.fn = torture_oplock_break_callback;
+ req->async.private = NULL;
+
+ return true;
+}
+
+bool torture_smb2_oplock_batch1(struct torture_context *tctx,
+ struct smb2_tree *tree)
+{
+ TALLOC_CTX *mem_ctx = talloc_new(tctx);
+ struct smb2_handle h1, h2;
+ struct smb2_create io;
+ NTSTATUS status;
+ const char *fname = "oplock.dat";
+ bool ret = true;
+
+ tree->session->transport->oplock.handler = torture_oplock_handler;
+ tree->session->transport->oplock.private_data = tree;
+
+ smb2_util_unlink(tree, fname);
+
+ ZERO_STRUCT(break_info);
+
+ ZERO_STRUCT(io);
+ io.in.security_flags = 0x00;
+ io.in.oplock_level = SMB2_OPLOCK_LEVEL_BATCH;
+ io.in.impersonation_level = NTCREATEX_IMPERSONATION_IMPERSONATION;
+ io.in.create_flags = 0x00000000;
+ io.in.reserved = 0x00000000;
+ io.in.desired_access = SEC_RIGHTS_FILE_ALL;
+ io.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
+ io.in.share_access = NTCREATEX_SHARE_ACCESS_READ |
+ NTCREATEX_SHARE_ACCESS_WRITE |
+ NTCREATEX_SHARE_ACCESS_DELETE;
+ io.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
+ io.in.create_options = NTCREATEX_OPTIONS_SEQUENTIAL_ONLY |
+ NTCREATEX_OPTIONS_ASYNC_ALERT |
+ NTCREATEX_OPTIONS_NON_DIRECTORY_FILE |
+ 0x00200000;
+ io.in.fname = fname;
+
+ status = smb2_create(tree, mem_ctx, &io);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_VAL(io.out.oplock_level, SMB2_OPLOCK_LEVEL_BATCH);
+ /*CHECK_VAL(io.out.reserved, 0);*/
+ CHECK_VAL(io.out.create_action, NTCREATEX_ACTION_CREATED);
+ CHECK_VAL(io.out.alloc_size, 0);
+ CHECK_VAL(io.out.size, 0);
+ CHECK_VAL(io.out.file_attr, FILE_ATTRIBUTE_ARCHIVE);
+ CHECK_VAL(io.out.reserved2, 0);
+ CHECK_VAL(break_info.count, 0);
+
+ h1 = io.out.file.handle;
+
+ ZERO_STRUCT(io.in.blobs);
+ status = smb2_create(tree, mem_ctx, &io);
+ CHECK_VAL(break_info.count, 1);
+ CHECK_VAL(break_info.failures, 0);
+ CHECK_VAL(break_info.level, SMB2_OPLOCK_LEVEL_II);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_VAL(io.out.oplock_level, SMB2_OPLOCK_LEVEL_II);
+ /*CHECK_VAL(io.out.reserved, 0);*/
+ CHECK_VAL(io.out.create_action, NTCREATEX_ACTION_EXISTED);
+ CHECK_VAL(io.out.alloc_size, 0);
+ CHECK_VAL(io.out.size, 0);
+ CHECK_VAL(io.out.file_attr, FILE_ATTRIBUTE_ARCHIVE);
+ CHECK_VAL(io.out.reserved2, 0);
+
+ h2 = io.out.file.handle;
+
+done:
+ talloc_free(mem_ctx);
+
+ smb2_util_close(tree, h1);
+ smb2_util_close(tree, h2);
+ smb2_util_unlink(tree, fname);
+ return ret;
+}
diff --git a/source4/torture/smb2/persistent_handles.c b/source4/torture/smb2/persistent_handles.c
new file mode 100644
index 0000000000..249ddd1733
--- /dev/null
+++ b/source4/torture/smb2/persistent_handles.c
@@ -0,0 +1,184 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ test suite for SMB2 persistent file handles
+
+ Copyright (C) Stefan Metzmacher 2008
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "librpc/gen_ndr/security.h"
+#include "libcli/smb2/smb2.h"
+#include "libcli/smb2/smb2_calls.h"
+#include "torture/torture.h"
+#include "torture/smb2/proto.h"
+#include "param/param.h"
+
+#define CHECK_VAL(v, correct) do { \
+ if ((v) != (correct)) { \
+ torture_result(tctx, TORTURE_FAIL, "(%s): wrong value for %s got 0x%x - should be 0x%x\n", \
+ __location__, #v, (int)v, (int)correct); \
+ ret = false; \
+ }} while (0)
+
+#define CHECK_STATUS(status, correct) do { \
+ if (!NT_STATUS_EQUAL(status, correct)) { \
+ torture_result(tctx, TORTURE_FAIL, __location__": Incorrect status %s - should be %s", \
+ nt_errstr(status), nt_errstr(correct)); \
+ ret = false; \
+ goto done; \
+ }} while (0)
+
+/*
+ basic testing of SMB2 persistent file handles
+ regarding the position information on the handle
+*/
+bool torture_smb2_persistent_handles1(struct torture_context *tctx,
+ struct smb2_tree *tree1,
+ struct smb2_tree *tree2)
+{
+ TALLOC_CTX *mem_ctx = talloc_new(tctx);
+ struct smb2_handle h1, h2;
+ struct smb2_create io1, io2;
+ NTSTATUS status;
+ const char *fname = "persistent_handles.dat";
+ DATA_BLOB b;
+ union smb_fileinfo qfinfo;
+ union smb_setfileinfo sfinfo;
+ bool ret = true;
+ uint64_t pos;
+
+ smb2_util_unlink(tree1, fname);
+
+ ZERO_STRUCT(io1);
+ io1.in.security_flags = 0x00;
+ io1.in.oplock_level = SMB2_OPLOCK_LEVEL_BATCH;
+ io1.in.impersonation_level = NTCREATEX_IMPERSONATION_IMPERSONATION;
+ io1.in.create_flags = 0x00000000;
+ io1.in.reserved = 0x00000000;
+ io1.in.desired_access = SEC_RIGHTS_FILE_ALL;
+ io1.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
+ io1.in.share_access = NTCREATEX_SHARE_ACCESS_READ |
+ NTCREATEX_SHARE_ACCESS_WRITE |
+ NTCREATEX_SHARE_ACCESS_DELETE;
+ io1.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
+ io1.in.create_options = NTCREATEX_OPTIONS_SEQUENTIAL_ONLY |
+ NTCREATEX_OPTIONS_ASYNC_ALERT |
+ NTCREATEX_OPTIONS_NON_DIRECTORY_FILE |
+ 0x00200000;
+ io1.in.fname = fname;
+
+ b = data_blob_talloc(mem_ctx, NULL, 16);
+ SBVAL(b.data, 0, 0);
+ SBVAL(b.data, 8, 0);
+
+ status = smb2_create_blob_add(tree1, &io1.in.blobs,
+ SMB2_CREATE_TAG_DHNQ,
+ b);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ status = smb2_create(tree1, mem_ctx, &io1);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_VAL(io1.out.oplock_level, SMB2_OPLOCK_LEVEL_BATCH);
+ /*CHECK_VAL(io1.out.reserved, 0);*/
+ CHECK_VAL(io1.out.create_action, NTCREATEX_ACTION_CREATED);
+ CHECK_VAL(io1.out.alloc_size, 0);
+ CHECK_VAL(io1.out.size, 0);
+ CHECK_VAL(io1.out.file_attr, FILE_ATTRIBUTE_ARCHIVE);
+ CHECK_VAL(io1.out.reserved2, 0);
+
+ /* TODO: check extra blob content */
+
+ h1 = io1.out.file.handle;
+
+ ZERO_STRUCT(qfinfo);
+ qfinfo.generic.level = RAW_FILEINFO_POSITION_INFORMATION;
+ qfinfo.generic.in.file.handle = h1;
+ status = smb2_getinfo_file(tree1, mem_ctx, &qfinfo);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_VAL(qfinfo.position_information.out.position, 0);
+ pos = qfinfo.position_information.out.position;
+ torture_comment(tctx, "position: %llu\n",
+ (unsigned long long)pos);
+
+ ZERO_STRUCT(sfinfo);
+ sfinfo.generic.level = RAW_SFILEINFO_POSITION_INFORMATION;
+ sfinfo.generic.in.file.handle = h1;
+ sfinfo.position_information.in.position = 0x1000;
+ status = smb2_setinfo_file(tree1, &sfinfo);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ ZERO_STRUCT(qfinfo);
+ qfinfo.generic.level = RAW_FILEINFO_POSITION_INFORMATION;
+ qfinfo.generic.in.file.handle = h1;
+ status = smb2_getinfo_file(tree1, mem_ctx, &qfinfo);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_VAL(qfinfo.position_information.out.position, 0x1000);
+ pos = qfinfo.position_information.out.position;
+ torture_comment(tctx, "position: %llu\n",
+ (unsigned long long)pos);
+
+ talloc_free(tree1);
+ tree1 = NULL;
+
+ ZERO_STRUCT(qfinfo);
+ qfinfo.generic.level = RAW_FILEINFO_POSITION_INFORMATION;
+ qfinfo.generic.in.file.handle = h1;
+ status = smb2_getinfo_file(tree2, mem_ctx, &qfinfo);
+ CHECK_STATUS(status, NT_STATUS_FILE_CLOSED);
+
+ ZERO_STRUCT(io2);
+ io2.in.fname = fname;
+
+ b = data_blob_talloc(tctx, NULL, 16);
+ SBVAL(b.data, 0, h1.data[0]);
+ SBVAL(b.data, 8, h1.data[1]);
+
+ status = smb2_create_blob_add(tree2, &io2.in.blobs,
+ SMB2_CREATE_TAG_DHNC,
+ b);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ status = smb2_create(tree2, mem_ctx, &io2);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_VAL(io2.out.oplock_level, SMB2_OPLOCK_LEVEL_BATCH);
+ CHECK_VAL(io2.out.reserved, 0x00);
+ CHECK_VAL(io2.out.create_action, NTCREATEX_ACTION_EXISTED);
+ CHECK_VAL(io2.out.alloc_size, 0);
+ CHECK_VAL(io2.out.size, 0);
+ CHECK_VAL(io2.out.file_attr, FILE_ATTRIBUTE_ARCHIVE);
+ CHECK_VAL(io2.out.reserved2, 0);
+
+ h2 = io2.out.file.handle;
+
+ ZERO_STRUCT(qfinfo);
+ qfinfo.generic.level = RAW_FILEINFO_POSITION_INFORMATION;
+ qfinfo.generic.in.file.handle = h2;
+ status = smb2_getinfo_file(tree2, mem_ctx, &qfinfo);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_VAL(qfinfo.position_information.out.position, 0x1000);
+ pos = qfinfo.position_information.out.position;
+ torture_comment(tctx, "position: %llu\n",
+ (unsigned long long)pos);
+
+ smb2_util_close(tree2, h2);
+
+ talloc_free(mem_ctx);
+
+ smb2_util_unlink(tree2, fname);
+done:
+ return ret;
+}
diff --git a/source4/torture/smb2/scan.c b/source4/torture/smb2/scan.c
index 0f4c9fefdf..889d343a49 100644
--- a/source4/torture/smb2/scan.c
+++ b/source4/torture/smb2/scan.c
@@ -207,7 +207,7 @@ bool torture_smb2_scan(struct torture_context *torture)
status = smb2_connect(mem_ctx, host, share,
lp_resolve_context(torture->lp_ctx),
credentials, &tree,
- event_context_find(mem_ctx));
+ torture->ev);
if (!NT_STATUS_IS_OK(status)) {
printf("Connection failed - %s\n", nt_errstr(status));
return false;
@@ -224,7 +224,7 @@ bool torture_smb2_scan(struct torture_context *torture)
status = smb2_connect(mem_ctx, host, share,
lp_resolve_context(torture->lp_ctx),
credentials, &tree,
- event_context_find(mem_ctx));
+ torture->ev);
if (!NT_STATUS_IS_OK(status)) {
printf("Connection failed - %s\n", nt_errstr(status));
return false;
diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c
index d07611264b..f406b7d6e8 100644
--- a/source4/torture/smb2/smb2.c
+++ b/source4/torture/smb2/smb2.c
@@ -47,9 +47,9 @@ static bool wrap_simple_1smb2_test(struct torture_context *torture_ctx,
}
struct torture_test *torture_suite_add_1smb2_test(struct torture_suite *suite,
- const char *name,
- bool (*run) (struct torture_context *,
- struct smb2_tree *))
+ const char *name,
+ bool (*run)(struct torture_context *,
+ struct smb2_tree *))
{
struct torture_test *test;
struct torture_tcase *tcase;
@@ -69,6 +69,61 @@ struct torture_test *torture_suite_add_1smb2_test(struct torture_suite *suite,
return test;
}
+
+static bool wrap_simple_2smb2_test(struct torture_context *torture_ctx,
+ struct torture_tcase *tcase,
+ struct torture_test *test)
+{
+ bool (*fn) (struct torture_context *, struct smb2_tree *, struct smb2_tree *);
+ bool ret;
+
+ struct smb2_tree *tree1;
+ struct smb2_tree *tree2;
+ TALLOC_CTX *mem_ctx = talloc_new(torture_ctx);
+
+ if (!torture_smb2_connection(torture_ctx, &tree1) ||
+ !torture_smb2_connection(torture_ctx, &tree2)) {
+ return false;
+ }
+
+ talloc_steal(mem_ctx, tree1);
+ talloc_steal(mem_ctx, tree2);
+
+ fn = test->fn;
+
+ ret = fn(torture_ctx, tree1, tree2);
+
+ /* the test may already closed some of the connections */
+ talloc_free(mem_ctx);
+
+ return ret;
+}
+
+
+_PUBLIC_ struct torture_test *torture_suite_add_2smb2_test(struct torture_suite *suite,
+ const char *name,
+ bool (*run)(struct torture_context *,
+ struct smb2_tree *,
+ struct smb2_tree *))
+{
+ struct torture_test *test;
+ struct torture_tcase *tcase;
+
+ tcase = torture_suite_add_tcase(suite, name);
+
+ test = talloc(tcase, struct torture_test);
+
+ test->name = talloc_strdup(test, name);
+ test->description = NULL;
+ test->run = wrap_simple_2smb2_test;
+ test->fn = run;
+ test->dangerous = false;
+
+ DLIST_ADD_END(tcase->tests, test, struct torture_test *);
+
+ return test;
+}
+
NTSTATUS torture_smb2_init(void)
{
struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "SMB2");
@@ -82,6 +137,8 @@ NTSTATUS torture_smb2_init(void)
torture_suite_add_simple_test(suite, "FIND", torture_smb2_find);
torture_suite_add_suite(suite, torture_smb2_lock_init());
torture_suite_add_simple_test(suite, "NOTIFY", torture_smb2_notify);
+ torture_suite_add_2smb2_test(suite, "PERSISTENT-HANDLES1", torture_smb2_persistent_handles1);
+ torture_suite_add_1smb2_test(suite, "OPLOCK-BATCH1", torture_smb2_oplock_batch1);
suite->description = talloc_strdup(suite, "SMB2-specific tests");
diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c
index f85b1c42ff..6ac3926c98 100644
--- a/source4/torture/smb2/util.c
+++ b/source4/torture/smb2/util.c
@@ -314,7 +314,7 @@ bool torture_smb2_connection(struct torture_context *tctx, struct smb2_tree **tr
status = smb2_connect(tctx, host, share,
lp_resolve_context(tctx->lp_ctx),
credentials, tree,
- event_context_find(tctx));
+ tctx->ev);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to connect to SMB2 share \\\\%s\\%s - %s\n",
host, share, nt_errstr(status));
diff --git a/source4/torture/smbtorture.c b/source4/torture/smbtorture.c
index 8f0b988ab4..5c5f96c505 100644
--- a/source4/torture/smbtorture.c
+++ b/source4/torture/smbtorture.c
@@ -35,6 +35,8 @@
#include "librpc/rpc/dcerpc.h"
#include "param/param.h"
+#include "auth/credentials/credentials.h"
+
static bool run_matching(struct torture_context *torture,
const char *prefix,
const char *expr,
@@ -672,7 +674,7 @@ int main(int argc,char *argv[])
exit(1);
}
- torture = torture_context_init(talloc_autofree_context(), ui_ops);
+ torture = torture_context_init(event_context_init(NULL), ui_ops);
if (basedir != NULL) {
if (basedir[0] != '/') {
fprintf(stderr, "Please specify an absolute path to --basedir\n");
diff --git a/source4/torture/ui.c b/source4/torture/ui.c
index a7025aac95..abbd814747 100644
--- a/source4/torture/ui.c
+++ b/source4/torture/ui.c
@@ -27,14 +27,14 @@
#include "auth/credentials/credentials.h"
#include "lib/cmdline/popt_common.h"
-struct torture_context *torture_context_init(TALLOC_CTX *mem_ctx,
+struct torture_context *torture_context_init(struct event_context *event_ctx,
const struct torture_ui_ops *ui_ops)
{
- struct torture_context *torture = talloc_zero(mem_ctx,
+ struct torture_context *torture = talloc_zero(event_ctx,
struct torture_context);
torture->ui_ops = ui_ops;
torture->returncode = true;
- torture->ev = cli_credentials_get_event_context(cmdline_credentials);
+ torture->ev = event_ctx;
if (ui_ops->init)
ui_ops->init(torture);
@@ -578,6 +578,3 @@ struct torture_test *torture_tcase_add_simple_test(struct torture_tcase *tcase,
return test;
}
-
-
-
diff --git a/source4/torture/ui.h b/source4/torture/ui.h
index 6645d9b012..15b04c2397 100644
--- a/source4/torture/ui.h
+++ b/source4/torture/ui.h
@@ -253,6 +253,15 @@ void torture_result(struct torture_context *test,
} \
} while(0)
+#define torture_assert_mem_equal(torture_ctx,got,expected,len,cmt)\
+ do { const void *__got = (got), *__expected = (expected); \
+ if (memcmp(__got, __expected, len) != 0) { \
+ torture_result(torture_ctx, TORTURE_FAIL, \
+ __location__": "#got" of len %d did not match"#expected": %s", len, cmt); \
+ return false; \
+ } \
+ } while(0)
+
#define torture_assert_file_contains_text(torture_ctx,filename,expected,cmt)\
do { \
char *__got; \
@@ -381,7 +390,7 @@ bool torture_suite_init_tcase(struct torture_suite *suite,
struct torture_tcase *tcase,
const char *name);
-struct torture_context *torture_context_init(TALLOC_CTX *mem_ctx,
+struct torture_context *torture_context_init(struct event_context *event_ctx,
const struct torture_ui_ops *ui_ops);
#endif /* __TORTURE_UI_H__ */
diff --git a/source4/torture/unix/unix_info2.c b/source4/torture/unix/unix_info2.c
index c14be9e2d0..d7482ddcf1 100644
--- a/source4/torture/unix/unix_info2.c
+++ b/source4/torture/unix/unix_info2.c
@@ -63,8 +63,8 @@ static struct smbcli_state *connect_to_server(struct torture_context *tctx)
lp_smb_ports(tctx->lp_ctx),
share, NULL,
cmdline_credentials,
- lp_resolve_context(tctx->lp_ctx), NULL,
- &options);
+ lp_resolve_context(tctx->lp_ctx),
+ tctx->ev, &options);
if (!NT_STATUS_IS_OK(status)) {
printf("failed to connect to //%s/%s: %s\n",
diff --git a/source4/torture/unix/whoami.c b/source4/torture/unix/whoami.c
index a1333ac5bd..d4f19bb57a 100644
--- a/source4/torture/unix/whoami.c
+++ b/source4/torture/unix/whoami.c
@@ -84,7 +84,7 @@ static struct smbcli_state *connect_to_server(struct torture_context *tctx,
lp_smb_ports(tctx->lp_ctx),
share, NULL,
creds, lp_resolve_context(tctx->lp_ctx),
- NULL, &options);
+ tctx->ev, &options);
if (!NT_STATUS_IS_OK(status)) {
printf("failed to connect to //%s/%s: %s\n",
diff --git a/source4/torture/util.h b/source4/torture/util.h
index 477a828120..1009fcf9f1 100644
--- a/source4/torture/util.h
+++ b/source4/torture/util.h
@@ -20,28 +20,6 @@
#ifndef _TORTURE_PROVISION_H_
#define _TORTURE_PROVISION_H_
-struct provision_settings {
- const char *dns_name;
- const char *site_name;
- const char *root_dn_str;
- const char *domain_dn_str;
- const char *config_dn_str;
- const char *schema_dn_str;
- const struct GUID *invocation_id;
- const char *netbios_name;
- const char *host_ip;
- const char *realm;
- const char *domain;
- const struct GUID *ntds_guid;
- const char *ntds_dn_str;
- const char *machine_password;
- const char *targetdir;
-};
-
-NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
- struct provision_settings *settings);
-
-
/**
setup a directory ready for a test
*/
diff --git a/source4/torture/util_provision.c b/source4/torture/util_provision.c
deleted file mode 100644
index cce8e18fdc..0000000000
--- a/source4/torture/util_provision.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Samba utility functions
- Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.h"
-#include "auth/auth.h"
-#include "lib/ldb_wrap.h"
-#include "torture/torture.h"
-#include "libcli/raw/libcliraw.h"
-#include "torture/util.h"
-#include "librpc/ndr/libndr.h"
-
-#include "param/param.h"
-#include <Python.h>
-#include "scripting/python/modules.h"
-
-NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
- struct provision_settings *settings)
-{
- PyObject *provision_mod, *provision_dict, *provision_fn, *result, *parameters;
-
- DEBUG(0,("Provision for Become-DC test using python\n"));
-
- py_load_samba_modules();
- Py_Initialize();
- py_update_path("bin"); /* FIXME: Can't assume this is always the case */
-
- provision_mod = PyImport_Import(PyString_FromString("samba.provision"));
-
- if (provision_mod == NULL) {
- PyErr_Print();
- DEBUG(0, ("Unable to import provision Python module.\n"));
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- provision_dict = PyModule_GetDict(provision_mod);
-
- if (provision_dict == NULL) {
- DEBUG(0, ("Unable to get dictionary for provision module\n"));
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- provision_fn = PyDict_GetItemString(provision_dict, "provision_become_dc");
- if (provision_fn == NULL) {
- PyErr_Print();
- DEBUG(0, ("Unable to get provision_become_dc function\n"));
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- DEBUG(0,("New Server[%s] in Site[%s]\n", settings->dns_name,
- settings->site_name));
-
- DEBUG(0,("DSA Instance [%s]\n"
- "\tobjectGUID[%s]\n"
- "\tinvocationId[%s]\n",
- settings->ntds_dn_str,
- settings->ntds_guid == NULL?"None":GUID_string(mem_ctx, settings->ntds_guid),
- settings->invocation_id == NULL?"None":GUID_string(mem_ctx, settings->invocation_id)));
-
- DEBUG(0,("Pathes under targetdir[%s]\n",
- settings->targetdir));
- parameters = PyDict_New();
-
- PyDict_SetItemString(parameters, "rootdn",
- PyString_FromString(settings->root_dn_str));
- if (settings->targetdir != NULL)
- PyDict_SetItemString(parameters, "targetdir",
- PyString_FromString(settings->targetdir));
- PyDict_SetItemString(parameters, "setup_dir",
- PyString_FromString("setup"));
- PyDict_SetItemString(parameters, "hostname",
- PyString_FromString(settings->netbios_name));
- PyDict_SetItemString(parameters, "domain",
- PyString_FromString(settings->domain));
- PyDict_SetItemString(parameters, "realm",
- PyString_FromString(settings->realm));
- if (settings->root_dn_str)
- PyDict_SetItemString(parameters, "rootdn",
- PyString_FromString(settings->root_dn_str));
-
- if (settings->domain_dn_str)
- PyDict_SetItemString(parameters, "domaindn",
- PyString_FromString(settings->domain_dn_str));
-
- if (settings->schema_dn_str)
- PyDict_SetItemString(parameters, "schemadn",
- PyString_FromString(settings->schema_dn_str));
-
- if (settings->config_dn_str)
- PyDict_SetItemString(parameters, "configdn",
- PyString_FromString(settings->config_dn_str));
-
- if (settings->site_name)
- PyDict_SetItemString(parameters, "sitename",
- PyString_FromString(settings->site_name));
-
- PyDict_SetItemString(parameters, "machinepass",
- PyString_FromString(settings->machine_password));
-
- result = PyEval_CallObjectWithKeywords(provision_fn, NULL, parameters);
-
- Py_DECREF(parameters);
-
- if (result == NULL) {
- PyErr_Print();
- PyErr_Clear();
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- return NT_STATUS_OK;
-}
diff --git a/source4/torture/util_smb.c b/source4/torture/util_smb.c
index 513070500e..c1a20094f3 100644
--- a/source4/torture/util_smb.c
+++ b/source4/torture/util_smb.c
@@ -553,8 +553,7 @@ _PUBLIC_ bool torture_open_connection_ev(struct smbcli_state **c,
_PUBLIC_ bool torture_open_connection(struct smbcli_state **c, struct torture_context *tctx, int conn_index)
{
- return torture_open_connection_ev(c, conn_index, tctx,
- cli_credentials_get_event_context(cmdline_credentials));
+ return torture_open_connection_ev(c, conn_index, tctx, tctx->ev);
}
diff --git a/source4/torture/winbind/struct_based.c b/source4/torture/winbind/struct_based.c
index 0fe2148b75..87378aadb8 100644
--- a/source4/torture/winbind/struct_based.c
+++ b/source4/torture/winbind/struct_based.c
@@ -181,7 +181,8 @@ static bool torture_winbind_struct_netbios_name(struct torture_context *torture)
expected = torture_setting_string(torture,
"winbindd netbios name",
lp_netbios_name(torture->lp_ctx));
-
+ expected = strupper_talloc(torture, expected);
+
torture_assert_str_equal(torture,
rep.data.netbios_name, expected,
"winbindd's netbios name doesn't match");
@@ -261,7 +262,7 @@ static bool torture_winbind_struct_check_machacc(struct torture_context *torture
torture_assert_str_equal(torture,
rep.data.auth.error_string,
- nt_errstr(NT_STATUS_OK),
+ get_friendly_nt_error_msg(NT_STATUS_OK),
"WINBINDD_CHECK_MACHACC ok: error_string");
torture_assert_int_equal(torture,
@@ -294,6 +295,10 @@ static bool get_trusted_domains(struct torture_context *torture,
DO_STRUCT_REQ_REP(WINBINDD_LIST_TRUSTDOM, &req, &rep);
extra_data = (char *)rep.extra_data.data;
+ if (!extra_data) {
+ return true;
+ }
+
torture_assert(torture, extra_data, "NULL trust list");
while (next_token(&extra_data, line, "\n", sizeof(fstring))) {
@@ -355,7 +360,6 @@ static bool torture_winbind_struct_list_trustdom(struct torture_context *torture
DO_STRUCT_REQ_REP(WINBINDD_LIST_TRUSTDOM, &req, &rep);
list1 = (char *)rep.extra_data.data;
- torture_assert(torture, list1, "NULL trust list");
torture_comment(torture, "%s\n", list1);
@@ -367,7 +371,6 @@ static bool torture_winbind_struct_list_trustdom(struct torture_context *torture
DO_STRUCT_REQ_REP(WINBINDD_LIST_TRUSTDOM, &req, &rep);
list2 = (char *)rep.extra_data.data;
- torture_assert(torture, list2, "NULL trust list");
/*
* The list_all_domains parameter should be ignored
@@ -380,7 +383,7 @@ static bool torture_winbind_struct_list_trustdom(struct torture_context *torture
ok = get_trusted_domains(torture, &listd);
torture_assert(torture, ok, "failed to get trust list");
- for (i=0; listd[i].netbios_name; i++) {
+ for (i=0; listd && listd[i].netbios_name; i++) {
if (i == 0) {
struct dom_sid *builtin_sid;
@@ -423,7 +426,7 @@ static bool torture_winbind_struct_domain_info(struct torture_context *torture)
ok = get_trusted_domains(torture, &listd);
torture_assert(torture, ok, "failed to get trust list");
- for (i=0; listd[i].netbios_name; i++) {
+ for (i=0; listd && listd[i].netbios_name; i++) {
struct winbindd_request req;
struct winbindd_response rep;
struct dom_sid *sid;
@@ -484,14 +487,14 @@ static bool torture_winbind_struct_getdcname(struct torture_context *torture)
bool ok;
bool strict = torture_setting_bool(torture, "strict mode", false);
struct torture_trust_domain *listd = NULL;
- uint32_t i;
+ uint32_t i, count = 0;
torture_comment(torture, "Running WINBINDD_GETDCNAME (struct based)\n");
ok = get_trusted_domains(torture, &listd);
torture_assert(torture, ok, "failed to get trust list");
- for (i=0; listd[i].netbios_name; i++) {
+ for (i=0; listd && listd[i].netbios_name; i++) {
struct winbindd_request req;
struct winbindd_response rep;
@@ -511,8 +514,13 @@ static bool torture_winbind_struct_getdcname(struct torture_context *torture)
/* TODO: check rep.data.dc_name; */
torture_comment(torture, "DOMAIN '%s' => DCNAME '%s'\n",
req.domain_name, rep.data.dc_name);
+ count++;
}
+ if (strict) {
+ torture_assert(torture, count > 0,
+ "WiNBINDD_GETDCNAME was not tested");
+ }
return true;
}
@@ -529,7 +537,7 @@ static bool torture_winbind_struct_dsgetdcname(struct torture_context *torture)
ok = get_trusted_domains(torture, &listd);
torture_assert(torture, ok, "failed to get trust list");
- for (i=0; listd[i].netbios_name; i++) {
+ for (i=0; listd && listd[i].netbios_name; i++) {
struct winbindd_request req;
struct winbindd_response rep;