]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: du/bigtime: try harder to find a suitable filesystem
authorNicolas Boichat <nicolas@boichat.ch>
Sat, 26 Jul 2025 06:58:33 +0000 (14:58 +0800)
committerPádraig Brady <P@draigBrady.com>
Thu, 16 Oct 2025 17:28:52 +0000 (18:28 +0100)
* tests/du/bigtime.sh: At least on Linux, the ext4 filesystem
doesn't support such large timestamp, while tmpfs does.  Try a bit
harder to look for a filesystem with large timestamp support.

tests/du/bigtime.sh

index 4b0a1a3d3afe00ddf95677b75c42aca87c02e9e6..cba55aaa7f02f2e0c457dc60bb5631521e0d6b4a 100755 (executable)
@@ -25,22 +25,33 @@ export TZ=UTC0
 # 2**63 - 1
 bignum=9223372036854775807
 
-touch -d @$bignum future 2>/dev/null &&
-future_time=$(ls -l future) &&
-case "$future_time" in
-*" $bignum "*)
-  : ;;
-*' Dec  4  300627798676 '*)
-  skip_ "file system and localtime both handle big timestamps" ;;
-*)
-  skip_ "file system or localtime mishandles big timestamps:" \
-      "$future_time" ;;
-esac || skip_ "file system cannot represent big timestamps"
-
-printf "0\t$bignum\tfuture\n" > exp || framework_failure_
+good=0
+future=
+cleanup_() { rm -rf "$future"; }
+
+for fs in ./ /tmp /dev/shm; do
+  future=$(mktemp -p "$fs" future.XXXXXX) || continue
+  touch -d @$bignum "$future" 2>/dev/null &&
+  future_time=$(ls -l "$future") &&
+  case "$future_time" in
+  *" $bignum "*)
+    echo "file system at $fs handles big timestamps"
+    good=1; break ;;
+  *' Dec  4  300627798676 '*)
+    warn_ "file system at $fs and localtime both handle big timestamps" ;;
+  *)
+    warn_ "file system at $fs or localtime mishandles big timestamps:" \
+        "$future_time" ;;
+  esac || warn_ "file system at $fs cannot represent big timestamps"
+  rm -f "$future" || framework_failure_
+done
+
+test "$good" = 1 || skip_ "Cannot find required big timestamp support"
+
+printf "0\t$bignum\t$future\n" > exp || framework_failure_
 printf "du: time '$bignum' is out of range\n" > err_ok || framework_failure_
 
-du --time future >out 2>err || fail=1
+du --time "$future" >out 2>err || fail=1
 
 # On some systems an empty file occupies 4 blocks.
 # Map the number of blocks to 0.