Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-15:Update
parted
tests-use-wait_for_dev_to_-functions.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File tests-use-wait_for_dev_to_-functions.patch of Package parted
From: "Brian C. Lane" <bcl@redhat.com> Date: Fri, 7 Aug 2015 11:43:17 -0700 Subject: tests: Use wait_for_dev_to_ functions For: upstream code Patch-mainline: v3.3 Git-commit: db1728e6402a27fe64e8e132f810c22160ab8bcc Recent changes to udev have made some long-standing problems appear more frequently. udev executes various actions when changes are made to devices. Sometimes this can result in device nodes not appearing immediately. Other times it can result in EBUSY being returned. This patch only addresses devices that are slow to appear/disappear. It is best to use the wait_for_dev_to_appear_ and wait_for_dev_to_disappear_ functions than to test for existance. These will loop and wait for up to 2 seconds for it to appear. This also changes t9041 to fail if mkfs doesn't work since using skip here may hide cases when the device node doesn't appear. [sparschauer: remove hunks for non-existing tests] Signed-off-by: Sebastian Parschauer <sparschauer@suse.de> --- tests/t1100-busy-label.sh | 10 ++-------- tests/t1102-loop-label.sh | 25 +++++-------------------- tests/t2320-dos-extended-noclobber.sh | 1 + tests/t6001-psep.sh | 4 ++-- tests/t6004-dm-many-partitions.sh | 6 ++---- tests/t6006-dm-512b-sectors.sh | 1 + tests/t6100-mdraid-partitions.sh | 5 +++-- tests/t9041-undetected-in-use-16th-partition.sh | 2 +- 8 files changed, 17 insertions(+), 37 deletions(-) diff --git a/tests/t1100-busy-label.sh b/tests/t1100-busy-label.sh index 4e256d32a010..70e8edec8a60 100755 --- a/tests/t1100-busy-label.sh +++ b/tests/t1100-busy-label.sh @@ -27,22 +27,16 @@ dev=$(cat dev-name) parted -s "$dev" mklabel msdos mkpart primary fat32 1 40 > out 2>&1 || fail=1 compare /dev/null out || fail=1 -mkfs.vfat ${dev}1 || skip_ "mkfs.vfat failed" +wait_for_dev_to_appear_ ${dev}1 || fail=1 +mkfs.vfat ${dev}1 || fail=1 mount_point="`pwd`/mnt" # Be sure to unmount upon interrupt, failure, etc. cleanup_fn_() { umount "${dev}1" > /dev/null 2>&1; } -# There's a race condition here: on udev-based systems, the partition#1 -# device, ${dev}1 (i.e., /dev/sdd1) is not created immediately, and -# without some delay, this mount command would fail. Using a flash card -# as $dev, the loop below typically iterates 7-20 times. - # create mount point dir. and mount the just-created partition on it mkdir $mount_point || fail=1 -i=0; while :; do test -e "${dev}1" && break; test $i = 90 && break; - i=$(expr $i + 1); done; mount "${dev}1" $mount_point || fail=1 # now that a partition is mounted, mklabel attempt must fail diff --git a/tests/t1102-loop-label.sh b/tests/t1102-loop-label.sh index 97520021004d..68b9af45b428 100644 --- a/tests/t1102-loop-label.sh +++ b/tests/t1102-loop-label.sh @@ -44,15 +44,9 @@ mv out o2 && sed -e "s,$dev,DEVICE,;s/ *$//" o2 > out compare exp out || fail=1 parted -s $dev rm 1 || fail=1 -if [ -e ${dev}1 ]; then - echo "Partition should not exist on loop device" - fail=1 -fi +wait_for_dev_to_disappear_ ${dev}1 2 || fail=1 partprobe $dev || fail=1 -if [ -e ${dev}1 ]; then - echo "Partition should not exist on loop device" - fail=1 -fi +wait_for_dev_to_disappear_ ${dev}1 2 || fail=1 mount_point="`pwd`/mnt" @@ -80,24 +74,15 @@ umount "$mount_point" # make sure partprobe cleans up stale partition devices parted -s $dev mklabel msdos mkpart primary ext2 0% 100% || fail=1 -if [ ! -e ${dev}1 ]; then - echo "Partition doesn't exist on loop device" - fail=1 -fi +wait_for_dev_to_appear_ ${dev}1 || fail=1 mke2fs -F $dev partprobe $dev || fail=1 -if [ -e ${dev}1 ]; then - echo "Partition should not exist on loop device" - fail=1 -fi +wait_for_dev_to_disappear_ ${dev}1 2 || fail=1 # make sure new loop label removes old partitions > 1 parted -s $dev mklabel msdos mkpart primary ext2 0% 50% mkpart primary ext2 50% 100% || fail=1 parted -s $dev mklabel loop || fail=1 -if [ -e ${dev}2 ]; then - echo "Partition 2 not removed" - fail=1 -fi +wait_for_dev_to_disappear_ ${dev}2 2 || fail=1 Exit $fail diff --git a/tests/t6001-psep.sh b/tests/t6001-psep.sh index f15090abb3e7..4c758e8fbc73 100644 --- a/tests/t6001-psep.sh +++ b/tests/t6001-psep.sh @@ -54,7 +54,7 @@ parted -s $dev mklabel msdos mkpart primary fat32 1m 5m > out 2>&1 || fail=1 compare /dev/null out || fail=1 #make sure device name is correct -test -e ${dev}p1 || fail=1 +wait_for_dev_to_appear_ ${dev}p1 || fail=1 #repeat on name not ending in a digit # setup: create a mapping @@ -66,7 +66,7 @@ parted -s $dev mklabel msdos mkpart primary fat32 1m 5m > out 2>&1 || fail=1 compare /dev/null out || fail=1 #make sure device name is correct -test -e ${dev}1 || fail=1 +wait_for_dev_to_appear_ ${dev}1 || fail=1 if [ -n "$fail" ]; then ls /dev/mapper diff --git a/tests/t6004-dm-many-partitions.sh b/tests/t6004-dm-many-partitions.sh index 8d291ef55664..7ebc48a18db8 100755 --- a/tests/t6004-dm-many-partitions.sh +++ b/tests/t6004-dm-many-partitions.sh @@ -49,10 +49,8 @@ parted -m -a min -s /dev/mapper/$dm_name mklabel gpt $cmd > /dev/null 2>&1 || fa # Make sure all the partitions appeared under /dev/mapper/ for ((i=1; i<=$n_partitions; i+=1)); do - if [ ! -e "/dev/mapper/${dm_name}p$i" ]; then - fail=1 - break - fi + wait_for_dev_to_appear_ "/dev/mapper/${dm_name}p$i" || { fail=1; break; } + # remove the partitions as we go, otherwise cleanup won't work. dmsetup remove /dev/mapper/${dm_name}p$i done diff --git a/tests/t6100-mdraid-partitions.sh b/tests/t6100-mdraid-partitions.sh index 6f08442dd66d..dbc5986b9019 100755 --- a/tests/t6100-mdraid-partitions.sh +++ b/tests/t6100-mdraid-partitions.sh @@ -54,13 +54,14 @@ parted -s $md_dev mklabel gpt \ compare /dev/null out || fail=1 # Verify that kernel has been informed about the second device. -grep "${md_name}p2" /proc/partitions || { fail=1; cat /proc/partitions; } +wait_for_dev_to_appear_ ${md_dev}p2 || { fail=1; cat /proc/partitions; } # Remove partitions from the raid device. parted -s $md_dev rm 2 rm 1 > out 2>&1 || fail=1 compare /dev/null out || fail=1 # Verify that kernel has been informed about those removals. -grep "${md_name}p[12]" /proc/partitions && { fail=1; cat /proc/partitions; } +wait_for_dev_to_disappear_ ${md_dev}p1 2 || { fail=1; cat /proc/partitions; } +wait_for_dev_to_disappear_ ${md_dev}p2 2 || { fail=1; cat /proc/partitions; } Exit $fail diff --git a/tests/t9041-undetected-in-use-16th-partition.sh b/tests/t9041-undetected-in-use-16th-partition.sh index edaae1bf8116..673e508319a3 100644 --- a/tests/t9041-undetected-in-use-16th-partition.sh +++ b/tests/t9041-undetected-in-use-16th-partition.sh @@ -72,7 +72,7 @@ wait_for_dev_to_appear_ ${scsi_dev}16 || fail_ ${scsi_dev}16 did not appear partitions="${scsi_dev}14 ${scsi_dev}15 ${scsi_dev}16" for i in $partitions; do - mkfs.ext3 $i || skip_ mkfs.ext3 $i failed + mkfs.ext3 $i || fail=1 done # be sure to unmount upon interrupt, failure, etc.
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor