bug-parted
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] tests: root-only test would fail to remove its loop device


From: Jim Meyering
Subject: [PATCH] tests: root-only test would fail to remove its loop device
Date: Mon, 09 Jan 2012 15:30:04 +0100

FYI,

>From b81cf3d3d63c5aaf7422ff689fd665b694351f47 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Mon, 9 Jan 2012 15:29:45 +0100
Subject: [PATCH] tests: root-only test would fail to remove its loop device

* tests/t8001-loop-blkpg.sh: Ironically, when skipping this test,
there was a race condition where in more than 7 out of 10 trials,
this test's "losetup -d $dev" command would fail with "device in use".
Hence, with enough testing, I would eventually use up all loop devices
and start getting new test failures due to losetup *creation* failure.
---
 tests/t8001-loop-blkpg.sh |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/tests/t8001-loop-blkpg.sh b/tests/t8001-loop-blkpg.sh
index cb7ba92..deef18b 100755
--- a/tests/t8001-loop-blkpg.sh
+++ b/tests/t8001-loop-blkpg.sh
@@ -23,7 +23,8 @@ require_udevadm_settle_

 cleanup_fn_()
 {
-  test -n "$loopdev" && losetup -d "$loopdev"
+  test -n "$loopdev" \
+    && { udevadm settle --timeout=3; losetup -d "$loopdev"; }
 }

 # If the loop module is loaded, unload it first
@@ -38,7 +39,7 @@ modprobe loop max_part=7 || fail=1
 dd if=/dev/zero of=backing_file bs=1M count=4 >/dev/null 2>&1 || fail=1

 # Set up loop device on top of backing file
-loopdev=`losetup -f --show backing_file`
+loopdev=$(losetup -f --show backing_file)
 test -z "$loopdev" && fail=1

 require_partitionable_loop_device_ $loopdev
@@ -53,7 +54,7 @@ compare /dev/null err || fail=1     # expect no output
 udevadm settle --timeout=5 || fail=1

 # Verify that the partition appeared in /proc/partitions
-entry=`basename "$loopdev"p1`
+entry=$(basename "$loopdev"p1)
 grep "$entry" /proc/partitions || { cat /proc/partitions; fail=1; }

 # Remove the partition
--
1.7.9.rc0.2.g4b783



reply via email to

[Prev in Thread] Current Thread [Next in Thread]