Skip to content

Commit

Permalink
selftests: pmtu: Allow selection of single tests
Browse files Browse the repository at this point in the history
As number of tests is growing, it's quite convenient to allow
single tests to be run.

Display usage when the script is run with any invalid argument,
keep existing semantics when no arguments are passed so that
automated runs won't break.

Instead of just looping on the list of requested tests, if any,
check first that they exist, and go through them in a nested
loop to keep the existing way to display test descriptions.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Stefano Brivio authored and David S. Miller committed Oct 16, 2018
1 parent 2527e40 commit 55bbc8f
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tools/testing/selftests/net/pmtu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,20 @@ test_pmtu_vti6_link_change_mtu() {
return ${fail}
}

usage() {
echo
echo "$0 [TEST]..."
echo "If no TEST argument is given, all tests will be run."
echo
echo "Available tests${tests}"
exit 1
}

for arg do
# Check first that all requested tests are available before running any
command -v > /dev/null "test_${arg}" || { echo "=== Test ${arg} not found"; usage; }
done

trap cleanup EXIT

exitcode=0
Expand All @@ -650,6 +664,13 @@ IFS="
for t in ${tests}; do
[ $desc -eq 0 ] && name="${t}" && desc=1 && continue || desc=0

run_this=1
for arg do
[ "${arg}" = "${name}" ] && run_this=1 && break
run_this=0
done
[ $run_this -eq 0 ] && continue

(
unset IFS
eval test_${name}
Expand Down

0 comments on commit 55bbc8f

Please sign in to comment.