[parted-devel] [PATCH] tests: Add udevadm settle to wait_for_ loop (#1260664)

Brian C. Lane bcl at redhat.com
Tue Mar 1 21:45:15 UTC 2016


Sometimes the device will vanish after the wait_for_dev_to_appear exits.
Add udevadm settle in an attempt to make sure the udev system is done
flapping around and the device will stay in place.

Related: rhbz#1260664
---
 tests/t-lib-helpers.sh            | 2 ++
 tests/t-local.sh                  | 2 ++
 tests/t6001-psep.sh               | 2 ++
 tests/t6004-dm-many-partitions.sh | 1 +
 tests/t6005-dm-uuid.sh            | 2 ++
 tests/t6100-mdraid-partitions.sh  | 1 +
 6 files changed, 10 insertions(+)

diff --git a/tests/t-lib-helpers.sh b/tests/t-lib-helpers.sh
index c8684bb..9312343 100644
--- a/tests/t-lib-helpers.sh
+++ b/tests/t-lib-helpers.sh
@@ -377,6 +377,7 @@ wait_for_dev_to_appear_()
   local i=0
   local incr=1
   while :; do
+    udevadm settle
     ls "$file" > /dev/null 2>&1 && return 0
     sleep .1 2>/dev/null || { sleep 1; incr=10; }
     i=$(expr $i + $incr); test $i = 20 && break
@@ -392,6 +393,7 @@ wait_for_dev_to_disappear_()
   local i=0
   local incr=1
   while :; do
+    udevadm settle
     ls "$file" > /dev/null 2>&1 || return 0
     sleep .1 2>/dev/null || { sleep 1; incr=10; }
     i=$(expr $i + $incr); test $i -ge $(expr $n_sec \* 10) && break
diff --git a/tests/t-local.sh b/tests/t-local.sh
index b40a5a0..a7d5226 100644
--- a/tests/t-local.sh
+++ b/tests/t-local.sh
@@ -47,6 +47,7 @@ wait_for_dev_to_appear_()
   local i=0
   local incr=1
   while :; do
+    udevadm settle
     ls "$file" > /dev/null 2>&1 && return 0
     sleep .1 2>/dev/null || { sleep 1; incr=10; }
     i=$(expr $i + $incr); test $i = 20 && break
@@ -110,6 +111,7 @@ scsi_debug_setup_()
   local i=0
   local new_dev
   while :; do
+    udevadm settle
     new_dev=$(new_sdX_) && break
     sleep .1 2>/dev/null || { sleep 1; incr=10; }
     i=$(expr $i + $incr); test $i = 20 && break
diff --git a/tests/t6001-psep.sh b/tests/t6001-psep.sh
index 4c758e8..2985cf5 100644
--- a/tests/t6001-psep.sh
+++ b/tests/t6001-psep.sh
@@ -19,6 +19,8 @@
 . "${srcdir=.}/init.sh"; path_prepend_ ../parted
 
 require_root_
+require_udevadm_settle_
+
 (dmsetup --help) > /dev/null 2>&1 || skip_test_ "No dmsetup installed"
 
 # Device maps names - should be random to not conflict with existing ones on
diff --git a/tests/t6004-dm-many-partitions.sh b/tests/t6004-dm-many-partitions.sh
index 7ebc48a..01d7fc0 100755
--- a/tests/t6004-dm-many-partitions.sh
+++ b/tests/t6004-dm-many-partitions.sh
@@ -20,6 +20,7 @@
 . "${srcdir=.}/init.sh"; path_prepend_ ../parted
 
 require_root_
+require_udevadm_settle_
 (dmsetup --help) > /dev/null 2>&1 || skip_test_ "No dmsetup installed"
 
 ss=$sector_size_
diff --git a/tests/t6005-dm-uuid.sh b/tests/t6005-dm-uuid.sh
index ce1251a..a48ae72 100755
--- a/tests/t6005-dm-uuid.sh
+++ b/tests/t6005-dm-uuid.sh
@@ -20,6 +20,7 @@
 . "${srcdir=.}/init.sh"; path_prepend_ ../parted
 
 require_root_
+require_udevadm_settle_
 (dmsetup --help) > /dev/null 2>&1 || skip_test_ "No dmsetup installed"
 
 ss=$sector_size_
@@ -46,6 +47,7 @@ for ((i=1; i<=$n_partitions; i+=1)); do
   cmd="$cmd mkpart p$i ${s}s ${s}s"
 done
 parted -m -a min -s /dev/mapper/$dm_name mklabel gpt $cmd > /dev/null 2>&1 || fail=1
+wait_for_dev_to_appear_ /dev/mapper/${dm_name}p${n_partitions} || fail=1
 
 # Make sure all the partitions have UUIDs
 for ((i=1; i<=$n_partitions; i+=1)); do
diff --git a/tests/t6100-mdraid-partitions.sh b/tests/t6100-mdraid-partitions.sh
index dbc5986..dbb1686 100755
--- a/tests/t6100-mdraid-partitions.sh
+++ b/tests/t6100-mdraid-partitions.sh
@@ -38,6 +38,7 @@ parted -s "$scsi_dev" mklabel gpt \
     mkpart p1 ext2 1M 4M \
     mkpart p2 ext2 5M 8M > out 2>&1 || fail=1
 compare /dev/null out || fail=1
+wait_for_dev_to_appear_ ${scsi_dev}2 || { fail=1; cat /proc/partitions; }
 
 cleanup_fn_() {
   # stop mdraid array
-- 
2.5.0




More information about the parted-devel mailing list