[Parted-commits] GNU Parted Official Repository: Changes to 'master'

Jim Meyering meyering at alioth.debian.org
Thu Jun 11 09:57:46 UTC 2009


 tests/t6001-dm-ignoremd.sh |   33 +++++----------------------------
 tests/test-lib.sh          |   29 +++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 28 deletions(-)

New commits:
commit ebb2720c5dc4ae50f41b137cf2a2826e4ccbacce
Author: Joel Granados Moreno <jgranado at redhat.com>
Date:   Wed Jun 10 19:05:53 2009 +0200

    tests: simplify t6001-dm-ignoremd.sh
    
    * tests/t6001-dm-ignoremd.sh (md_dev_create_): Use functions in
    test-util.sh for mdadm commands.  Move mddev_ to the top of the
    file.  Remove unneeded comment.

diff --git a/tests/t6001-dm-ignoremd.sh b/tests/t6001-dm-ignoremd.sh
index 4fd9763..6a3f205 100755
--- a/tests/t6001-dm-ignoremd.sh
+++ b/tests/t6001-dm-ignoremd.sh
@@ -18,12 +18,15 @@
 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
 
+require_mdadm_
+
+mddev_=
+
 test "x$ENABLE_DEVICE_MAPPER" = xyes ||
   {
     say "skipping $0: no device-mapper support"
@@ -38,45 +41,19 @@ test -d /sys/block ||
     exit
   }
 
-which mdadm > /dev/null 2>&1 ||
-  {
-    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' \

commit 1fd0465cb1042c4934807396aa35449b9552c925
Author: Joel Granados Moreno <jgranado at redhat.com>
Date:   Wed Jun 10 19:05:54 2009 +0200

    tests: add mdadm specific functions
    
    * tests/test-lib.sh (require_mdadm_): New function.
    (mdadm_create_linear_device_): New function.

diff --git a/tests/test-lib.sh b/tests/test-lib.sh
index 7fa81ce..a144a11 100644
--- a/tests/test-lib.sh
+++ b/tests/test-lib.sh
@@ -317,3 +317,32 @@ elif ( cmp --version < /dev/null 2>&1 | grep GNU ) 2>&1 > /dev/null; then
 else
   compare() { cmp "$@"; }
 fi
+
+require_mdadm_()
+{
+  ( mdadm --version ) > /dev/null 2>&1 ||
+    {
+      say "skipping $0: could not find mdadm executable"
+      test_done
+      exit
+    }
+}
+
+# Will look for an md number that is not in use and create a md device with
+# that number.  If the system has more than 9 md devices, it will fail.
+mdadm_create_linear_device_()
+{
+  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
+}



More information about the Parted-commits mailing list