Skip to content

Commit

Permalink
selftests: mptcp: join: helpers to skip tests
Browse files Browse the repository at this point in the history
Selftests are supposed to run on any kernels, including the old ones not
supporting all MPTCP features.

Here are some helpers that will be used to mark subtests as skipped if a
feature is not supported. Marking as a fix for the commit introducing
this selftest to help with the backports.

While at it, also check if kallsyms feature is available as it will also
be used in the following commits to check if MPTCP features are
available before starting a test.

Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368
Fixes: b08fbf2 ("selftests: add test-cases for MPTCP MP_JOIN")
Cc: stable@vger.kernel.org
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Matthieu Baerts authored and Jakub Kicinski committed Jun 12, 2023
1 parent 0c4cd3f commit cdb5052
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tools/testing/selftests/net/mptcp/mptcp_join.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ cleanup_partial()
check_tools()
{
mptcp_lib_check_mptcp
mptcp_lib_check_kallsyms

if ! ip -Version &> /dev/null; then
echo "SKIP: Could not run test without ip tool"
Expand Down Expand Up @@ -191,6 +192,32 @@ cleanup()
cleanup_partial
}

# $1: msg
print_title()
{
printf "%03u %-36s %s" "${TEST_COUNT}" "${TEST_NAME}" "${1}"
}

# [ $1: fail msg ]
mark_as_skipped()
{
local msg="${1:-"Feature not supported"}"

mptcp_lib_fail_if_expected_feature "${msg}"

print_title "[ skip ] ${msg}"
printf "\n"
}

# $@: condition
continue_if()
{
if ! "${@}"; then
mark_as_skipped
return 1
fi
}

skip_test()
{
if [ "${#only_tests_ids[@]}" -eq 0 ] && [ "${#only_tests_names[@]}" -eq 0 ]; then
Expand Down

0 comments on commit cdb5052

Please sign in to comment.