findutils-patches
[Top][All Lists]
Advanced

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

[PATCH] tests/find/used.sh: make more robust


From: Bernhard Voelker
Subject: [PATCH] tests/find/used.sh: make more robust
Date: Mon, 4 Jan 2021 01:33:16 +0100

This test was prone to false-positive errors due to sub-second rounding
issues.  Failures have been seen on openSUSE's build system.

* tests/find/used.sh: Use larger time intervals for the future access
times of the test files (compared to the '-used N' search), and adjust
the expected output accordingly.
---
 tests/find/used.sh | 91 +++++++++++++++++++++++++---------------------
 1 file changed, 49 insertions(+), 42 deletions(-)

diff --git a/tests/find/used.sh b/tests/find/used.sh
index 8e41a747..d061c2dc 100755
--- a/tests/find/used.sh
+++ b/tests/find/used.sh
@@ -19,8 +19,8 @@
 . "${srcdir=.}/tests/init.sh"; fu_path_prepend_
 print_ver_ find
 
-# Create sample files with the access date D=1,3,5,7 days in the future.
-for d in 1 3 5 7; do
+# Create sample files with the access date D=10,20,30,40 days in the future.
+for d in 10 20 30 40; do
   touch -a -d "$(date -d "$d day" '+%Y-%m-%d %H:%M:%S')" t$d \
     || skip_ "creating files with future timestamp failed"
 
@@ -33,14 +33,14 @@ for d in 1 3 5 7; do
     || skip_ "cannot verify timestamps of sample files"
 done
 # Create another sample file with timestamp now.
-touch t0 \
+touch t00 \
   || skip_ "creating sample file failed"
 
-stat -c "Name: %n  Access: %x  Change: %z" t? || : # ignore error.
+stat -c "Name: %n  Access: %x  Change: %z" t?0 || : # ignore error.
 
 # Verify the output for "find -used $d".  Use even number of days to avoid
 # possibly strange effects due to atime/ctime precision etc.
-for d in -8 -6 -4 -2 -0 0 2 4 6 8 +0 +2 +4 +6 +8; do
+for d in -45 -35 -25 -15 -5 0 5 15 25 35 45 +0 +5 +15 +25 +35 +45; do
   echo "== testing: find -used $d"
   find . -type f -name 't*' -used $d > out2 \
     || fail=1
@@ -48,45 +48,52 @@ for d in -8 -6 -4 -2 -0 0 2 4 6 8 +0 +2 +4 +6 +8; do
 done > out
 
 cat <<\EOF > exp || framework_failure_
-== testing: find -used -8
-./t0
-./t1
-./t3
-./t5
-./t7
-== testing: find -used -6
-./t0
-./t1
-./t3
-./t5
-== testing: find -used -4
-./t0
-./t1
-./t3
-== testing: find -used -2
-./t0
-./t1
-== testing: find -used -0
+== testing: find -used -45
+./t00
+./t10
+./t20
+./t30
+./t40
+== testing: find -used -35
+./t00
+./t10
+./t20
+./t30
+== testing: find -used -25
+./t00
+./t10
+./t20
+== testing: find -used -15
+./t00
+./t10
+== testing: find -used -5
+./t00
 == testing: find -used 0
-== testing: find -used 2
-== testing: find -used 4
-== testing: find -used 6
-== testing: find -used 8
+== testing: find -used 5
+== testing: find -used 15
+== testing: find -used 25
+== testing: find -used 35
+== testing: find -used 45
 == testing: find -used +0
-./t1
-./t3
-./t5
-./t7
-== testing: find -used +2
-./t3
-./t5
-./t7
-== testing: find -used +4
-./t5
-./t7
-== testing: find -used +6
-./t7
-== testing: find -used +8
+./t10
+./t20
+./t30
+./t40
+== testing: find -used +5
+./t10
+./t20
+./t30
+./t40
+== testing: find -used +15
+./t20
+./t30
+./t40
+== testing: find -used +25
+./t30
+./t40
+== testing: find -used +35
+./t40
+== testing: find -used +45
 EOF
 
 compare exp out || { fail=1; cat out; }
-- 
2.29.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]