Files
coreutils/tests/cat/splice.sh
T
Pádraig Brady b3cdc09344 tests: avoid hangs with strace on cygwin
`strace -e tee true` will run the tee command on cygwin,
rather than filtering for the tee syscall.
Reported by Bruno Haible on Cygwin 2.9.0

* init.cfg: Use -e trace=foo where foo might be a command,
so that strace probes will fail rather than invoke foo on Cygwin.
* tests/cat/cat-distinct-err.sh: Likewise.
* tests/cat/splice.sh: Likewise.
* tests/ls/no-cap.sh: Likewise.
* tests/misc/yes.sh: Likewise.
* tests/mv/atomic.sh: Likewise.
* tests/mv/atomic2.sh: Likewise.
* tests/nproc/nproc-quota.sh: Likewise.
* tests/pwd/pwd-long.sh: Likewise.
* tests/stty/stty.sh: Likewise.
* tests/tail/debug.sh: Likewise.
* tests/tail/inotify-only-regular.sh: Likewise.
2026-09-10 16:40:06 +01:00

54 lines
1.8 KiB
Bash
Executable File

#!/bin/sh
# Test some cases where 'cat' uses the splice system call.
# Copyright (C) 2026 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ cat
getlimits_
uses_strace_
# Check the non pipe output case, since that is different with splice
if timeout 10 true; then
timeout .1 cat /dev/zero >/dev/null
test $? = 124 || fail=1
fi
# Ensure we fallback to write() if there is an issue with (async) zero-copy
zc_syscalls='io_uring_setup io_uring_enter io_uring_register memfd_create
sendfile splice tee vmsplice'
syscalls=$(
for s in $zc_syscalls; do
strace -qe trace="$s" true >/dev/null 2>&1 && echo "$s"
done | paste -s -d,)
no_zero_copy() {
strace -f -o /dev/null -e inject=${syscalls}:error=ENOSYS "$@"
}
if no_zero_copy true; then
test "$(no_zero_copy cat /dev/zero | head -c 2 | tr '\0' 'y')" = 'yy' \
|| fail=1
fi
# Ensure we fallback to write() if there is an issue with pipe2()
# For example if we don't have enough file descriptors available.
no_pipe() { strace -f -o /dev/null -e inject=pipe,pipe2:error=EMFILE "$@"; }
if no_pipe true; then
no_pipe timeout .1 cat /dev/zero >/dev/null
test $? = 124 || fail=1
fi
Exit $fail