]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - test
Sort mdstat entries so that composites are well-ordered.
[thirdparty/mdadm.git] / test
diff --git a/test b/test
index dadca13ad216c0876fe332e27ff92f7417511a40..307bfb839f7c0f8be7a9d1386ddfd9a6c89c034c 100644 (file)
--- a/test
+++ b/test
@@ -24,10 +24,12 @@ md0=/dev/md0 md1=/dev/md1 md2=/dev/md2
 
 # We test mdadm on loop-back block devices.
 # dir for storing files should be settable by command line maybe
-targetdir=/tmp
+targetdir=/var/tmp
 size=20000
 mdsize0=19904
 mdsize1=19992
+mdsize11=19996
+mdsize12=19992
 
 cleanup() {
        $mdadm -Ss
@@ -55,21 +57,31 @@ done
 path0=$dev6
 path1=$dev7
 
+if [ " $1" = " setup" ]
+then trap 0 ; exit 0
+fi
 
 # mdadm always adds --quiet, and we want to see any unexpected messages
 mdadm() {
-    $mdadm 2>&1 --quiet "$@"
+    $mdadm --quiet "$@"
 }
 
 # check various things
 check() {
    case $1 in
+    spares )
+       spares=`tr '] ' '\012\012' < /proc/mdstat | grep -c '(S)' || exit 0`
+       if [ $spares -ne $2 ]
+       then
+          echo >&2 "ERROR expected $2 spares, found $spares"; exit 1;
+       fi
+      ;;
     raid* | linear )
       grep -s "active $1 " /proc/mdstat > /dev/null || {
                echo >&2 "ERROR active $1 not found" ; cat /proc/mdstat ; exit 1;}
      ;;
     resync | recovery )
-      sleep 0.1
+      sleep 0.5
       grep -s $1 /proc/mdstat > /dev/null || {
                echo >&2 ERROR no $1 happening; cat /proc/mdstat; exit 1; }
      ;;
@@ -96,7 +108,7 @@ check() {
 
     bitmap )
        grep -s bitmap > /dev/null /proc/mdstat || {
-          echo >&2 ERROR no bitmap ; cat /proc/mdstat ; exist 1; }
+          echo >&2 ERROR no bitmap ; cat /proc/mdstat ; exit 1; }
       ;;
     nobitmap )
        if grep -s "bitmap" > /dev/null /proc/mdstat 
@@ -134,8 +146,10 @@ rotest() {
 
 
 
-for script in tests/$prefix*[^~]
+for script in tests/$prefix tests/$prefix*[^~]
 do
+  if [ -f "$script" ]
+  then
    # source script in a subshell, so it has access to our
    # namespace, but cannot change it.
    if ( set -ex ; . $script )  2> $targetdir/log
@@ -144,5 +158,6 @@ do
         echo "$script failed"
        exit 1
    fi
+  fi
 done
 exit 0