Skip to content

Commit

Permalink
selftests/net: packetdrill: report benign debug flakes as xfail
Browse files Browse the repository at this point in the history
A few recently added packetdrill tests that are known time sensitive
(e.g., because testing timestamping) occasionally fail in debug mode:
https://netdev.bots.linux.dev/contest.html?executor=vmksft-packetdrill-dbg

These failures are well understood. Correctness of the tests is
verified in non-debug mode. Continue running in debug mode also, to
keep coverage with debug instrumentation.

But, only in debug mode, mark these tests with well understood
timing issues as XFAIL (known failing) rather than FAIL when failing.

Introduce an allow list xfail_list with known cases.

Expand the ktap infrastructure with XFAIL support.

Fixes: eab3598 ("selftests/net: packetdrill: import tcp/fast_recovery, tcp/nagle, tcp/timestamping")
Reported-by: Jakub Kicinski <kuba@kernel.org>
Closes: https://lore.kernel.org/netdev/20241218100013.0c698629@kernel.org/
Signed-off-by: Willem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/20250103113142.129251-1-willemdebruijn.kernel@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
  • Loading branch information
Willem de Bruijn authored and Paolo Abeni committed Jan 7, 2025
1 parent 51cfbed commit 912d6f6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
15 changes: 13 additions & 2 deletions tools/testing/selftests/kselftest/ktap_helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
KTAP_TESTNO=1
KTAP_CNT_PASS=0
KTAP_CNT_FAIL=0
KTAP_CNT_XFAIL=0
KTAP_CNT_SKIP=0

KSFT_PASS=0
Expand Down Expand Up @@ -69,6 +70,16 @@ ktap_test_skip() {
KTAP_CNT_SKIP=$((KTAP_CNT_SKIP+1))
}

ktap_test_xfail() {
description="$1"

result="ok"
directive="XFAIL"
__ktap_test "$result" "$description" "$directive"

KTAP_CNT_XFAIL=$((KTAP_CNT_XFAIL+1))
}

ktap_test_fail() {
description="$1"

Expand Down Expand Up @@ -99,13 +110,13 @@ ktap_exit_fail_msg() {
ktap_finished() {
ktap_print_totals

if [ $((KTAP_CNT_PASS + KTAP_CNT_SKIP)) -eq "$KSFT_NUM_TESTS" ]; then
if [ $((KTAP_CNT_PASS + KTAP_CNT_SKIP + KTAP_CNT_XFAIL)) -eq "$KSFT_NUM_TESTS" ]; then
exit "$KSFT_PASS"
else
exit "$KSFT_FAIL"
fi
}

ktap_print_totals() {
echo "# Totals: pass:$KTAP_CNT_PASS fail:$KTAP_CNT_FAIL xfail:0 xpass:0 skip:$KTAP_CNT_SKIP error:0"
echo "# Totals: pass:$KTAP_CNT_PASS fail:$KTAP_CNT_FAIL xfail:$KTAP_CNT_XFAIL xpass:0 skip:$KTAP_CNT_SKIP error:0"
}
23 changes: 18 additions & 5 deletions tools/testing/selftests/net/packetdrill/ksft_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,37 @@ if [ $# -ne 1 ]; then
ktap_exit_fail_msg "usage: $0 <script>"
exit "$KSFT_FAIL"
fi
script="$1"
script="$(basename $1)"

if [ -z "$(which packetdrill)" ]; then
ktap_skip_all "packetdrill not found in PATH"
exit "$KSFT_SKIP"
fi

declare -a optargs
failfunc=ktap_test_fail

if [[ -n "${KSFT_MACHINE_SLOW}" ]]; then
optargs+=('--tolerance_usecs=14000')

# xfail tests that are known flaky with dbg config, not fixable.
# still run them for coverage (and expect 100% pass without dbg).
declare -ar xfail_list=(
"tcp_fast_recovery_prr-ss.*.pkt"
"tcp_timestamping.*.pkt"
"tcp_user_timeout_user-timeout-probe.pkt"
"tcp_zerocopy_epoll_.*.pkt"
)
readonly xfail_regex="^($(printf '%s|' "${xfail_list[@]}"))$"
[[ "$script" =~ ${xfail_regex} ]] && failfunc=ktap_test_xfail
fi

ktap_print_header
ktap_set_plan 2

unshare -n packetdrill ${ipv4_args[@]} ${optargs[@]} $(basename $script) > /dev/null \
&& ktap_test_pass "ipv4" || ktap_test_fail "ipv4"
unshare -n packetdrill ${ipv6_args[@]} ${optargs[@]} $(basename $script) > /dev/null \
&& ktap_test_pass "ipv6" || ktap_test_fail "ipv6"
unshare -n packetdrill ${ipv4_args[@]} ${optargs[@]} $script > /dev/null \
&& ktap_test_pass "ipv4" || $failfunc "ipv4"
unshare -n packetdrill ${ipv6_args[@]} ${optargs[@]} $script > /dev/null \
&& ktap_test_pass "ipv6" || $failfunc "ipv6"

ktap_finished

0 comments on commit 912d6f6

Please sign in to comment.