works SMB1
authorStefan Metzmacher <metze@samba.org>
Wed, 15 Aug 2018 08:23:14 +0000 (10:23 +0200)
committerStefan Metzmacher <metze@samba.org>
Wed, 15 Aug 2018 08:27:56 +0000 (10:27 +0200)
source4/torture/basic/delaywrite.c
source4/torture/util_writetime.c

index c95d8ab518d2f2cac7abf3bb105ace3f9058f1de..9e99298af51d78a0367d2b731c5bf46bbb9ef9bf 100644 (file)
@@ -3172,6 +3172,7 @@ static bool test_delaywrite_delaywrite1_get_info(void *private_data,
        struct torture_context *tctx = state->tctx;
        struct smbcli_state *cli = state->cli1;
        struct smbcli_state *cli2 = state->cli2;
+       struct smbcli_state *tmpcli = NULL;
        union smb_fileinfo t1finfo;
        union smb_fileinfo t2finfo;
        union smb_fileinfo t2pinfo;
@@ -3190,20 +3191,30 @@ static bool test_delaywrite_delaywrite1_get_info(void *private_data,
        t2pinfo.basic_info.level = RAW_FILEINFO_BASIC_INFORMATION;
        t2pinfo.basic_info.in.file.path = state->fname;
 
-       GET_INFO_FILE2(t2finfo);
-       GET_INFO_PATH(t2pinfo);
+       if (state->fnum2 != -1) {
+               GET_INFO_FILE2(t2finfo);
+       }
+       tmpcli = cli2;
+       cli2 = cli;
+       if (0) GET_INFO_PATH(t2pinfo);
+       cli2 = tmpcli;
        GET_INFO_FILE(t1finfo);
+if (0) {
        if (t1finfo.basic_info.out.write_time != t2finfo.basic_info.out.write_time) {
                /*
                 * There was a race, get it again on handle 2,
                 * but then they have to match.
                 */
+       if (state->fnum2 != -1) {
                GET_INFO_FILE2(t2finfo);
-               GET_INFO_PATH(t2pinfo);
        }
+               if (0) GET_INFO_PATH(t2pinfo);
+       }
+       if (state->fnum2 != -1) {
        COMPARE_ALL_TIMES_EQUAL(t1finfo, t2finfo);
+       }
        COMPARE_ALL_TIMES_EQUAL(t1finfo, t2pinfo);
-
+}
        finfo->basic_info.out = t1finfo.basic_info.out;
 done:
        return ret;
@@ -3253,15 +3264,22 @@ static bool test_delaywrite_delaywrite1_close(void *private_data,
        t2pinfo.basic_info.level = RAW_FILEINFO_BASIC_INFO;
        t2pinfo.basic_info.in.file.path = state->fname;
 
-       GET_INFO_FILE2(t2finfo);
+       if (state->fnum2 != -1) {
+               GET_INFO_FILE2(t2finfo);
+       }
 
-       smbcli_close(state->cli2->tree, state->fnum2);
-       state->fnum2 = -1;
+       if (state->fnum2 != -1) {
+               smbcli_close(state->cli2->tree, state->fnum2);
+               state->fnum2 = -1;
+       }
 
        GET_INFO_PATH(t2pinfo);
+       if (state->fnum2 != -1) {
        COMPARE_ALL_TIMES_EQUAL(t2pinfo, t2finfo);
+       }
 
        finfo->basic_info.out = t2finfo.basic_info.out;
+       finfo->basic_info.out = t2pinfo.basic_info.out;
 
 done:
        return ret;
@@ -3299,12 +3317,12 @@ static bool test_delaywrite_delaywrite1(struct torture_context *tctx,
                torture_result(tctx, TORTURE_FAIL, __location__": unable to open %s", fname);
                goto done;
        }
-       state.fnum2 = smbcli_open(cli2->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
-       if (state.fnum2 == -1) {
-               ret = false;
-               torture_result(tctx, TORTURE_FAIL, __location__": unable to open %s", fname);
-               goto done;
-       }
+       //state.fnum2 = smbcli_open(cli2->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
+       //if (state.fnum2 == -1) {
+       //      ret = false;
+       //      torture_result(tctx, TORTURE_FAIL, __location__": unable to open %s", fname);
+       //      goto done;
+       //}
 
        state.fname = fname;
 
@@ -3314,7 +3332,7 @@ static bool test_delaywrite_delaywrite1(struct torture_context *tctx,
                        test_delaywrite_delaywrite1_write_data,
                        test_delaywrite_delaywrite1_close,
                        &state);
-       torture_assert_goto(tctx, ok, ret, done, "test_delay_writetime2(2)");
+       torture_assert_goto(tctx, ok, ret, done, "test_delay_writetime1()");
 
  done:
        if (state.fnum1 != -1) {
index a6e42274466c0c5b81e1b5fe6b17144fbecb5ee5..c3e2cde75afbf1192d6cc281d6085428ee9afa0e 100644 (file)
@@ -142,12 +142,13 @@ bool test_delay_writetime1(struct torture_context *tctx,
        bool ret = true;
        bool ok;
 
+       smb1 = false;
        torture_comment(tctx, "START: %s\n", description);
 
        /* get the initial times */
        ok = get_basic_info_cb(private_data, &finfo0);
        torture_assert(tctx, ok, "get_basic_info_cb: finfo0");
-
+if (1 || !smb1) {
        /*
         * Make sure the time doesn't change during the next 5 seconds
         */
@@ -164,7 +165,7 @@ bool test_delay_writetime1(struct torture_context *tctx,
        ok = get_basic_info_cb(private_data, &finfoT);
        torture_assert(tctx, ok, "get_basic_info_cb: finfoT");
        COMPARE_WRITE_TIME_EQUAL(finfoT, finfo0);
-
+}
        torture_comment(tctx, "Do a write on the file handle\n");
        before_write = timeval_current();
        ok = write_data_cb(private_data);
@@ -200,7 +201,8 @@ bool test_delay_writetime1(struct torture_context *tctx,
                }
 
                COMPARE_ALL_TIMES_EQUAL(finfoT, finfo0);
-               smb_msleep(0.01 * msec);
+               //smb_msleep(0.01 * msec);
+               smb_msleep(1 * msec);
        }
 
        ok = get_basic_info_cb(private_data, &finfo1);
@@ -231,8 +233,8 @@ bool test_delay_writetime1(struct torture_context *tctx,
        torture_assert(tctx, ok, "write_data_cb");
 
        if (smb1) {
-               finfo2 = finfo1;
-               goto no_change;
+               //finfo2 = finfo1;
+               if (0) goto no_change;
        }
 
        ZERO_STRUCT(finfo2);
@@ -316,7 +318,8 @@ no_change:
        ok = close_cb(private_data, &finfoT);
        torture_assert(tctx, ok, "close_cb: finfoT");
        if (smb1) {
-               COMPARE_TIMES_AFTER_CLOSE(finfoT, finfo1);
+               COMPARE_ALL_TIMES_EQUAL(finfoT, finfo3);
+               //COMPARE_TIMES_AFTER_CLOSE(finfoT, finfo1);
        } else {
                COMPARE_ALL_TIMES_EQUAL(finfoT, finfo3);
        }