Add command line argument parsing to 'test' sript
This adds more generic command line argument parsing to the test script. It also introduces a couple of new options, while preserving the old '<prefix>' and 'setup' arguments. The new options are --disable-multipath and --tests=<test1>,<test2>,... Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
parent
04c1ca5f29
commit
4e5ce543f0
88
test
88
test
|
@ -8,9 +8,6 @@ then echo >&2 "test: testing can only be done as 'root'."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
prefix='[0-9][0-9]'
|
prefix='[0-9][0-9]'
|
||||||
if [ -n "$1" ]
|
|
||||||
then prefix=$1
|
|
||||||
fi
|
|
||||||
|
|
||||||
dir=`pwd`
|
dir=`pwd`
|
||||||
mdadm=$dir/mdadm
|
mdadm=$dir/mdadm
|
||||||
|
@ -94,10 +91,6 @@ ulimit -c unlimited
|
||||||
echo 2000 > /proc/sys/dev/raid/speed_limit_max
|
echo 2000 > /proc/sys/dev/raid/speed_limit_max
|
||||||
echo 0 > /sys/module/md_mod/parameters/start_ro
|
echo 0 > /sys/module/md_mod/parameters/start_ro
|
||||||
|
|
||||||
if [ " $1" = " setup" ]
|
|
||||||
then trap 0 ; exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -209,23 +202,72 @@ rotest() {
|
||||||
fsck -fn $dev >&2
|
fsck -fn $dev >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
for script in tests/$prefix tests/$prefix*[^~]
|
do_test() {
|
||||||
do
|
_script=$1
|
||||||
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
|
||||||
# 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 ) 2> $targetdir/log
|
if ( set -ex ; . $_script ) 2> $targetdir/log
|
||||||
then echo "succeeded"
|
then echo "succeeded"
|
||||||
else echo "FAILED - see $targetdir/log for details"
|
else echo "FAILED - see $targetdir/log for details"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
do_help() {
|
||||||
|
echo "Usage: "
|
||||||
|
echo " $0 [--tests=<test1,test2,..>] [--disable-multipath] [setup] [prefix]"
|
||||||
|
}
|
||||||
|
|
||||||
|
parse_args() {
|
||||||
|
for i in $*
|
||||||
|
do
|
||||||
|
case $i in
|
||||||
|
[0-9]*)
|
||||||
|
prefix=$i
|
||||||
|
;;
|
||||||
|
setup)
|
||||||
|
echo "mdadm test environment setup"
|
||||||
|
trap 0; exit 0
|
||||||
|
;;
|
||||||
|
--tests=*)
|
||||||
|
TESTLIST=`expr "x$i" : 'x[^=]*=\(.*\)' | sed -e 's/,/ /g'`
|
||||||
|
;;
|
||||||
|
--disable-multipath)
|
||||||
|
unset MULTIPATH
|
||||||
|
;;
|
||||||
|
--help)
|
||||||
|
do_help
|
||||||
|
exit 0;
|
||||||
|
;;
|
||||||
|
-*)
|
||||||
|
echo " $0: Unknown argument: $i"
|
||||||
|
do_help
|
||||||
|
exit 0;
|
||||||
|
;;
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
parse_args $@
|
||||||
|
|
||||||
|
if [ "x$TESTLIST" != "x" ]; then
|
||||||
|
for script in $TESTLIST
|
||||||
|
do
|
||||||
|
do_test tests/$script
|
||||||
|
done
|
||||||
|
else
|
||||||
|
for script in tests/$prefix tests/$prefix*[^~]
|
||||||
|
do
|
||||||
|
do_test $script
|
||||||
|
done
|
||||||
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in New Issue