3 # run test suite for mdadm
9 system_speed_limit_max
=0
10 system_speed_limit_min
=0
11 test_speed_limit_min
=100
12 test_speed_limit_max
=500
14 # If super1 metadata name doesn't have the same hostname with machine,
15 # it's treated as foreign.
16 # For example, /dev/md0 is created, stops it, then assemble it, the
17 # device node will be /dev/md127 (127 is choosed by mdadm autumatically)
20 sys_selinux
="Permissive"
23 skipping_multipath
="no"
32 # use loop devices by default if doesn't specify --dev
37 # assume md0, md1, md2 exist in /dev
41 # if user doesn't specify minor number, mdadm chooses minor number
42 # automatically from 127.
50 echo -e "\n\tERROR: $* \n"
61 rm -f $targetdir/stderr
65 p
=`cat /proc/sys/dev/raid/speed_limit_max`
66 echo 20000 > /proc
/sys
/dev
/raid
/speed_limit_max
70 *-C* |
*--create* |
*-B* |
*--build* )
71 # clear superblock every time once creating or
72 # building arrays, because it's always creating
73 # and building array many times in a test case.
76 [[ $args =~
"/dev/" ]] && {
77 [[ $args =~
"md" ]] ||
78 $mdadm --zero $args > /dev
/null
81 $mdadm 2> $targetdir/stderr
"$@" --auto=yes
84 $mdadm 2> $targetdir/stderr
"$@"
91 echo $p > /proc
/sys
/dev
/raid
/speed_limit_max
94 cat >&2 $targetdir/stderr
100 _basename
=`basename $_script`
105 if [ -f "${_script}.broken" ]; then
107 _broken_msg
=$
(head -n1 "${_script}.broken" |
tr -d '\n')
108 if [ "$skipbroken" == "all" ]; then
110 elif [ "$skipbroken" == "always" ] &&
111 [[ "$_broken_msg" == *always
* ]]; then
116 rm -f $targetdir/stderr
118 # source script in a subshell, so it has access to our
119 # namespace, but cannot change it.
120 control_system_speed_limit
121 echo -ne "$_script... "
122 if ( set -ex ; .
$_script ) &> $targetdir/log
124 if [ -f "${_script}.inject_error" ]; then
125 echo "dmesg checking is skipped because test inject error"
127 dmesg |
grep -iq "error\|call trace\|segfault" |
grep -v "systemd" &&
128 die
"dmesg prints errors when testing $_basename!"
135 if [ "$_broken" == "1" ]; then
136 echo " (KNOWN BROKEN TEST: $_broken_msg)"
139 restore_system_speed_limit
140 [ "$savelogs" == "1" ] &&
141 mv -f $targetdir/log
$logdir/$_basename.log
142 [ "$ctrl_c_error" == "1" ] && exit 1
143 [ "$_fail" == "1" -a "$exitonerror" == "1" \
144 -a "$_broken" == "0" ] && exit 1
151 Example for disk mode: ./test --dev=disk --disks=/dev/sda{2..15}
153 --tests=test1,test2,... Comma separated list of tests to run
154 --testdir= Specify testdir as tests|clustermd_tests
155 --raidtype= raid0|linear|raid1|raid456|raid10|ddf|imsm
156 --disable-multipath Disable any tests involving multipath
157 --disable-integrity Disable slow tests of RAID[56] consistency
158 --disable-linear Disable any tests involving linear
159 --logdir=directory Directory to save all logfiles in
160 --save-logs Usually use with --logdir together
161 --keep-going | --no-error Don't stop on error, ie. run all tests
162 --loop=N Run tests N times (0 to run forever)
163 --skip-broken Skip tests that are known to be broken
164 --skip-always-broken Skip tests that are known to always fail
165 --dev=loop|lvm|ram|disk Use loop devices (default), LVM, RAM or disk
166 --disks= Provide a bunch of physical devices for test
167 --volgroup=name LVM volume group for LVM test
168 setup Setup test environment and exit
169 cleanup Cleanup test environment
170 prefix Run tests with <prefix>
171 --help | -h Print this usage
185 testdir
=clustermd_tests
186 CLUSTER_CONF
="$PWD/$testdir/cluster_conf"
189 echo "Unknown argument: $i"
197 [ -z "$testdir" ] && testdir
=tests
206 echo "mdadm test environment setup"
218 TESTLIST
=($
(echo ${i##*=} |
sed -e 's/,/ /g'))
223 TESTLIST
=($
(ls $testdir |
grep "[0-9][0-9]r0\|raid0"))
226 TESTLIST
=($
(ls $testdir |
grep "linear"))
229 TESTLIST
=($
(ls $testdir |
grep "[0-9][0-9]r1\|raid1" |
grep -vi "r10\|raid10"))
232 TESTLIST
=($
(ls $testdir |
grep "[0-9][0-9]r[4-6]\|raid[4-6]"))
235 TESTLIST
=($
(ls $testdir |
grep "[0-9][0-9]r10\|raid10"))
238 TESTLIST
=($
(ls $testdir |
grep "[0-9][0-9]ddf"))
241 TESTLIST
=($
(ls $testdir |
grep "[0-9][0-9]imsm"))
244 echo "Unknown argument: $i"
256 --keep-going |
--no-error )
265 --skip-always-broken )
268 --disable-multipath )
271 --disable-integrity )
292 echo "Unknown argument: $i"
299 disks
=(${disks[*]} ${i##*=})
302 LVM_VOLGROUP
=`expr "x$i" : 'x[^=]*=\(.*\)'`
309 echo " $0: Unknown argument: $i"
319 Warning! Tests are performed on system level mdadm!
320 If you want to test local build, you need to install it first!
328 echo "Testing on linux-$(uname -r) kernel"
329 [ "$savelogs" == "1" ] &&
330 echo "Saving logs to $logdir"
333 if [ "x$TESTLIST" != "x" ]
335 for script in ${TESTLIST[@]}
337 do_test
$testdir/$script
340 for script in $testdir/$prefix $testdir/$prefix*[^~
]
351 if [ "$loop" == "0" ]; then