test: do not fail if scsi_debug module not available

On Debian it's only built on amd64 kernels, so skip test cases if it
cannot be loaded
This commit is contained in:
Luca Boccassi
2025-07-04 01:18:47 +01:00
parent 1f0acba512
commit b6be8bf2c6
2 changed files with 8 additions and 4 deletions

View File

@@ -190,8 +190,8 @@ udevadm test-builtin "factory_reset status" "$loopdev"
# systemd-hwdb update is extremely slow when combined with sanitizers and run
# in a VM without acceleration, so let's just skip the one particular test
# if we detect this combination
if ! [[ -v ASAN_OPTIONS && "$(systemd-detect-virt -v)" == "qemu" ]]; then
modprobe scsi_debug
# scsi_debug is not available in all architectures/kernels combinations
if ! [[ -v ASAN_OPTIONS && "$(systemd-detect-virt -v)" == "qemu" ]] && modprobe scsi_debug; then
scsidev=$(readlink -f /sys/bus/pseudo/drivers/scsi_debug/adapter*/host*/target*/[0-9]*)
mkdir -p /etc/udev/hwdb.d
cat >/etc/udev/hwdb.d/99-test.hwdb <<EOF

View File

@@ -298,7 +298,7 @@ teardown_session() (
rm -f /run/udev/rules.d/70-logindtest-scsi_debug-user.rules
udevadm control --reload
rmmod scsi_debug
rmmod scsi_debug || true
return 0
)
@@ -446,7 +446,11 @@ EOF
# coldplug: logind started with existing device
systemctl stop systemd-logind.service
modprobe scsi_debug
if ! modprobe scsi_debug; then
echo "scsi_debug module not available, skipping test ${FUNCNAME[0]}."
systemctl start systemd-logind.service
return
fi
timeout 30 bash -c 'until ls /sys/bus/pseudo/drivers/scsi_debug/adapter*/host*/target*/*:*/block 2>/dev/null; do sleep 1; done'
dev=/dev/$(ls /sys/bus/pseudo/drivers/scsi_debug/adapter*/host*/target*/*:*/block 2>/dev/null)
if [[ ! -b "$dev" ]]; then