test: coverage for #19946

This commit is contained in:
Frantisek Sumsal 2021-09-10 17:16:51 +02:00
parent d430e451c9
commit 35497c7c33
2 changed files with 53 additions and 0 deletions

View file

@ -230,6 +230,22 @@ EOF
test_run_one "${1:?}"
}
# Test case for issue https://github.com/systemd/systemd/issues/19946
testcase_simultaneous_events() {
local qemu_opts=("-device virtio-scsi-pci,id=scsi")
local partdisk="${TESTDIR:?}/simultaneousevents.img"
dd if=/dev/zero of="$partdisk" bs=1M count=110
qemu_opts+=(
"-device scsi-hd,drive=drive1,serial=deadbeeftest"
"-drive format=raw,cache=unsafe,file=$partdisk,if=none,id=drive1"
)
KERNEL_APPEND="systemd.setenv=TEST_FUNCTION_NAME=${FUNCNAME[0]} ${USER_KERNEL_APPEND:-}"
QEMU_OPTIONS="${qemu_opts[*]} ${USER_QEMU_OPTIONS:-}"
test_run_one "${1:?}"
}
# Allow overriding which tests should be run from the "outside", useful for manual
# testing (make -C test/... TESTCASES="testcase1 testcase2")
if [[ -v "TESTCASES" && -n "$TESTCASES" ]]; then

View file

@ -140,6 +140,43 @@ EOF
rm -fr "$mpoint"
}
testcase_simultaneous_events() {
local blockdev part partscript
blockdev="$(readlink -f /dev/disk/by-id/scsi-*_deadbeeftest)"
partscript="$(mktemp)"
if [[ ! -b "$blockdev" ]]; then
echo "ERROR: failed to find the test SCSI block device"
return 1
fi
cat >"$partscript" <<EOF
$(printf 'name="test%d", size=2M\n' {1..50})
EOF
# Initial partition table
sfdisk -q -X gpt "$blockdev" <"$partscript"
# Delete the partitions, immediatelly recreate them, wait for udev to settle
# down, and then check if we have any dangling symlinks in /dev/disk/. Rinse
# and repeat.
#
# On unpatched udev versions the delete-recreate cycle may trigger a race
# leading to dead symlinks in /dev/disk/
for i in {1..100}; do
sfdisk -q --delete "$blockdev"
sfdisk -q -X gpt "$blockdev" <"$partscript"
if ((i % 10 == 0)); then
udevadm settle
helper_check_device_symlinks
fi
done
rm -f "$partscript"
}
: >/failed
udevadm settle