]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
selftests: mptcp: join: helpers to skip tests
authorMatthieu Baerts <matthieu.baerts@tessares.net>
Sat, 10 Jun 2023 16:11:38 +0000 (18:11 +0200)
committerRoxana Nicolescu <roxana.nicolescu@canonical.com>
Mon, 2 Oct 2023 15:19:16 +0000 (17:19 +0200)
BugLink: https://bugs.launchpad.net/bugs/2033931
commit cdb50525345cf5a8359ee391032ef606a7826f08 upstream.

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: b08fbf241064 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
tools/testing/selftests/net/mptcp/mptcp_join.sh

index 1ef595de25e2465b9f447d0140df16ecfb8e021c..1a9a3e85fe65bc79b4a14de7c08a9769b4a51bda 100755 (executable)
@@ -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"
@@ -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