From f7d52524a70eab0b7f264d0a9c587ab4158d5913 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 1 Nov 2024 21:27:52 +0100 Subject: [PATCH] TEST-64-UDEV-STORAGE: Don't hardcode device name in long-sysfs-path test There's no guarantee our device will be named /dev/vda, so give it a serial so we can query for its devname inside the test. (cherry picked from commit 2ec809dd3baf39b83b8f581e7ea837b9732f9964) --- .../long_sysfs_path.configure | 2 +- test/TEST-64-UDEV-STORAGE/test.sh | 2 +- test/units/TEST-64-UDEV-STORAGE.sh | 24 ++++++++++--------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/test/TEST-64-UDEV-STORAGE/long_sysfs_path.configure b/test/TEST-64-UDEV-STORAGE/long_sysfs_path.configure index f29677ce663..02e2ac4daaa 100755 --- a/test/TEST-64-UDEV-STORAGE/long_sysfs_path.configure +++ b/test/TEST-64-UDEV-STORAGE/long_sysfs_path.configure @@ -26,6 +26,6 @@ for bridge in range(1, 26): f"pci-bridge,id=pci_bridge{bridge},bus=pci_bridge{bridge - 1},chassis_nr={64 + bridge},addr=1", ] -config["QemuArgs"] += ["-device", f"virtio-blk-pci,drive=drive0,bus=pci_bridge25,addr=1"] +config["QemuArgs"] += ["-device", f"virtio-blk-pci,drive=drive0,bus=pci_bridge25,addr=1,serial=long-sysfs-path"] json.dump(config, sys.stdout) diff --git a/test/TEST-64-UDEV-STORAGE/test.sh b/test/TEST-64-UDEV-STORAGE/test.sh index 2fd7bf2bfb9..104902055b5 100755 --- a/test/TEST-64-UDEV-STORAGE/test.sh +++ b/test/TEST-64-UDEV-STORAGE/test.sh @@ -464,7 +464,7 @@ testcase_long_sysfs_path() { qemu_opts+=("-device pci-bridge,id=pci_bridge$brid,bus=pci_bridge$((brid-1)),chassis_nr=$((64+brid))") done - qemu_opts+=("-device virtio-blk-pci,drive=drive0,bus=pci_bridge$brid") + qemu_opts+=("-device virtio-blk-pci,drive=drive0,bus=pci_bridge$brid,serial=long-sysfs-path") KERNEL_APPEND="systemd.setenv=TEST_FUNCTION_NAME=${FUNCNAME[0]} ${USER_KERNEL_APPEND:-}" QEMU_OPTIONS="${qemu_opts[*]} ${USER_QEMU_OPTIONS:-}" diff --git a/test/units/TEST-64-UDEV-STORAGE.sh b/test/units/TEST-64-UDEV-STORAGE.sh index 39054f83d55..8df4e030b05 100755 --- a/test/units/TEST-64-UDEV-STORAGE.sh +++ b/test/units/TEST-64-UDEV-STORAGE.sh @@ -1006,19 +1006,21 @@ testcase_long_sysfs_path() { journalctl --cursor-file="${cursor:?}" -n0 -q # Make sure the test device is connected and show its "wonderful" path - stat /sys/block/vda - readlink -f /sys/block/vda/dev + dev="$(udevadm info -e --property-match=ID_SERIAL=long-sysfs-path --property-match DEVTYPE=disk --json=short | jq -r .DEVNAME)" + dev="${dev#/dev/}" - dev="/dev/vda" - udevadm lock --device "$dev" sfdisk "$dev" </etc/fstab