Hi Pádraig, Pádraig Brady <[email protected]> writes:
> Good catch. > > Re the test, there are various file _name_ "stat" functions, > so to increase coverage one might use similar techniques like > done in tests/ls/stat-free-symlinks.sh? > At least it would be good to verify the negative case also, > so something like: > > if open_stat_fail true && ! open_stat_fail stat file; then > ... > fi Good idea. I pushed the attached patch just copying that snippet accumulating the stat system calls from tests/ls/stat-free-symlinks.sh. It probably makes sense to add something like this in init.cfg if we add more tests like it. However, I have held off on that for now because we will likely want to consider only checking the stat or lstat variants then. Collin
>From 2f865e275da31f3c09e4689c71f48d2f44d6dad6 Mon Sep 17 00:00:00 2001 Message-ID: <2f865e275da31f3c09e4689c71f48d2f44d6dad6.1779331149.git.collin.fu...@gmail.com> From: Collin Funk <[email protected]> Date: Wed, 20 May 2026 19:31:34 -0700 Subject: [PATCH] tests: shred: improve coverage for stat checks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * tests/shred/fifo.sh: Check for more stat system calls. Copied from tests/ls/stat-free-symlinks.sh. Suggested by Pádraig Brady. --- tests/shred/fifo.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/shred/fifo.sh b/tests/shred/fifo.sh index 40af9c2f5..c7c3ac235 100755 --- a/tests/shred/fifo.sh +++ b/tests/shred/fifo.sh @@ -21,10 +21,18 @@ 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 + open_stat_fail () { strace --quiet=all -o /dev/null -P file -e inject=open,openat:error=ENXIO \ - -e inject=stat,newfstatat:error=ENOSYS "$@" + -e inject=$stats:error=ENOSYS "$@" } # If open fails with ENXIO and the subsequent stat fails, e.g., because the -- 2.54.0
