From d64b44be527fd852a245ebff2c7d16cb27da7423 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 15 Apr 2022 11:13:29 +0900 Subject: [PATCH] test: add testcase for link priority --- test/TEST-64-UDEV-STORAGE/test.sh | 18 ++++--- test/units/testsuite-64.sh | 80 +++++++++++++++++++++++-------- 2 files changed, 72 insertions(+), 26 deletions(-) diff --git a/test/TEST-64-UDEV-STORAGE/test.sh b/test/TEST-64-UDEV-STORAGE/test.sh index 6eed43cc25c..26d72944987 100755 --- a/test/TEST-64-UDEV-STORAGE/test.sh +++ b/test/TEST-64-UDEV-STORAGE/test.sh @@ -312,19 +312,23 @@ EOF # 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" + local diskpath i - 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" - ) + for i in {0..9}; do + diskpath="${TESTDIR:?}/simultaneousevents${i}.img" + + dd if=/dev/zero of="$diskpath" bs=1M count=32 + qemu_opts+=( + "-device scsi-hd,drive=drive$i,serial=deadbeeftest$i" + "-drive format=raw,cache=unsafe,file=$diskpath,if=none,id=drive$i" + ) + done KERNEL_APPEND="systemd.setenv=TEST_FUNCTION_NAME=${FUNCNAME[0]} ${USER_KERNEL_APPEND:-}" QEMU_OPTIONS="${qemu_opts[*]} ${USER_QEMU_OPTIONS:-}" test_run_one "${1:?}" || return $? - rm -f "$partdisk" + rm -f "$diskpath" } testcase_lvm_basic() { diff --git a/test/units/testsuite-64.sh b/test/units/testsuite-64.sh index 4ddea69c51c..9a2540ad0cd 100755 --- a/test/units/testsuite-64.sh +++ b/test/units/testsuite-64.sh @@ -203,32 +203,49 @@ EOF } testcase_simultaneous_events() { - local blockdev iterations num_part part partscript timeout - - 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 + local disk expected i iterations link num_part part partscript rule target timeout + local -a devices symlinks if [[ -n "${ASAN_OPTIONS:-}" ]] || [[ "$(systemd-detect-virt -v)" == "qemu" ]]; then - num_part=10 + num_part=2 iterations=10 timeout=240 else - num_part=50 + num_part=10 iterations=100 timeout=30 fi + for disk in {0..9}; do + link="/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_deadbeeftest${disk}" + target="$(readlink -f "$link")" + if [[ ! -b "$target" ]]; then + echo "ERROR: failed to find the test SCSI block device $link" + return 1 + fi + + devices+=("$target") + done + + for ((part = 1; part <= num_part; part++)); do + symlinks+=( + "/dev/disk/by-partlabel/test${part}" + ) + done + + partscript="$(mktemp)" + cat >"$partscript" <"$rule" <&2 "ERROR: symlink '/dev/disk/by-partlabel/test${part}' points to '$target' but '$expected' was expected" + return 1 + fi + done fi done - rm -f "$partscript" + rm -f "$rule" "$partscript" + + udevadm control --reload } testcase_lvm_basic() {