]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
maint: refactor stat syscall determination
authorPádraig Brady <P@draigBrady.com>
Wed, 22 Jul 2026 19:10:57 +0000 (20:10 +0100)
committerPádraig Brady <P@draigBrady.com>
Fri, 24 Jul 2026 12:19:23 +0000 (13:19 +0100)
* init.cfg (+get_stat_syscalls_): Refactor from ...
* tests/ls/stat-free-color.sh: ... here.
* tests/ls/stat-free-symlinks.sh: ... here.
* tests/misc/traversal-missing.sh: ... here.
* tests/shred/fifo.sh: .. here.

init.cfg
tests/ls/stat-free-color.sh
tests/ls/stat-free-symlinks.sh
tests/misc/traversal-missing.sh
tests/shred/fifo.sh

index 0896d8ddac7518990c289e8e2ff983f28e06bee5..8630940acae90b520d9f411e8185151732684411 100644 (file)
--- a/init.cfg
+++ b/init.cfg
@@ -265,6 +265,20 @@ require_strace_()
   fi
 }
 
+# Output a comma-separated list of file-name stat syscalls recognized
+# by strace.  Callers that require strace should invoke require_strace_
+# separately.
+get_stat_syscalls_()
+{
+  local stats=stat
+  local stat
+  for stat in statx lstat stat64 lstat64 newfstatat fstatat64; do
+    strace -qe "$stat" true > /dev/null 2>&1 &&
+      stats="$stats,$stat"
+  done
+  printf '%s\n' "$stats"
+}
+
 # Skip the current test if valgrind doesn't work,
 # which could happen if not installed,
 # or hasn't support for the built architecture,
index 7e95671f52a93fa5bdd09d2569f2ef294227cca0..27fe0d7b6d005b977c4f0207c34770b12ae6fd00 100755 (executable)
@@ -21,13 +21,7 @@ print_ver_ ls
 require_strace_ stat
 require_dirent_d_type_
 
-stats='stat'
-# List of other _file name_ stat functions to increase coverage.
-other_stats='statx lstat stat64 lstat64 newfstatat fstatat64'
-for stat in $other_stats; do
-  strace -qe "$stat" true > /dev/null 2>&1 &&
-    stats="$stats,$stat"
-done
+stats=$(get_stat_syscalls_)
 
 # Disable enough features via LS_COLORS so that ls --color
 # can do its job without calling stat (other than the obligatory
index 5597c04ccb53021cf371812b8fc7159bb5a80ea4..2d884adecd2c9a09627f57849b3878cd05ead7c9 100755 (executable)
 print_ver_ ls
 require_strace_ stat
 
-stats='stat'
-# List of other _file name_ stat functions to increase coverage.
-other_stats='statx lstat stat64 lstat64 newfstatat fstatat64'
-for stat in $other_stats; do
-  strace -qe "$stat" true > /dev/null 2>&1 &&
-    stats="$stats,$stat"
-done
+stats=$(get_stat_syscalls_)
 
 # The system may perform additional stat-like calls before main.
 # Furthermore, underlying library functions may also implicitly
index 73523310026ea3f795283f26225cd8ccc9c9af5d..764d9ca10a0b3c04db6ca04e45d3b1434fb81423 100755 (executable)
@@ -25,14 +25,7 @@ touch d/foo || framework_failure_
 uid=$(id -u) || framework_failure_
 gid=$(id -g) || framework_failure_
 
-stats='stat'
-# List other _file name_ stat functions to increase coverage.
-other_stats='statx lstat stat64 lstat64 newfstatat fstatat64'
-for stat in $other_stats; do
-  strace -qe "$stat" true > /dev/null 2>&1 &&
-    stats="$stats,$stat"
-done
-
+stats=$(get_stat_syscalls_)
 chmods=chmod,fchmodat,fchmodat2
 chowns=chown,lchown,fchownat
 
index d89cd2ff7cc7640c4c6f9a7594de8499773417d9..377fc6568077635b228a4ce2d17ea7fa813920ad 100755 (executable)
@@ -21,13 +21,7 @@ print_ver_ shred
 getlimits_
 uses_strace_
 
-stats='stat'
-# List of other _file name_ stat functions to increase coverage.
-other_stats='statx lstat stat64 lstat64 newfstatat fstatat64'
-for stat in $other_stats; do
-  strace -qe "$stat" true > /dev/null 2>&1 &&
-    stats="$stats,$stat"
-done
+stats=$(get_stat_syscalls_)
 
 open_stat_fail ()
 {