From: Ralph Boehme Date: Tue, 4 Mar 2025 15:32:11 +0000 (+0100) Subject: smbtorture: adjust "base.delaywrite.delayed update of write time 3c" for modern SMB... X-Git-Tag: tevent-0.17.0~489 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=86cb56eda688934029d4c1fee415c7987a9c18a4;p=thirdparty%2Fsamba.git smbtorture: adjust "base.delaywrite.delayed update of write time 3c" for modern SMB delayed write The adjusted test passes against Windows Server 2022. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13594 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/selftest/knownfail.d/samba3.base.delaywrite b/selftest/knownfail.d/samba3.base.delaywrite index 24480bb2588..394e8e04710 100644 --- a/selftest/knownfail.d/samba3.base.delaywrite +++ b/selftest/knownfail.d/samba3.base.delaywrite @@ -8,3 +8,4 @@ ^samba3.base.delaywrite.delayed update of write time 3\(fileserver_smb1\) ^samba3.base.delaywrite.delayed update of write time 3a\(fileserver_smb1\) ^samba3.base.delaywrite.delayed update of write time 3b\(fileserver_smb1\) +^samba3.base.delaywrite.delayed update of write time 3c\(fileserver_smb1\) diff --git a/source4/torture/basic/delaywrite.c b/source4/torture/basic/delaywrite.c index 56ac3aa15e7..94d08608311 100644 --- a/source4/torture/basic/delaywrite.c +++ b/source4/torture/basic/delaywrite.c @@ -1625,10 +1625,10 @@ static bool test_delayed_write_update3b(struct torture_context *tctx, } /* - * Check that a write after a truncate write doesn't update - * the timestamp, but a truncate write after a write does. - * Also prove that a close after a truncate write updates the - * timestamp to current, not the time of last write. + * Check that a write after a truncate write updates + * the timestamp and a truncate write after a write does. + * Also prove that a close after a truncate write does not update the + * timestamp. */ static bool test_delayed_write_update3c(struct torture_context *tctx, @@ -1680,7 +1680,7 @@ static bool test_delayed_write_update3c(struct torture_context *tctx, * sleep some time, to demonstrate the handling of write times * doesn't depend on the time since the open */ - smb_msleep(5 * msec); + smb_msleep(2 * msec); /* get the initial times */ GET_INFO_BOTH(finfo1,pinfo1); @@ -1691,7 +1691,8 @@ static bool test_delayed_write_update3c(struct torture_context *tctx, * updates the write time immediately */ for (i=0; i < 3; i++) { - smb_msleep(2 * msec); + /* Bypass possible filesystem granularity */ + smb_msleep(20); /* do a write */ torture_comment(tctx, "Do a truncate SMBwrite [%d] on the file handle\n", i); written = smbcli_smbwrite(cli->tree, fnum1, "x", 512, 0); @@ -1706,6 +1707,9 @@ static bool test_delayed_write_update3c(struct torture_context *tctx, finfo1 = finfo2; } + /* Bypass possible filesystem granularity */ + smb_msleep(20); + start = timeval_current(); end = timeval_add(&start, 7 * sec, 0); while (!timeval_expired(&end)) { @@ -1720,25 +1724,17 @@ static bool test_delayed_write_update3c(struct torture_context *tctx, /* get the times after the write */ GET_INFO_FILE(finfo2); - 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"); + /* Bypass possible filesystem granularity */ + smb_msleep(20); } /* sleep */ - smb_msleep(5 * msec); + smb_msleep(20); /* get the initial times */ GET_INFO_BOTH(finfo1,pinfo1); @@ -1764,15 +1760,15 @@ static bool test_delayed_write_update3c(struct torture_context *tctx, finfo1 = finfo2; } - /* sleep */ - smb_msleep(5 * msec); + /* Bypass possible filesystem granularity */ + smb_msleep(20); GET_INFO_BOTH(finfo2,pinfo2); COMPARE_WRITE_TIME_EQUAL(finfo2, finfo1); - /* sure any further write doesn't update the write time */ + /* check further writes also update 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"); @@ -1785,43 +1781,34 @@ static bool test_delayed_write_update3c(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"); + smb_msleep(20); } - /* sleep */ - smb_msleep(5 * msec); + /* Bypass possible filesystem granularity */ + smb_msleep(20); GET_INFO_BOTH(finfo3,pinfo3); COMPARE_WRITE_TIME_EQUAL(finfo3, finfo2); /* - * the close updates the write time to the time of the close - * and not to the time of the last write! + * the close must not 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, + finfo3.all_info.out.write_time, + "Server did not update write time " + "immediately"); done: if (fnum1 != -1)