linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Test suite enhancements
@ 2012-05-22 16:55 Jes.Sorensen
  2012-05-22 16:55 ` [PATCH 1/2] Check for multipath module before running multipath tests Jes.Sorensen
  2012-05-22 16:55 ` [PATCH 2/2] Add command line argument parsing to 'test' sript Jes.Sorensen
  0 siblings, 2 replies; 4+ messages in thread
From: Jes.Sorensen @ 2012-05-22 16:55 UTC (permalink / raw)
  To: neilb; +Cc: linux-raid

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Hi,

Two fixes for the testsuite. The first is just to allow it to run on
systems which do not include the multipath module. The second adds
command line arguments to 'test'. In particular it makes it possible
to specify explicit tests to run. I believe I managed to preserve the
behavior for old style arguments.

Cheers,
Jes


Jes Sorensen (2):
  Check for multipath module before running multipath tests
  Add command line argument parsing to 'test' sript

 test              |   94 ++++++++++++++++++++++++++++++++++++++++-------------
 tests/00multipath |    5 +++
 2 files changed, 76 insertions(+), 23 deletions(-)

-- 
1.7.7.6


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] Check for multipath module before running multipath tests
  2012-05-22 16:55 [PATCH 0/2] Test suite enhancements Jes.Sorensen
@ 2012-05-22 16:55 ` Jes.Sorensen
  2012-05-22 16:55 ` [PATCH 2/2] Add command line argument parsing to 'test' sript Jes.Sorensen
  1 sibling, 0 replies; 4+ messages in thread
From: Jes.Sorensen @ 2012-05-22 16:55 UTC (permalink / raw)
  To: neilb; +Cc: linux-raid

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Some systems do not ship the md multipath module. If not available
simply skip any multipath tests.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
 test              |    6 ++++++
 tests/00multipath |    5 +++++
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/test b/test
index 4f0979e..0679983 100755
--- a/test
+++ b/test
@@ -19,6 +19,12 @@ then
    echo >&2 "test: $mdadm isn't usable."
 fi
 
+# Check whether to run multipath tests
+modprobe multipath 2> /dev/null
+if grep -s 'Personalities : .*multipath' > /dev/null /proc/mdstat ; then
+    MULTIPATH="yes"
+fi
+
 # assume md0, md1, md2 exist in /dev
 md0=/dev/md0 md1=/dev/md1 md2=/dev/md2
 mdp0=/dev/md_d0
diff --git a/tests/00multipath b/tests/00multipath
index bc0429f..84e4d69 100644
--- a/tests/00multipath
+++ b/tests/00multipath
@@ -2,6 +2,11 @@
 #
 # create a multipath, and fail and stuff
 
+if [ "$MULTIPATH" != "yes" ]; then
+  echo -ne 'skipping... '
+  exit 0
+fi
+
 mdadm -CR $md1 -l multipath -n2 $path0 $path1
 
 testdev $md1 1 $mdsize12 1
-- 
1.7.7.6


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] Add command line argument parsing to 'test' sript
  2012-05-22 16:55 [PATCH 0/2] Test suite enhancements Jes.Sorensen
  2012-05-22 16:55 ` [PATCH 1/2] Check for multipath module before running multipath tests Jes.Sorensen
@ 2012-05-22 16:55 ` Jes.Sorensen
  2012-05-23  3:39   ` NeilBrown
  1 sibling, 1 reply; 4+ messages in thread
From: Jes.Sorensen @ 2012-05-22 16:55 UTC (permalink / raw)
  To: neilb; +Cc: linux-raid

From: Jes Sorensen <Jes.Sorensen@redhat.com>

This adds more generic command line argument parsing to the test
script. It also introduces a couple of new options, while preserving
the old '<prefix>' and 'setup' arguments. The new options are
--disable-multipath and --tests=<test1>,<test2>,...

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
 test |   88 ++++++++++++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 65 insertions(+), 23 deletions(-)

diff --git a/test b/test
index 0679983..9428b20 100755
--- a/test
+++ b/test
@@ -8,9 +8,6 @@ then echo >&2 "test: testing can only be done as 'root'."
 fi
 
 prefix='[0-9][0-9]'
-if [ -n "$1" ]
-then prefix=$1
-fi
 
 dir=`pwd`
 mdadm=$dir/mdadm
@@ -94,10 +91,6 @@ ulimit -c unlimited
 echo 2000 > /proc/sys/dev/raid/speed_limit_max
 echo 0 > /sys/module/md_mod/parameters/start_ro
 
-if [ " $1" = " setup" ]
-then trap 0 ; exit 0
-fi
-
 # mdadm always adds --quiet, and we want to see any unexpected messages
 mdadm() {
     rm -f $targetdir/stderr
@@ -209,23 +202,72 @@ rotest() {
   fsck -fn $dev >&2
 }
 
-for script in tests/$prefix tests/$prefix*[^~]
-do
-  if [ -f "$script" ]
+do_test() {
+  _script=$1
+  if [ -f "$_script" ]
   then
-   rm -f $targetdir/stderr
-   # stop all arrays, just incase some script left an array active.
-   $mdadm -Ssq 2> /dev/null
-   mdadm --zero $devlist 2> /dev/null
-   mdadm --zero $devlist 2> /dev/null
-   # source script in a subshell, so it has access to our
-   # namespace, but cannot change it.
-   echo -ne "$script... "
-   if ( set -ex ; . $script )  2> $targetdir/log
-   then echo "succeeded"
-   else echo "FAILED - see $targetdir/log for details"
-       exit 1
-   fi
+    rm -f $targetdir/stderr
+    # stop all arrays, just incase some script left an array active.
+    $mdadm -Ssq 2> /dev/null
+    mdadm --zero $devlist 2> /dev/null
+    mdadm --zero $devlist 2> /dev/null
+    # source script in a subshell, so it has access to our
+    # namespace, but cannot change it.
+    echo -ne "$_script... "
+    if ( set -ex ; . $_script )  2> $targetdir/log
+    then echo "succeeded"
+    else echo "FAILED - see $targetdir/log for details"
+      exit 1
+    fi
   fi
+}
+
+do_help() {
+  echo "Usage: "
+  echo " $0 [--tests=<test1,test2,..>] [--disable-multipath] [setup] [prefix]"
+}
+
+parse_args() {
+  for i in $*
+  do
+    case $i in
+    [0-9][0-9])
+      prefix=$i
+      ;;      
+    setup)
+      echo "mdadm test environment setup"
+      trap 0; exit 0
+      ;;
+    --tests=*)
+      TESTLIST=`expr "x$i" : 'x[^=]*=\(.*\)' | sed -e 's/,/ /g'`
+      ;;
+    --disable-multipath)
+      unset MULTIPATH
+      ;;
+    --help)
+      do_help
+      exit 0;
+      ;;
+    -*)
+      echo " $0: Unknown argument: $i"
+      do_help
+      exit 0;
+      ;;
+    esac
 done
+}
+
+parse_args $@
+
+if [ "x$TESTLIST" != "x" ]; then
+  for script in $TESTLIST
+  do
+    do_test tests/$script
+  done
+else
+  for script in tests/$prefix tests/$prefix*[^~]
+  do
+    do_test $script
+  done
+fi
 exit 0
-- 
1.7.7.6


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] Add command line argument parsing to 'test' sript
  2012-05-22 16:55 ` [PATCH 2/2] Add command line argument parsing to 'test' sript Jes.Sorensen
@ 2012-05-23  3:39   ` NeilBrown
  0 siblings, 0 replies; 4+ messages in thread
From: NeilBrown @ 2012-05-23  3:39 UTC (permalink / raw)
  To: Jes.Sorensen; +Cc: linux-raid

[-- Attachment #1: Type: text/plain, Size: 3777 bytes --]

On Tue, 22 May 2012 18:55:30 +0200 Jes.Sorensen@redhat.com wrote:

> From: Jes Sorensen <Jes.Sorensen@redhat.com>
> 
> This adds more generic command line argument parsing to the test
> script. It also introduces a couple of new options, while preserving
> the old '<prefix>' and 'setup' arguments. The new options are
> --disable-multipath and --tests=<test1>,<test2>,...
> 
> Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
> ---
>  test |   88 ++++++++++++++++++++++++++++++++++++++++++++++++-----------------
>  1 files changed, 65 insertions(+), 23 deletions(-)
> 
> diff --git a/test b/test
> index 0679983..9428b20 100755
> --- a/test
> +++ b/test
> @@ -8,9 +8,6 @@ then echo >&2 "test: testing can only be done as 'root'."
>  fi
>  
>  prefix='[0-9][0-9]'
> -if [ -n "$1" ]
> -then prefix=$1
> -fi
>  
>  dir=`pwd`
>  mdadm=$dir/mdadm
> @@ -94,10 +91,6 @@ ulimit -c unlimited
>  echo 2000 > /proc/sys/dev/raid/speed_limit_max
>  echo 0 > /sys/module/md_mod/parameters/start_ro
>  
> -if [ " $1" = " setup" ]
> -then trap 0 ; exit 0
> -fi
> -
>  # mdadm always adds --quiet, and we want to see any unexpected messages
>  mdadm() {
>      rm -f $targetdir/stderr
> @@ -209,23 +202,72 @@ rotest() {
>    fsck -fn $dev >&2
>  }
>  
> -for script in tests/$prefix tests/$prefix*[^~]
> -do
> -  if [ -f "$script" ]
> +do_test() {
> +  _script=$1
> +  if [ -f "$_script" ]
>    then
> -   rm -f $targetdir/stderr
> -   # stop all arrays, just incase some script left an array active.
> -   $mdadm -Ssq 2> /dev/null
> -   mdadm --zero $devlist 2> /dev/null
> -   mdadm --zero $devlist 2> /dev/null
> -   # source script in a subshell, so it has access to our
> -   # namespace, but cannot change it.
> -   echo -ne "$script... "
> -   if ( set -ex ; . $script )  2> $targetdir/log
> -   then echo "succeeded"
> -   else echo "FAILED - see $targetdir/log for details"
> -       exit 1
> -   fi
> +    rm -f $targetdir/stderr
> +    # stop all arrays, just incase some script left an array active.
> +    $mdadm -Ssq 2> /dev/null
> +    mdadm --zero $devlist 2> /dev/null
> +    mdadm --zero $devlist 2> /dev/null
> +    # source script in a subshell, so it has access to our
> +    # namespace, but cannot change it.
> +    echo -ne "$_script... "
> +    if ( set -ex ; . $_script )  2> $targetdir/log
> +    then echo "succeeded"
> +    else echo "FAILED - see $targetdir/log for details"
> +      exit 1
> +    fi
>    fi
> +}
> +
> +do_help() {
> +  echo "Usage: "
> +  echo " $0 [--tests=<test1,test2,..>] [--disable-multipath] [setup] [prefix]"
> +}
> +
> +parse_args() {
> +  for i in $*
> +  do
> +    case $i in
> +    [0-9][0-9])

I changed that to
       [0-9]*)
so that I can
   sh test 0
to avoid 10 and 11, or
   sh test 02r1
to just run the raid1 tests from 02.

> +      prefix=$i
> +      ;;      

I removed the trailing spaces here :-)

But with just those fixes I've applied both patches,
Thanks,
NeilBrown


> +    setup)
> +      echo "mdadm test environment setup"
> +      trap 0; exit 0
> +      ;;
> +    --tests=*)
> +      TESTLIST=`expr "x$i" : 'x[^=]*=\(.*\)' | sed -e 's/,/ /g'`
> +      ;;
> +    --disable-multipath)
> +      unset MULTIPATH
> +      ;;
> +    --help)
> +      do_help
> +      exit 0;
> +      ;;
> +    -*)
> +      echo " $0: Unknown argument: $i"
> +      do_help
> +      exit 0;
> +      ;;
> +    esac
>  done
> +}
> +
> +parse_args $@
> +
> +if [ "x$TESTLIST" != "x" ]; then
> +  for script in $TESTLIST
> +  do
> +    do_test tests/$script
> +  done
> +else
> +  for script in tests/$prefix tests/$prefix*[^~]
> +  do
> +    do_test $script
> +  done
> +fi
>  exit 0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-05-23  3:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-22 16:55 [PATCH 0/2] Test suite enhancements Jes.Sorensen
2012-05-22 16:55 ` [PATCH 1/2] Check for multipath module before running multipath tests Jes.Sorensen
2012-05-22 16:55 ` [PATCH 2/2] Add command line argument parsing to 'test' sript Jes.Sorensen
2012-05-23  3:39   ` NeilBrown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).