selftests: net: vrf_strict_mode_test: add support to select a test to run
Add a boilerplate test loop to run all tests in vrf_strict_mode_test.sh. Add a -t flag that allows a selected test to run. Remove the vrf_strict_mode_tests function which is now unused. Signed-off-by: Jaehee Park <jhpark1013@gmail.com> Reviewed-by: David Ahern <dsahern@kernel.org> Link: https://lore.kernel.org/r/20220429164658.GA656707@jaehee-ThinkPad-X1-Extreme Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
parent
0f0c0452bb
commit
a313f858ed
@ -14,6 +14,8 @@ INIT_NETNS_NAME="init"
|
|||||||
|
|
||||||
PAUSE_ON_FAIL=${PAUSE_ON_FAIL:=no}
|
PAUSE_ON_FAIL=${PAUSE_ON_FAIL:=no}
|
||||||
|
|
||||||
|
TESTS="init testns mix"
|
||||||
|
|
||||||
log_test()
|
log_test()
|
||||||
{
|
{
|
||||||
local rc=$1
|
local rc=$1
|
||||||
@ -262,6 +264,8 @@ cleanup()
|
|||||||
|
|
||||||
vrf_strict_mode_tests_init()
|
vrf_strict_mode_tests_init()
|
||||||
{
|
{
|
||||||
|
log_section "VRF strict_mode test on init network namespace"
|
||||||
|
|
||||||
vrf_strict_mode_check_support init
|
vrf_strict_mode_check_support init
|
||||||
|
|
||||||
strict_mode_check_default init
|
strict_mode_check_default init
|
||||||
@ -292,6 +296,8 @@ vrf_strict_mode_tests_init()
|
|||||||
|
|
||||||
vrf_strict_mode_tests_testns()
|
vrf_strict_mode_tests_testns()
|
||||||
{
|
{
|
||||||
|
log_section "VRF strict_mode test on testns network namespace"
|
||||||
|
|
||||||
vrf_strict_mode_check_support testns
|
vrf_strict_mode_check_support testns
|
||||||
|
|
||||||
strict_mode_check_default testns
|
strict_mode_check_default testns
|
||||||
@ -318,6 +324,8 @@ vrf_strict_mode_tests_testns()
|
|||||||
|
|
||||||
vrf_strict_mode_tests_mix()
|
vrf_strict_mode_tests_mix()
|
||||||
{
|
{
|
||||||
|
log_section "VRF strict_mode test mixing init and testns network namespaces"
|
||||||
|
|
||||||
read_strict_mode_compare_and_check init 1
|
read_strict_mode_compare_and_check init 1
|
||||||
|
|
||||||
read_strict_mode_compare_and_check testns 0
|
read_strict_mode_compare_and_check testns 0
|
||||||
@ -341,18 +349,30 @@ vrf_strict_mode_tests_mix()
|
|||||||
read_strict_mode_compare_and_check testns 0
|
read_strict_mode_compare_and_check testns 0
|
||||||
}
|
}
|
||||||
|
|
||||||
vrf_strict_mode_tests()
|
################################################################################
|
||||||
|
# usage
|
||||||
|
|
||||||
|
usage()
|
||||||
{
|
{
|
||||||
log_section "VRF strict_mode test on init network namespace"
|
cat <<EOF
|
||||||
vrf_strict_mode_tests_init
|
usage: ${0##*/} OPTS
|
||||||
|
|
||||||
log_section "VRF strict_mode test on testns network namespace"
|
-t <test> Test(s) to run (default: all)
|
||||||
vrf_strict_mode_tests_testns
|
(options: $TESTS)
|
||||||
|
EOF
|
||||||
log_section "VRF strict_mode test mixing init and testns network namespaces"
|
|
||||||
vrf_strict_mode_tests_mix
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# main
|
||||||
|
|
||||||
|
while getopts ":t:h" opt; do
|
||||||
|
case $opt in
|
||||||
|
t) TESTS=$OPTARG;;
|
||||||
|
h) usage; exit 0;;
|
||||||
|
*) usage; exit 1;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
vrf_strict_mode_check_support()
|
vrf_strict_mode_check_support()
|
||||||
{
|
{
|
||||||
local nsname=$1
|
local nsname=$1
|
||||||
@ -391,7 +411,17 @@ fi
|
|||||||
cleanup &> /dev/null
|
cleanup &> /dev/null
|
||||||
|
|
||||||
setup
|
setup
|
||||||
vrf_strict_mode_tests
|
for t in $TESTS
|
||||||
|
do
|
||||||
|
case $t in
|
||||||
|
vrf_strict_mode_tests_init|init) vrf_strict_mode_tests_init;;
|
||||||
|
vrf_strict_mode_tests_testns|testns) vrf_strict_mode_tests_testns;;
|
||||||
|
vrf_strict_mode_tests_mix|mix) vrf_strict_mode_tests_mix;;
|
||||||
|
|
||||||
|
help) echo "Test names: $TESTS"; exit 0;;
|
||||||
|
|
||||||
|
esac
|
||||||
|
done
|
||||||
cleanup
|
cleanup
|
||||||
|
|
||||||
print_log_test_results
|
print_log_test_results
|
||||||
|
Loading…
Reference in New Issue
Block a user