Skip to content

Commit 7ba0732

Browse files
author
Paolo Abeni
committed
Merge branch 'selftests-mptcp-skip-tests-not-supported-by-old-kernels-part-1'
Matthieu Baerts says: ==================== selftests: mptcp: skip tests not supported by old kernels (part 1) After a few years of increasing test coverage in the MPTCP selftests, we realised [1] the last version of the selftests is supposed to run on old kernels without issues. Supporting older versions is not that easy for this MPTCP case: these selftests are often validating the internals by checking packets that are exchanged, when some MIB counters are incremented after some actions, how connections are getting opened and closed in some cases, etc. In other words, it is not limited to the socket interface between the userspace and the kernelspace. In addition, the current selftests run a lot of different sub-tests but the TAP13 protocol used in the selftests don't support sub-tests: in other words, one failure in sub-tests implies that the whole selftest is seen as failed at the end because sub-tests are not tracked. It is then important to skip sub-tests not supported by old kernels. To minimise the modifications and reduce the complexity to support old versions, the idea is to look at external signs and skip the whole selftests or just some sub-tests before starting them. This first part focuses on marking the different selftests as skipped if MPTCP is not even supported. That's what is done in patches 2 to 8. Patch 2/8 introduces a new file (mptcp_lib.sh) to be able to re-use some helpers in the different selftests. The first MPTCP selftest has been introduced in v5.6. Patch 1/8 is a bit different but still linked: it modifies mptcp_join.sh selftest not to use 'cmp --bytes' which is not supported by the BusyBox implementation. It is apparently quite common to use BusyBox in CI environments. This tool is needed for a subtest introduced in v6.1. Link: https://lore.kernel.org/stable/CA+G9fYtDGpgT4dckXD-y-N92nqUxuvue_7AtDdBcHrbOMsDZLg@mail.gmail.com/ [1] Link: multipath-tcp/mptcp_net-next#368 ==================== Link: https://lore.kernel.org/r/20230528-upstream-net-20230528-mptcp-selftests-support-old-kernels-part-1-v1-0-a32d85577fc6@tessares.net Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2 parents 1919b39 + 6321260 commit 7ba0732

9 files changed

Lines changed: 80 additions & 3 deletions

File tree

tools/testing/selftests/net/mptcp/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ TEST_PROGS := mptcp_connect.sh pm_netlink.sh mptcp_join.sh diag.sh \
99

1010
TEST_GEN_FILES = mptcp_connect pm_nl_ctl mptcp_sockopt mptcp_inq
1111

12-
TEST_FILES := settings
12+
TEST_FILES := mptcp_lib.sh settings
1313

1414
EXTRA_CLEAN := *.pcap
1515

tools/testing/selftests/net/mptcp/diag.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/bash
22
# SPDX-License-Identifier: GPL-2.0
33

4+
. "$(dirname "${0}")/mptcp_lib.sh"
5+
46
sec=$(date +%s)
57
rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)
68
ns="ns1-$rndh"
@@ -31,6 +33,8 @@ cleanup()
3133
ip netns del $ns
3234
}
3335

36+
mptcp_lib_check_mptcp
37+
3438
ip -Version > /dev/null 2>&1
3539
if [ $? -ne 0 ];then
3640
echo "SKIP: Could not run test without ip tool"

tools/testing/selftests/net/mptcp/mptcp_connect.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/bash
22
# SPDX-License-Identifier: GPL-2.0
33

4+
. "$(dirname "${0}")/mptcp_lib.sh"
5+
46
time_start=$(date +%s)
57

68
optstring="S:R:d:e:l:r:h4cm:f:tC"
@@ -141,6 +143,8 @@ cleanup()
141143
done
142144
}
143145

146+
mptcp_lib_check_mptcp
147+
144148
ip -Version > /dev/null 2>&1
145149
if [ $? -ne 0 ];then
146150
echo "SKIP: Could not run test without ip tool"

tools/testing/selftests/net/mptcp/mptcp_join.sh

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@
1010
# because it's invoked by variable name, see how the "tests" array is used
1111
#shellcheck disable=SC2317
1212

13+
. "$(dirname "${0}")/mptcp_lib.sh"
14+
1315
ret=0
1416
sin=""
1517
sinfail=""
1618
sout=""
1719
cin=""
1820
cinfail=""
1921
cinsent=""
22+
tmpfile=""
2023
cout=""
2124
capout=""
2225
ns1=""
@@ -136,6 +139,8 @@ cleanup_partial()
136139

137140
check_tools()
138141
{
142+
mptcp_lib_check_mptcp
143+
139144
if ! ip -Version &> /dev/null; then
140145
echo "SKIP: Could not run test without ip tool"
141146
exit $ksft_skip
@@ -175,6 +180,7 @@ cleanup()
175180
{
176181
rm -f "$cin" "$cout" "$sinfail"
177182
rm -f "$sin" "$sout" "$cinsent" "$cinfail"
183+
rm -f "$tmpfile"
178184
rm -rf $evts_ns1 $evts_ns2
179185
cleanup_partial
180186
}
@@ -383,9 +389,16 @@ check_transfer()
383389
fail_test
384390
return 1
385391
fi
386-
bytes="--bytes=${bytes}"
392+
393+
# note: BusyBox's "cmp" command doesn't support --bytes
394+
tmpfile=$(mktemp)
395+
head --bytes="$bytes" "$in" > "$tmpfile"
396+
mv "$tmpfile" "$in"
397+
head --bytes="$bytes" "$out" > "$tmpfile"
398+
mv "$tmpfile" "$out"
399+
tmpfile=""
387400
fi
388-
cmp -l "$in" "$out" ${bytes} | while read -r i a b; do
401+
cmp -l "$in" "$out" | while read -r i a b; do
389402
local sum=$((0${a} + 0${b}))
390403
if [ $check_invert -eq 0 ] || [ $sum -ne $((0xff)) ]; then
391404
echo "[ FAIL ] $what does not match (in, out):"
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#! /bin/bash
2+
# SPDX-License-Identifier: GPL-2.0
3+
4+
readonly KSFT_FAIL=1
5+
readonly KSFT_SKIP=4
6+
7+
# SELFTESTS_MPTCP_LIB_EXPECT_ALL_FEATURES env var can be set when validating all
8+
# features using the last version of the kernel and the selftests to make sure
9+
# a test is not being skipped by mistake.
10+
mptcp_lib_expect_all_features() {
11+
[ "${SELFTESTS_MPTCP_LIB_EXPECT_ALL_FEATURES:-}" = "1" ]
12+
}
13+
14+
# $1: msg
15+
mptcp_lib_fail_if_expected_feature() {
16+
if mptcp_lib_expect_all_features; then
17+
echo "ERROR: missing feature: ${*}"
18+
exit ${KSFT_FAIL}
19+
fi
20+
21+
return 1
22+
}
23+
24+
# $1: file
25+
mptcp_lib_has_file() {
26+
local f="${1}"
27+
28+
if [ -f "${f}" ]; then
29+
return 0
30+
fi
31+
32+
mptcp_lib_fail_if_expected_feature "${f} file not found"
33+
}
34+
35+
mptcp_lib_check_mptcp() {
36+
if ! mptcp_lib_has_file "/proc/sys/net/mptcp/enabled"; then
37+
echo "SKIP: MPTCP support is not available"
38+
exit ${KSFT_SKIP}
39+
fi
40+
}

tools/testing/selftests/net/mptcp/mptcp_sockopt.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/bash
22
# SPDX-License-Identifier: GPL-2.0
33

4+
. "$(dirname "${0}")/mptcp_lib.sh"
5+
46
ret=0
57
sin=""
68
sout=""
@@ -84,6 +86,8 @@ cleanup()
8486
rm -f "$sin" "$sout"
8587
}
8688

89+
mptcp_lib_check_mptcp
90+
8791
ip -Version > /dev/null 2>&1
8892
if [ $? -ne 0 ];then
8993
echo "SKIP: Could not run test without ip tool"

tools/testing/selftests/net/mptcp/pm_netlink.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/bash
22
# SPDX-License-Identifier: GPL-2.0
33

4+
. "$(dirname "${0}")/mptcp_lib.sh"
5+
46
ksft_skip=4
57
ret=0
68

@@ -34,6 +36,8 @@ cleanup()
3436
ip netns del $ns1
3537
}
3638

39+
mptcp_lib_check_mptcp
40+
3741
ip -Version > /dev/null 2>&1
3842
if [ $? -ne 0 ];then
3943
echo "SKIP: Could not run test without ip tool"

tools/testing/selftests/net/mptcp/simult_flows.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/bash
22
# SPDX-License-Identifier: GPL-2.0
33

4+
. "$(dirname "${0}")/mptcp_lib.sh"
5+
46
sec=$(date +%s)
57
rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)
68
ns1="ns1-$rndh"
@@ -34,6 +36,8 @@ cleanup()
3436
done
3537
}
3638

39+
mptcp_lib_check_mptcp
40+
3741
ip -Version > /dev/null 2>&1
3842
if [ $? -ne 0 ];then
3943
echo "SKIP: Could not run test without ip tool"

tools/testing/selftests/net/mptcp/userspace_pm.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#!/bin/bash
22
# SPDX-License-Identifier: GPL-2.0
33

4+
. "$(dirname "${0}")/mptcp_lib.sh"
5+
6+
mptcp_lib_check_mptcp
7+
48
ip -Version > /dev/null 2>&1
59
if [ $? -ne 0 ];then
610
echo "SKIP: Cannot not run test without ip tool"

0 commit comments

Comments
 (0)