summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--ReadMe.c2
-rw-r--r--inventory25
-rw-r--r--mdadm.82
-rw-r--r--mdadm.spec2
-rw-r--r--test66
-rw-r--r--tests/00linear22
-rw-r--r--tests/00raid044
-rw-r--r--tests/00raid135
-rw-r--r--tests/00raid1019
-rw-r--r--tests/00raid417
-rw-r--r--tests/00raid534
-rw-r--r--tests/00raid617
-rw-r--r--tests/01r1fail30
-rw-r--r--tests/01r5fail27
-rw-r--r--tests/02r1add41
-rw-r--r--tests/02r1grow37
-rw-r--r--tests/02r5grow37
-rw-r--r--tests/02r6grow37
-rw-r--r--tests/03r0assem132
-rw-r--r--tests/03r5assem110
-rw-r--r--tests/04r0update21
-rw-r--r--tests/04r1update15
-rw-r--r--tests/05r1-bitmapfile49
-rw-r--r--tests/05r1-internalbitmap47
-rw-r--r--tests/05r1-n3-bitmapfile53
-rw-r--r--tests/ToTest44
-rw-r--r--tests/check35
-rw-r--r--tests/testdev14
29 files changed, 1012 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 0dfba4e..c70bda1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
Changes Prior to 2.0-devel-3 release
- Assorted fixes for multiple bugs...
+ - Add test suite
Changes Prior to 1.12.0 release
Several of these are backported from the Debian package
diff --git a/ReadMe.c b/ReadMe.c
index 5339ab5..1d28adf 100644
--- a/ReadMe.c
+++ b/ReadMe.c
@@ -29,7 +29,7 @@
#include "mdadm.h"
-char Version[] = Name " - v2.0-devel-2 - DEVELOPMENT VERSION NOT FOR REGULAR USE - 7 July 2005\n";
+char Version[] = Name " - v2.0-devel-3 - DEVELOPMENT VERSION NOT FOR REGULAR USE - 4 August 2005\n";
/*
* File: ReadMe.c
diff --git a/inventory b/inventory
index 86eae4f..4a69616 100644
--- a/inventory
+++ b/inventory
@@ -55,4 +55,29 @@ misc/syslog-events
raid5extend.c
super0.c
super1.c
+test
+tests/
+tests/00linear
+tests/00raid0
+tests/00raid1
+tests/00raid10
+tests/00raid4
+tests/00raid5
+tests/00raid6
+tests/01r1fail
+tests/01r5fail
+tests/02r1add
+tests/02r1grow
+tests/02r5grow
+tests/02r6grow
+tests/03r0assem
+tests/03r5assem
+tests/04r0update
+tests/04r1update
+tests/05r1-bitmapfile
+tests/05r1-internalbitmap
+tests/05r1-n3-bitmapfile
+tests/ToTest
+tests/check
+tests/testdev
util.c
diff --git a/mdadm.8 b/mdadm.8
index bc227e2..b0ac74a 100644
--- a/mdadm.8
+++ b/mdadm.8
@@ -1,5 +1,5 @@
.\" -*- nroff -*-
-.TH MDADM 8 "" v2.0-devel-2
+.TH MDADM 8 "" v2.0-devel-3
.SH NAME
mdadm \- manage MD devices
.I aka
diff --git a/mdadm.spec b/mdadm.spec
index e37486b..3291a51 100644
--- a/mdadm.spec
+++ b/mdadm.spec
@@ -1,6 +1,6 @@
Summary: mdadm is used for controlling Linux md devices (aka RAID arrays)
Name: mdadm
-Version: 2.0-devel-2
+Version: 2.0-devel-3
Release: 1
Source: http://www.cse.unsw.edu.au/~neilb/source/mdadm/mdadm-%{version}.tgz
URL: http://www.cse.unsw.edu.au/~neilb/source/mdadm/
diff --git a/test b/test
new file mode 100644
index 0000000..ea1851c
--- /dev/null
+++ b/test
@@ -0,0 +1,66 @@
+#!/bin/sh
+#
+# run test suite for mdadm
+user=`id -un`
+if [ " $user" != " root" ]
+then echo >&2 "test: testing can only be done as 'root'."
+ exit 1;
+fi
+
+prefix='[0-9][0-9]'
+if [ -n "$1" ]
+then prefix=$1
+fi
+
+dir=`pwd`
+mdadm=$dir/mdadm
+export mdadm
+if [ \! -x $mdadm ]
+then
+ echo >&2 "test: $mdadm isn't usable."
+fi
+
+export check="sh $dir/tests/check"
+
+# assume md0, md1, md2 exist in /dev
+export 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
+export targetdir
+size=20000
+mdsize0=19904
+mdsize1=19992
+export size mdsize0 mdsize1
+
+cleanup() {
+ $mdadm -Ss
+ for d in 0 1 2 3 4 5 6 7
+ do losetup -d /dev/loop$d ; # rm -f $targetdir/mdtest$d
+ done
+}
+
+trap cleanup 0 1 2 3 15
+
+devlist=
+for d in 0 1 2 3 4 5 6 7
+do
+ [ -f $targetdir/mdtest$d ] || dd if=/dev/zero of=$targetdir/mdtest$d count=$size bs=1K > /dev/null 2>&1
+ losetup /dev/loop$d $targetdir/mdtest$d
+ export dev$d=/dev/loop$d
+ eval devlist=\"\$devlist \$dev$d\"
+done
+export devlist
+
+
+for script in tests/$prefix*[^~]
+do
+ if sh -x $script > $targetdir/log 2>&1
+ then echo "$script succeeded"
+ else cat $targetdir/log
+ echo "$script failed"
+ exit 1
+ fi
+done
+exit 0
diff --git a/tests/00linear b/tests/00linear
new file mode 100644
index 0000000..9e77569
--- /dev/null
+++ b/tests/00linear
@@ -0,0 +1,22 @@
+
+# create a simple linear
+set -ex
+
+$mdadm -CR $md0 -l linear -n3 $dev0 $dev1 $dev2
+$check linear
+sh tests/testdev $md0 3 $mdsize0 64
+$mdadm -S $md0
+
+# now with verion-1 superblock
+$mdadm -CR $md0 -e1 --level=linear -n4 $dev0 $dev1 $dev2 $dev3
+$check linear
+sh tests/testdev $md0 4 $mdsize1 64
+$mdadm -S $md0
+
+# now with no superblock
+$mdadm -B $md0 -l linear -n5 $dev0 $dev1 $dev2 $dev3 $dev4
+$check linear
+sh tests/testdev $md0 5 $size 64
+$mdadm -S $md0
+
+exit 0
diff --git a/tests/00raid0 b/tests/00raid0
new file mode 100644
index 0000000..c5ea9d3
--- /dev/null
+++ b/tests/00raid0
@@ -0,0 +1,44 @@
+
+# create a simple raid0
+set -e
+
+$mdadm -CR $md0 -l raid0 -n3 $dev0 $dev1 $dev2
+$check raid0
+sh tests/testdev $md0 3 $mdsize0 64
+$mdadm -S $md0
+
+# now with verion-1 superblock
+$mdadm -CR $md0 -e1 -l0 -n4 $dev0 $dev1 $dev2 $dev3
+$check raid0
+sh tests/testdev $md0 4 $mdsize1 64
+$mdadm -S $md0
+
+# now with no superblock
+$mdadm -B $md0 -l0 -n5 $dev0 $dev1 $dev2 $dev3 $dev4
+$check raid0
+sh tests/testdev $md0 5 $size 64
+$mdadm -S $md0
+
+
+# now same again with different chunk size
+for chunk in 4 32 256
+do
+ $mdadm -CR $md0 -l raid0 --chunk $chunk -n3 $dev0 $dev1 $dev2
+ $check raid0
+ sh tests/testdev $md0 3 $mdsize0 $chunk
+ $mdadm -S $md0
+
+ # now with verion-1 superblock
+ $mdadm -CR $md0 -e1 -l0 -c $chunk -n4 $dev0 $dev1 $dev2 $dev3
+ $check raid0
+ sh tests/testdev $md0 4 $mdsize1 $chunk
+ $mdadm -S $md0
+
+ # now with no superblock
+ $mdadm -B $md0 -l0 -n5 --chun=$chunk $dev0 $dev1 $dev2 $dev3 $dev4
+ $check raid0
+ sh tests/testdev $md0 5 $size $chunk
+ $mdadm -S $md0
+
+done
+exit 0
diff --git a/tests/00raid1 b/tests/00raid1
new file mode 100644
index 0000000..4ffdbae
--- /dev/null
+++ b/tests/00raid1
@@ -0,0 +1,35 @@
+
+# create a simple mirror
+# test version0, version1, and no super
+# test resync and recovery.
+set -e
+
+$mdadm -CR $md0 -l 1 -n2 $dev0 $dev1
+$check resync
+$check raid1
+sh tests/testdev $md0 1 $mdsize0 1
+$mdadm -S $md0
+
+# now with verion-1 superblock, spare
+$mdadm -CR $md0 -e1 --level=raid1 -n3 -x2 $dev0 missing missing $dev1 $dev2
+$check recovery
+$check raid1
+sh tests/testdev $md0 1 $mdsize1 1
+$mdadm -S $md0
+
+# now with no superblock
+$mdadm -B $md0 -l mirror -n2 $dev0 $dev1
+$check resync
+$check raid1
+sh tests/testdev $md0 1 $size 1
+$mdadm -S $md0
+
+# again, but with no resync
+$mdadm -B $md0 -l 1 --assume-clean -n2 $dev0 $dev1
+$check raid1
+$check nosync
+sh tests/testdev $md0 1 $size 1
+$mdadm -S $md0
+
+
+exit 0
diff --git a/tests/00raid10 b/tests/00raid10
new file mode 100644
index 0000000..12fa9d3
--- /dev/null
+++ b/tests/00raid10
@@ -0,0 +1,19 @@
+set -ex
+
+# Create some raid10 arrays, all with 6 devices and one spare
+devs="$dev0 $dev1 $dev2 $dev3 $dev4 $dev5 $dev6"
+
+for lo in n2 n3 f2 f3
+do
+ cm=1
+ case $lo in
+ f2 ) m=3 cm=2;;
+ f3 ) m=2 cm=3;;
+ n2 ) m=3;;
+ n3 ) m=2;;
+ esac
+ $mdadm --create --run --level=raid10 --layout $lo --raid-disks 6 -x 1 $md0 $devs
+ $check resync ; $check raid10
+ sh tests/testdev $md0 $m $mdsize0 $[64*cm]
+ $mdadm -S $md0
+done
diff --git a/tests/00raid4 b/tests/00raid4
new file mode 100644
index 0000000..a087d63
--- /dev/null
+++ b/tests/00raid4
@@ -0,0 +1,17 @@
+
+# create a simple raid4 set
+set -e
+
+$mdadm -CfR $md0 -l 4 -n3 $dev0 $dev1 $dev2
+$check resync ; $check raid5
+sh tests/testdev $md0 2 $mdsize0 64
+$mdadm -S $md0
+
+# now with verion-1 superblock
+$mdadm -CR $md0 -e1 --level=raid4 -n4 $dev0 $dev1 $dev2 $dev3
+$check resync; $check raid5
+sh tests/testdev $md0 3 $mdsize1 64
+$mdadm -S $md0
+
+
+exit 0
diff --git a/tests/00raid5 b/tests/00raid5
new file mode 100644
index 0000000..6ca86e0
--- /dev/null
+++ b/tests/00raid5
@@ -0,0 +1,34 @@
+
+# create a simple raid5 set
+set -e
+
+$mdadm -CfR $md0 -l 5 -n3 $dev0 $dev1 $dev2
+$check resync
+sh tests/testdev $md0 2 $mdsize0 64
+$mdadm -S $md0
+
+# now with verion-1 superblock
+$mdadm -CR $md0 -e1 --level=raid5 -n4 $dev0 $dev1 $dev2 $dev3
+$check recovery
+sh tests/testdev $md0 3 $mdsize1 64
+$mdadm -S $md0
+
+# now same again with explicit layout
+
+for lo in la ra left-symmetric right-symmetric
+do
+
+ $mdadm -CfR $md0 -l 5 -p $lo -n3 $dev0 $dev1 $dev2
+ $check resync ; $check raid5
+ sh tests/testdev $md0 2 $mdsize0 64
+ $mdadm -S $md0
+
+ # now with verion-1 superblock
+ $mdadm -CR $md0 -e1 --level=raid5 --layout $lo -n4 $dev0 $dev1 $dev2 $dev3
+ $check recovery ; $check raid5
+ sh tests/testdev $md0 3 $mdsize1 64
+ $mdadm -S $md0
+
+done
+
+exit 0
diff --git a/tests/00raid6 b/tests/00raid6
new file mode 100644
index 0000000..827fdaf
--- /dev/null
+++ b/tests/00raid6
@@ -0,0 +1,17 @@
+
+# create a simple raid6 set
+set -e
+
+$mdadm -CfR $md0 -l 6 -n4 $dev0 $dev1 $dev2 $dev3
+$check resync ; $check raid6
+sh tests/testdev $md0 2 $mdsize0 64
+$mdadm -S $md0
+
+# now with verion-1 superblock
+$mdadm -CR $md0 -e1 --level=raid6 -n5 $dev0 $dev1 $dev2 $dev3 $dev4
+$check resync ; $check raid6
+sh tests/testdev $md0 3 $mdsize1 64
+$mdadm -S $md0
+
+
+exit 0
diff --git a/tests/01r1fail b/tests/01r1fail
new file mode 100644
index 0000000..76488b0
--- /dev/null
+++ b/tests/01r1fail
@@ -0,0 +1,30 @@
+
+set -e
+
+# create a raid1, fail and remove a drive during initial sync
+# Add two more, fail and remove one
+# wait for sync to complete, fail, remove, re-add
+
+$mdadm -CR $md0 -l1 -n4 $dev0 $dev1 $dev2 missing
+$check resync
+$mdadm $md0 --fail $dev2
+$check resync
+$mdadm $md0 --fail $dev1
+sleep 1
+$check nosync
+$check state U___
+$mdadm $md0 --add $dev4 $dev3
+$check recovery
+# there could be two separate recoveries, one for each dev
+$check wait
+$check wait
+$mdadm $md0 --remove $dev2 $dev1
+$check nosync
+$check state UUU_
+
+$mdadm $md0 -a $dev2
+$check recovery
+$check wait
+$check state UUUU
+
+$mdadm -S $md0
diff --git a/tests/01r5fail b/tests/01r5fail
new file mode 100644
index 0000000..1aaa597
--- /dev/null
+++ b/tests/01r5fail
@@ -0,0 +1,27 @@
+
+set -e
+
+# create a raid5, fail and remove a drive during initial sync
+# Add two more, fail and remove one
+# wait for sync to complete, fail, remove, re-add
+
+$mdadm -CR $md0 -l5 -n4 $dev0 $dev1 $dev2 $dev3
+$check recovery
+$mdadm $md0 --fail $dev3
+$check nosync
+$check state UUU_
+
+$mdadm $md0 --add $dev4 $dev5
+$check recovery
+$check wait
+$mdadm $md0 --fail $dev0
+$mdadm $md0 --remove $dev3 $dev0
+$check recovery
+$check state _UUU
+
+$mdadm $md0 -a $dev3
+$check recovery
+$check wait
+$check state UUUU
+
+$mdadm -S $md0 \ No newline at end of file
diff --git a/tests/02r1add b/tests/02r1add
new file mode 100644
index 0000000..10507a7
--- /dev/null
+++ b/tests/02r1add
@@ -0,0 +1,41 @@
+
+set -e
+# Make a raid1, add a device, then remove it again.
+
+$mdadm -CR $md0 -l1 -n2 -x1 $dev0 $dev1 $dev2
+$check resync
+$check wait
+$check state UU
+
+$mdadm --grow $md0 -n 3
+$check recovery
+$check wait
+$check state UUU
+
+$mdadm $md0 --fail $dev0
+$check state _UU
+
+$mdadm --grow $md0 -n 2
+$check state UU
+
+$mdadm -S $md0
+# same again for version-1
+
+
+$mdadm -CR $md0 -l1 -n2 -e1.2 -x1 $dev0 $dev1 $dev2
+$check resync
+$check wait
+$check state UU
+
+$mdadm --grow $md0 -n 3
+$check recovery
+$check wait
+$check state UUU
+
+$mdadm $md0 --fail $dev0
+$check state _UU
+
+$mdadm --grow $md0 -n 2
+$check state UU
+
+$mdadm -S $md0
diff --git a/tests/02r1grow b/tests/02r1grow
new file mode 100644
index 0000000..95873ea
--- /dev/null
+++ b/tests/02r1grow
@@ -0,0 +1,37 @@
+
+set -e
+
+# create a small raid1 array, make it larger. Then make it smaller
+
+$mdadm -CR $md0 --level raid1 --raid-disks 3 --size $[size/2] $dev1 $dev2 $dev3
+$check wait
+$check state UUU
+sh tests/testdev $md0 1 $[size/2] 1
+
+$mdadm --grow $md0 --size max
+$check resync
+$check wait
+sh tests/testdev $md0 1 $mdsize0 1
+
+$mdadm --grow $md0 --size $[size/2]
+$check nosync
+sh tests/testdev $md0 1 $[size/2] 1
+
+$mdadm -S $md0
+
+# same again with version 1.1 superblock
+$mdadm -CR $md0 --level raid1 --metadata=1.1 --raid-disks 3 --size $[size/2] $dev1 $dev2 $dev3
+$check wait
+$check state UUU
+sh tests/testdev $md0 1 $[size/2] 1
+
+$mdadm --grow $md0 --size max
+$check resync
+$check wait
+sh tests/testdev $md0 1 $[size-1] 1
+
+$mdadm --grow $md0 --size $[size/2]
+$check nosync
+sh tests/testdev $md0 1 $[size/2] 1
+
+$mdadm -S $md0
diff --git a/tests/02r5grow b/tests/02r5grow
new file mode 100644
index 0000000..0ac968c
--- /dev/null
+++ b/tests/02r5grow
@@ -0,0 +1,37 @@
+
+set -e
+
+# create a small raid5 array, make it larger. Then make it smaller
+
+$mdadm -CR $md0 --level raid5 --chunk=32 --raid-disks 3 --size $[size/2] $dev1 $dev2 $dev3
+$check wait
+$check state UUU
+sh tests/testdev $md0 2 $[size/2] 32
+
+$mdadm --grow $md0 --size max
+$check resync
+$check wait
+sh tests/testdev $md0 2 $mdsize0 64
+
+$mdadm --grow $md0 --size $[size/2]
+$check nosync
+sh tests/testdev $md0 2 $[size/2] 64
+
+$mdadm -S $md0
+
+# same again with version 1.1 superblock
+$mdadm -CR $md0 --level raid5 --metadata=1.1 --chunk=128 --raid-disks 4 --size $[size/2] $dev1 $dev2 $dev3 $dev4
+$check wait
+$check state UUUU
+sh tests/testdev $md0 3 $[size/2] 128
+
+$mdadm --grow $md0 --size max
+$check resync
+$check wait
+sh tests/testdev $md0 3 $[size-1] 128
+
+$mdadm --grow $md0 --size $[size/2]
+$check nosync
+sh tests/testdev $md0 3 $[size/2] 128
+
+$mdadm -S $md0
diff --git a/tests/02r6grow b/tests/02r6grow
new file mode 100644
index 0000000..ef864e2
--- /dev/null
+++ b/tests/02r6grow
@@ -0,0 +1,37 @@
+
+set -e
+
+# create a small raid6 array, make it larger. Then make it smaller
+
+$mdadm -CR $md0 --level raid6 --chunk=32 --raid-disks 4 --size $[size/2] $dev1 $dev2 $dev3 $dev4
+$check wait
+$check state UUUU
+sh tests/testdev $md0 2 $[size/2] 32
+
+$mdadm --grow $md0 --size max
+$check resync
+$check wait
+sh tests/testdev $md0 2 $mdsize0 64
+
+$mdadm --grow $md0 --size $[size/2]
+$check nosync
+sh tests/testdev $md0 2 $[size/2] 64
+
+$mdadm -S $md0
+
+# same again with version 1.1 superblock
+$mdadm -CR $md0 --level raid6 --metadata=1.1 --chunk=128 --raid-disks 4 --size $[size/2] $dev1 $dev2 $dev3 $dev4
+$check wait
+$check state UUUU
+sh tests/testdev $md0 2 $[size/2] 128
+
+$mdadm --grow $md0 --size max
+$check resync
+$check wait
+sh tests/testdev $md0 2 $[size-1] 128
+
+$mdadm --grow $md0 --size $[size/2]
+$check nosync
+sh tests/testdev $md0 2 $[size/2] 128
+
+$mdadm -S $md0
diff --git a/tests/03r0assem b/tests/03r0assem
new file mode 100644
index 0000000..96da6a5
--- /dev/null
+++ b/tests/03r0assem
@@ -0,0 +1,132 @@
+set -e
+
+# create a raid0 array from 3 devices, and assemble it in a multitude of ways.
+# explicitly list devices
+# uuid, md-minor on command line with wildcard devices
+# mdadm.conf file
+
+$mdadm -CR $md2 -l0 -n3 $dev0 $dev1 $dev2
+$check raid0
+tst="sh tests/testdev $md2 3 $mdsize0 64"
+$tst
+uuid=`$mdadm -Db $md2 | sed 's/.*UUID=//'`
+$mdadm -S $md2
+
+$mdadm -A $md2 $dev0 $dev1 $dev2
+$tst
+$mdadm -S $md2
+
+$mdadm -A $md2 -u $uuid $devlist
+$tst
+$mdadm -S $md2
+
+$mdadm --assemble $md2 --super-minor=2 $devlist
+$tst
+$mdadm -S $md2
+
+conf=$targetdir/mdadm.conf
+{
+ echo DEVICE $devlist
+ echo array $md2 UUID=$uuid
+} > $conf
+
+$mdadm -As -c $conf $md2
+$tst
+$mdadm -S $md2
+
+{
+ echo DEVICE $devlist
+ echo array $md2 super-minor=2
+} > $conf
+
+$mdadm -As -c $conf $md2
+$tst
+$mdadm -S $md2
+
+
+{
+ echo DEVICE $devlist
+ echo array $md2 devices=$dev0,$dev1,$dev2
+} > $conf
+
+$mdadm -As -c $conf $md2
+$tst
+
+echo "DEVICE $devlist" > $conf
+$mdadm -Db $md2 >> $conf
+$mdadm -S $md2
+
+$mdadm --assemble --scan --config=$conf $md2
+$tst
+$mdadm -S $md2
+
+echo " metadata=0.90 devices=$dev0,$dev1,$dev2" >> $conf
+$mdadm --assemble --scan --config=$conf $md2
+$tst
+$mdadm -S $md2
+
+
+### Now for version 1...
+
+
+$mdadm -CR $md2 -l0 --metadata=1.0 -n3 $dev0 $dev1 $dev2
+$check raid0
+tst="sh tests/testdev $md2 3 $mdsize1 64"
+$tst
+
+uuid=`$mdadm -Db $md2 | sed 's/.*UUID=//'`
+$mdadm -S $md2
+
+$mdadm -A $md2 $dev0 $dev1 $dev2
+$tst
+$mdadm -S $md2
+
+$mdadm -A $md2 -u $uuid $devlist
+$tst
+$mdadm -S $md2
+
+# version 1 has now super-minor
+# $mdadm --assemble $md2 --super-minor=2 $devlist #
+# $tst
+# $mdadm -S $md2
+
+conf=$targetdir/mdadm.conf
+{
+ echo DEVICE $devlist
+ echo array $md2 UUID=$uuid
+} > $conf
+
+$mdadm -As -c $conf $md2
+$tst
+$mdadm -S $md2
+
+#{
+# echo DEVICE $devlist
+# echo array $md2 super-minor=2
+#} > $conf
+#
+#$mdadm -As -c $conf $md2
+#$tst
+#$mdadm -S $md2
+
+
+{
+ echo DEVICE $devlist
+ echo array $md2 devices=$dev0,$dev1,$dev2
+} > $conf
+
+$mdadm -As -c $conf $md2
+$tst
+
+echo "DEVICE $devlist" > $conf
+$mdadm -Db $md2 >> $conf
+$mdadm -S $md2
+
+$mdadm --assemble --scan --config=$conf $md2
+$tst
+$mdadm -S $md2
+
+echo " metadata=1 devices=$dev0,$dev1,$dev2" >> $conf
+$mdadm --assemble --scan --config=$conf $md2
+$tst
+$mdadm -S $md2
diff --git a/tests/03r5assem b/tests/03r5assem
new file mode 100644
index 0000000..5ca5ddd
--- /dev/null
+++ b/tests/03r5assem
@@ -0,0 +1,110 @@
+set -e
+
+# create a raid5 array and assemble it in various ways,
+# including with missing devices.
+
+$mdadm -CR $md1 -l5 -n3 $dev0 $dev1 $dev2
+tst="$check raid5 ;sh tests/testdev $md1 2 $mdsize0 64 ; $mdadm -S $md1"
+uuid=`$mdadm -Db $md1 | sed 's/.*UUID=//'`
+$check wait
+eval $tst
+
+$mdadm -A $md1 $dev0 $dev1 $dev2
+eval $tst
+
+$mdadm -A $md1 -u $uuid $devlist
+eval $tst
+
+$mdadm -A $md1 -m 1 $devlist
+eval $tst
+
+
+conf=$targetdir/mdadm.conf
+{
+ echo DEVICE $devlist
+ echo array $md1 UUID=$uuid
+} > $conf
+
+$mdadm -As -c $conf $md1
+eval $tst
+
+{
+ echo DEVICE $devlist
+ echo array $md1 super-minor=1
+} > $conf
+
+$mdadm -As -c $conf
+eval $tst
+
+{
+ echo DEVICE $devlist
+ echo array $md1 devices=$dev0,$dev1,$dev2
+} > $conf
+
+$mdadm -As -c $conf
+
+echo "DEVICE $devlist" > $conf
+$mdadm -Db $md1 >> $conf
+eval $tst
+
+$mdadm --assemble --scan --config=$conf $md1
+eval $tst
+
+echo " metadata=0.90 devices=$dev0,$dev1,$dev2" >> $conf
+$mdadm --assemble --scan --config=$conf $md1
+eval $tst
+
+### Now with a missing device
+
+$mdadm -AR $md1 $dev0 $dev2 #
+$check state U_U
+eval $tst
+
+$mdadm -A $md1 -u $uuid $devlist
+$check state U_U
+eval $tst
+
+$mdadm -A $md1 -m 1 $devlist
+$check state U_U
+eval $tst
+
+
+conf=$targetdir/mdadm.conf
+{
+ echo DEVICE $devlist
+ echo array $md1 UUID=$uuid
+} > $conf
+
+$mdadm -As -c $conf $md1
+$check state U_U
+eval $tst
+
+{
+ echo DEVICE $devlist
+ echo array $md1 super-minor=1
+} > $conf
+
+$mdadm -As -c $conf
+$check state U_U
+eval $tst
+
+{
+ echo DEVICE $devlist
+ echo array $md1 devices=$dev0,$dev1,$dev2
+} > $conf
+
+$mdadm -As -c $conf
+
+echo "DEVICE $devlist" > $conf
+$mdadm -Db $md1 >> $conf
+$check state U_U
+eval $tst
+
+$mdadm --assemble --scan --config=$conf $md1
+$check state U_U
+eval $tst
+
+echo " metadata=0.90 devices=$dev0,$dev1,$dev2" >> $conf
+$mdadm --assemble --scan --config=$conf $md1
+$check state U_U
+eval $tst
diff --git a/tests/04r0update b/tests/04r0update
new file mode 100644
index 0000000..73ecbd5
--- /dev/null
+++ b/tests/04r0update
@@ -0,0 +1,21 @@
+set -e
+
+# create a raid0, re-assemble with a different super-minor
+$mdadm -CR $md0 -l0 -n3 $dev0 $dev1 $dev2
+sh tests/testdev $md0 3 $mdsize0 64
+minor1=`$mdadm -E $dev0 | sed -n -e 's/.*Preferred Minor : //p'`
+$mdadm -S /dev/md0
+
+$mdadm -A $md1 $dev0 $dev1 $dev2
+minor2=`$mdadm -E $dev0 | sed -n -e 's/.*Preferred Minor : //p'`
+$mdadm -S /dev/md1
+
+$mdadm -A $md1 --update=super-minor $dev0 $dev1 $dev2
+minor3=`$mdadm -E $dev0 | sed -n -e 's/.*Preferred Minor : //p'`
+$mdadm -S /dev/md1
+
+case "$minor1 $minor2 $minor3" in
+ "0 0 1" ) ;;
+ * ) echo >&2 "ERROR minors should be '0 0 1' but are '$minor1 $minor2 $minor3'"
+ exit 1
+esac
diff --git a/tests/04r1update b/tests/04r1update
new file mode 100644
index 0000000..e76df89
--- /dev/null
+++ b/tests/04r1update
@@ -0,0 +1,15 @@
+set -i
+
+# create a raid1 array, let it sync, then re-assemble with a force-sync
+
+$mdadm -CR $md0 -l1 -n2 $dev0 $dev1
+$check wait
+$mdadm -S $md0
+
+$mdadm -A $md0 $dev0 $dev1
+$check nosync
+$mdadm -S $md0
+
+$mdadm -A $md0 -U resync $dev0 $dev1
+$check resync
+$mdadm -S $md0
diff --git a/tests/05r1-bitmapfile b/tests/05r1-bitmapfile
new file mode 100644
index 0000000..777c467
--- /dev/null
+++ b/tests/05r1-bitmapfile
@@ -0,0 +1,49 @@
+set -e
+
+#
+# create a raid1 with a bitmap file
+#
+bmf=$targetdir/bitmap
+rm -f $bmf
+$mdadm --create --run $md0 --level=1 -n2 --delay=1 --bitmap $bmf $dev1 $dev2
+$check wait
+sh tests/testdev $md0 1 $mdsize0 1
+$mdadm -S $md0
+
+$mdadm --assemble $md0 --bitmap=$bmf $dev1 $dev2
+sh tests/testdev $md0 1 $mdsize0 1
+dirty1=`$mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'`
+sleep 4
+dirty2=`$mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'`
+
+if [ $dirty1 -lt 400 -o $dirty2 -ne 0 ]
+then echo >&2 "ERROR bad 'dirty' counts: $dirty1 and $dirty2"
+ exit 1
+fi
+$mdadm $md0 -f $dev1
+sh tests/testdev $md0 1 $mdsize0 1
+sleep 4
+dirty3=`$mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'`
+if [ $dirty3 -lt 400 ]
+then
+ echo >&2 "ERROR dirty count $dirty3 is too small"
+ exit 2
+fi
+
+$mdadm -S $md0
+
+$mdadm --assemble -R $md0 --bitmap=$bmf $dev2
+$mdadm $md0 --add $dev1
+$check recovery
+
+dirty4=`$mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'`
+$check wait
+sleep 4
+dirty5=`$mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'`
+
+if [ $dirty4 -lt 400 -o $dirty5 -ne 0 ]
+then echo echo >&2 "ERROR bad 'dirty' counts at end: $dirty4 $dirty5"
+ exit 1
+fi
+
+$mdadm -S $md0
diff --git a/tests/05r1-internalbitmap b/tests/05r1-internalbitmap
new file mode 100644
index 0000000..9e15c10
--- /dev/null
+++ b/tests/05r1-internalbitmap
@@ -0,0 +1,47 @@
+set -e
+
+#
+# create a raid1 with an internal bitmap
+#
+$mdadm --create --run $md0 --level=1 -n2 --delay=1 --bitmap internal $dev1 $dev2
+$check wait
+sh tests/testdev $md0 1 $mdsize0 1
+$mdadm -S $md0
+
+$mdadm --assemble $md0 $dev1 $dev2
+sh tests/testdev $md0 1 $mdsize0 1
+dirty1=`$mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'`
+sleep 4
+dirty2=`$mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'`
+
+if [ $dirty1 -lt 400 -o $dirty2 -ne 0 ]
+then echo >&2 "ERROR bad 'dirty' counts: $dirty1 and $dirty2"
+ exit 1
+fi
+$mdadm $md0 -f $dev1
+sh tests/testdev $md0 1 $mdsize0 1
+sleep 4
+dirty3=`$mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'`
+if [ $dirty3 -lt 400 ]
+then
+ echo >&2 "ERROR dirty count $dirty3 is too small"
+ exit 2
+fi
+
+$mdadm -S $md0
+
+$mdadm --assemble -R $md0 $dev2
+$mdadm $md0 --add $dev1
+$check recovery
+
+dirty4=`$mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'`
+$check wait
+sleep 4
+dirty5=`$mdadm -X $dev2 | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'`
+
+if [ $dirty4 -lt 400 -o $dirty5 -ne 0 ]
+then echo echo >&2 "ERROR bad 'dirty' counts at end: $dirty4 $dirty5"
+ exit 1
+fi
+
+$mdadm -S $md0
diff --git a/tests/05r1-n3-bitmapfile b/tests/05r1-n3-bitmapfile
new file mode 100644
index 0000000..72d2e08
--- /dev/null
+++ b/tests/05r1-n3-bitmapfile
@@ -0,0 +1,53 @@
+set -e
+
+#
+# create a raid1 with 3 devices and a bitmap file
+# make sure resync does right thing.
+#
+#
+bmf=$targetdir/bitmap
+rm -f $bmf
+$mdadm --create --run $md0 --level=1 -n3 --delay=1 --bitmap $bmf $dev1 $dev2 $dev3
+$check wait
+sh tests/testdev $md0 1 $mdsize0 1
+$mdadm -S $md0
+
+$mdadm --assemble $md0 --bitmap=$bmf $dev1 $dev2 $dev3
+sh tests/testdev $md0 1 $mdsize0 1
+dirty1=`$mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'`
+sleep 4
+dirty2=`$mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'`
+
+if [ $dirty1 -lt 400 -o $dirty2 -ne 0 ]
+then echo >&2 "ERROR bad 'dirty' counts: $dirty1 and $dirty2"
+ exit 1
+fi
+$mdadm $md0 -f $dev2
+sh tests/testdev $md0 1 $mdsize0 1
+sleep 4
+dirty3=`$mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'`
+if [ $dirty3 -lt 400 ]
+then
+ echo >&2 "ERROR dirty count $dirty3 is too small"
+ exit 2
+fi
+
+$mdadm -S $md0
+
+$mdadm --assemble -R $md0 --bitmap=$bmf $dev1 $dev3
+$check nosync
+$mdadm $md0 --add $dev2
+$check recovery
+
+dirty4=`$mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'`
+$check wait
+sleep 4
+dirty5=`$mdadm -X $bmf | sed -n -e 's/.*Bitmap.* \([0-9]*\) dirty.*/\1/p'`
+
+if [ $dirty4 -lt 400 -o $dirty5 -ne 0 ]
+then echo echo >&2 "ERROR bad 'dirty' counts at end: $dirty4 $dirty5"
+ exit 1
+fi
+
+$mdadm -S $md0
+exit 0
diff --git a/tests/ToTest b/tests/ToTest
new file mode 100644
index 0000000..31d7082
--- /dev/null
+++ b/tests/ToTest
@@ -0,0 +1,44 @@
+
+multipath!!
+
+add/remove/fail
+ raid1 DONE
+ raid5 DONE
+ raid6/10 needed??
+
+assemble
+ by devices DONE
+ by uuid DONE
+ by superminor DONE
+ by config file DONE
+
+ various --updates DONE (not sparc2.2 or summaries)
+
+stop
+ --scan
+
+readonly/readwrite
+
+bitmap
+ separate file
+ internal
+ filename in config file
+
+examine
+ --scan
+ --brief
+
+detail
+
+grow:
+ size
+ raid1/5/6 DONE
+ devices
+ raid1 add DONE
+ raid1 shrink DONE
+
+'--quiet' option, and remove ""
+'--name' option fo v1, and configfile etc...
+
+faulty
+ errors in raid1/5/6
diff --git a/tests/check b/tests/check
new file mode 100644
index 0000000..f4ed6d5
--- /dev/null
+++ b/tests/check
@@ -0,0 +1,35 @@
+
+case $1 in
+ 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
+ grep -s $1 /proc/mdstat > /dev/null || {
+ echo >&2 ERROR no $1 happening; cat /proc/mdstat; exit 1; }
+ ;;
+
+ nosync )
+ sleep 0.5
+ grep -s 're[synccovery]* =' > /dev/null /proc/mdstat && {
+ echo >&2 "ERROR resync or recovery is happening!"; cat /proc/mdstat ; exit 1; }
+ ;;
+
+ wait )
+ sleep 0.1
+ while grep 're[synccovery]* =' > /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; }
+ sleep 0.5
+ ;;
+
+ * ) echo >&2 ERROR unknown check $1 ; exit 1;
+esac
+
+exit 0
diff --git a/tests/testdev b/tests/testdev
new file mode 100644
index 0000000..9e490f9
--- /dev/null
+++ b/tests/testdev
@@ -0,0 +1,14 @@
+dev=$1
+cnt=$2
+size=$3
+chunk=$4
+mkfs -j $dev > /dev/null 2>&1 && fsck -fn $dev
+dsize=$[size/chunk]
+dsize=$[dsize*chunk]
+rasize=$[dsize*1024*cnt]
+if [ $rasize -ne `/sbin/blockdev --getsize64 $dev` ]
+then
+ echo "ERROR: size is wrong for $dev: $cnt * $size (chunk=$chunk) = $rasize, not `/sbin/blockdev --getsize64 $dev`"
+ exit 1;
+fi
+