]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: stat: ensure independence from /proc/ master
authorPádraig Brady <P@draigBrady.com>
Fri, 10 Apr 2026 13:55:07 +0000 (14:55 +0100)
committerPádraig Brady <P@draigBrady.com>
Fri, 10 Apr 2026 13:55:07 +0000 (14:55 +0100)
* tests/stat/stat-mount.sh: Ensure stat -c '%a'
is independent from /proc.
https://github.com/coreutils/coreutils/pull/250

tests/stat/stat-mount.sh

index b630d5b52d61d0de3afbff2c9ef52c25d1f06fc0..18b544043500b7b7574c90edb7718f88d122ba7b 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/sh
-# Test stat -c%m
+# Test stat interactions with mounts
 
 # Copyright (C) 2010-2026 Free Software Foundation, Inc.
 
@@ -25,4 +25,12 @@ case "$stat_mnt" in
   *) fail=1;;
 esac
 
+# Ensure stat works without mounting /proc
+hide_proc() {
+  unshare -rm $SHELL -c 'mount -t tmpfs tmpfs /proc && "$@"' -- "$@"
+}
+if hide_proc true; then
+  hide_proc stat -c '0%#a' / || fail=1
+fi
+
 Exit $fail