]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: use the new `udevadm wait` verb to wait for the loop device
authorFrantisek Sumsal <frantisek@sumsal.cz>
Mon, 4 Apr 2022 13:58:03 +0000 (15:58 +0200)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Mon, 4 Apr 2022 13:58:03 +0000 (15:58 +0200)
 The original workaround didn't work, as `systemd-repart` kept failing
 even when the `/dev/loopX` device was present:

 ```
 [   13.959419] H testsuite-58.sh[280]: + LOOP=/dev/loop1
 [   13.959636] H testsuite-58.sh[280]: + :
 [   13.959764] H testsuite-58.sh[280]: + test -e /dev/loop1
 [   13.959895] H testsuite-58.sh[280]: + break
 [   13.960023] H testsuite-58.sh[280]: + systemd-repart --pretty=yes --definitions=/tmp/testsuite-58-sector/ --seed=750b6cd5c4ae4012a15e7be3c29e6a47 --empty=require --dry-run=no /dev/loop1
 [   13.970538] H testsuite-58.sh[363]: Device '/dev/loop1' has no dm-crypt/dm-verity device, no need to look for underlying block device.
 [   13.970538] H testsuite-58.sh[363]: Failed to determine canonical path for '/dev/loop1': No such file or directory
 [   13.970538] H testsuite-58.sh[363]: Failed to open file or determine backing device of /dev/loop1: No such file or directory
 ```

test/units/testsuite-58.sh

index cef7d094fd5b0790aacb3fccef31720af7932e0a..21f762d3996c276e2e78e3847e713e4824cf2c28 100755 (executable)
@@ -174,10 +174,7 @@ rm -r /tmp/testsuite-58.3-defs/
 mkdir -p /tmp/testsuite-58-issue-21817-defs/
 truncate -s 100m /var/tmp/testsuite-58-issue-21817.img
 LOOP=$(losetup -P --show -f /var/tmp/testsuite-58-issue-21817.img)
-while : ; do
-    test -e "$LOOP" && break
-    sleep .2
-done
+udevadm wait --timeout 60 --initialized=yes --settle "${LOOP:?}"
 printf 'size=50M,type=%s\n,\n' "${root_guid}" | sfdisk -X gpt "$LOOP"
 cat >/tmp/testsuite-58-issue-21817-defs/test.conf <<EOF
 [Partition]
@@ -219,10 +216,7 @@ EOF
 
     truncate -s 100m "/tmp/testsuite-58-sector-$1.img"
     LOOP=$(losetup -b "$1" -P --show -f "/tmp/testsuite-58-sector-$1.img" )
-    while : ; do
-        test -e "$LOOP" && break
-        sleep .2
-    done
+    udevadm wait --timeout 60 --initialized=yes --settle "${LOOP:?}"
     systemd-repart --pretty=yes --definitions=/tmp/testsuite-58-sector/ --seed=750b6cd5c4ae4012a15e7be3c29e6a47 --empty=require --dry-run=no "$LOOP"
     rm -rf /tmp/testsuite-58-sector
     sfdisk --verify "$LOOP"