1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-27 18:55:40 +03:00

test: wait for loopback device being actually created

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
```
This commit is contained in:
Yu Watanabe 2022-03-14 22:02:37 +09:00
parent 8c166c962d
commit 6626ea08f6

View File

@ -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"