Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/fs/vfs PR kern/49033



details:   https://anonhg.NetBSD.org/src/rev/d184f6e88f3a
branches:  trunk
changeset: 347506:d184f6e88f3a
user:      kre <kre%NetBSD.org@localhost>
date:      Mon Aug 29 02:31:46 2016 +0000

description:
PR kern/49033

POSIX allows for the atime (or technically, any of the times) to be
updated as a side effect of searching a directory (allows, not requires).
The NetBSD UDF implementation apparently works that way, treating a
directory search as a read of the directory, and hence updating the
access time.   Compensate for that in the test (rather than just
expecting failure) by verifying that the atime after the directory
search is within a small margin of the atime before the search
(currently, "small" is 1 second).   We could fetch the time before
the mkdir and both stat() calls, do all of that, fetch the time after,
subtract, and require the after stat() atime to be bounded by the atime
set by the original mkdir and returned in the first stat() and that time
+ the difference in elapsed time - that would be more accurate, but is
a lot more work for little real benefit.

Should anyone be interested in doing that extra work, remember to use
monotonic time (clock_gettime(CLOCK_MOMNOTONIC, ...)) not the time of day
clock for measuring the elapsed time.

Along with this, remove the "if (udf) failure expected" and the
if (udf && we haven't failed yet) fail("random failure failed to happen")
stuff...  (the "random" would have been that sometimes the mkdir and
two lookups (stat() calls) would all occur within the same clock tick,
meaning that the atimes would all be the same.  Other times the clock
would tick somewhere between the mkdir() and the 2nd stat().)

diffstat:

 tests/fs/vfs/t_vnops.c |  28 +++++++++++++++++++++-------
 1 files changed, 21 insertions(+), 7 deletions(-)

diffs (66 lines):

diff -r 24e31fcbc1b8 -r d184f6e88f3a tests/fs/vfs/t_vnops.c
--- a/tests/fs/vfs/t_vnops.c    Mon Aug 29 01:13:56 2016 +0000
+++ b/tests/fs/vfs/t_vnops.c    Mon Aug 29 02:31:46 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_vnops.c,v 1.57 2016/08/21 13:23:36 christos Exp $    */
+/*     $NetBSD: t_vnops.c,v 1.58 2016/08/29 02:31:46 kre Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -28,6 +28,7 @@
 
 #include <sys/stat.h>
 #include <sys/statvfs.h>
+#include <sys/time.h>
 
 #include <assert.h>
 #include <atf-c.h>
@@ -85,12 +86,10 @@
 {
        char pb[MAXPATHLEN];
        struct stat sb1, sb2;
+       struct timespec atplus1, onesec;
 
        USES_DIRS;
 
-       if (FSTYPE_UDF(tc))
-               atf_tc_expect_fail("PR kern/49033");
-
        snprintf(pb, sizeof(pb), "%s/dir", mountpath);
        if (rump_sys_mkdir(pb, 0777) == -1)
                atf_tc_fail_errno("mkdir");
@@ -101,6 +100,24 @@
        if (rump_sys_stat(pb, &sb2) == -1)
                atf_tc_fail_errno("stat 2");
 
+       /*
+        * The lookup is permitted to modify the access time of
+        * any directories searched - such a directory is the
+        * subject of this test.   Any difference should cause
+        * the 2nd lookup atime tp be >= the first, if it is ==, all is
+        * OK (atime is not required to be modified by the search, or
+        * both references may happen within the came clock tick), if the
+        * 2nd lookup atime is > the first, but not "too much" greater,
+        * just set it back, so the memcmp just below succeeds
+        * (assuming all else is OK).
+        */
+       onesec.tv_sec = 1;
+       onesec.tv_nsec = 0;
+       timespecadd(&sb1.st_atimespec, &onesec, &atplus1);
+       if (timespeccmp(&sb2.st_atimespec, &sb1.st_atimespec, >) &&
+           timespeccmp(&sb2.st_atimespec, &atplus1, <))
+               sb2.st_atimespec = sb1.st_atimespec;
+
        if (memcmp(&sb1, &sb2, sizeof(sb1)) != 0) {
                printf("what\tsb1\t\tsb2\n");
 
@@ -133,9 +150,6 @@
 
                atf_tc_fail("stat results differ, see ouput for more details");
        }
-       if (FSTYPE_UDF(tc))
-               atf_tc_fail("random failure of PR kern/49033 "
-                           "did not happen this time");
 }
 
 static void



Home | Main Index | Thread Index | Old Index