tests: bfq: skip tests on misbehaving udev systems

openSUSE has an unfortunate default udev setup which forcefully sets all
loop devices to use the "none" scheduler, even if you manually set it.
As this is a property of the host configuration (and udev is monitoring
from the host) we cannot really change this behaviour from inside our
test container.

So we should just skip the test in this (hopefully unusual) case.
Ideally tools running the test suite should disable this behaviour when
running our test suite.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
This commit is contained in:
Aleksa Sarai
2025-07-31 13:26:41 +10:00
parent ceef984fb3
commit e6b4b5a128

View File

@@ -156,12 +156,26 @@ function setup() {
dev="$(setup_loopdev)"
# Some distributions (like openSUSE) have udev configured to forcefully
# reset the scheduler for loopN devices to be "none", which breaks this
# test. We cannot modify the udev behaviour of the host, but since this is
# usually triggered by the "change" event from losetup, we can wait for a
# little bit before continuing the test. For more details, see
# <https://github.com/opencontainers/runc/issues/4781>.
sleep 2s
# See if BFQ scheduler is available.
if ! { grep -qw bfq "/sys/block/${dev#/dev/}/queue/scheduler" &&
echo bfq >"/sys/block/${dev#/dev/}/queue/scheduler"; }; then
skip "BFQ scheduler not available"
fi
# Check that the device still has the right scheduler, in case we lost the
# race above...
if ! grep -qw '\[bfq\]' "/sys/block/${dev#/dev/}/queue/scheduler"; then
skip "udev is configured to reset loop device io scheduler"
fi
set_cgroups_path
IFS=$' \t:' read -r major minor <<<"$(lsblk -nd -o MAJ:MIN "$dev")"