]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: wait for unit generated from /proc/self/mountinfo to be unloaded
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 20 May 2024 19:48:42 +0000 (04:48 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 21 May 2024 14:09:38 +0000 (23:09 +0900)
Fixes https://github.com/systemd/systemd/issues/32680#issuecomment-2120974685.
===
May 21 02:45:08 TEST-74-AUX-UTILS.sh[2475]: + mountpoint /tmp/tmp.eaRV7lSbX2/mnt
May 21 02:45:08 TEST-74-AUX-UTILS.sh[2476]: /tmp/tmp.eaRV7lSbX2/mnt is not a mountpoint
May 21 02:45:08 TEST-74-AUX-UTILS.sh[2449]: + systemd-mount /dev/loop0 /tmp/tmp.eaRV7lSbX2/mnt
May 21 02:45:08 systemd-mount[2477]: Failed to start transient mount unit: Unit tmp-tmp.eaRV7lSbX2-mnt.mount was already loaded or has a fragment file.
===

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

index a3b44ee91bc14113ebcecf71b0f1e03aeb671d70..5bba5a3ac50850aae1d67827424304ec06c0c25f 100755 (executable)
@@ -58,6 +58,9 @@ mount "$LOOP" "$WORK_DIR/mnt"
 touch "$WORK_DIR/mnt/foo.bar"
 umount "$LOOP"
 (! mountpoint "$WORK_DIR/mnt")
+# Wait for the mount unit to be unloaded. Otherwise, creation of the transient unit below may fail.
+MOUNT_UNIT=$(systemd-escape --path --suffix=mount "$WORK_DIR/mnt")
+timeout 60 bash -c "while [[ -n \$(systemctl list-units --all --no-legend $MOUNT_UNIT) ]]; do sleep 1; done"
 
 # Mount with both source and destination set
 systemd-mount "$LOOP" "$WORK_DIR/mnt"