test: wait for the nvme device to appear

Also, use a /dev/disk/by-id/ symlink to the device, which should be
predictable, unlike the /dev/nvmeX stuff.
This commit is contained in:
Frantisek Sumsal 2023-11-03 15:31:52 +01:00 committed by Luca Boccassi
parent 775c005026
commit 12c2560997

View file

@ -11,15 +11,16 @@ systemctl start sys-kernel-config.mount
dd if=/dev/urandom of=/var/tmp/storagetm.test bs=1024 count=10240
systemd-run -u teststoragetm.service -p Type=notify /usr/lib/systemd/systemd-storagetm /var/tmp/storagetm.test --nqn=quux
NVME_SERIAL="$(</sys/kernel/config/nvmet/subsystems/quux.storagetm.test/attr_serial)"
NVME_DEVICE="/dev/disk/by-id/nvme-Linux_${NVME_SERIAL:?}"
nvme connect-all -t tcp -a 127.0.0.1 -s 16858 --hostid="$(cat /proc/sys/kernel/random/uuid)"
udevadm wait --settle "$NVME_DEVICE"
dd if=/dev/nvme1n1 bs=1024 | cmp /var/tmp/storagetm.test -
nvme disconnect --device=nvme1
dd if="$NVME_DEVICE" bs=1024 | cmp /var/tmp/storagetm.test -
nvme disconnect-all
systemctl stop teststoragetm.service
rm /var/tmp/storagetm.test
touch /testok