mdadm/test: Convert code format to use Tab
In case to make codes neat, this commit didn't change any codes, just tidy up and use Tab as code format. Signed-off-by: Zhilong Liu <zlliu@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
This commit is contained in:
parent
922a58292f
commit
662c349a5a
702
test
702
test
|
@ -3,8 +3,9 @@
|
||||||
# run test suite for mdadm
|
# run test suite for mdadm
|
||||||
user=`id -un`
|
user=`id -un`
|
||||||
if [ " $user" != " root" ]
|
if [ " $user" != " root" ]
|
||||||
then echo >&2 "test: testing can only be done as 'root'."
|
then
|
||||||
exit 1;
|
echo >&2 "test: testing can only be done as 'root'."
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
prefix='[0-9][0-9]'
|
prefix='[0-9][0-9]'
|
||||||
|
@ -13,7 +14,7 @@ dir=`pwd`
|
||||||
mdadm=$dir/mdadm
|
mdadm=$dir/mdadm
|
||||||
if [ \! -x $mdadm ]
|
if [ \! -x $mdadm ]
|
||||||
then
|
then
|
||||||
echo >&2 "test: $mdadm isn't usable."
|
echo >&2 "test: $mdadm isn't usable."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
testdir="tests"
|
testdir="tests"
|
||||||
|
@ -25,8 +26,9 @@ echo "Testing on linux-$(uname -r) kernel"
|
||||||
|
|
||||||
# Check whether to run multipath tests
|
# Check whether to run multipath tests
|
||||||
modprobe multipath 2> /dev/null
|
modprobe multipath 2> /dev/null
|
||||||
if grep -s 'Personalities : .*multipath' > /dev/null /proc/mdstat ; then
|
if grep -s 'Personalities : .*multipath' > /dev/null /proc/mdstat
|
||||||
MULTIPATH="yes"
|
then
|
||||||
|
MULTIPATH="yes"
|
||||||
fi
|
fi
|
||||||
INTEGRITY=yes
|
INTEGRITY=yes
|
||||||
DEVTYPE=loop
|
DEVTYPE=loop
|
||||||
|
@ -36,7 +38,9 @@ LVM_VOLGROUP=mdtest
|
||||||
export MDADM_NO_SYSTEMCTL=1
|
export MDADM_NO_SYSTEMCTL=1
|
||||||
|
|
||||||
# assume md0, md1, md2 exist in /dev
|
# assume md0, md1, md2 exist in /dev
|
||||||
md0=/dev/md0 md1=/dev/md1 md2=/dev/md2
|
md0=/dev/md0
|
||||||
|
md1=/dev/md1
|
||||||
|
md2=/dev/md2
|
||||||
mdp0=/dev/md_d0
|
mdp0=/dev/md_d0
|
||||||
mdp1=/dev/md_d1
|
mdp1=/dev/md_d1
|
||||||
|
|
||||||
|
@ -69,21 +73,21 @@ config=/tmp/mdadm.conf
|
||||||
cleanup() {
|
cleanup() {
|
||||||
udevadm settle
|
udevadm settle
|
||||||
$mdadm -Ssq 2> /dev/null
|
$mdadm -Ssq 2> /dev/null
|
||||||
case $DEVTYPE in
|
case $DEVTYPE in
|
||||||
loop)
|
loop)
|
||||||
for d in 0 1 2 3 4 5 6 7 8 9 10 11 12 13
|
for d in 0 1 2 3 4 5 6 7 8 9 10 11 12 13
|
||||||
do
|
do
|
||||||
losetup -d /dev/loop$d ; # rm -f $targetdir/mdtest$d
|
losetup -d /dev/loop$d # rm -f $targetdir/mdtest$d
|
||||||
rm -f /dev/disk/by-path/loop*
|
rm -f /dev/disk/by-path/loop*
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
lvm)
|
lvm)
|
||||||
for d in 0 1 2 3 4 5 6 7 8 9 10 11 12 13
|
for d in 0 1 2 3 4 5 6 7 8 9 10 11 12 13
|
||||||
do
|
do
|
||||||
eval "lvremove --quiet -f \$dev$d"
|
eval "lvremove --quiet -f \$dev$d"
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
ctrl_c() {
|
ctrl_c() {
|
||||||
|
@ -91,329 +95,377 @@ ctrl_c() {
|
||||||
}
|
}
|
||||||
|
|
||||||
do_setup() {
|
do_setup() {
|
||||||
trap cleanup 0 1 3 15
|
trap cleanup 0 1 3 15
|
||||||
trap ctrl_c 2
|
trap ctrl_c 2
|
||||||
|
|
||||||
# make sure there are no loop devices remaining.
|
# make sure there are no loop devices remaining.
|
||||||
# udev started things can sometimes prevent them being stopped
|
# udev started things can sometimes prevent them being stopped
|
||||||
# immediately
|
# immediately
|
||||||
while grep loop /proc/partitions > /dev/null 2>&1
|
while grep loop /proc/partitions > /dev/null 2>&1
|
||||||
do
|
do
|
||||||
mdadm -Ss
|
mdadm -Ss
|
||||||
losetup -d /dev/loop[0-9]* 2> /dev/null
|
losetup -d /dev/loop[0-9]* 2> /dev/null
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
devlist=
|
devlist=
|
||||||
for d in 0 1 2 3 4 5 6 7 8 9 10 11 12 13
|
for d in 0 1 2 3 4 5 6 7 8 9 10 11 12 13
|
||||||
do
|
do
|
||||||
sz=$size
|
sz=$size
|
||||||
if [ $d -gt 7 ]; then sz=$ddfsize ; fi
|
if [ $d -gt 7 ]
|
||||||
case $DEVTYPE in
|
then
|
||||||
loop)
|
sz=$ddfsize
|
||||||
[ -f $targetdir/mdtest$d ] || dd if=/dev/zero of=$targetdir/mdtest$d count=$sz bs=1K > /dev/null 2>&1
|
fi
|
||||||
# make sure udev doesn't touch
|
case $DEVTYPE in
|
||||||
mdadm --zero $targetdir/mdtest$d 2> /dev/null
|
loop)
|
||||||
[ -b /dev/loop$d ] || mknod /dev/loop$d b 7 $d
|
[ -f $targetdir/mdtest$d ] ||
|
||||||
if [ $d -eq 7 ]
|
dd if=/dev/zero of=$targetdir/mdtest$d count=$sz bs=1K > /dev/null 2>&1
|
||||||
then
|
# make sure udev doesn't touch
|
||||||
losetup /dev/loop$d $targetdir/mdtest6 # for multipath use
|
mdadm --zero $targetdir/mdtest$d 2> /dev/null
|
||||||
else
|
[ -b /dev/loop$d ] || mknod /dev/loop$d b 7 $d
|
||||||
losetup /dev/loop$d $targetdir/mdtest$d
|
if [ $d -eq 7 ]
|
||||||
fi
|
then
|
||||||
eval dev$d=/dev/loop$d
|
losetup /dev/loop$d $targetdir/mdtest6 # for multipath use
|
||||||
eval file$d=$targetdir/mdtest$d
|
else
|
||||||
;;
|
losetup /dev/loop$d $targetdir/mdtest$d
|
||||||
lvm)
|
fi
|
||||||
unset MULTIPATH
|
eval dev$d=/dev/loop$d
|
||||||
eval dev$d=/dev/mapper/${LVM_VOLGROUP}-mdtest$d
|
eval file$d=$targetdir/mdtest$d
|
||||||
if ! lvcreate --quiet -L ${sz}K -n mdtest$d $LVM_VOLGROUP; then
|
;;
|
||||||
trap '' 0 # make sure lvremove is not called
|
lvm)
|
||||||
eval echo error creating \$dev$d
|
unset MULTIPATH
|
||||||
exit 129
|
eval dev$d=/dev/mapper/${LVM_VOLGROUP}-mdtest$d
|
||||||
fi
|
if ! lvcreate --quiet -L ${sz}K -n mdtest$d $LVM_VOLGROUP
|
||||||
;;
|
then
|
||||||
ram)
|
trap '' 0 # make sure lvremove is not called
|
||||||
unset MULTIPATH
|
eval echo error creating \$dev$d
|
||||||
eval dev$d=/dev/ram$d
|
exit 129
|
||||||
;;
|
fi
|
||||||
esac
|
;;
|
||||||
eval devlist=\"\$devlist \$dev$d\"
|
ram)
|
||||||
eval devlist$d=\"\$devlist\"
|
unset MULTIPATH
|
||||||
#" <-- add this quote to un-confuse vim syntax highlighting
|
eval dev$d=/dev/ram$d
|
||||||
done
|
;;
|
||||||
path0=$dev6
|
esac
|
||||||
path1=$dev7
|
eval devlist=\"\$devlist \$dev$d\"
|
||||||
|
eval devlist$d=\"\$devlist\"
|
||||||
ulimit -c unlimited
|
#" <-- add this quote to un-confuse vim syntax highlighting
|
||||||
[ -f /proc/mdstat ] || modprobe md_mod
|
done
|
||||||
echo 2000 > /proc/sys/dev/raid/speed_limit_max
|
path0=$dev6
|
||||||
echo 0 > /sys/module/md_mod/parameters/start_ro
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
# mdadm always adds --quiet, and we want to see any unexpected messages
|
# mdadm always adds --quiet, and we want to see any unexpected messages
|
||||||
mdadm() {
|
mdadm() {
|
||||||
rm -f $targetdir/stderr
|
rm -f $targetdir/stderr
|
||||||
case $* in
|
case $* in
|
||||||
*-S* ) udevadm settle
|
*-S* )
|
||||||
p=`cat /proc/sys/dev/raid/speed_limit_max`
|
udevadm settle
|
||||||
echo 20000 > /proc/sys/dev/raid/speed_limit_max
|
p=`cat /proc/sys/dev/raid/speed_limit_max`
|
||||||
esac
|
echo 20000 > /proc/sys/dev/raid/speed_limit_max
|
||||||
case $* in
|
;;
|
||||||
*-C* ) $mdadm 2> $targetdir/stderr --quiet "$@" --auto=yes;;
|
esac
|
||||||
* ) $mdadm 2> $targetdir/stderr --quiet "$@"
|
case $* in
|
||||||
esac
|
*-C* )
|
||||||
rv=$?
|
$mdadm 2> $targetdir/stderr --quiet "$@" --auto=yes
|
||||||
case $* in
|
;;
|
||||||
*-S* ) udevadm settle
|
* )
|
||||||
echo $p > /proc/sys/dev/raid/speed_limit_max
|
$mdadm 2> $targetdir/stderr --quiet "$@"
|
||||||
esac
|
;;
|
||||||
cat >&2 $targetdir/stderr
|
esac
|
||||||
return $rv
|
rv=$?
|
||||||
|
case $* in
|
||||||
|
*-S* )
|
||||||
|
udevadm settle
|
||||||
|
echo $p > /proc/sys/dev/raid/speed_limit_max
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
cat >&2 $targetdir/stderr
|
||||||
|
return $rv
|
||||||
}
|
}
|
||||||
|
|
||||||
# check various things
|
# check various things
|
||||||
check() {
|
check() {
|
||||||
case $1 in
|
case $1 in
|
||||||
spares )
|
spares )
|
||||||
spares=`tr '] ' '\012\012' < /proc/mdstat | grep -c '(S)' || exit 0`
|
spares=`tr '] ' '\012\012' < /proc/mdstat | grep -c '(S)' || exit 0`
|
||||||
if [ $spares -ne $2 ]
|
if [ $spares -ne $2 ]
|
||||||
then
|
then
|
||||||
echo >&2 "ERROR expected $2 spares, found $spares"; exit 1;
|
echo >&2 "ERROR expected $2 spares, found $spares"
|
||||||
fi
|
exit 1
|
||||||
;;
|
fi
|
||||||
raid* | linear )
|
;;
|
||||||
grep -s "active $1 " /proc/mdstat > /dev/null || {
|
raid* | linear )
|
||||||
echo >&2 "ERROR active $1 not found" ; cat /proc/mdstat ; exit 1;}
|
grep -s "active $1 " /proc/mdstat > /dev/null || {
|
||||||
;;
|
echo >&2 "ERROR active $1 not found"
|
||||||
algorithm )
|
cat /proc/mdstat
|
||||||
grep -s " algorithm $2 " /proc/mdstat > /dev/null || {
|
exit 1
|
||||||
echo >&2 "ERROR algorithm $2 not found"; cat /proc/mdstat; exit 1;}
|
}
|
||||||
;;
|
;;
|
||||||
resync | recovery | reshape)
|
algorithm )
|
||||||
cnt=5
|
grep -s " algorithm $2 " /proc/mdstat > /dev/null || {
|
||||||
while ! grep -s $1 /proc/mdstat > /dev/null
|
echo >&2 "ERROR algorithm $2 not found"
|
||||||
do
|
cat /proc/mdstat
|
||||||
if [ $cnt -gt 0 ] && grep -v idle /sys/block/md*/md/sync_action > /dev/null
|
exit 1
|
||||||
then # Something isn't idle - wait a bit
|
}
|
||||||
|
;;
|
||||||
|
resync | recovery | reshape )
|
||||||
|
cnt=5
|
||||||
|
while ! grep -s $1 /proc/mdstat > /dev/null
|
||||||
|
do
|
||||||
|
if [ $cnt -gt 0 ] && grep -v idle /sys/block/md*/md/sync_action > /dev/null
|
||||||
|
then # Something isn't idle - wait a bit
|
||||||
|
sleep 0.5
|
||||||
|
cnt=$[cnt-1]
|
||||||
|
else
|
||||||
|
echo >&2 ERROR no $1 happening
|
||||||
|
cat /proc/mdstat
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
nosync )
|
||||||
sleep 0.5
|
sleep 0.5
|
||||||
cnt=$[cnt-1]
|
# Since 4.2 we delay the close of recovery until there has been a chance for
|
||||||
else
|
# spares to be activated. That means that a recovery that finds nothing
|
||||||
echo >&2 ERROR no $1 happening; cat /proc/mdstat; exit 1
|
# to do can still take a little longer than expected.
|
||||||
fi
|
# add an extra check: is sync_completed shows the end is reached, assume
|
||||||
done
|
# there is no recovery.
|
||||||
;;
|
if grep -s -E '(resync|recovery|reshape) *=' > /dev/null /proc/mdstat
|
||||||
|
then
|
||||||
nosync )
|
incomplete=`grep / /sys/block/md*/md/sync_completed 2> /dev/null | sed '/^ *\([0-9]*\) \/ \1/d'`
|
||||||
sleep 0.5
|
if [ -n "$incomplete" ]
|
||||||
# Since 4.2 we delay the close of recovery until there has been a chance for
|
then
|
||||||
# spares to be activated. That means that a recovery that finds nothing
|
echo >&2 "ERROR resync or recovery is happening!"
|
||||||
# to do can still take a little longer than expected.
|
cat /proc/mdstat
|
||||||
# add an extra check: is sync_completed shows the end is reached, assume
|
exit 1
|
||||||
# there is no recovery.
|
fi
|
||||||
if grep -s -E '(resync|recovery|reshape) *=' > /dev/null /proc/mdstat ; then
|
fi
|
||||||
incomplete=`grep / /sys/block/md*/md/sync_completed 2> /dev/null | sed '/^ *\([0-9]*\) \/ \1/d'`
|
;;
|
||||||
if [ -n "$incomplete" ]; then
|
wait )
|
||||||
echo >&2 "ERROR resync or recovery is happening!"; cat /proc/mdstat ; exit 1;
|
p=`cat /proc/sys/dev/raid/speed_limit_max`
|
||||||
fi
|
echo 2000000 > /proc/sys/dev/raid/speed_limit_max
|
||||||
fi
|
sleep 0.1
|
||||||
;;
|
while grep -E '(resync|recovery|reshape|check|repair) *=' > /dev/null /proc/mdstat ||
|
||||||
|
grep -v idle > /dev/null /sys/block/md*/md/sync_action
|
||||||
wait )
|
do
|
||||||
p=`cat /proc/sys/dev/raid/speed_limit_max`
|
sleep 0.5
|
||||||
echo 2000000 > /proc/sys/dev/raid/speed_limit_max
|
done
|
||||||
sleep 0.1
|
echo $p > /proc/sys/dev/raid/speed_limit_max
|
||||||
while grep -E '(resync|recovery|reshape|check|repair) *=' > /dev/null /proc/mdstat ||
|
;;
|
||||||
grep -v idle > /dev/null /sys/block/md*/md/sync_action
|
state )
|
||||||
do sleep 0.5;
|
grep -s "blocks.*\[$2\]\$" /proc/mdstat > /dev/null || {
|
||||||
done
|
echo >&2 "ERROR state $2 not found!"
|
||||||
echo $p > /proc/sys/dev/raid/speed_limit_max
|
cat /proc/mdstat
|
||||||
;;
|
exit 1
|
||||||
|
}
|
||||||
state )
|
sleep 0.5
|
||||||
grep -s "blocks.*\[$2\]\$" /proc/mdstat > /dev/null || {
|
;;
|
||||||
echo >&2 "ERROR state $2 not found!"; cat /proc/mdstat ; exit 1; }
|
bitmap )
|
||||||
sleep 0.5
|
grep -s bitmap > /dev/null /proc/mdstat || {
|
||||||
;;
|
echo >&2 ERROR no bitmap
|
||||||
|
cat /proc/mdstat
|
||||||
bitmap )
|
exit 1
|
||||||
grep -s bitmap > /dev/null /proc/mdstat || {
|
}
|
||||||
echo >&2 ERROR no bitmap ; cat /proc/mdstat ; exit 1; }
|
;;
|
||||||
;;
|
nobitmap )
|
||||||
nobitmap )
|
if grep -s "bitmap" > /dev/null /proc/mdstat
|
||||||
if grep -s "bitmap" > /dev/null /proc/mdstat
|
then
|
||||||
then
|
echo >&2 ERROR bitmap present
|
||||||
echo >&2 ERROR bitmap present ; cat /proc/mdstat ; exit 1;
|
cat /proc/mdstat
|
||||||
fi
|
exit 1
|
||||||
;;
|
fi
|
||||||
|
;;
|
||||||
readonly )
|
readonly )
|
||||||
grep -s "read-only" > /dev/null /proc/mdstat || {
|
grep -s "read-only" > /dev/null /proc/mdstat || {
|
||||||
echo >&2 "ERROR array is not read-only!"; cat /proc/mdstat ; exit 1; }
|
echo >&2 "ERROR array is not read-only!"
|
||||||
;;
|
cat /proc/mdstat
|
||||||
|
exit 1
|
||||||
inactive )
|
}
|
||||||
grep -s "inactive" > /dev/null /proc/mdstat || {
|
;;
|
||||||
echo >&2 "ERROR array is not inactive!"; cat /proc/mdstat ; exit 1; }
|
inactive )
|
||||||
;;
|
grep -s "inactive" > /dev/null /proc/mdstat || {
|
||||||
* ) echo >&2 ERROR unknown check $1 ; exit 1;
|
echo >&2 "ERROR array is not inactive!"
|
||||||
esac
|
cat /proc/mdstat
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
echo >&2 ERROR unknown check $1
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
no_errors() {
|
no_errors() {
|
||||||
if [ -s $targetdir/stderr ]
|
if [ -s $targetdir/stderr ]
|
||||||
then echo Bad errors from mdadm: ; cat $targetdir/stderr; exit 2;
|
then
|
||||||
fi
|
echo Bad errors from mdadm:
|
||||||
|
cat $targetdir/stderr
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
# basic device test
|
|
||||||
|
|
||||||
|
# basic device test
|
||||||
testdev() {
|
testdev() {
|
||||||
udevadm settle
|
udevadm settle
|
||||||
dev=$1
|
dev=$1
|
||||||
cnt=$2
|
cnt=$2
|
||||||
dvsize=$3
|
dvsize=$3
|
||||||
chunk=$4
|
chunk=$4
|
||||||
if [ -z "$5" ]; then
|
if [ -z "$5" ]
|
||||||
mkfs.ext3 -F -j $dev > /dev/null 2>&1 && fsck -fn $dev >&2
|
then
|
||||||
fi
|
mkfs.ext3 -F -j $dev > /dev/null 2>&1 && fsck -fn $dev >&2
|
||||||
dsize=$[dvsize/chunk]
|
fi
|
||||||
dsize=$[dsize*chunk]
|
dsize=$[dvsize/chunk]
|
||||||
rasize=$[dsize*2*cnt]
|
dsize=$[dsize*chunk]
|
||||||
# rasize is in sectors
|
rasize=$[dsize*2*cnt]
|
||||||
if [ -n "$DEV_ROUND_K" ]; then
|
# rasize is in sectors
|
||||||
rasize=$[rasize/DEV_ROUND_K/2]
|
if [ -n "$DEV_ROUND_K" ]
|
||||||
rasize=$[rasize*DEV_ROUND_K*2]
|
then
|
||||||
fi
|
rasize=$[rasize/DEV_ROUND_K/2]
|
||||||
if [ `/sbin/blockdev --getsize $dev` -eq 0 ]; then sleep 2 ; fi
|
rasize=$[rasize*DEV_ROUND_K*2]
|
||||||
_sz=`/sbin/blockdev --getsize $dev`
|
fi
|
||||||
if [ $rasize -lt $_sz -o $[rasize*4/5] -gt $_sz ]
|
if [ `/sbin/blockdev --getsize $dev` -eq 0 ]
|
||||||
then
|
then
|
||||||
echo "ERROR: size is wrong for $dev: $cnt * $dvsize (chunk=$chunk) = $rasize, not $_sz"
|
sleep 2
|
||||||
exit 1
|
fi
|
||||||
fi
|
_sz=`/sbin/blockdev --getsize $dev`
|
||||||
|
if [ $rasize -lt $_sz -o $[rasize*4/5] -gt $_sz ]
|
||||||
|
then
|
||||||
|
echo "ERROR: size is wrong for $dev: $cnt * $dvsize (chunk=$chunk) = $rasize, not $_sz"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
fast_sync() {
|
fast_sync() {
|
||||||
echo 200000 > /proc/sys/dev/raid/speed_limit_max
|
echo 200000 > /proc/sys/dev/raid/speed_limit_max
|
||||||
}
|
}
|
||||||
|
|
||||||
rotest() {
|
rotest() {
|
||||||
dev=$1
|
dev=$1
|
||||||
fsck -fn $dev >&2
|
fsck -fn $dev >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
do_test() {
|
do_test() {
|
||||||
_script=$1
|
_script=$1
|
||||||
_basename=`basename $_script`
|
_basename=`basename $_script`
|
||||||
if [ -f "$_script" ]
|
if [ -f "$_script" ]
|
||||||
then
|
then
|
||||||
rm -f $targetdir/stderr
|
rm -f $targetdir/stderr
|
||||||
# stop all arrays, just incase some script left an array active.
|
# stop all arrays, just incase some script left an array active.
|
||||||
$mdadm -Ssq 2> /dev/null
|
$mdadm -Ssq 2> /dev/null
|
||||||
mdadm --zero $devlist 2> /dev/null
|
mdadm --zero $devlist 2> /dev/null
|
||||||
mdadm --zero $devlist 2> /dev/null
|
mdadm --zero $devlist 2> /dev/null
|
||||||
# this might have been reset: restore the default.
|
# this might have been reset: restore the default.
|
||||||
echo 2000 > /proc/sys/dev/raid/speed_limit_max
|
echo 2000 > /proc/sys/dev/raid/speed_limit_max
|
||||||
# source script in a subshell, so it has access to our
|
# source script in a subshell, so it has access to our
|
||||||
# namespace, but cannot change it.
|
# namespace, but cannot change it.
|
||||||
echo -ne "$_script... "
|
echo -ne "$_script... "
|
||||||
if ( set -ex ; . $_script ) &> $targetdir/log
|
if ( set -ex ; . $_script ) &> $targetdir/log
|
||||||
then
|
then
|
||||||
echo "succeeded"
|
echo "succeeded"
|
||||||
_fail=0
|
_fail=0
|
||||||
else
|
else
|
||||||
log=log
|
log=log
|
||||||
cat $targetdir/stderr >> $targetdir/log
|
cat $targetdir/stderr >> $targetdir/log
|
||||||
echo "=======================dmesg=================" >> $targetdir/log
|
echo "=======================dmesg=================" >> $targetdir/log
|
||||||
dmesg | tail -n 200 >> $targetdir/log
|
dmesg | tail -n 200 >> $targetdir/log
|
||||||
if [ $exitonerror == 0 ]; then
|
if [ $exitonerror == 0 ]; then
|
||||||
log=log-`basename $_script`
|
log=log-`basename $_script`
|
||||||
mv $targetdir/log $logdir/$log
|
mv $targetdir/log $logdir/$log
|
||||||
fi
|
fi
|
||||||
echo "FAILED - see $logdir/$log for details"
|
echo "FAILED - see $logdir/$log for details"
|
||||||
_fail=1
|
_fail=1
|
||||||
fi
|
fi
|
||||||
if [ "$savelogs" == "1" ]; then
|
if [ "$savelogs" == "1" ]
|
||||||
cp $targetdir/log $logdir/$_basename.log
|
then
|
||||||
fi
|
cp $targetdir/log $logdir/$_basename.log
|
||||||
if [ "$_fail" == "1" -a "$exitonerror" == "1" ]; then
|
fi
|
||||||
exit 1
|
if [ "$_fail" == "1" -a "$exitonerror" == "1" ]
|
||||||
fi
|
then
|
||||||
fi
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
do_help() {
|
do_help() {
|
||||||
echo "Usage: $0 [options]"
|
echo "Usage: $0 [options]"
|
||||||
echo " Options:"
|
echo " Options:"
|
||||||
echo " --tests=<test1,test2,..> Comma separated list of tests to run"
|
echo " --tests=<test1,test2,..> Comma separated list of tests to run"
|
||||||
echo " --disable-multipath Disable any tests involving multipath"
|
echo " --disable-multipath Disable any tests involving multipath"
|
||||||
echo " --disable-integrity Disable slow tests of RAID[56] consistency"
|
echo " --disable-integrity Disable slow tests of RAID[56] consistency"
|
||||||
echo " --logdir=<directory> Directory to save logfiles in"
|
echo " --logdir=<directory> Directory to save logfiles in"
|
||||||
echo " --save-logs Save all logs in <logdir>"
|
echo " --save-logs Save all logs in <logdir>"
|
||||||
echo " --keep-going Don't stop on error, ie. run all tests"
|
echo " --keep-going Don't stop on error, ie. run all tests"
|
||||||
echo " --dev=[loop|lvm|ram] Use loop devices (default), LVM, or RAM disk"
|
echo " --dev=[loop|lvm|ram] Use loop devices (default), LVM, or RAM disk"
|
||||||
echo " --volgroup=<name> LVM volume group for LVM test"
|
echo " --volgroup=<name> LVM volume group for LVM test"
|
||||||
echo " setup Setup test environment and exit"
|
echo " setup Setup test environment and exit"
|
||||||
echo " cleanup Cleanup test environment"
|
echo " cleanup Cleanup test environment"
|
||||||
echo " <prefix> Run tests with <prefix>"
|
echo " <prefix> Run tests with <prefix>"
|
||||||
}
|
}
|
||||||
|
|
||||||
parse_args() {
|
parse_args() {
|
||||||
for i in $*
|
for i in $*
|
||||||
do
|
do
|
||||||
case $i in
|
case $i in
|
||||||
[0-9]*)
|
[0-9]* )
|
||||||
prefix=$i
|
prefix=$i
|
||||||
;;
|
;;
|
||||||
setup)
|
setup )
|
||||||
echo "mdadm test environment setup"
|
echo "mdadm test environment setup"
|
||||||
do_setup
|
do_setup
|
||||||
trap 0; exit 0
|
trap 0
|
||||||
;;
|
exit 0
|
||||||
cleanup)
|
;;
|
||||||
cleanup
|
cleanup )
|
||||||
exit 0
|
cleanup
|
||||||
;;
|
exit 0
|
||||||
--tests=*)
|
;;
|
||||||
TESTLIST=`expr "x$i" : 'x[^=]*=\(.*\)' | sed -e 's/,/ /g'`
|
--tests=* )
|
||||||
;;
|
TESTLIST=`expr "x$i" : 'x[^=]*=\(.*\)' | sed -e 's/,/ /g'`
|
||||||
--logdir=*)
|
;;
|
||||||
logdir=`expr "x$i" : 'x[^=]*=\(.*\)'`
|
--logdir=* )
|
||||||
;;
|
logdir=`expr "x$i" : 'x[^=]*=\(.*\)'`
|
||||||
--save-logs)
|
;;
|
||||||
savelogs=1
|
--save-logs )
|
||||||
;;
|
savelogs=1
|
||||||
--keep-going | --no-error)
|
;;
|
||||||
exitonerror=0
|
--keep-going | --no-error )
|
||||||
;;
|
exitonerror=0
|
||||||
--disable-multipath)
|
;;
|
||||||
unset MULTIPATH
|
--disable-multipath )
|
||||||
;;
|
unset MULTIPATH
|
||||||
--disable-integrity)
|
;;
|
||||||
unset INTEGRITY
|
--disable-integrity )
|
||||||
;;
|
unset INTEGRITY
|
||||||
--dev=loop)
|
;;
|
||||||
DEVTYPE=loop
|
--dev=loop )
|
||||||
;;
|
DEVTYPE=loop
|
||||||
--dev=lvm)
|
;;
|
||||||
DEVTYPE=lvm
|
--dev=lvm )
|
||||||
;;
|
DEVTYPE=lvm
|
||||||
--dev=ram)
|
;;
|
||||||
DEVTYPE=ram
|
--dev=ram )
|
||||||
;;
|
DEVTYPE=ram
|
||||||
--volgroup=*)
|
;;
|
||||||
LVM_VOLGROUP=`expr "x$i" : 'x[^=]*=\(.*\)'`
|
--volgroup=* )
|
||||||
;;
|
LVM_VOLGROUP=`expr "x$i" : 'x[^=]*=\(.*\)'`
|
||||||
--help)
|
;;
|
||||||
do_help
|
--help )
|
||||||
exit 0;
|
do_help
|
||||||
;;
|
exit 0
|
||||||
-*)
|
;;
|
||||||
echo " $0: Unknown argument: $i"
|
-* )
|
||||||
do_help
|
echo " $0: Unknown argument: $i"
|
||||||
exit 0;
|
do_help
|
||||||
;;
|
exit 0
|
||||||
esac
|
;;
|
||||||
done
|
esac
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
logdir=$targetdir
|
logdir=$targetdir
|
||||||
|
@ -422,19 +474,21 @@ parse_args $@
|
||||||
do_setup
|
do_setup
|
||||||
mkdir -p $logdir
|
mkdir -p $logdir
|
||||||
|
|
||||||
if [ "$savelogs" == "1" ]; then
|
if [ "$savelogs" == "1" ]
|
||||||
echo "Saving logs to $logdir"
|
then
|
||||||
|
echo "Saving logs to $logdir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "x$TESTLIST" != "x" ]; then
|
if [ "x$TESTLIST" != "x" ]
|
||||||
for script in $TESTLIST
|
then
|
||||||
do
|
for script in $TESTLIST
|
||||||
do_test $testdir/$script
|
do
|
||||||
done
|
do_test $testdir/$script
|
||||||
|
done
|
||||||
else
|
else
|
||||||
for script in $testdir/$prefix $testdir/$prefix*[^~]
|
for script in $testdir/$prefix $testdir/$prefix*[^~]
|
||||||
do
|
do
|
||||||
do_test $script
|
do_test $script
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in New Issue