]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: wait for the kernel finishes to attach backing file to loop device
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 28 May 2024 02:51:48 +0000 (11:51 +0900)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 28 May 2024 06:49:47 +0000 (08:49 +0200)
Fixes #32680.

test/units/TEST-74-AUX-UTILS.mount.sh

index ba47b5384db89d9a84d46c70fe8f9bd2a6d0961a..14253c358d1a11fd480cfd3a847869df204daf61 100755 (executable)
@@ -159,7 +159,12 @@ timeout 60 bash -c "while [[ -e /sys/$LOOP_AUTO_DEVPATH/loop/backing_file ]]; do
 dd if=/dev/zero of="$WORK_DIR/owner-vfat.img" bs=1M count=16
 mkfs.vfat -n owner-vfat "$WORK_DIR/owner-vfat.img"
 LOOP="$(losetup --show --find "$WORK_DIR/owner-vfat.img")"
-udevadm wait --timeout 60 --settle "$LOOP"
+# If the synthesized uevent triggered by inotify event has been processed earlier than the kernel finishes to
+# attach the backing file, then SYSTEMD_READY=0 is set for the device. As a workaround, monitor sysattr
+# and re-trigger uevent after that.
+LOOP_DEVPATH=$(udevadm info --query property --property DEVPATH --value "$LOOP")
+timeout 60 bash -c "until [[ -e /sys/$LOOP_DEVPATH/loop/backing_file ]]; do sleep 1; done"
+udevadm trigger --settle "$LOOP"
 # Also wait for the .device unit for the loop device is active. Otherwise, the .device unit activation
 # that is triggered by the .mount unit introduced by systemd-mount below may time out.
 if ! timeout 60 bash -c "until systemctl is-active $LOOP; do sleep 1; done"; then