mirror of
https://github.com/systemd/systemd.git
synced 2024-12-22 17:35:35 +03:00
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.
This commit is contained in:
parent
29a8e71d9c
commit
2ec809dd3b
@ -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)
|
||||
|
@ -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:-}"
|
||||
|
@ -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" <<EOF
|
||||
stat "/sys/block/${dev}"
|
||||
readlink -f "/sys/block/${dev}/dev"
|
||||
|
||||
udevadm lock --device "/dev/${dev}" sfdisk "/dev/${dev}" <<EOF
|
||||
label: gpt
|
||||
|
||||
name="test_swap", size=32M
|
||||
uuid="deadbeef-dead-dead-beef-000000000000", name="test_part", size=5M
|
||||
EOF
|
||||
udevadm settle
|
||||
udevadm lock --device "${dev}1" mkswap -U "deadbeef-dead-dead-beef-111111111111" -L "swap_vol" "${dev}1"
|
||||
udevadm lock --device "${dev}2" mkfs.ext4 -U "deadbeef-dead-dead-beef-222222222222" -L "data_vol" "${dev}2"
|
||||
udevadm lock --device "/dev/${dev}1" mkswap -U "deadbeef-dead-dead-beef-111111111111" -L "swap_vol" "/dev/${dev}1"
|
||||
udevadm lock --device "/dev/${dev}2" mkfs.ext4 -U "deadbeef-dead-dead-beef-222222222222" -L "data_vol" "/dev/${dev}2"
|
||||
udevadm wait --settle --timeout=30 "${expected_symlinks[@]}"
|
||||
|
||||
# Try to mount the data partition manually (using its label)
|
||||
@ -1044,13 +1046,13 @@ EOF
|
||||
# Check state of affairs after https://github.com/systemd/systemd/pull/22759
|
||||
# Note: can't use `--cursor-file` here, since we don't want to update the cursor
|
||||
# after using it
|
||||
[[ "$(journalctl --after-cursor="$(<"$cursor")" -q --no-pager -o short-monotonic -p info --grep "Device path.*vda.?' too long to fit into unit name" | wc -l)" -eq 0 ]]
|
||||
[[ "$(journalctl --after-cursor="$(<"$cursor")" -q --no-pager -o short-monotonic --grep "Unit name .*vda.?\.device\" too long, falling back to hashed unit name" | wc -l)" -gt 0 ]]
|
||||
[[ "$(journalctl --after-cursor="$(<"$cursor")" -q --no-pager -o short-monotonic -p info --grep "Device path.*${dev}.?' too long to fit into unit name" | wc -l)" -eq 0 ]]
|
||||
[[ "$(journalctl --after-cursor="$(<"$cursor")" -q --no-pager -o short-monotonic --grep "Unit name .*${dev}.?\.device\" too long, falling back to hashed unit name" | wc -l)" -gt 0 ]]
|
||||
# Check if the respective "hashed" units exist and are active (plugged)
|
||||
systemctl status --no-pager "$(readlink -f /sys/block/vda/vda1)"
|
||||
systemctl status --no-pager "$(readlink -f /sys/block/vda/vda2)"
|
||||
systemctl status --no-pager "$(readlink -f "/sys/block/${dev}/${dev}1")"
|
||||
systemctl status --no-pager "$(readlink -f "/sys/block/${dev}/${dev}2")"
|
||||
# Make sure we don't unnecessarily spam the log
|
||||
{ journalctl -b -q --no-pager -o short-monotonic -p info --grep "/sys/devices/.+/vda[0-9]?" _PID=1 + UNIT=systemd-udevd.service || :;} | tee "$logfile"
|
||||
{ journalctl -b -q --no-pager -o short-monotonic -p info --grep "/sys/devices/.+/${dev}[0-9]?" _PID=1 + UNIT=systemd-udevd.service || :;} | tee "$logfile"
|
||||
[[ "$(wc -l <"$logfile")" -lt 10 ]]
|
||||
|
||||
: >/etc/fstab
|
||||
|
Loading…
Reference in New Issue
Block a user