test: avoid getting stuck on /dev/fuse

On Fedora Rawhide checking /dev/fuse in the test is getting stuck and timing out:

[   47.930104] TEST-13-NSPAWN.sh[2588]: + testcase_fuse
[   47.930424] TEST-13-NSPAWN.sh[2589]: ++ cat
[   58.772538] audit: type=1131 audit(1777728357.726:778): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=systemd-importd comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
[  901.882562] audit: type=1131 audit(1777729200.830:782): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=systemd-tmpfiles-clean comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Finishing after writing 176921 entries
qemu-system-x86_64: terminating on signal 15 from pid 70717 (/usr/bin/python3)

Wrap it with a timeout to avoid getting stuck forever

Follow-up for dc3223919f

(cherry picked from commit afa4a559e1)
(cherry picked from commit 71e40ed5c1)
This commit is contained in:
Luca Boccassi
2026-05-02 23:46:46 +01:00
parent 630e114b4e
commit 223df01544

View File

@@ -1347,7 +1347,10 @@ testcase_unpriv() {
}
testcase_fuse() {
if [[ "$(cat <>/dev/fuse 2>&1)" != 'cat: -: Operation not permitted' ]]; then
# On some kernels reading from /dev/fuse without an attached connection blocks indefinitely
# rather than returning EPERM, so guard the probe with a short timeout and skip the test
# whenever we don't get the expected error string.
if [[ "$(timeout --foreground 5 cat <>/dev/fuse 2>&1)" != 'cat: -: Operation not permitted' ]]; then
echo "FUSE is not supported, skipping the test..."
return 0
fi
@@ -1378,7 +1381,7 @@ testcase_fuse() {
# "cat: -: Operation not permitted" # pass the test; opened but not read
# "bash: line 1: /dev/fuse: Operation not permitted" # fail the test; could not open
# "" # fail the test; reading worked
[[ "$(systemd-nspawn --register=no --pipe --directory="$root" \
[[ "$(timeout --foreground 30 systemd-nspawn --register=no --pipe --directory="$root" \
bash -c 'cat <>/dev/fuse' 2>&1)" == 'cat: -: Operation not permitted' ]]
rm -fr "$root"
@@ -1387,7 +1390,7 @@ testcase_fuse() {
testcase_unpriv_fuse() {
# Same as above, but for unprivileged operation.
if [[ "$(cat <>/dev/fuse 2>&1)" != 'cat: -: Operation not permitted' ]]; then
if [[ "$(timeout --foreground 5 cat <>/dev/fuse 2>&1)" != 'cat: -: Operation not permitted' ]]; then
echo "FUSE is not supported, skipping the test..."
return 0
fi
@@ -1406,7 +1409,7 @@ testcase_unpriv_fuse() {
create_dummy_ddi "$tmpdir" "$name"
chown --recursive testuser: "$tmpdir"
[[ "$(run0 -u testuser --pipe systemd-run \
[[ "$(timeout --foreground 60 run0 -u testuser --pipe systemd-run \
--user \
--pipe \
--property=Delegate=yes \