mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-18 22:14:16 +00:00
selftests: fib-onlink: Make quiet by default
Add VERBOSE argument to fib-onlink-tests.sh and make output quiet by default. Add getopt parsing of inputs and support for -v (verbose) and -p (pause on fail). Signed-off-by: David Ahern <dsahern@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
75425657fe
commit
9b7e94e6e8
1 changed files with 43 additions and 5 deletions
|
@ -4,6 +4,7 @@
|
||||||
# IPv4 and IPv6 onlink tests
|
# IPv4 and IPv6 onlink tests
|
||||||
|
|
||||||
PAUSE_ON_FAIL=${PAUSE_ON_FAIL:=no}
|
PAUSE_ON_FAIL=${PAUSE_ON_FAIL:=no}
|
||||||
|
VERBOSE=0
|
||||||
|
|
||||||
# Network interfaces
|
# Network interfaces
|
||||||
# - odd in current namespace; even in peer ns
|
# - odd in current namespace; even in peer ns
|
||||||
|
@ -91,10 +92,10 @@ log_test()
|
||||||
|
|
||||||
if [ ${rc} -eq ${expected} ]; then
|
if [ ${rc} -eq ${expected} ]; then
|
||||||
nsuccess=$((nsuccess+1))
|
nsuccess=$((nsuccess+1))
|
||||||
printf "\n TEST: %-50s [ OK ]\n" "${msg}"
|
printf " TEST: %-50s [ OK ]\n" "${msg}"
|
||||||
else
|
else
|
||||||
nfail=$((nfail+1))
|
nfail=$((nfail+1))
|
||||||
printf "\n TEST: %-50s [FAIL]\n" "${msg}"
|
printf " TEST: %-50s [FAIL]\n" "${msg}"
|
||||||
if [ "${PAUSE_ON_FAIL}" = "yes" ]; then
|
if [ "${PAUSE_ON_FAIL}" = "yes" ]; then
|
||||||
echo
|
echo
|
||||||
echo "hit enter to continue, 'q' to quit"
|
echo "hit enter to continue, 'q' to quit"
|
||||||
|
@ -121,9 +122,23 @@ log_subsection()
|
||||||
|
|
||||||
run_cmd()
|
run_cmd()
|
||||||
{
|
{
|
||||||
echo
|
local cmd="$*"
|
||||||
echo "COMMAND: $*"
|
local out
|
||||||
eval $*
|
local rc
|
||||||
|
|
||||||
|
if [ "$VERBOSE" = "1" ]; then
|
||||||
|
printf " COMMAND: $cmd\n"
|
||||||
|
fi
|
||||||
|
|
||||||
|
out=$(eval $cmd 2>&1)
|
||||||
|
rc=$?
|
||||||
|
if [ "$VERBOSE" = "1" -a -n "$out" ]; then
|
||||||
|
echo " $out"
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ "$VERBOSE" = "1" ] && echo
|
||||||
|
|
||||||
|
return $rc
|
||||||
}
|
}
|
||||||
|
|
||||||
get_linklocal()
|
get_linklocal()
|
||||||
|
@ -450,12 +465,35 @@ run_onlink_tests()
|
||||||
invalid_onlink_ipv6
|
invalid_onlink_ipv6
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# usage
|
||||||
|
|
||||||
|
usage()
|
||||||
|
{
|
||||||
|
cat <<EOF
|
||||||
|
usage: ${0##*/} OPTS
|
||||||
|
|
||||||
|
-p Pause on fail
|
||||||
|
-v verbose mode (show commands and output)
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# main
|
# main
|
||||||
|
|
||||||
nsuccess=0
|
nsuccess=0
|
||||||
nfail=0
|
nfail=0
|
||||||
|
|
||||||
|
while getopts :t:pPhv o
|
||||||
|
do
|
||||||
|
case $o in
|
||||||
|
p) PAUSE_ON_FAIL=yes;;
|
||||||
|
v) VERBOSE=$(($VERBOSE + 1));;
|
||||||
|
h) usage; exit 0;;
|
||||||
|
*) usage; exit 1;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
cleanup
|
cleanup
|
||||||
setup
|
setup
|
||||||
run_onlink_tests
|
run_onlink_tests
|
||||||
|
|
Loading…
Add table
Reference in a new issue