]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: test-N: include subsecond values in gating check
authorPádraig Brady <P@draigBrady.com>
Sun, 10 Mar 2019 07:48:06 +0000 (23:48 -0800)
committerPádraig Brady <P@draigBrady.com>
Sun, 10 Mar 2019 22:05:26 +0000 (15:05 -0700)
* tests/misc/test-N.sh: The subsecond values for atime and mtime
were potentially seen to differ on newlyl created files.
So we include the subsecond portion when comparing stat values.

tests/misc/test-N.sh

index e4a95c81d02e3b9610af24aa383a821e418d936c..d7f0aa964ba19d2a0be581107cf4ed3a948647ae 100755 (executable)
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ test stat
 
-stat_mtime() { env stat -c '%Y' "$1"; }
-stat_atime() { env stat -c '%X' "$1"; }
-stat_test_N() { env test "$(stat_mtime "$1")" -gt "$(stat_atime "$1")"; }
+stat_test_N() {
+  mtime=$(env stat -c '%.Y' "$1")
+  atime=$(env stat -c '%.X' "$1")
+  test "$mtime" = "$atime" && return 1
+  latest=$(printf '%s\n' "$mtime" "$atime" | sort -g | tail -n1)
+  test "$mtime" = "$latest"
+}
 
 # For a freshly touched file, atime should equal mtime: 'test -N' returns 1.
 touch file || framework_failure_