3 # run test suite for mdadm
9 system_speed_limit
=`cat /proc/sys/dev/raid/speed_limit_max`
19 # use loop devices by default if doesn't specify --dev
24 # assume md0, md1, md2 exist in /dev
32 echo -e "\n\tERROR: $* \n"
42 restore_system_speed_limit
() {
43 echo $system_speed_limit > /proc
/sys
/dev
/raid
/speed_limit_max
47 rm -f $targetdir/stderr
51 p
=`cat /proc/sys/dev/raid/speed_limit_max`
52 echo 20000 > /proc
/sys
/dev
/raid
/speed_limit_max
56 *-C* |
*--create* |
*-B* |
*--build* )
57 # clear superblock every time once creating or
58 # building arrays, because it's always creating
59 # and building array many times in a test case.
62 [[ $args =~
"/dev/" ]] && {
63 [[ $args =~
"md" ]] ||
64 $mdadm --zero $args > /dev
/null
67 $mdadm 2> $targetdir/stderr
"$@" --auto=yes
70 $mdadm 2> $targetdir/stderr
"$@"
77 echo $p > /proc
/sys
/dev
/raid
/speed_limit_max
80 cat >&2 $targetdir/stderr
86 _basename
=`basename $_script`
91 if [ -f "${_script}.broken" ]; then
93 _broken_msg
=$
(head -n1 "${_script}.broken" |
tr -d '\n')
94 if [ "$skipbroken" == "all" ]; then
96 elif [ "$skipbroken" == "always" ] &&
97 [[ "$_broken_msg" == *always
* ]]; then
102 rm -f $targetdir/stderr
104 # source script in a subshell, so it has access to our
105 # namespace, but cannot change it.
106 echo -ne "$_script... "
107 if ( set -ex ; .
$_script ) &> $targetdir/log
109 if [ -f "${_script}.inject_error" ]; then
110 echo "dmesg checking is skipped because test inject error"
112 dmesg |
grep -iq "error\|call trace\|segfault" &&
113 die
"dmesg prints errors when testing $_basename!"
120 if [ "$_broken" == "1" ]; then
121 echo " (KNOWN BROKEN TEST: $_broken_msg)"
124 restore_system_speed_limit
125 [ "$savelogs" == "1" ] &&
126 mv -f $targetdir/log
$logdir/$_basename.log
127 [ "$ctrl_c_error" == "1" ] && exit 1
128 [ "$_fail" == "1" -a "$exitonerror" == "1" \
129 -a "$_broken" == "0" ] && exit 1
136 Example for disk mode: ./test --dev=disk --disks=/dev/sda{2..15}
138 --tests=test1,test2,... Comma separated list of tests to run
139 --testdir= Specify testdir as tests|clustermd_tests
140 --raidtype= raid0|linear|raid1|raid456|raid10|ddf|imsm
141 --disable-multipath Disable any tests involving multipath
142 --disable-integrity Disable slow tests of RAID[56] consistency
143 --disable-linear Disable any tests involving linear
144 --logdir=directory Directory to save all logfiles in
145 --save-logs Usually use with --logdir together
146 --keep-going | --no-error Don't stop on error, ie. run all tests
147 --loop=N Run tests N times (0 to run forever)
148 --skip-broken Skip tests that are known to be broken
149 --skip-always-broken Skip tests that are known to always fail
150 --dev=loop|lvm|ram|disk Use loop devices (default), LVM, RAM or disk
151 --disks= Provide a bunch of physical devices for test
152 --volgroup=name LVM volume group for LVM test
153 setup Setup test environment and exit
154 cleanup Cleanup test environment
155 prefix Run tests with <prefix>
156 --help | -h Print this usage
170 testdir
=clustermd_tests
171 CLUSTER_CONF
="$PWD/$testdir/cluster_conf"
174 echo "Unknown argument: $i"
182 [ -z "$testdir" ] && testdir
=tests
191 echo "mdadm test environment setup"
203 TESTLIST
=($
(echo ${i##*=} |
sed -e 's/,/ /g'))
208 TESTLIST
=($
(ls $testdir |
grep "[0-9][0-9]r0\|raid0"))
211 TESTLIST
=($
(ls $testdir |
grep "linear"))
214 TESTLIST
=($
(ls $testdir |
grep "[0-9][0-9]r1\|raid1" |
grep -vi "r10\|raid10"))
217 TESTLIST
=($
(ls $testdir |
grep "[0-9][0-9]r[4-6]\|raid[4-6]"))
220 TESTLIST
=($
(ls $testdir |
grep "[0-9][0-9]r10\|raid10"))
223 TESTLIST
=($
(ls $testdir |
grep "[0-9][0-9]ddf"))
226 TESTLIST
=($
(ls $testdir |
grep "[0-9][0-9]imsm"))
229 echo "Unknown argument: $i"
241 --keep-going |
--no-error )
250 --skip-always-broken )
253 --disable-multipath )
256 --disable-integrity )
277 echo "Unknown argument: $i"
284 disks
=(${disks[*]} ${i##*=})
287 LVM_VOLGROUP
=`expr "x$i" : 'x[^=]*=\(.*\)'`
294 echo " $0: Unknown argument: $i"
304 Warning! Tests are performed on system level mdadm!
305 If you want to test local build, you need to install it first!
313 echo "Testing on linux-$(uname -r) kernel"
314 [ "$savelogs" == "1" ] &&
315 echo "Saving logs to $logdir"
318 if [ "x$TESTLIST" != "x" ]
320 for script in ${TESTLIST[@]}
322 do_test
$testdir/$script
325 for script in $testdir/$prefix $testdir/$prefix*[^~
]
336 if [ "$loop" == "0" ]; then