Skip to contentSkip to conversation

generic/528: take fs timestamps granularity into account in tolerance interval

PATCH In review Luís Henriques 2 participants 2 messages Nov 8, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 generic/528: take fs timestamps granularity into account in tolerance interval

Filesystems timestamps granularity can cause spurious test failures:

QA output created by 528
btime has value of 1635818936
btime is NOT in range 1635818937 .. 1635818942

This test output makes it looks like $testfile was created *before* the 'date' command was executed. What really happen was that btime was truncated according to the granularity defined by filesystem (I've seen this with both ext4 and xfs, but I guess others are also affected).

Since granularity can't be worse than a second, simply adjust the test tolerance interval by 1 second.

---
 tests/generic/528 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/generic/528 +1 -1
index 24d1ee0e5ec7..a63827b1139b 100755
@@ -41,7 +41,7 @@ btime=$(date +%s -d "$($XFS_IO_PROG -c "statx -v -m $STATX_BTIME" $testfile | \
 	grep 'stat.btime =' | cut -d '=' -f 2)")
 test -n "$btime" || echo "error: did not see btime in output??"
 
-_within_tolerance "btime" "$btime" "$now" 0 5 -v
+_within_tolerance "btime" "$btime" "$now" 1 5 -v
 
 status=0
 exit
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Luís Henriques

Filesystems timestamps granularity can cause spurious test failures:

QA output created by 528
btime has value of 1635818936
btime is NOT in range 1635818937 .. 1635818942

Quoted 7 lines

This test output makes it looks like $testfile was created *before* the 'date' command was executed. What really happen was that btime was truncated according to the granularity defined by filesystem (I've seen this with both ext4 and xfs, but I guess others are also affected).

Since granularity can't be worse than a second, simply adjust the test tolerance interval by 1 second.

/me wonders if that's still going to trip over vfat/ntfs, but as far as modern xfs/ext4/btrfs go, this should be sufficient.

--D

Quoted 18 lines
---
 tests/generic/528 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/generic/528 +1 -1
index 24d1ee0e5ec7..a63827b1139b 100755
@@ -41,7 +41,7 @@ btime=$(date +%s -d "$($XFS_IO_PROG -c "statx -v -m $STATX_BTIME" $testfile | \
 	grep 'stat.btime =' | cut -d '=' -f 2)")
 test -n "$btime" || echo "error: did not see btime in output??"
 
-_within_tolerance "btime" "$btime" "$now" 0 5 -v
+_within_tolerance "btime" "$btime" "$now" 1 5 -v
 
 status=0
 exit