File tests-wait_for_-loop.patch of Package parted.30108

From: "Brian C. Lane" <bcl@redhat.com>
Date: Tue, 1 Mar 2016 10:38:26 -0800
Subject: tests: Add udevadm settle to wait_for_ loop (#1260664)
For: upstream code
Patch-mainline: v3.3
Git-commit: f5cc84cdb5a607449c339cad50fe8be5dd77eb6c

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
[sparschauer: Removed hunks for not existing tests]
Acked-by: Sebastian Parschauer <sparschauer@suse.de>
---
 tests/t-lib-helpers.sh            | 2 ++
 tests/t-local.sh                  | 2 ++
 tests/t6001-psep.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 c8684bbd264e..93123432922b 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 b40a5a0ebbf5..a7d5226a3956 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 4c758e8fbc73..2985cf5e7d0e 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/t6100-mdraid-partitions.sh b/tests/t6100-mdraid-partitions.sh
index dbc5986b9019..dbb16861f9f3 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
openSUSE Build Service is sponsored by