From 3452ae90ea385f2d8a96f7263b980da49d9b36cc Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 6 Apr 2022 21:42:44 +0900 Subject: [PATCH 1/3] test: --initialized=yes is the default for udevadm wait --- src/partition/test-repart.sh | 2 +- test/units/testsuite-58.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/partition/test-repart.sh b/src/partition/test-repart.sh index 88b696ba015..89f62665391 100755 --- a/src/partition/test-repart.sh +++ b/src/partition/test-repart.sh @@ -201,7 +201,7 @@ $D/zzz7 : start= 6291416, size= 98304, type=0FC63DAF-8483-4772-8E79-3D EOF LOOP="$(losetup -P --show --find "$D/zzz")" - "${udevadm:?}" wait --timeout 60 --initialized=yes --settle "${LOOP:?}" + "${udevadm:?}" wait --timeout 60 --settle "${LOOP:?}" VOLUME="test-repart-$RANDOM" diff --git a/test/units/testsuite-58.sh b/test/units/testsuite-58.sh index 21f762d3996..98b31277f0c 100755 --- a/test/units/testsuite-58.sh +++ b/test/units/testsuite-58.sh @@ -174,7 +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) -udevadm wait --timeout 60 --initialized=yes --settle "${LOOP:?}" +udevadm wait --timeout 60 --settle "${LOOP:?}" printf 'size=50M,type=%s\n,\n' "${root_guid}" | sfdisk -X gpt "$LOOP" cat >/tmp/testsuite-58-issue-21817-defs/test.conf < Date: Thu, 7 Apr 2022 01:35:26 +0900 Subject: [PATCH 2/3] test: use udevadm lock when partitioning block devices We can use `sfdisk --lock` for these cases, but some CI environments have old sfdisk which does not support `--lock` option. --- test/units/testsuite-64.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/units/testsuite-64.sh b/test/units/testsuite-64.sh index 44f362ec6f3..5f50131dd5d 100755 --- a/test/units/testsuite-64.sh +++ b/test/units/testsuite-64.sh @@ -168,7 +168,7 @@ $(printf 'name="test%d", size=2M\n' {1..50}) EOF # Initial partition table - sfdisk -q -X gpt "$blockdev" <"$partscript" + udevadm lock --device="$blockdev" sfdisk -q -X gpt "$blockdev" <"$partscript" # Delete the partitions, immediately recreate them, wait for udev to settle # down, and then check if we have any dangling symlinks in /dev/disk/. Rinse @@ -177,8 +177,8 @@ EOF # On unpatched udev versions the delete-recreate cycle may trigger a race # leading to dead symlinks in /dev/disk/ for i in {1..100}; do - sfdisk -q --delete "$blockdev" - sfdisk -q -X gpt "$blockdev" <"$partscript" + udevadm lock --device="$blockdev" sfdisk -q --delete "$blockdev" + udevadm lock --device="$blockdev" sfdisk -q -X gpt "$blockdev" <"$partscript" if ((i % 10 == 0)); then udevadm wait --settle --timeout=30 "$blockdev" @@ -281,7 +281,7 @@ testcase_btrfs_basic() { echo "Multiple devices: using partitions, data: single, metadata: raid1" uuid="deadbeef-dead-dead-beef-000000000001" label="btrfs_mpart" - sfdisk --wipe=always "${devices[0]}" < Date: Thu, 7 Apr 2022 01:39:20 +0900 Subject: [PATCH 3/3] test: drop unnecessary use of loop device To avoid inferences with udevd. --- test/units/testsuite-58.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/test/units/testsuite-58.sh b/test/units/testsuite-58.sh index 98b31277f0c..8dadcc0a958 100755 --- a/test/units/testsuite-58.sh +++ b/test/units/testsuite-58.sh @@ -173,20 +173,22 @@ rm -r /tmp/testsuite-58.3-defs/ # testcase for #21817 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) -udevadm wait --timeout 60 --settle "${LOOP:?}" -printf 'size=50M,type=%s\n,\n' "${root_guid}" | sfdisk -X gpt "$LOOP" +sfdisk /var/tmp/testsuite-58-issue-21817.img </tmp/testsuite-58-issue-21817-defs/test.conf <