Commit 1c7447b4 authored by David Ahern's avatar David Ahern Committed by David S. Miller

selftests: fib_tests: Add command line options

Add command line options for controlling pause on fail, controlling
specific tests to run and verbose mode rather than relying on environment
variables.
Signed-off-by: default avatarDavid Ahern <dsahern@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 37ce42c1
...@@ -6,8 +6,9 @@ ...@@ -6,8 +6,9 @@
ret=0 ret=0
VERBOSE=${VERBOSE:=0} TESTS="unregister down carrier nexthop"
PAUSE_ON_FAIL=${PAUSE_ON_FAIL:=no} VERBOSE=0
PAUSE_ON_FAIL=no
IP="ip -netns testns" IP="ip -netns testns"
log_test() log_test()
...@@ -565,20 +566,36 @@ fib_nexthop_test() ...@@ -565,20 +566,36 @@ fib_nexthop_test()
} }
################################################################################ ################################################################################
# # usage
fib_test() usage()
{ {
if [ -n "$TEST" ]; then cat <<EOF
eval $TEST usage: ${0##*/} OPTS
else
fib_unreg_test -t <test> Test(s) to run (default: all)
fib_down_test (options: $TESTS)
fib_carrier_test -p Pause on fail
fib_nexthop_test -v verbose mode (show commands and output)
fi EOF
} }
################################################################################
# main
while getopts :t:pPhv o
do
case $o in
t) TESTS=$OPTARG;;
p) PAUSE_ON_FAIL=yes;;
v) VERBOSE=$(($VERBOSE + 1));;
h) usage; exit 0;;
*) usage; exit 1;;
esac
done
PEER_CMD="ip netns exec ${PEER_NS}"
if [ "$(id -u)" -ne 0 ];then if [ "$(id -u)" -ne 0 ];then
echo "SKIP: Need root privileges" echo "SKIP: Need root privileges"
exit 0 exit 0
...@@ -598,7 +615,17 @@ fi ...@@ -598,7 +615,17 @@ fi
# start clean # start clean
cleanup &> /dev/null cleanup &> /dev/null
fib_test for t in $TESTS
do
case $t in
fib_unreg_test|unregister) fib_unreg_test;;
fib_down_test|down) fib_down_test;;
fib_carrier_test|carrier) fib_carrier_test;;
fib_nexthop_test|nexthop) fib_nexthop_test;;
help) echo "Test names: $TESTS"; exit 0;;
esac
done
if [ "$TESTS" != "none" ]; then if [ "$TESTS" != "none" ]; then
printf "\nTests passed: %3d\n" ${nsuccess} printf "\nTests passed: %3d\n" ${nsuccess}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment