On Mon, Aug 31, 2026 at 05:21:28PM +0800, Hangbin Liu wrote:
> From: Hangbin Liu <[email protected]>
> 
> Many test scripts under tools/testing/selftests/net/ each define their own
> log_test() function with near-identical logic for comparing a return
> code against an expected value and printing OK/FAIL. Add a shared
> log_test_expected() to lib.sh and replace each local definition with a
> thin wrapper that delegates to it.
> 
> The function is named log_test_expected() rather than log_test() because
> lib.sh already exports log_test() with a different signature used by
> the forwarding tests.
> 
> Two tests required special handling:
> 
> - icmp_redirect.sh passed a fourth "xfail" argument to log_test(). The
>   underlying issue has been fixed and the argument is always absent now,
>   so it is simply dropped.
> 
> - fib_nexthops.sh checked for ksft_skip (exit code 4) inside log_test(),
>   but no test in the file produces that code. The check is removed,
>   callers that need to report a skip should use log_test_skip() instead.
>   Two callers compared against exit code 2 are left as-is since code 2
>   correctly counts as a failure in the previous log_test().
> 
> Signed-off-by: Hangbin Liu <[email protected]>
> ---
> Changes in v2:
> - Remove skip/xfail checking in lib.sh, as any command can exits with 2 or 4 
> (sashiko)
> - Remove nskip counter in fib_nexthops.sh
> - Link to v1: 
> https://lore.kernel.org/r/[email protected]
> ---
>  tools/testing/selftests/net/drop_monitor_tests.sh  | 13 +------
>  tools/testing/selftests/net/fcnal-test.sh          | 29 +-------------
>  tools/testing/selftests/net/fdb_flush.sh           | 35 +----------------
>  tools/testing/selftests/net/fib-onlink-tests.sh    | 18 +--------
>  .../selftests/net/fib_nexthop_multiprefix.sh       | 21 +----------
>  tools/testing/selftests/net/fib_nexthop_nongw.sh   | 21 +----------
>  tools/testing/selftests/net/fib_nexthops.sh        | 44 
> ++--------------------
>  tools/testing/selftests/net/fib_rule_tests.sh      | 19 +---------
>  tools/testing/selftests/net/fib_tests.sh           | 26 +------------
>  tools/testing/selftests/net/gre_gso.sh             | 26 +------------
>  tools/testing/selftests/net/icmp_redirect.sh       | 28 ++------------
>  tools/testing/selftests/net/l2tp.sh                | 19 +---------
>  tools/testing/selftests/net/lib.sh                 | 31 +++++++++++++++
>  .../selftests/net/ndisc_unsolicited_na_test.sh     | 26 +------------
>  .../selftests/net/srv6_encap_lookup_l3vpn_test.sh  | 19 +---------
>  .../selftests/net/srv6_end_dt46_l3vpn_test.sh      | 19 +---------
>  .../selftests/net/srv6_end_dt4_l3vpn_test.sh       | 19 +---------
>  .../selftests/net/srv6_end_dt6_l3vpn_test.sh       | 19 +---------
>  .../selftests/net/srv6_end_dx4_netfilter_test.sh   | 23 ++---------
>  .../selftests/net/srv6_end_dx6_netfilter_test.sh   | 23 ++---------
>  .../testing/selftests/net/srv6_end_flavors_test.sh | 23 ++---------
>  .../selftests/net/srv6_end_next_csid_l3vpn_test.sh | 19 +---------
>  .../net/srv6_end_x_next_csid_l3vpn_test.sh         | 19 +---------
>  .../selftests/net/srv6_hencap_red_l3vpn_test.sh    | 19 +---------
>  .../selftests/net/srv6_hl2encap_red_l2vpn_test.sh  | 19 +---------
>  .../selftests/net/test_bridge_backup_port.sh       | 32 +---------------
>  .../selftests/net/test_bridge_neigh_suppress.sh    | 33 +---------------
>  tools/testing/selftests/net/test_vxlan_mdb.sh      | 32 +---------------
>  .../selftests/net/test_vxlan_nolocalbypass.sh      | 32 +---------------
>  .../selftests/net/test_vxlan_vnifiltering.sh       | 26 +------------
>  tools/testing/selftests/net/vrf-xfrm-tests.sh      | 19 +---------
>  tools/testing/selftests/net/vrf_route_leaking.sh   | 19 +---------
>  .../testing/selftests/net/vrf_strict_mode_test.sh  | 19 +---------
>  33 files changed, 73 insertions(+), 716 deletions(-)

Hi everyone,

This patch is a bit too long for review, and maybe cause conflicts for
stable backports. I plan to split it into small frags. But there are 2
ways to split it.

1. Split based on the test name. e.g. srv6 part, fib part, test_* part, and
   others.
2. Split based on the changes. e.g. group the tests that using exactly same
   log_test functions into one patch.

Does anyone has any suggestion?

Thanks
Hangbin

Reply via email to