]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
selftests: rtnetlink: skip tests if tools or feats are missing
authorAlessandro Ratti <alessandro@0x65c.net>
Fri, 22 Aug 2025 14:03:40 +0000 (16:03 +0200)
committerJakub Kicinski <kuba@kernel.org>
Mon, 25 Aug 2025 22:22:18 +0000 (15:22 -0700)
Some rtnetlink selftests assume the presence of ifconfig and iproute2
support for the `proto` keyword in `ip address` commands. These
assumptions can cause test failures on modern systems (e.g. Debian
Bookworm) where:

 - ifconfig is not installed by default
 - The iproute2 version lacks support for address protocol

This patch improves test robustness by:

 - Skipping kci_test_promote_secondaries if ifconfig is missing
 - Skipping do_test_address_proto if ip address help does not mention
   proto

These changes ensure the tests degrade gracefully by reporting SKIP
instead of FAIL when prerequisites are not met, improving portability
across systems.

Reviewed-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Alessandro Ratti <alessandro@0x65c.net>
Link: https://patch.msgid.link/20250822140633.891360-2-alessandro@0x65c.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/testing/selftests/net/rtnetlink.sh

index 91b0f6cae04dbd9b247cd8515e729e759c49b3c8..9da47a845be6380a211943cf436bb9447aa61609 100755 (executable)
@@ -325,6 +325,11 @@ kci_test_addrlft()
 
 kci_test_promote_secondaries()
 {
+       run_cmd ifconfig "$devdummy"
+       if [ $ret -ne 0 ]; then
+               end_test "SKIP: ifconfig not installed"
+               return $ksft_skip
+       fi
        promote=$(sysctl -n net.ipv4.conf.$devdummy.promote_secondaries)
 
        sysctl -q net.ipv4.conf.$devdummy.promote_secondaries=1
@@ -1203,6 +1208,12 @@ do_test_address_proto()
        local ret=0
        local err
 
+       run_cmd_grep 'proto' ip address help
+       if [ $? -ne 0 ];then
+               end_test "SKIP: addr proto ${what}: iproute2 too old"
+               return $ksft_skip
+       fi
+
        ip address add dev "$devdummy" "$addr3"
        check_err $?
        proto=$(address_get_proto "$addr3")