bug#79101: [PATCH] tests/du/bigtime: Try harder to find supported filesystem, and test negative timestamp

Nicolas Boichat <[email protected]>
Newsgroups gmane.comp.gnu.core-utils.bugs
Message-ID <CAM6NUi6fbQWwkq3h=yWeYpxFwYky-QcCO5NRwX-1VLjWBHcnGw@mail.gmail.com>
Hi,

I think this test might often be skipped due to lack of filesystem
support? Let's try a bit harder to run it.

And let's test past timestamps too.

Thanks!

Log:
## tests: du/bigtime: Try harder to find a suitable filesystem
At least on Linux, the "usual" filesystem (ext4) 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: Try both big and small timestamps
Try both future and past timestamps, for completeness.
0002-tests-du-bigtime-Try-both-big-and-small-timestamps.patch (text/x-patch, 2.4 KB)
From 77a131b1c9e898badfbefe894b611b93c8fac86c Mon Sep 17 00:00:00 2001
From: Nicolas Boichat <[email protected]>
Date: Sat, 26 Jul 2025 15:03:15 +0800
Subject: [PATCH 2/2] tests: du/bigtime: Try both big and small timestamps

Try both future and past timestamps, for completeness.
---
 tests/du/bigtime.sh | 37 +++++++++++++++++++++----------------
 1 file changed, 21 insertions(+), 16 deletions(-)

diff --git a/tests/du/bigtime.sh b/tests/du/bigtime.sh
index 4f43464d5e33..6f2b303ab61f 100755
--- a/tests/du/bigtime.sh
+++ b/tests/du/bigtime.sh
@@ -24,16 +24,18 @@ export TZ=UTC0
 
 # 2**63 - 1
 bignum=9223372036854775807
+# - 2**63
+smallnum=-9223372036854775808
 
 good=0
-future=
-cleanup_() { rm -rf "$future"; }
+file=
+cleanup_() { rm -rf "$file"; }
 
 for fs in ./ /tmp /dev/shm; do
-  future=$(mktemp -p "$fs" future.XXXXXX)
-  touch -d @$bignum $future 2>/dev/null &&
-  future_time=$(ls -l $future) &&
-  case "$future_time" in
+  file=$(mktemp -p "$fs" future.XXXXXX)
+  touch -d @$bignum $file 2>/dev/null &&
+  file_time=$(ls -l $file) &&
+  case "$file_time" in
   *" $bignum "*)
     echo "file system at $fs handles big timestamps"
     good=1; break ;;
@@ -41,23 +43,26 @@ for fs in ./ /tmp /dev/shm; do
     echo "file system at $fs and localtime both handle big timestamps" ;;
   *)
     echo "file system at $fs or localtime mishandles big timestamps:" \
-        "$future_time" ;;
+        "$file_time" ;;
   esac || echo "file system at $fs cannot represent big timestamps"
-  rm $future
+  rm $file
 done
 
 [ -n $good ] || skip_ "Cannot find filesystem with 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_
+for num in $bignum $smallnum; do
+  printf "0\t$num\t$file\n" > exp || framework_failure_
+  printf "du: time '$num' is out of range\n" > err_ok || framework_failure_
 
-du --time $future >out 2>err || fail=1
+  touch -d @$num $file 2>/dev/null &&
+    du --time $file >out 2>err || fail=1
 
-# On some systems an empty file occupies 4 blocks.
-# Map the number of blocks to 0.
-sed 's/^[0-9][0-9]*/0/' out > k && mv k out
+  # On some systems an empty file occupies 4 blocks.
+  # Map the number of blocks to 0.
+  sed 's/^[0-9][0-9]*/0/' out > k && mv k out
 
-compare exp out || fail=1
-compare err err_ok || fail=1
+  compare exp out || fail=1
+  compare err err_ok || fail=1
+done
 
 Exit $fail
-- 
2.50.1
0001-tests-du-bigtime-Try-harder-to-find-a-suitable-files.patch (text/x-patch, 2.2 KB)
From ff86cb6308bbce3d3177c5da1198c3a38387c919 Mon Sep 17 00:00:00 2001
From: Nicolas Boichat <[email protected]>
Date: Sat, 26 Jul 2025 14:58:33 +0800
Subject: [PATCH 1/2] tests: du/bigtime: Try harder to find a suitable
 filesystem

At least on Linux, the "usual" filesystem (ext4) 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 | 39 +++++++++++++++++++++++++--------------
 1 file changed, 25 insertions(+), 14 deletions(-)

diff --git a/tests/du/bigtime.sh b/tests/du/bigtime.sh
index 4b0a1a3d3afe..4f43464d5e33 100755
--- a/tests/du/bigtime.sh
+++ b/tests/du/bigtime.sh
@@ -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)
+  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 '*)
+    echo "file system at $fs and localtime both handle big timestamps" ;;
+  *)
+    echo "file system at $fs or localtime mishandles big timestamps:" \
+        "$future_time" ;;
+  esac || echo "file system at $fs cannot represent big timestamps"
+  rm $future
+done
+
+[ -n $good ] || skip_ "Cannot find filesystem with 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.
-- 
2.50.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.