]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - test
FIX: resolve make everything compilation error
[thirdparty/mdadm.git] / test
diff --git a/test b/test
old mode 100644 (file)
new mode 100755 (executable)
index 9ceb531..1aaf3c1
--- a/test
+++ b/test
@@ -34,25 +34,40 @@ mdsize0=19904
 mdsize00=19840
 # super1.0 round down to multiple of 2, subtract 8
 mdsize1=19992
+mdsize1a=19988
+mdsize12=19988
+# super1.2 for linear: round to multiple of 2, subtract 4
+mdsize1_l=18976
+mdsize2_l=18976
 # subtract another 4 for bitmaps
 mdsize1b=19988
 mdsize11=19992
+mdsize11a=18944
 mdsize12=19988
 
+# ddf needs bigger devices as 32Meg is reserved!
+ddfsize=65536
+
+config=/tmp/mdadm.conf
+
 cleanup() {
-       $mdadm -Ss
-       for d in 0 1 2 3 4 5 6 7
+       udevadm settle
+       $mdadm -Ssq 2> /dev/null
+       for d in 0 1 2 3 4 5 6 7  8 9 10 11 12
        do
-           losetup -d /dev/loop$d ; # rm -f $targetdir/mdtest$d
-        done
+           losetup -d /dev/loop$d ; # rm -f $targetdir/mdtest$d
+           rm -f /dev/disk/by-path/loop*
+       done
 }
 
 trap cleanup 0 1 2 3 15
 
 devlist=
-for d in 0 1 2 3 4 5 6 7
+for d in 0 1 2 3 4 5 6 7 8 9 10 11 12
 do
-   [ -f $targetdir/mdtest$d ] || dd if=/dev/zero of=$targetdir/mdtest$d count=$size bs=1K > /dev/null 2>&1
+   sz=$size
+   if [ $d -gt 7 ]; then sz=$ddfsize ; fi
+   [ -f $targetdir/mdtest$d ] || dd if=/dev/zero of=$targetdir/mdtest$d count=$sz bs=1K > /dev/null 2>&1
    [ -b /dev/loop$d ] || mknod /dev/loop$d b 7 $d
    if [ $d -eq 7 ]
    then
@@ -63,10 +78,13 @@ do
    eval dev$d=/dev/loop$d
    eval file$d=$targetdir/mdtest$d
    eval devlist=\"\$devlist \$dev$d\"
+   #" <-- add this quote to un-confuse vim syntax highlighting
 done
 path0=$dev6
 path1=$dev7
 
+ulimit -c unlimited
+[ -f /proc/mdstat ] || modprobe md_mod
 echo 2000 > /proc/sys/dev/raid/speed_limit_max
 echo 0 > /sys/module/md_mod/parameters/start_ro
 
@@ -77,11 +95,19 @@ fi
 # mdadm always adds --quiet, and we want to see any unexpected messages
 mdadm() {
     rm -f $targetdir/stderr
+    case $* in
+       *-S* ) udevadm settle;;
+    esac
     case $* in
        *-C* ) $mdadm 2> $targetdir/stderr --quiet "$@" --auto=yes;;
         * )   $mdadm 2> $targetdir/stderr --quiet "$@"
     esac
+    rv=$?
+    case $* in
+       *-S* ) udevadm settle;;
+    esac
     cat >&2 $targetdir/stderr
+    return $rv
 }
 
 # check various things
@@ -96,45 +122,45 @@ check() {
       ;;
     raid* | linear )
       grep -s "active $1 " /proc/mdstat > /dev/null || {
-               echo >&2 "ERROR active $1 not found" ; cat /proc/mdstat ; exit 1;}
+               echo >&2 "ERROR active $1 not found" ; cat /proc/mdstat ; exit 1;}
      ;;
     resync | recovery | reshape)
       sleep 0.5
       grep -s $1 /proc/mdstat > /dev/null || {
-               echo >&2 ERROR no $1 happening; cat /proc/mdstat; exit 1; }
+               echo >&2 ERROR no $1 happening; cat /proc/mdstat; exit 1; }
      ;;
-   
+
      nosync )
        sleep 0.5
-       if grep -s -E '(resync|recovery|reshape) =' > /dev/null /proc/mdstat ; then
-          echo >&2 "ERROR resync or recovery is happening!"; cat /proc/mdstat ; exit 1; 
+       if grep -s -E '(resync|recovery|reshape) *=' > /dev/null /proc/mdstat ; then
+               echo >&2 "ERROR resync or recovery is happening!"; cat /proc/mdstat ; exit 1;
        fi
      ;;
-   
+
     wait )
       sleep 0.1
-      while grep -E '(resync|recovery|reshape|check|repair) =' > /dev/null /proc/mdstat
+      while grep -E '(resync|recovery|reshape|check|repair) *=' > /dev/null /proc/mdstat
       do sleep 2;
       done
       ;;
-   
+
     state )
        grep -s "blocks.*\[$2\]\$" /proc/mdstat > /dev/null || {
-               echo >&2 "ERROR state $2 not found!"; cat /proc/mdstat ; exit 1; }
+               echo >&2 "ERROR state $2 not found!"; cat /proc/mdstat ; exit 1; }
        sleep 0.5
       ;;
 
     bitmap )
        grep -s bitmap > /dev/null /proc/mdstat || {
-          echo >&2 ERROR no bitmap ; cat /proc/mdstat ; exit 1; }
+               echo >&2 ERROR no bitmap ; cat /proc/mdstat ; exit 1; }
       ;;
     nobitmap )
-       if grep -s "bitmap" > /dev/null /proc/mdstat 
+       if grep -s "bitmap" > /dev/null /proc/mdstat
        then
-          echo >&2 ERROR bitmap present ; cat /proc/mdstat ; exit 1;
+               echo >&2 ERROR bitmap present ; cat /proc/mdstat ; exit 1;
        fi
       ;;
-   
+
     * ) echo >&2 ERROR unknown check $1 ; exit 1;
    esac
 }
@@ -147,14 +173,22 @@ no_errors() {
 # basic device test
 
 testdev() {
+   udevadm settle
    dev=$1
    cnt=$2
    dvsize=$3
    chunk=$4
-   mkfs -j $dev > /dev/null 2>&1 && fsck -fn $dev >&2
+   if [ -z "$5" ]; then
+      mkfs -j $dev > /dev/null 2>&1 && fsck -fn $dev >&2
+   fi
    dsize=$[dvsize/chunk]
    dsize=$[dsize*chunk]
    rasize=$[dsize*2*cnt]
+   # rasize is in sectors
+   if [ -n "$DEV_ROUND_K" ]; then
+      rasize=$[rasize/DEV_ROUND_K/2]
+      rasize=$[rasize*DEV_ROUND_K*2]
+   fi
    if [ `/sbin/blockdev --getsize $dev` -eq 0 ]; then sleep 2 ; fi
    if [ $rasize -ne `/sbin/blockdev --getsize $dev` ]
    then
@@ -168,21 +202,21 @@ rotest() {
   fsck -fn $dev >&2
 }
 
-
-
 for script in tests/$prefix tests/$prefix*[^~]
 do
   if [ -f "$script" ]
   then
    rm -f $targetdir/stderr
    # stop all arrays, just incase some script left an array active.
-   mdadm -Ssq
+   $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 "$script succeeded" 
-   else cat $targetdir/log ; cat $targetdir/stderr
-        echo "$script failed"
+   then echo "succeeded"
+   else echo "FAILED - see $targetdir/log for details"
        exit 1
    fi
   fi