-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
selftests: mptcp: connect: skip if MPTCP is not supported
Selftests are supposed to run on any kernels, including the old ones not supporting MPTCP. A new check is then added to make sure MPTCP is supported. If not, the test stops and is marked as "skipped". Note that this check can also mark the test as failed if 'SELFTESTS_MPTCP_LIB_EXPECT_ALL_FEATURES' env var is set to 1: by doing that, we can make sure a test is not being skipped by mistake. A new shared file is added here to be able to re-used the same check in the different selftests we have. Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368 Fixes: 048d19d ("mptcp: add basic kselftest for mptcp") Cc: stable@vger.kernel.org Acked-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
- Loading branch information
Matthieu Baerts
authored and
Paolo Abeni
committed
May 30, 2023
1 parent
d328fe8
commit d83013b
Showing
3 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#! /bin/bash | ||
# SPDX-License-Identifier: GPL-2.0 | ||
|
||
readonly KSFT_FAIL=1 | ||
readonly KSFT_SKIP=4 | ||
|
||
# SELFTESTS_MPTCP_LIB_EXPECT_ALL_FEATURES env var can be set when validating all | ||
# features using the last version of the kernel and the selftests to make sure | ||
# a test is not being skipped by mistake. | ||
mptcp_lib_expect_all_features() { | ||
[ "${SELFTESTS_MPTCP_LIB_EXPECT_ALL_FEATURES:-}" = "1" ] | ||
} | ||
|
||
# $1: msg | ||
mptcp_lib_fail_if_expected_feature() { | ||
if mptcp_lib_expect_all_features; then | ||
echo "ERROR: missing feature: ${*}" | ||
exit ${KSFT_FAIL} | ||
fi | ||
|
||
return 1 | ||
} | ||
|
||
# $1: file | ||
mptcp_lib_has_file() { | ||
local f="${1}" | ||
|
||
if [ -f "${f}" ]; then | ||
return 0 | ||
fi | ||
|
||
mptcp_lib_fail_if_expected_feature "${f} file not found" | ||
} | ||
|
||
mptcp_lib_check_mptcp() { | ||
if ! mptcp_lib_has_file "/proc/sys/net/mptcp/enabled"; then | ||
echo "SKIP: MPTCP support is not available" | ||
exit ${KSFT_SKIP} | ||
fi | ||
} |