summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/basic/delaywrite.c278
-rw-r--r--source4/torture/config.mk4
-rw-r--r--source4/torture/libnet/libnet_BecomeDC.c1
-rw-r--r--source4/torture/local/torture.c1
-rw-r--r--source4/torture/util.h23
-rw-r--r--source4/torture/util_provision.c130
6 files changed, 180 insertions, 257 deletions
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 1d09d74f99..7acb1e0792 100644
--- a/source4/torture/config.mk
+++ b/source4/torture/config.mk
@@ -16,8 +16,8 @@ PUBLIC_DEPENDENCIES = \
PUBLIC_HEADERS += torture/torture.h torture/ui.h
[SUBSYSTEM::TORTURE_UTIL]
-OBJ_FILES = util_smb.o util_provision.o
-PRIVATE_DEPENDENCIES = LIBCLI_RAW LIBPYTHON smbcalls
+OBJ_FILES = util_smb.o
+PRIVATE_DEPENDENCIES = LIBCLI_RAW LIBPYTHON smbcalls PROVISION
PUBLIC_DEPENDENCIES = POPT_CREDENTIALS
#################################
diff --git a/source4/torture/libnet/libnet_BecomeDC.c b/source4/torture/libnet/libnet_BecomeDC.c
index f8699fe06a..bb5e8fe061 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;
diff --git a/source4/torture/local/torture.c b/source4/torture/local/torture.c
index 9bd60d9620..718bd38aad 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)
{
diff --git a/source4/torture/util.h b/source4/torture/util.h
index 72f97e4766..1009fcf9f1 100644
--- a/source4/torture/util.h
+++ b/source4/torture/util.h
@@ -20,29 +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 char *server_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 3167a37cdf..0000000000
--- a/source4/torture/util_provision.c
+++ /dev/null
@@ -1,130 +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->server_dn_str)
- PyDict_SetItemString(parameters, "serverdn",
- PyString_FromString(settings->server_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;
-}