TODO source4/torture/smb2/durable_open.c
authorStefan Metzmacher <metze@samba.org>
Tue, 14 Aug 2018 13:16:21 +0000 (15:16 +0200)
committerStefan Metzmacher <metze@samba.org>
Tue, 14 Aug 2018 16:14:11 +0000 (18:14 +0200)
source4/torture/smb2/durable_open.c

index 58bbe3bf648fae7bd8c4ef5c86a1a9d4bc914af1..61412558b35c3b91f83fd6ce7d2339c438e4e1b1 100644 (file)
@@ -2793,20 +2793,22 @@ done:
        COMPARE_WRITE_TIME_CMP(given,correct,!=)
 #define COMPARE_WRITE_TIME_GREATER(given,correct) \
        COMPARE_WRITE_TIME_CMP(given,correct,<=)
-#define COMPARE_WRITE_TIME_LESS(given,correct) \
-       COMPARE_WRITE_TIME_CMP(given,correct,>=)
 
 #define COMPARE_ACCESS_TIME_CMP(given, correct, cmp) do { \
        COMPARE_TIME_CMP(given, access_time, correct, access_time, cmp); \
 } while (0)
 #define COMPARE_ACCESS_TIME_EQUAL(given,correct) \
        COMPARE_ACCESS_TIME_CMP(given,correct,!=)
+#define COMPARE_ACCESS_TIME_GREATER(given,correct) \
+       COMPARE_ACCESS_TIME_CMP(given,correct,<=)
 
 #define COMPARE_CHANGE_TIME_CMP(given, correct, cmp) do { \
        COMPARE_TIME_CMP(given, change_time, correct, change_time, cmp); \
 } while (0)
 #define COMPARE_CHANGE_TIME_EQUAL(given,correct) \
        COMPARE_CHANGE_TIME_CMP(given,correct,!=)
+#define COMPARE_CHANGE_TIME_GREATER(given,correct) \
+       COMPARE_CHANGE_TIME_CMP(given,correct,<=)
 
 #define COMPARE_CREATE_TIME_CMP(given, correct, cmp) do { \
        COMPARE_TIME_CMP(given, create_time, correct, create_time, cmp); \
@@ -2815,17 +2817,27 @@ done:
        COMPARE_CREATE_TIME_CMP(given,correct,!=)
 
 #define COMPARE_ALL_TIMES_EQUAL(given,correct) do { \
-       COMPARE_ACCESS_TIME_EQUAL(given,correct); \
        COMPARE_WRITE_TIME_EQUAL(given,correct); \
        COMPARE_CHANGE_TIME_EQUAL(given,correct); \
+       COMPARE_ACCESS_TIME_EQUAL(given,correct); \
        COMPARE_CREATE_TIME_EQUAL(given,correct); \
 } while (0)
 
 #define COMPARE_TIMES_AFTER_WRITE(given,correct) do { \
-       COMPARE_ACCESS_TIME_GREATER(given,correct); \
        COMPARE_WRITE_TIME_GREATER(given,correct); \
        COMPARE_CHANGE_TIME_GREATER(given,correct); \
+       COMPARE_ACCESS_TIME_EQUAL(given,correct); \
        COMPARE_CREATE_TIME_EQUAL(given,correct); \
+       COMPARE_TIME_CMP(given, change_time, given, write_time, !=); \
+} while (0)
+
+#define COMPARE_TIMES_AFTER_CLOSE(given,correct) do { \
+       COMPARE_WRITE_TIME_GREATER(given,correct); \
+       COMPARE_CHANGE_TIME_GREATER(given,correct); \
+       COMPARE_ACCESS_TIME_GREATER(given,correct); \
+       COMPARE_CREATE_TIME_EQUAL(given,correct); \
+       COMPARE_TIME_CMP(given, change_time, given, write_time, !=); \
+       COMPARE_TIME_CMP(given, access_time, given, write_time, !=); \
 } while (0)
 
 #define GET_INFO_FILE(tree, finfo) do { \
@@ -2914,7 +2926,7 @@ static bool test_delay_writetime(struct torture_context *tctx,
        double msec = 1000 * sec;
        double nsec = 1000 * msec;
        double expected_delay = used_delay / nsec;
-       double min_delay = expected_delay * 0.1;
+       double min_delay = expected_delay * 0.01;
        double max_delay = 5 * expected_delay;
        bool ret = true;
        bool ok;
@@ -2942,11 +2954,6 @@ static bool test_delay_writetime(struct torture_context *tctx,
        torture_assert(tctx, ok, "get_basic_info_cb: finfoT");
        COMPARE_WRITE_TIME_EQUAL(finfoT, finfo0);
 
-       /*
-        * make sure the write time is updated 2 seconds later
-        * calcuated from the first write
-        * (but expect upto 5 seconds extra time for a busy server)
-        */
        torture_comment(tctx, "Do a write on the file handle\n");
        before_write = timeval_current();
        ok = write_data_cb(private_data);
@@ -2979,7 +2986,7 @@ static bool test_delay_writetime(struct torture_context *tctx,
                        torture_assert(tctx, (delayS <= max_delay),
                                       "Server didn't update write_time!");
 
-                       COMPARE_WRITE_TIME_GREATER(finfoT, finfo0);
+                       COMPARE_TIMES_AFTER_WRITE(finfoT, finfo0);
                        break;
                }
 
@@ -2989,7 +2996,7 @@ static bool test_delay_writetime(struct torture_context *tctx,
 
        ok = get_basic_info_cb(private_data, &finfo1);
        torture_assert(tctx, ok, "get_basic_info_cb: finfo1");
-       COMPARE_WRITE_TIME_GREATER(finfo1, finfo0);
+       COMPARE_TIMES_AFTER_WRITE(finfo1, finfo0);
 
        /*
         * Make sure the time doesn't change during the next 5 seconds
@@ -3326,6 +3333,7 @@ static bool test_durable_open_delaywrite1(struct torture_context *tctx,
                        test_durable_open_delaywrite1_write_data,
                        &state);
        torture_assert(tctx, ok, "test_delay_writetime");
+goto close_handles;
 goto done;
        /*
         * make sure the write time is updated 2 seconds later
@@ -3439,6 +3447,7 @@ goto done;
                smb_msleep(0.1 * msec);
                //smb_msleep(1 * msec);
        }
+close_handles:
        GET_INFO_BOTH(finfo3, c2finfo3);
        //COMPARE_WRITE_TIME_EQUAL(finfo3, finfo2);
 
@@ -3468,7 +3477,11 @@ goto done;
        finfoCL.basic_info.out.write_time = cl.out.write_time;
        finfoCL.basic_info.out.change_time = cl.out.change_time;
        finfoCL.basic_info.out.attrib = cl.out.file_attr;
-       COMPARE_WRITE_TIME_GREATER(finfoCL, finfo3);
+       //COMPARE_WRITE_TIME_GREATER(finfoCL, finfo3);
+       //COMPARE_TIMES_AFTER_CLOSE(finfoCL, finfo3);
+
+       GET_INFO_FILE(tree2, c2finfo3);
+       COMPARE_ALL_TIMES_EQUAL(c2finfo3, finfoCL);
 
        ZERO_STRUCT(cl2);
        cl2.in.file.handle = *h2;
@@ -3482,7 +3495,7 @@ goto done;
        c2finfoCL.basic_info.out.write_time = cl2.out.write_time;
        c2finfoCL.basic_info.out.change_time = cl2.out.change_time;
        c2finfoCL.basic_info.out.attrib = cl2.out.file_attr;
-       COMPARE_WRITE_TIME_EQUAL(c2finfoCL, finfoCL);
+       COMPARE_ALL_TIMES_EQUAL(c2finfoCL, finfoCL);
                //struct {
                //      /* static body buffer 60 (0x3C) bytes */
                //      /* uint16_t buffer_code;  0x3C */