]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: wait for loopback device being actually created 22745/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 14 Mar 2022 13:02:37 +0000 (22:02 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 15 Mar 2022 03:35:50 +0000 (12:35 +0900)
It seems there exists a short time period that we cannot see the
loopback device after `losetup` is finished:
```
testsuite-58.sh[367]: ++ losetup -b 1024 -P --show -f /tmp/testsuite-58-sector-1024.img
kernel: loop1: detected capacity change from 0 to 204800
testsuite-58.sh[285]: + LOOP=/dev/loop1
testsuite-58.sh[285]: + systemd-repart --pretty=yes --definitions=/tmp/testsuite-58-sector/ --seed=750b6cd5c4ae4012a15e7be3c29e6a47 --empty=require --dry-run=no /dev/loop1
testsuite-58.sh[368]: Device '/dev/loop1' has no dm-crypt/dm-verity device, no need to look for underlying block device.
testsuite-58.sh[368]: Failed to determine canonical path for '/dev/loop1': No such file or directory
testsuite-58.sh[368]: Failed to open file or determine backing device of /dev/loop1: No such file or directory
```

test/units/testsuite-58.sh

index cc755a4f86dbb7ebc9d0827f8bb96a826b3577b4..cef7d094fd5b0790aacb3fccef31720af7932e0a 100755 (executable)
@@ -174,6 +174,10 @@ 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
 printf 'size=50M,type=%s\n,\n' "${root_guid}" | sfdisk -X gpt "$LOOP"
 cat >/tmp/testsuite-58-issue-21817-defs/test.conf <<EOF
 [Partition]
@@ -215,6 +219,10 @@ 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
     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"