]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbtorture: adjust "base.delaywrite.delayed update of write time 3" for modern SMB...
authorRalph Boehme <slow@samba.org>
Tue, 4 Mar 2025 15:32:11 +0000 (16:32 +0100)
committerRalph Boehme <slow@samba.org>
Thu, 27 Mar 2025 05:37:44 +0000 (05:37 +0000)
The adjusted test passes against Windows Server 2022.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13594

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
selftest/knownfail.d/samba3.base.delaywrite
source4/torture/basic/delaywrite.c

index 9cd836c89036d6665b88fc936dac3d2c85f2799a..306eb6a65c10f9f91f1a648356ddced2bf262a54 100644 (file)
@@ -5,3 +5,4 @@
 ^samba3.base.delaywrite.update of write time using SET_END_OF_FILE\(fileserver_smb1\)
 ^samba3.base.delaywrite.update of write time using SET_ALLOCATION_SIZE\(fileserver_smb1\)
 ^samba3.base.delaywrite.delayed update of write time using 2 connections\(fileserver_smb1\)
+^samba3.base.delaywrite.delayed update of write time 3\(fileserver_smb1\)
index d0d50c43c24f3dc4122805d3f016322b7e04bc7e..4684cb33cf511699517972aaa924bfffe51d3bd7 100644 (file)
@@ -1177,7 +1177,6 @@ static bool test_delayed_write_update3(struct torture_context *tctx,
        double used_delay = torture_setting_int(tctx, "writetimeupdatedelay", 2000000);
        int normal_delay = 2000000;
        double sec = ((double)used_delay) / ((double)normal_delay);
-       int msec = 1000 * sec;
 
        torture_comment(tctx, "\nRunning test_delayed_write_update3\n");
 
@@ -1206,13 +1205,14 @@ static bool test_delayed_write_update3(struct torture_context *tctx,
        /* get the initial times */
        GET_INFO_BOTH(finfo0,pinfo0);
 
+       /* Bypass possible filesystem granularity */
+       smb_msleep(20);
+
        /*
-        * make sure the write time is updated 2 seconds later
-        * calculated from the first write
-        * (but expect up to 5 seconds extra time for a busy server)
+        * make sure the write time is updated immediately
         */
        start = timeval_current();
-       end = timeval_add(&start, 7 * sec, 0);
+       end = timeval_add(&start, 4 * sec, 0);
        while (!timeval_expired(&end)) {
                /* do a write */
                torture_comment(tctx, "Do a write on the file handle\n");
@@ -1225,30 +1225,25 @@ static bool test_delayed_write_update3(struct torture_context *tctx,
                /* get the times after the write */
                GET_INFO_FILE(finfo1);
 
-               if (finfo1.basic_info.out.write_time > finfo0.basic_info.out.write_time) {
-                       double diff = timeval_elapsed(&start);
-                       if (diff < (used_delay / (double)1000000)) {
-                               torture_result(tctx, TORTURE_FAIL, "Server updated write_time after %.2f seconds "
-                                               "(write time update delay == %.2f) (wrong!)\n",
-                                               diff, used_delay / (double)1000000);
-                               ret = false;
-                               break;
-                       }
-
-                       torture_comment(tctx, "Server updated write_time after %.2f seconds "
-                                       "(correct)\n",
-                                       diff);
-                       break;
-               }
-               smb_msleep(0.5 * msec);
+               torture_assert_u64_not_equal(tctx,
+                                            finfo1.all_info.out.write_time,
+                                            finfo0.all_info.out.write_time,
+                                            "Server did not update write time "
+                                            "immediately");
+               finfo0 = finfo1;
+               /* Bypass possible filesystem granularity */
+               smb_msleep(20);
        }
 
        GET_INFO_BOTH(finfo1,pinfo1);
        COMPARE_WRITE_TIME_GREATER(pinfo1, pinfo0);
 
-       /* sure any further write doesn't update the write time */
+       /* Bypass possible filesystem granularity */
+       smb_msleep(20);
+
+       /* any further write also updates the write time */
        start = timeval_current();
-       end = timeval_add(&start, 15 * sec, 0);
+       end = timeval_add(&start, 4 * sec, 0);
        while (!timeval_expired(&end)) {
                /* do a write */
                torture_comment(tctx, "Do a write on the file handle\n");
@@ -1261,43 +1256,37 @@ static bool test_delayed_write_update3(struct torture_context *tctx,
                /* get the times after the write */
                GET_INFO_BOTH(finfo2,pinfo2);
 
-               if (finfo2.basic_info.out.write_time > finfo1.basic_info.out.write_time) {
-                       double diff = timeval_elapsed(&start);
-                       torture_result(tctx, TORTURE_FAIL, "Server updated write_time after %.2f seconds "
-                                       "(wrong!)\n",
-                                       diff);
-                       ret = false;
-                       break;
-               }
-               smb_msleep(1 * msec);
-       }
-
-       GET_INFO_BOTH(finfo2,pinfo2);
-       COMPARE_WRITE_TIME_EQUAL(finfo2, finfo1);
-       if (finfo2.basic_info.out.write_time == finfo1.basic_info.out.write_time) {
-               torture_comment(tctx, "Server did not update write_time (correct)\n");
+               torture_assert_u64_not_equal(tctx,
+                                            finfo2.all_info.out.write_time,
+                                            finfo1.all_info.out.write_time,
+                                            "Server did not update write time "
+                                            "immediately");
+               finfo1 = finfo2;
+               /* Bypass possible filesystem granularity */
+               smb_msleep(20);
        }
 
-       /* sleep */
-       smb_msleep(5 * msec);
-
        GET_INFO_BOTH(finfo3,pinfo3);
-       COMPARE_WRITE_TIME_EQUAL(finfo3, finfo2);
+
+       torture_assert_u64_equal(tctx,
+                                finfo3.all_info.out.write_time,
+                                finfo2.all_info.out.write_time,
+                                "Server unexpectedly updated write time");
 
        /*
-        * the close updates the write time to the time of the close
-        * and not to the time of the last write!
+        * the close doesn't update the write time
         */
        torture_comment(tctx, "Close the file handle\n");
        smbcli_close(cli->tree, fnum1);
        fnum1 = -1;
 
        GET_INFO_PATH(pinfo4);
-       COMPARE_WRITE_TIME_GREATER(pinfo4, pinfo3);
 
-       if (pinfo4.basic_info.out.write_time > pinfo3.basic_info.out.write_time) {
-               torture_comment(tctx, "Server updated the write_time on close (correct)\n");
-       }
+       torture_assert_u64_equal(tctx,
+                                pinfo4.all_info.out.write_time,
+                                pinfo3.all_info.out.write_time,
+                                "Server updated write time "
+                                "on close");
 
  done:
        if (fnum1 != -1)