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
178
test
178
test
|
@ -3,8 +3,9 @@
|
|||
# run test suite for mdadm
|
||||
user=`id -un`
|
||||
if [ " $user" != " root" ]
|
||||
then echo >&2 "test: testing can only be done as 'root'."
|
||||
exit 1;
|
||||
then
|
||||
echo >&2 "test: testing can only be done as 'root'."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
prefix='[0-9][0-9]'
|
||||
|
@ -25,7 +26,8 @@ echo "Testing on linux-$(uname -r) kernel"
|
|||
|
||||
# Check whether to run multipath tests
|
||||
modprobe multipath 2> /dev/null
|
||||
if grep -s 'Personalities : .*multipath' > /dev/null /proc/mdstat ; then
|
||||
if grep -s 'Personalities : .*multipath' > /dev/null /proc/mdstat
|
||||
then
|
||||
MULTIPATH="yes"
|
||||
fi
|
||||
INTEGRITY=yes
|
||||
|
@ -36,7 +38,9 @@ LVM_VOLGROUP=mdtest
|
|||
export MDADM_NO_SYSTEMCTL=1
|
||||
|
||||
# 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
|
||||
mdp1=/dev/md_d1
|
||||
|
||||
|
@ -73,7 +77,7 @@ cleanup() {
|
|||
loop)
|
||||
for d in 0 1 2 3 4 5 6 7 8 9 10 11 12 13
|
||||
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*
|
||||
done
|
||||
;;
|
||||
|
@ -107,10 +111,14 @@ do_setup() {
|
|||
for d in 0 1 2 3 4 5 6 7 8 9 10 11 12 13
|
||||
do
|
||||
sz=$size
|
||||
if [ $d -gt 7 ]; then sz=$ddfsize ; fi
|
||||
if [ $d -gt 7 ]
|
||||
then
|
||||
sz=$ddfsize
|
||||
fi
|
||||
case $DEVTYPE in
|
||||
loop)
|
||||
[ -f $targetdir/mdtest$d ] || dd if=/dev/zero of=$targetdir/mdtest$d count=$sz bs=1K > /dev/null 2>&1
|
||||
[ -f $targetdir/mdtest$d ] ||
|
||||
dd if=/dev/zero of=$targetdir/mdtest$d count=$sz bs=1K > /dev/null 2>&1
|
||||
# make sure udev doesn't touch
|
||||
mdadm --zero $targetdir/mdtest$d 2> /dev/null
|
||||
[ -b /dev/loop$d ] || mknod /dev/loop$d b 7 $d
|
||||
|
@ -126,7 +134,8 @@ do_setup() {
|
|||
lvm)
|
||||
unset MULTIPATH
|
||||
eval dev$d=/dev/mapper/${LVM_VOLGROUP}-mdtest$d
|
||||
if ! lvcreate --quiet -L ${sz}K -n mdtest$d $LVM_VOLGROUP; then
|
||||
if ! lvcreate --quiet -L ${sz}K -n mdtest$d $LVM_VOLGROUP
|
||||
then
|
||||
trap '' 0 # make sure lvremove is not called
|
||||
eval echo error creating \$dev$d
|
||||
exit 129
|
||||
|
@ -143,7 +152,6 @@ do_setup() {
|
|||
done
|
||||
path0=$dev6
|
||||
path1=$dev7
|
||||
|
||||
ulimit -c unlimited
|
||||
[ -f /proc/mdstat ] || modprobe md_mod
|
||||
echo 2000 > /proc/sys/dev/raid/speed_limit_max
|
||||
|
@ -154,18 +162,26 @@ do_setup() {
|
|||
mdadm() {
|
||||
rm -f $targetdir/stderr
|
||||
case $* in
|
||||
*-S* ) udevadm settle
|
||||
*-S* )
|
||||
udevadm settle
|
||||
p=`cat /proc/sys/dev/raid/speed_limit_max`
|
||||
echo 20000 > /proc/sys/dev/raid/speed_limit_max
|
||||
;;
|
||||
esac
|
||||
case $* in
|
||||
*-C* ) $mdadm 2> $targetdir/stderr --quiet "$@" --auto=yes;;
|
||||
* ) $mdadm 2> $targetdir/stderr --quiet "$@"
|
||||
*-C* )
|
||||
$mdadm 2> $targetdir/stderr --quiet "$@" --auto=yes
|
||||
;;
|
||||
* )
|
||||
$mdadm 2> $targetdir/stderr --quiet "$@"
|
||||
;;
|
||||
esac
|
||||
rv=$?
|
||||
case $* in
|
||||
*-S* ) udevadm settle
|
||||
*-S* )
|
||||
udevadm settle
|
||||
echo $p > /proc/sys/dev/raid/speed_limit_max
|
||||
;;
|
||||
esac
|
||||
cat >&2 $targetdir/stderr
|
||||
return $rv
|
||||
|
@ -178,18 +194,25 @@ check() {
|
|||
spares=`tr '] ' '\012\012' < /proc/mdstat | grep -c '(S)' || exit 0`
|
||||
if [ $spares -ne $2 ]
|
||||
then
|
||||
echo >&2 "ERROR expected $2 spares, found $spares"; exit 1;
|
||||
echo >&2 "ERROR expected $2 spares, found $spares"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
raid* | linear )
|
||||
grep -s "active $1 " /proc/mdstat > /dev/null || {
|
||||
echo >&2 "ERROR active $1 not found" ; cat /proc/mdstat ; exit 1;}
|
||||
echo >&2 "ERROR active $1 not found"
|
||||
cat /proc/mdstat
|
||||
exit 1
|
||||
}
|
||||
;;
|
||||
algorithm )
|
||||
grep -s " algorithm $2 " /proc/mdstat > /dev/null || {
|
||||
echo >&2 "ERROR algorithm $2 not found"; cat /proc/mdstat; exit 1;}
|
||||
echo >&2 "ERROR algorithm $2 not found"
|
||||
cat /proc/mdstat
|
||||
exit 1
|
||||
}
|
||||
;;
|
||||
resync | recovery | reshape)
|
||||
resync | recovery | reshape )
|
||||
cnt=5
|
||||
while ! grep -s $1 /proc/mdstat > /dev/null
|
||||
do
|
||||
|
@ -198,11 +221,12 @@ check() {
|
|||
sleep 0.5
|
||||
cnt=$[cnt-1]
|
||||
else
|
||||
echo >&2 ERROR no $1 happening; cat /proc/mdstat; exit 1
|
||||
echo >&2 ERROR no $1 happening
|
||||
cat /proc/mdstat
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
;;
|
||||
|
||||
nosync )
|
||||
sleep 0.5
|
||||
# Since 4.2 we delay the close of recovery until there has been a chance for
|
||||
|
@ -210,80 +234,105 @@ check() {
|
|||
# to do can still take a little longer than expected.
|
||||
# add an extra check: is sync_completed shows the end is reached, assume
|
||||
# there is no recovery.
|
||||
if grep -s -E '(resync|recovery|reshape) *=' > /dev/null /proc/mdstat ; then
|
||||
if grep -s -E '(resync|recovery|reshape) *=' > /dev/null /proc/mdstat
|
||||
then
|
||||
incomplete=`grep / /sys/block/md*/md/sync_completed 2> /dev/null | sed '/^ *\([0-9]*\) \/ \1/d'`
|
||||
if [ -n "$incomplete" ]; then
|
||||
echo >&2 "ERROR resync or recovery is happening!"; cat /proc/mdstat ; exit 1;
|
||||
if [ -n "$incomplete" ]
|
||||
then
|
||||
echo >&2 "ERROR resync or recovery is happening!"
|
||||
cat /proc/mdstat
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
wait )
|
||||
p=`cat /proc/sys/dev/raid/speed_limit_max`
|
||||
echo 2000000 > /proc/sys/dev/raid/speed_limit_max
|
||||
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
|
||||
do sleep 0.5;
|
||||
do
|
||||
sleep 0.5
|
||||
done
|
||||
echo $p > /proc/sys/dev/raid/speed_limit_max
|
||||
;;
|
||||
|
||||
state )
|
||||
grep -s "blocks.*\[$2\]\$" /proc/mdstat > /dev/null || {
|
||||
echo >&2 "ERROR state $2 not found!"; cat /proc/mdstat ; exit 1; }
|
||||
echo >&2 "ERROR state $2 not found!"
|
||||
cat /proc/mdstat
|
||||
exit 1
|
||||
}
|
||||
sleep 0.5
|
||||
;;
|
||||
|
||||
bitmap )
|
||||
grep -s bitmap > /dev/null /proc/mdstat || {
|
||||
echo >&2 ERROR no bitmap ; cat /proc/mdstat ; exit 1; }
|
||||
echo >&2 ERROR no bitmap
|
||||
cat /proc/mdstat
|
||||
exit 1
|
||||
}
|
||||
;;
|
||||
nobitmap )
|
||||
if grep -s "bitmap" > /dev/null /proc/mdstat
|
||||
then
|
||||
echo >&2 ERROR bitmap present ; cat /proc/mdstat ; exit 1;
|
||||
echo >&2 ERROR bitmap present
|
||||
cat /proc/mdstat
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
readonly )
|
||||
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; }
|
||||
echo >&2 "ERROR array is not inactive!"
|
||||
cat /proc/mdstat
|
||||
exit 1
|
||||
}
|
||||
;;
|
||||
* )
|
||||
echo >&2 ERROR unknown check $1
|
||||
exit 1
|
||||
;;
|
||||
* ) echo >&2 ERROR unknown check $1 ; exit 1;
|
||||
esac
|
||||
}
|
||||
|
||||
no_errors() {
|
||||
if [ -s $targetdir/stderr ]
|
||||
then echo Bad errors from mdadm: ; cat $targetdir/stderr; exit 2;
|
||||
then
|
||||
echo Bad errors from mdadm:
|
||||
cat $targetdir/stderr
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
# basic device test
|
||||
|
||||
# basic device test
|
||||
testdev() {
|
||||
udevadm settle
|
||||
dev=$1
|
||||
cnt=$2
|
||||
dvsize=$3
|
||||
chunk=$4
|
||||
if [ -z "$5" ]; then
|
||||
if [ -z "$5" ]
|
||||
then
|
||||
mkfs.ext3 -F -j $dev > /dev/null 2>&1 && fsck -fn $dev >&2
|
||||
fi
|
||||
dsize=$[dvsize/chunk]
|
||||
dsize=$[dsize*chunk]
|
||||
rasize=$[dsize*2*cnt]
|
||||
# rasize is in sectors
|
||||
if [ -n "$DEV_ROUND_K" ]; then
|
||||
if [ -n "$DEV_ROUND_K" ]
|
||||
then
|
||||
rasize=$[rasize/DEV_ROUND_K/2]
|
||||
rasize=$[rasize*DEV_ROUND_K*2]
|
||||
fi
|
||||
if [ `/sbin/blockdev --getsize $dev` -eq 0 ]; then sleep 2 ; fi
|
||||
if [ `/sbin/blockdev --getsize $dev` -eq 0 ]
|
||||
then
|
||||
sleep 2
|
||||
fi
|
||||
_sz=`/sbin/blockdev --getsize $dev`
|
||||
if [ $rasize -lt $_sz -o $[rasize*4/5] -gt $_sz ]
|
||||
then
|
||||
|
@ -332,10 +381,12 @@ do_test() {
|
|||
echo "FAILED - see $logdir/$log for details"
|
||||
_fail=1
|
||||
fi
|
||||
if [ "$savelogs" == "1" ]; then
|
||||
if [ "$savelogs" == "1" ]
|
||||
then
|
||||
cp $targetdir/log $logdir/$_basename.log
|
||||
fi
|
||||
if [ "$_fail" == "1" -a "$exitonerror" == "1" ]; then
|
||||
if [ "$_fail" == "1" -a "$exitonerror" == "1" ]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
@ -361,59 +412,60 @@ parse_args() {
|
|||
for i in $*
|
||||
do
|
||||
case $i in
|
||||
[0-9]*)
|
||||
[0-9]* )
|
||||
prefix=$i
|
||||
;;
|
||||
setup)
|
||||
setup )
|
||||
echo "mdadm test environment setup"
|
||||
do_setup
|
||||
trap 0; exit 0
|
||||
trap 0
|
||||
exit 0
|
||||
;;
|
||||
cleanup)
|
||||
cleanup )
|
||||
cleanup
|
||||
exit 0
|
||||
;;
|
||||
--tests=*)
|
||||
--tests=* )
|
||||
TESTLIST=`expr "x$i" : 'x[^=]*=\(.*\)' | sed -e 's/,/ /g'`
|
||||
;;
|
||||
--logdir=*)
|
||||
--logdir=* )
|
||||
logdir=`expr "x$i" : 'x[^=]*=\(.*\)'`
|
||||
;;
|
||||
--save-logs)
|
||||
--save-logs )
|
||||
savelogs=1
|
||||
;;
|
||||
--keep-going | --no-error)
|
||||
--keep-going | --no-error )
|
||||
exitonerror=0
|
||||
;;
|
||||
--disable-multipath)
|
||||
--disable-multipath )
|
||||
unset MULTIPATH
|
||||
;;
|
||||
--disable-integrity)
|
||||
--disable-integrity )
|
||||
unset INTEGRITY
|
||||
;;
|
||||
--dev=loop)
|
||||
--dev=loop )
|
||||
DEVTYPE=loop
|
||||
;;
|
||||
--dev=lvm)
|
||||
--dev=lvm )
|
||||
DEVTYPE=lvm
|
||||
;;
|
||||
--dev=ram)
|
||||
--dev=ram )
|
||||
DEVTYPE=ram
|
||||
;;
|
||||
--volgroup=*)
|
||||
--volgroup=* )
|
||||
LVM_VOLGROUP=`expr "x$i" : 'x[^=]*=\(.*\)'`
|
||||
;;
|
||||
--help)
|
||||
--help )
|
||||
do_help
|
||||
exit 0;
|
||||
exit 0
|
||||
;;
|
||||
-*)
|
||||
-* )
|
||||
echo " $0: Unknown argument: $i"
|
||||
do_help
|
||||
exit 0;
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
logdir=$targetdir
|
||||
|
@ -422,11 +474,13 @@ parse_args $@
|
|||
do_setup
|
||||
mkdir -p $logdir
|
||||
|
||||
if [ "$savelogs" == "1" ]; then
|
||||
if [ "$savelogs" == "1" ]
|
||||
then
|
||||
echo "Saving logs to $logdir"
|
||||
fi
|
||||
|
||||
if [ "x$TESTLIST" != "x" ]; then
|
||||
if [ "x$TESTLIST" != "x" ]
|
||||
then
|
||||
for script in $TESTLIST
|
||||
do
|
||||
do_test $testdir/$script
|
||||
|
|
Loading…
Reference in New Issue