[parted-devel] [PATCH 12/14] Simplify t6001-dm-ignoremd.sh

Joel Granados Moreno jgranado at redhat.com
Fri Jun 5 12:14:19 UTC 2009


* Use functions in lvm-utils.sh for mdadm commands.
* Move mddev_ to the top of the file.
* Erase unneeded comment.
---
 tests/t6001-dm-ignoremd.sh |   26 ++++----------------------
 1 files changed, 4 insertions(+), 22 deletions(-)

diff --git a/tests/t6001-dm-ignoremd.sh b/tests/t6001-dm-ignoremd.sh
index 4fd9763..449d177 100755
--- a/tests/t6001-dm-ignoremd.sh
+++ b/tests/t6001-dm-ignoremd.sh
@@ -18,12 +18,13 @@
 test_description='Ignore devices that start with md from /sys/block.'
 
 privileges_required_=1
-# This will setup private /dev and /etc
 device_mapper_required_=1
 
 : ${srcdir=.}
 . $srcdir/test-lib.sh
 
+mddev_=
+
 test "x$ENABLE_DEVICE_MAPPER" = xyes ||
   {
     say "skipping $0: no device-mapper support"
@@ -38,45 +39,26 @@ test -d /sys/block ||
     exit
   }
 
-which mdadm > /dev/null 2>&1 ||
+mdadm_exists_ ||
   {
     say "skipping $0: could not find mdadm executable"
     test_done
     exit
   }
 
-# The md device.
-mddev_=
-
 cleanup_() {
     mdadm --stop $mddev_ > /dev/null 2>&1
     test -n "$d1" && losetup -d "$d1"
     rm -f "$f1";
 }
 
-md_dev_create_()
-{
-  lo_dev=$1
-  mdd=$G_dev_/md0
-  for i in 0 1 2 3 4 5 6 7 8 9 ; do
-      mdd=$G_dev_/md$i
-      mdadm  --create --force $mdd --level=linear --raid-devices=1 $lo_dev > /dev/null 2>&1 \
-      && break
-
-      if [ $i -eq 9 ]; then echo $mdd ; return 1 ; fi
-  done
-
-  echo $mdd
-  return 0
-}
-
 test_expect_success \
     'setup: create loop devices' \
     'f1=$(pwd)/1 && d1=$(loop_setup_ "$f1")'
 
 test_expect_success \
     'setup: create md# device' \
-    'mddev_=$(md_dev_create_ "$d1")'
+    'mddev_=$(mdadm_create_linear_device_ "$d1")'
 
 test_expect_failure \
     'grep for the created md device' \
-- 
1.6.0.6




More information about the parted-devel mailing list