[parted-devel] [PATCH 5/5] Try harder to clean up scsi_debug

Jim Meyering jim at meyering.net
Tue Jan 3 08:21:57 UTC 2012


Phillip Susi wrote:
> Tests were failing because the previous test gave up while trying to unload
> the scsi_debug module.  Try longer to remove it, and then throw in a call
> to udevadm settle for good measure.
>
> Signed-off-by: Phillip Susi <psusi at cfl.rr.com>
> ---
>  tests/t-local.sh               |    6 +++++-
>  tests/t9040-many-partitions.sh |   12 ------------
>  2 files changed, 5 insertions(+), 13 deletions(-)

Thanks.  I've had to modify this somewhat.
Since any use of scsi_debug now requires udevadm,
we need to move the require_udevadm_settle_ from
individual tests into the scsi_debug set-up code:

diff --git a/tests/t-local.sh b/tests/t-local.sh
index 1decb4d..dde1b8d 100644
--- a/tests/t-local.sh
+++ b/tests/t-local.sh
@@ -6,6 +6,7 @@ scsi_debug_lock_dir_="$abs_srcdir/scsi_debug.lock"

 require_scsi_debug_module_()
 {
+  require_udevadm_settle_
   # check for scsi_debug module
   modprobe -n scsi_debug ||
     skip_ "you lack the scsi_debug kernel module"

Also, I've adjusted subject and log, and reformatted to fit
within 72-column lines.


>From 9caea81516d829fcf41d594b937d86f132b21554 Mon Sep 17 00:00:00 2001
From: Phillip Susi <phillsusi at gmail.com>
Date: Mon, 2 Jan 2012 20:12:42 -0500
Subject: [PATCH] tests: try harder to clean up scsi_debug

Tests were failing because the previous test gave up while trying to
unload the scsi_debug module.  Try longer to remove it, and then throw
in a call to udevadm settle for good measure.
* tests/t-local.sh: Try harder to release resources here, rather than...
* tests/t9040-many-partitions.sh: ...in this one test.
* tests/t-local.sh (require_scsi_debug_module_): Now that
cleanup requires "udevadm settle", add that requirement here:
call require_udevadm_settle_.
---
 tests/t-local.sh               |    7 ++++++-
 tests/t9040-many-partitions.sh |   12 ------------
 2 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/tests/t-local.sh b/tests/t-local.sh
index 159cc62..dde1b8d 100644
--- a/tests/t-local.sh
+++ b/tests/t-local.sh
@@ -6,6 +6,7 @@ scsi_debug_lock_dir_="$abs_srcdir/scsi_debug.lock"

 require_scsi_debug_module_()
 {
+  require_udevadm_settle_
   # check for scsi_debug module
   modprobe -n scsi_debug ||
     skip_ "you lack the scsi_debug kernel module"
@@ -24,11 +25,15 @@ scsi_debug_cleanup_()
     # We have to insist.  Otherwise, a single rmmod usually fails to remove it,
     # due either to "Resource temporarily unavailable" or to
     # "Module scsi_debug is in use".
-    for i in 1 2 3; do
+    i=0
+    udevadm settle
+    while [ $i -lt 10 ] ; do
       rmmod scsi_debug \
 	&& { test "$VERBOSE" = yes && warn_ $ME_ rmmod scsi_debug...; break; }
       sleep .2 || sleep 1
+      i=$((i + 1))
     done
+    udevadm settle
   fi
   rm -fr $scsi_debug_lock_dir_
 }
diff --git a/tests/t9040-many-partitions.sh b/tests/t9040-many-partitions.sh
index bd82fb9..c77628c 100644
--- a/tests/t9040-many-partitions.sh
+++ b/tests/t9040-many-partitions.sh
@@ -68,16 +68,4 @@ $AWK "BEGIN {d = $t_final - $t0; n = $n_partitions; st = 60 < d;"\
 parted -m -s $scsi_dev u s p > out || fail=1
 compare exp out || fail=1

-# We must remove these partitions before terminating.
-# Otherwise, even though cleanup-driven rmmod will eventually cause
-# them to be removed, they may continue to be removed long after
-# the rmmod cleanup lock has been released, and such removals
-# can (and regularly did) interfere with the following test.
-i=1
-while :; do
-    parted -s $scsi_dev rm $i || fail=1
-    test $i = $n_partitions && break
-    i=$((i+1))
-done
-
 Exit $fail
--
1.7.8.1.391.g2c2ad



More information about the parted-devel mailing list