parted/tests-wait_for_-loop.patch
Sebastian Parschauer 2142b28987 Accepting request 525898 from home:sparschauer:branches:Base:System
- Make SUSE parted pass all tests in upstream test suite
- Fix partition naming for dm devices not ending in a digit and
  also fix resizing of dm partitions (bsc#1056508)

OBS-URL: https://build.opensuse.org/request/show/525898
OBS-URL: https://build.opensuse.org/package/show/Base:System/parted?expand=0&rev=133
2017-09-13 15:19:44 +00:00

120 lines
4.0 KiB
Diff

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
Acked-by: Sebastian Parschauer <sparschauer@suse.de>
---
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 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/t6004-dm-many-partitions.sh b/tests/t6004-dm-many-partitions.sh
index 7ebc48a18db8..01d7fc0da8f3 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 ce1251a9f16a..a48ae727f940 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 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