You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
3.9 KiB

From 0d00bd73ba85c18082cbe47dd76e2adeba7e8620 Mon Sep 17 00:00:00 2001
From: "Brian C. Lane" <bcl@redhat.com>
Date: Tue, 1 Mar 2016 10:38:26 -0800
Subject: [PATCH] tests: Add udevadm settle to wait_for_ loop (#1260664)
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/t6002-dm-many-partitions.sh | 1 +
tests/t6003-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 4b3c122..b65d675 100644
--- a/tests/t-lib-helpers.sh
+++ b/tests/t-lib-helpers.sh
@@ -371,6 +371,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
@@ -386,6 +387,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 dde1b8d..5305865 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 b747732..f22c877 100644
--- a/tests/t6001-psep.sh
+++ b/tests/t6001-psep.sh
@@ -20,6 +20,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/t6002-dm-many-partitions.sh b/tests/t6002-dm-many-partitions.sh
index 247c9ee..13894f5 100755
--- a/tests/t6002-dm-many-partitions.sh
+++ b/tests/t6002-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/t6003-dm-uuid.sh b/tests/t6003-dm-uuid.sh
index f58cb06..f51e45f 100755
--- a/tests/t6003-dm-uuid.sh
+++ b/tests/t6003-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 d7e7d6a..a74afe0 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