diff options
author | Bernhard Voelker <mail@bernhard-voelker.de> | 2021-01-04 01:20:10 +0100 |
---|---|---|
committer | Bernhard Voelker <mail@bernhard-voelker.de> | 2021-01-04 01:21:27 +0100 |
commit | 1c061fb00300e0374b92130d5e6a4d846e1dcb76 (patch) | |
tree | 2a2766001582aaac798184f2db80d91fbdb798fb | |
parent | 1ca94cd43be6df182bafdcb25ebea72f9c6c2ea9 (diff) | |
download | findutils-1c061fb00300e0374b92130d5e6a4d846e1dcb76.tar.gz |
tests/find/used.sh: make more robust
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.
-rwxr-xr-x | tests/find/used.sh | 91 |
1 files 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; } |