]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: wait for loop device to be removed
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 25 Aug 2022 21:33:49 +0000 (06:33 +0900)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Fri, 26 Aug 2022 07:38:38 +0000 (07:38 +0000)
Follow-up for bca762ce1abafd24016eba7310fdd38c758419f8.

Fixes #24450.

test/units/testsuite-50.sh

index 6170c8ab63fd758059fee9b632e5a98504a3ad0f..d91eeaabe825742b48c66ee5e3e06411e65538c1 100755 (executable)
@@ -187,6 +187,7 @@ if [ "${HAVE_OPENSSL}" -eq 1 ]; then
     sfdisk --part-label "${image}.gpt" 3 "Signature Partition"
 fi
 loop="$(losetup --show -P -f "${image}.gpt")"
+# kernel sometimes(?) does not emit add uevent for partitions, let's wait for the whole block device.
 udevadm wait --timeout 60 --settle "${loop:?}"
 dd if="${image}.raw" of="${loop}p1"
 dd if="${image}.verity" of="${loop}p2"
@@ -194,6 +195,11 @@ if [ "${HAVE_OPENSSL}" -eq 1 ]; then
     dd if="${image}.verity-sig" of="${loop}p3"
 fi
 losetup -d "${loop}"
+# Interestingly, kernel does not emit remove uevent for the whole block device, but does for partitions.
+udevadm wait --timeout 60 --settle --removed "${loop}p1" "${loop}p2"
+if [ "${HAVE_OPENSSL}" -eq 1 ]; then
+    udevadm wait --timeout 60 --settle --removed "${loop}p3"
+fi
 
 # Derive partition UUIDs from root hash, in UUID syntax
 ROOT_UUID="$(systemd-id128 -u show "$(head -c 32 "${image}.roothash")" -u | tail -n 1 | cut -b 6-)"