]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbtorture: adjust "base.delaywrite.delayed update of write time using 2 connections...
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 4b9574d627fa96ba297faf5c33d96794fb9669ee..9cd836c89036d6665b88fc936dac3d2c85f2799a 100644 (file)
@@ -4,3 +4,4 @@
 ^samba3.base.delaywrite.update of write time and SMBwrite truncate expand\(fileserver_smb1\)
 ^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\)
index f2a6459ed65a38955dccf6530fffb373683e06f2..d0d50c43c24f3dc4122805d3f016322b7e04bc7e 100644 (file)
@@ -620,9 +620,8 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
        torture_comment(tctx, "Initial write time %s\n",
               nt_time_string(tctx, finfo1.basic_info.out.write_time));
 
-       /* 3 second delay to ensure we get past any 2 second time
-          granularity (older systems may have that) */
-       smb_msleep(3 * msec);
+       /* Bypass possible filesystem granularity */
+       smb_msleep(20);
 
        {
                /* Try using setfileinfo instead of write to update write time. */
@@ -659,12 +658,11 @@ 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 (correct)\n");
-       } else {
-               torture_result(tctx, TORTURE_FAIL, "Server did not update write time (wrong!)\n");
-               ret = false;
-       }
+       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");
 
        /* Now try a write to see if the write time gets reset. */
 
@@ -709,7 +707,7 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
        /* Once the time was set using setfileinfo then it stays set - writes
           don't have any effect. But make sure. */
        start = timeval_current();
-       end = timeval_add(&start, (15*sec), 0);
+       end = timeval_add(&start, (4*sec), 0);
        while (!timeval_expired(&end)) {
                status = smb_raw_fileinfo(cli->tree, tctx, &finfo2);
 
@@ -720,22 +718,16 @@ 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) {
-                       double diff = timeval_elapsed(&start);
-                       torture_result(tctx, TORTURE_FAIL, "Server updated write_time after %.2f seconds"
-                                       "(wrong!)\n",
-                                       diff);
-                       ret = false;
-                       break;
-               }
+
+               torture_assert_u64_equal(tctx,
+                                        finfo2.all_info.out.write_time,
+                                        finfo1.all_info.out.write_time,
+                                        "Server updated write time");
+
                fflush(stdout);
                smb_msleep(1 * msec);
        }
 
-       if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) {
-               torture_comment(tctx, "Server did not update write time (correct)\n");
-       }
-
        fflush(stdout);
        smb_msleep(2 * msec);
 
@@ -763,10 +755,11 @@ 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_result(tctx, TORTURE_FAIL, "Server updated write_time (wrong!)\n");
-               ret = false;
-       }
+
+       torture_assert_u64_not_equal(tctx,
+                                    finfo2.all_info.out.write_time,
+                                    finfo1.all_info.out.write_time,
+                                    "Server did not update write time");
 
        torture_comment(tctx, "Closing the first fd to see if write time updated.\n");
        smbcli_close(cli->tree, fnum1);
@@ -793,15 +786,19 @@ 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_result(tctx, TORTURE_FAIL, "Server updated write_time (wrong!)\n");
-               ret = false;
-       }
 
-       /* Once the time was set using setfileinfo then it stays set - writes
-          don't have any effect. But make sure. */
+       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");
+
+       /*
+        * Sticky write time only applied to the handle
+        * that was used to set the write time.
+        */
        start = timeval_current();
-       end = timeval_add(&start, (15*sec), 0);
+       end = timeval_add(&start, (4*sec), 0);
        while (!timeval_expired(&end)) {
                status = smb_raw_fileinfo(cli->tree, tctx, &finfo2);
 
@@ -813,20 +810,17 @@ 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) {
-                       double diff = timeval_elapsed(&start);
-                       torture_result(tctx, TORTURE_FAIL, "Server updated write_time after %.2f seconds "
-                                       "(wrong!)\n",
-                                       diff);
-                       ret = false;
                        break;
                }
                fflush(stdout);
                smb_msleep(1 * msec);
        }
 
-       if (finfo1.basic_info.out.write_time == finfo2.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");
 
        torture_comment(tctx, "Closing second fd to see if write time updated.\n");
 
@@ -875,48 +869,12 @@ 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_result(tctx, TORTURE_FAIL, "Server updated write_time (wrong!)\n");
-               ret = false;
-       }
-
-       /* Now the write time should be updated again */
-       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)) {
-                       DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status)));
-                       ret = false;
-                       break;
-               }
-               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) {
-                       double diff = timeval_elapsed(&start);
-                       if (diff < (used_delay / (double)1000000)) {
-                               torture_result(tctx, TORTURE_FAIL, "Server updated write_time after %.2f seconds"
-                                               "(expected > %.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;
-               }
-               fflush(stdout);
-               smb_msleep(1*msec);
-       }
-
-       if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) {
-               torture_result(tctx, TORTURE_FAIL, "Server did not update write time (wrong!)\n");
-               ret = false;
-       }
 
+       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");
 
        /* One more test to do. We should read the filetime via findfirst on the
           second connection to ensure it's the same. This is very easy for a Windows