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"
31 skipcheckfile
=$testdir/$skipfile
36 # use loop devices by default if doesn't specify --dev
41 # assume md0, md1, md2 exist in /dev
45 # if user doesn't specify minor number, mdadm chooses minor number
46 # automatically from 127.
56 echo -e "\n\tERROR: $* \n"
62 echo -e "\n\tSKIPPING, REASON: $* \n"
72 rm -f $targetdir/stderr
76 p
=`cat /proc/sys/dev/raid/speed_limit_max`
77 echo 20000 > /proc
/sys
/dev
/raid
/speed_limit_max
81 *-C* |
*--create* |
*-B* |
*--build* )
82 # clear superblock every time once creating or
83 # building arrays, because it's always creating
84 # and building array many times in a test case.
87 [[ $args =~
"/dev/" ]] && {
88 [[ $args =~
"md" ]] ||
89 $mdadm --zero $args > /dev
/null
92 $mdadm 2> $targetdir/stderr
"$@"
95 $mdadm 2> $targetdir/stderr
"$@"
102 echo $p > /proc
/sys
/dev
/raid
/speed_limit_max
105 cat >&2 $targetdir/stderr
109 print_time_elapsed
() {
111 local end_sec
=$
(date +%s
)
113 local execution_time
=$
((end_sec
- start_sec
))
115 echo -ne "Execution time (seconds): ${execution_time} "
120 _basename
=`basename $_script`
123 local start_sec
=$
(date +%s
)
127 if [ -f "${_script}.broken" ]; then
129 _broken_msg
=$
(head -n1 "${_script}.broken" |
tr -d '\n')
130 if [ "$skipbroken" == "all" ]; then
132 elif [ "$skipbroken" == "always" ] &&
133 [[ "$_broken_msg" == *always
* ]]; then
138 rm -f $targetdir/stderr
140 # source script in a subshell, so it has access to our
141 # namespace, but cannot change it.
142 control_system_speed_limit
143 echo -ne "$_script... "
144 if ( set -ex ; .
$_script ) &> $targetdir/log
146 print_time_elapsed
$start_sec
147 if [ -f "${_script}.inject_error" ]; then
148 echo "dmesg checking is skipped because test inject error"
150 dmesg |
grep -iq "error\|call trace\|segfault" |
grep -v "systemd" &&
151 die
"dmesg prints errors when testing $_basename!"
153 succeed
"succeeded\n"
156 exit_code
=$?
# Capture the exit code from the script
157 if [ $exit_code -eq $SKIP ]; then
162 print_time_elapsed
$start_sec
165 if [ "$_broken" == "1" ]; then
166 echo " (KNOWN BROKEN TEST: $_broken_msg)"
170 restore_system_speed_limit
172 [ "$savelogs" == "1" ] && mv -f $targetdir/log
$logdir/$_basename.log
174 [ "$ctrl_c_error" == "1" ] && exit 1
176 [ "$_fail" == "1" -a "$exitonerror" == "1" -a "$_broken" == "0" ] && exit 1
178 [ "$_fail" == "1" ] && do_test_ret
=1
185 Example for disk mode: ./test --dev=disk --disks=/dev/sda{2..15}
187 --tests=test1,test2,... Comma separated list of tests to run
188 --testdir= Specify testdir as tests|clustermd_tests
189 --raidtype= raid0|linear|raid1|raid456|raid10|ddf|imsm
190 --disable-multipath Disable any tests involving multipath
191 --disable-integrity Disable slow tests of RAID[56] consistency
192 --disable-linear Disable any tests involving linear
193 --logdir=directory Directory to save all logfiles in
194 --save-logs Usually use with --logdir together
195 --keep-going | --no-error Don't stop on error, ie. run all tests
196 --loop=N Run tests N times (0 to run forever)
197 --skip-broken Skip tests that are known to be broken
198 --skip-always-broken Skip tests that are known to always fail
199 --skip-bigcase Skip tests that need time than 200 seconds
200 --dev=loop|lvm|ram|disk Use loop devices (default), LVM, RAM or disk
201 --disks= Provide a bunch of physical devices for test
202 --volgroup=name LVM volume group for LVM test
203 setup Setup test environment and exit
204 cleanup Cleanup test environment
205 prefix Run tests with <prefix>
206 --help | -h Print this usage
220 testdir
=clustermd_tests
221 CLUSTER_CONF
="$PWD/$testdir/cluster_conf"
224 echo "Unknown argument: $i"
232 [ -z "$testdir" ] && testdir
=tests
241 echo "mdadm test environment setup"
253 TESTLIST
=($
(echo ${i##*=} |
sed -e 's/,/ /g'))
258 TESTLIST
=($
(ls $testdir |
grep "[0-9][0-9]r0\|raid0"))
261 TESTLIST
=($
(ls $testdir |
grep "linear"))
264 TESTLIST
=($
(ls $testdir |
grep "[0-9][0-9]r1\|raid1" |
grep -vi "r10\|raid10"))
267 TESTLIST
=($
(ls $testdir |
grep "[0-9][0-9]r[4-6]\|raid[4-6]"))
270 TESTLIST
=($
(ls $testdir |
grep "[0-9][0-9]r10\|raid10"))
273 TESTLIST
=($
(ls $testdir |
grep "[0-9][0-9]ddf"))
276 TESTLIST
=($
(ls $testdir |
grep "[0-9][0-9]imsm"))
279 echo "Unknown argument: $i"
291 --keep-going |
--no-error )
300 --skip-always-broken )
306 --disable-multipath )
309 --disable-integrity )
330 echo "Unknown argument: $i"
337 disks
=(${disks[*]} ${i##*=})
340 LVM_VOLGROUP
=`expr "x$i" : 'x[^=]*=\(.*\)'`
347 echo " $0: Unknown argument: $i"
356 warn
"Warning! Tests are performed on system level mdadm!\n"
357 echo "If you want to test local build, you need to install it first!"
364 echo "Testing on linux-$(uname -r) kernel"
365 [ "$savelogs" == "1" ] &&
366 echo "Saving logs to $logdir"
371 if [ "x$TESTLIST" != "x" ]
373 for script in ${TESTLIST[@]}
375 do_test
$testdir/$script
378 for script in $testdir/$prefix $testdir/$prefix*[^~
]
380 checkscript
="${script##*/}"
385 if grep -q "$checkscript" "$skipcheckfile"; then
386 if [ "$skipbigcase" == "all" ]; then
396 if [ "$loop" == "0" ]; then