From nobody Thu Sep 24 18:44:19 2026 Received: from mta0.migadu.com (out-79.mta0.migadu.com [91.218.175.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9410F2C032E for ; Tue, 22 Sep 2026 00:37:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.79 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790037472; cv=none; b=kGagNb/5zC2bse7XFNJYJyNnZns8cJKyDllGkhEY2X/yk2SxAD/yo9Y9WZghEVd0EABCLZbsB+AlI8xXAJzCvkHq4TVh6wEMZr2GnIEIdR8d1G8uugL1ZlWxIvTxbNoRjFWqA5VIhWCRAU+vZVmC0rlUD6ct2DMWGlEcIlr4pI8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790037472; c=relaxed/simple; bh=kouMgfVbb1YooXvotzbC+EE1ZpPLPLK6nec6gNzk1rQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=FlRuV/6Tnlvk2jhsO7uUs3GJZjjWvktRF/tpvwJTTiGsOWD5Dl8QdXrcq1N27HdgL5PSeS0qvlawn2WCGHI/DCRH1DCRwIp9o4+GdFdiW9etmLW8nbVhPGrTVw7hQ7vjojdXmScx4OvfoSbnqUphjYqYxTjhJ+QT1ChZRLVmGyY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=OG6c0eH4; arc=none smtp.client-ip=91.218.175.79 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="OG6c0eH4" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=kouMgfVbb1YooXvotzbC+EE1ZpPLPLK6nec6gNzk1rQ=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1790037465; v=1; x=1790642265; b=OG6c0eH46Ng3mBOj4JMhS56KCML9/wIcJkHptPNb1GQ0V6J3kwqvG4rbZrPXostfoQQ0TpIs IyzedLhFvx54SMmPe22CdTAV8UllColKJK/dBQJZTtqIsGwa+3CCkOYMtH/90mIq9l+feiFHXEE ulpDBd33JJkapadDOhh6uAlQ= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 1a20567292285c50; Tue, 22 Sep 2026 00:37:45 +0000 X-Mizu-Trace-ID: 1a20567292285c50 X-Migadu-Flow: FLOW_OUT From: Hangbin Liu Date: Tue, 22 Sep 2026 08:37:34 +0800 Subject: [PATCH net-next v4] selftests: net: move log_test to lib file and remove duplicate code Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260922-self_log_test-v4-1-4c656801f8dc@kylinos.cn> X-B4-Tracking: v=1; b=H4sIAAAAAAAC/2XN3wqCMBTH8VeJXbfwnJmbXfUeEeKfMx3JFm6II r57Q4LKLn8cPt+zME+DIc8uh4UNNBpvnI0jPR5Y3ZW2JW6auBkmmCUKkHvqddG7tgjkA69kRqW WglBoFs1zIG2mrXdjlgK3NAV2j5fO+OCGeXs0wnZ/N8WuOQIHrpWqABKpUqTrY+6Ndf5U2y014 hcXsOcYOTUlkkrzpNb5HxcfnsN5z0XkJUiJCmQmRPrD13V9AZJ9WDwzAQAA X-Change-ID: 20260812-self_log_test-b76eaf73e23f To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Shuah Khan , David Ahern , Ido Schimmel , Andrea Mayer Cc: Hangbin Liu , netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Hangbin Liu X-Mailer: b4 0.14.3 From: Hangbin Liu 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 so we can replace each local definitions. 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. Most of the checks in log_test_expected() are the same as log_test() in other tests. The differences are: - The function always returns 0 to avoid influencing later code. - On failure with VERBOSE=3D1, the actual and expected return codes are printed (echo " rc=3D$rc, expected $expected"). - A PAUSE_ON_FAIL check is added via pause_on_fail() for scripts that did not have one. - A PAUSE=3Dyes check is added for scripts that did not have one. - A trailing [ "$VERBOSE" =3D "1" ] && echo is added for scripts that did not have one. Several tests required special handling: - fcnal-test.sh - Print format: it uses %-70s, while log_test_expected() uses %-60s. - The old code always printed "expected rc $expected; actual rc $rc" on failure. The new code only prints when VERBOSE=3D1. - The old [ "${VERBOSE}" =3D "1" ] && echo ran before the comparison; now it runs after the PAUSE check. - fdb_flush.sh - It used local ret, nsuccess, and nfail, which are not used outside the function. The log_test_expected() uses global variables as all other tests do. - fib-onlink-tests.sh - Print format: it uses %-50s, while log_test_expected() uses %-60s. - srv6_end_dx*.sh and srv6_end_flavors_test.sh - These three tests previously defined ksft_skip locally instead of sourcing lib.sh. They now source lib.sh, which provides ksft_skip and other framework constants. Note that srv6_end_flavors_test.sh previously declared ksft_skip as readonly; the lib.sh definition does not use readonly. - test_bridge_neigh_suppress.sh - The test use ksft_exit_status_merge "$ret" "$ksft_fail", which always set ret=3D1 as ksft_fail has the maximum weight. So in the lib we just discarded ksft_exit_status_merge and set ret to 1 directly. In addition to the above, 13 tests that previously used "TEST:" now use " TEST:" (4-space prefix), and srv6 tests plus vrf_strict_mode_test.sh that previously used "\n TEST:" (newline + 4-space prefix) now with no leading newline. The fib_nexthops.sh test is skipped because it has a ksft_skip check that needs special handling. Signed-off-by: Hangbin Liu --- Sashiko previously reported two issues that are unrelated to this patch. - fdb_flush.sh, fib-onlink-tests.sh and l2tp.sh can print [FAIL] subtests while exiting with status 0. - fib_tests.sh uses the same global `ret` that the shared helper treats as cumulative exit status as per-test scratch storage. These issues will be addressed in separate patches since they are not related to this one. Changes in v4: - drop the fib_nexthops.sh change since it need special handle for nskip (s= ashiko) - set ret=3D1 in the lib function (sashiko) - Link to v3: https://lore.kernel.org/r/20260915-self_log_test-v3-1-a177281= 76334@kylinos.cn Changes in v3: - Always return 0 for log_test_expected (Jakub) - Add detailed change log in commit description. - Link to v2: https://lore.kernel.org/r/20260831-self_log_test-v2-1-eda2e84= 90cf9@kylinos.cn 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/20260813-self_log_test-v1-1-f88b110= 7842e@kylinos.cn --- 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_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 | 19 +----------- tools/testing/selftests/net/l2tp.sh | 19 +----------- tools/testing/selftests/net/lib.sh | 33 ++++++++++++++++++= ++ .../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 | 34 +-----------------= --- 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 +----------- 32 files changed, 70 insertions(+), 669 deletions(-) diff --git a/tools/testing/selftests/net/drop_monitor_tests.sh b/tools/test= ing/selftests/net/drop_monitor_tests.sh index 507d0a82f5f0..7da85608561b 100755 --- a/tools/testing/selftests/net/drop_monitor_tests.sh +++ b/tools/testing/selftests/net/drop_monitor_tests.sh @@ -18,18 +18,7 @@ DEVLINK_DEV=3Dnetdevsim/${DEV} =20 log_test() { - local rc=3D$1 - local expected=3D$2 - local msg=3D"$3" - - if [ ${rc} -eq ${expected} ]; then - printf " TEST: %-60s [ OK ]\n" "${msg}" - nsuccess=3D$((nsuccess+1)) - else - ret=3D1 - nfail=3D$((nfail+1)) - printf " TEST: %-60s [FAIL]\n" "${msg}" - fi + log_test_expected "$1" "$2" "$3" } =20 setup() diff --git a/tools/testing/selftests/net/fcnal-test.sh b/tools/testing/self= tests/net/fcnal-test.sh index 890c3f8e51bb..a50609535fed 100755 --- a/tools/testing/selftests/net/fcnal-test.sh +++ b/tools/testing/selftests/net/fcnal-test.sh @@ -97,34 +97,7 @@ fi =20 log_test() { - local rc=3D$1 - local expected=3D$2 - local msg=3D"$3" - local ans - - [ "${VERBOSE}" =3D "1" ] && echo - - if [ ${rc} -eq ${expected} ]; then - nsuccess=3D$((nsuccess+1)) - printf "TEST: %-70s [ OK ]\n" "${msg}" - else - nfail=3D$((nfail+1)) - printf "TEST: %-70s [FAIL]\n" "${msg}" - echo " expected rc $expected; actual rc $rc" - if [ "${PAUSE_ON_FAIL}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read ans - [ "$ans" =3D "q" ] && exit 1 - fi - fi - - if [ "${PAUSE}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read ans - [ "$ans" =3D "q" ] && exit 1 - fi + log_test_expected "$1" "$2" "$3" =20 kill_procs } diff --git a/tools/testing/selftests/net/fdb_flush.sh b/tools/testing/selft= ests/net/fdb_flush.sh index 9931a1e36e3d..4965e52d5ef5 100755 --- a/tools/testing/selftests/net/fdb_flush.sh +++ b/tools/testing/selftests/net/fdb_flush.sh @@ -67,40 +67,7 @@ run_cmd() =20 log_test() { - local rc=3D$1 - local expected=3D$2 - local msg=3D"$3" - local nsuccess - local nfail - local ret - - if [ ${rc} -eq ${expected} ]; then - printf "TEST: %-60s [ OK ]\n" "${msg}" - nsuccess=3D$((nsuccess+1)) - else - ret=3D1 - nfail=3D$((nfail+1)) - printf "TEST: %-60s [FAIL]\n" "${msg}" - if [ "$VERBOSE" =3D "1" ]; then - echo " rc=3D$rc, expected $expected" - fi - - if [ "${PAUSE_ON_FAIL}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi - fi - - if [ "${PAUSE}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi - - [ "$VERBOSE" =3D "1" ] && echo + log_test_expected "$1" "$2" "$3" } =20 MAC_POOL_1=3D" diff --git a/tools/testing/selftests/net/fib-onlink-tests.sh b/tools/testin= g/selftests/net/fib-onlink-tests.sh index e0d45292a298..a26075abf7d2 100755 --- a/tools/testing/selftests/net/fib-onlink-tests.sh +++ b/tools/testing/selftests/net/fib-onlink-tests.sh @@ -85,23 +85,7 @@ PBR_TABLE=3D101 =20 log_test() { - local rc=3D$1 - local expected=3D$2 - local msg=3D"$3" - - if [ ${rc} -eq ${expected} ]; then - nsuccess=3D$((nsuccess+1)) - printf " TEST: %-50s [ OK ]\n" "${msg}" - else - nfail=3D$((nfail+1)) - printf " TEST: %-50s [FAIL]\n" "${msg}" - if [ "${PAUSE_ON_FAIL}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi - fi + log_test_expected "$1" "$2" "$3" } =20 log_section() diff --git a/tools/testing/selftests/net/fib_nexthop_multiprefix.sh b/tools= /testing/selftests/net/fib_nexthop_multiprefix.sh index e85248609af4..bd0b8a053ea1 100755 --- a/tools/testing/selftests/net/fib_nexthop_multiprefix.sh +++ b/tools/testing/selftests/net/fib_nexthop_multiprefix.sh @@ -23,26 +23,7 @@ which ping6 > /dev/null 2>&1 && ping6=3D$(which ping6) |= | ping6=3D$(which ping) =20 log_test() { - local rc=3D$1 - local expected=3D$2 - local msg=3D"$3" - - if [ ${rc} -eq ${expected} ]; then - printf "TEST: %-60s [ OK ]\n" "${msg}" - nsuccess=3D$((nsuccess+1)) - else - ret=3D1 - nfail=3D$((nfail+1)) - printf "TEST: %-60s [FAIL]\n" "${msg}" - if [ "${PAUSE_ON_FAIL}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi - fi - - [ "$VERBOSE" =3D "1" ] && echo + log_test_expected "$1" "$2" "$3" } =20 run_cmd() diff --git a/tools/testing/selftests/net/fib_nexthop_nongw.sh b/tools/testi= ng/selftests/net/fib_nexthop_nongw.sh index 1ccf56f10171..4d483cb83593 100755 --- a/tools/testing/selftests/net/fib_nexthop_nongw.sh +++ b/tools/testing/selftests/net/fib_nexthop_nongw.sh @@ -18,26 +18,7 @@ ret=3D0 =20 log_test() { - local rc=3D$1 - local expected=3D$2 - local msg=3D"$3" - - if [ ${rc} -eq ${expected} ]; then - printf "TEST: %-60s [ OK ]\n" "${msg}" - nsuccess=3D$((nsuccess+1)) - else - ret=3D1 - nfail=3D$((nfail+1)) - printf "TEST: %-60s [FAIL]\n" "${msg}" - if [ "${PAUSE_ON_FAIL}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi - fi - - [ "$VERBOSE" =3D "1" ] && echo + log_test_expected "$1" "$2" "$3" } =20 run_cmd() diff --git a/tools/testing/selftests/net/fib_rule_tests.sh b/tools/testing/= selftests/net/fib_rule_tests.sh index 5fbdd2a0b537..5d66b00e61b2 100755 --- a/tools/testing/selftests/net/fib_rule_tests.sh +++ b/tools/testing/selftests/net/fib_rule_tests.sh @@ -31,24 +31,7 @@ SELFTEST_PATH=3D"" =20 log_test() { - local rc=3D$1 - local expected=3D$2 - local msg=3D"$3" - - if [ ${rc} -eq ${expected} ]; then - nsuccess=3D$((nsuccess+1)) - printf " TEST: %-60s [ OK ]\n" "${msg}" - else - ret=3D1 - nfail=3D$((nfail+1)) - printf " TEST: %-60s [FAIL]\n" "${msg}" - if [ "${PAUSE_ON_FAIL}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi - fi + log_test_expected "$1" "$2" "$3" } =20 setup() diff --git a/tools/testing/selftests/net/fib_tests.sh b/tools/testing/selft= ests/net/fib_tests.sh index b338bfb196a2..7df967a2d669 100755 --- a/tools/testing/selftests/net/fib_tests.sh +++ b/tools/testing/selftests/net/fib_tests.sh @@ -24,31 +24,7 @@ which ping6 > /dev/null 2>&1 && ping6=3D$(which ping6) |= | ping6=3D$(which ping) =20 log_test() { - local rc=3D$1 - local expected=3D$2 - local msg=3D"$3" - - if [ ${rc} -eq ${expected} ]; then - printf " TEST: %-60s [ OK ]\n" "${msg}" - nsuccess=3D$((nsuccess+1)) - else - ret=3D1 - nfail=3D$((nfail+1)) - printf " TEST: %-60s [FAIL]\n" "${msg}" - if [ "${PAUSE_ON_FAIL}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi - fi - - if [ "${PAUSE}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi + log_test_expected "$1" "$2" "$3" } =20 setup() diff --git a/tools/testing/selftests/net/gre_gso.sh b/tools/testing/selftes= ts/net/gre_gso.sh index 5100d90f92d2..4ebe1ed6e9c9 100755 --- a/tools/testing/selftests/net/gre_gso.sh +++ b/tools/testing/selftests/net/gre_gso.sh @@ -16,31 +16,7 @@ PID=3D =20 log_test() { - local rc=3D$1 - local expected=3D$2 - local msg=3D"$3" - - if [ ${rc} -eq ${expected} ]; then - printf " TEST: %-60s [ OK ]\n" "${msg}" - nsuccess=3D$((nsuccess+1)) - else - ret=3D1 - nfail=3D$((nfail+1)) - printf " TEST: %-60s [FAIL]\n" "${msg}" - if [ "${PAUSE_ON_FAIL}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi - fi - - if [ "${PAUSE}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi + log_test_expected "$1" "$2" "$3" } =20 setup() diff --git a/tools/testing/selftests/net/icmp_redirect.sh b/tools/testing/s= elftests/net/icmp_redirect.sh index 35357d02e823..e724f895ae2c 100755 --- a/tools/testing/selftests/net/icmp_redirect.sh +++ b/tools/testing/selftests/net/icmp_redirect.sh @@ -61,24 +61,7 @@ log_section() =20 log_test() { - local rc=3D$1 - local expected=3D$2 - local msg=3D"$3" - - if [ ${rc} -eq ${expected} ]; then - printf "TEST: %-60s [ OK ]\n" "${msg}" - nsuccess=3D$((nsuccess+1)) - else - ret=3D1 - nfail=3D$((nfail+1)) - printf "TEST: %-60s [FAIL]\n" "${msg}" - if [ "${PAUSE_ON_FAIL}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi - fi + log_test_expected "$1" "$2" "$3" } =20 log_debug() diff --git a/tools/testing/selftests/net/l2tp.sh b/tools/testing/selftests/= net/l2tp.sh index 88de7166c8ae..41e8b19d1bd3 100755 --- a/tools/testing/selftests/net/l2tp.sh +++ b/tools/testing/selftests/net/l2tp.sh @@ -23,24 +23,7 @@ which ping6 > /dev/null 2>&1 && ping6=3D$(which ping6) |= | ping6=3D$(which ping) # log_test() { - local rc=3D$1 - local expected=3D$2 - local msg=3D"$3" - - if [ ${rc} -eq ${expected} ]; then - printf "TEST: %-60s [ OK ]\n" "${msg}" - nsuccess=3D$((nsuccess+1)) - else - ret=3D1 - nfail=3D$((nfail+1)) - printf "TEST: %-60s [FAIL]\n" "${msg}" - if [ "${PAUSE_ON_FAIL}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi - fi + log_test_expected "$1" "$2" "$3" } =20 run_cmd() diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/n= et/lib.sh index d46d2cec89e4..f6f8b100a70c 100644 --- a/tools/testing/selftests/net/lib.sh +++ b/tools/testing/selftests/net/lib.sh @@ -454,6 +454,39 @@ log_test_xfail() RET=3D$ksft_xfail retmsg=3D log_test "$@" } =20 +# Log test result with expected return value +log_test_expected() +{ + local rc=3D$1 + local expected=3D$2 + local msg=3D"$3" + + if [ "${rc}" -eq "${expected}" ]; then + nsuccess=3D$((nsuccess+1)) + printf " TEST: %-60s [ OK ]\n" "${msg}" + else + ret=3D"$ksft_fail" + nfail=3D$((nfail+1)) + printf " TEST: %-60s [FAIL]\n" "${msg}" + if [ "$VERBOSE" =3D "1" ]; then + echo " rc=3D$rc, expected $expected" + fi + + pause_on_fail + fi + + if [ "${PAUSE}" =3D "yes" ]; then + echo + echo "hit enter to continue, 'q' to quit" + read -r a + [ "$a" =3D "q" ] && exit 1 + fi + + [ "$VERBOSE" =3D "1" ] && echo + + return 0 +} + log_info() { local msg=3D$1 diff --git a/tools/testing/selftests/net/ndisc_unsolicited_na_test.sh b/too= ls/testing/selftests/net/ndisc_unsolicited_na_test.sh index 5db69dad0cfc..89072d30fc59 100755 --- a/tools/testing/selftests/net/ndisc_unsolicited_na_test.sh +++ b/tools/testing/selftests/net/ndisc_unsolicited_na_test.sh @@ -30,31 +30,7 @@ tcpdump_stderr=3D =20 log_test() { - local rc=3D$1 - local expected=3D$2 - local msg=3D"$3" - - if [ ${rc} -eq ${expected} ]; then - printf " TEST: %-60s [ OK ]\n" "${msg}" - nsuccess=3D$((nsuccess+1)) - else - ret=3D1 - nfail=3D$((nfail+1)) - printf " TEST: %-60s [FAIL]\n" "${msg}" - if [ "${PAUSE_ON_FAIL}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi - fi - - if [ "${PAUSE}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi + log_test_expected "$1" "$2" "$3" } =20 setup() diff --git a/tools/testing/selftests/net/srv6_encap_lookup_l3vpn_test.sh b/= tools/testing/selftests/net/srv6_encap_lookup_l3vpn_test.sh index d6249303b7ea..8241de6827de 100755 --- a/tools/testing/selftests/net/srv6_encap_lookup_l3vpn_test.sh +++ b/tools/testing/selftests/net/srv6_encap_lookup_l3vpn_test.sh @@ -202,24 +202,7 @@ PAUSE_ON_FAIL=3D${PAUSE_ON_FAIL:=3Dno} =20 log_test() { - local rc=3D"$1" - local expected=3D"$2" - local msg=3D"$3" - - if [ "${rc}" -eq "${expected}" ]; then - nsuccess=3D$((nsuccess+1)) - printf "\n TEST: %-60s [ OK ]\n" "${msg}" - else - ret=3D1 - nfail=3D$((nfail+1)) - printf "\n TEST: %-60s [FAIL]\n" "${msg}" - if [ "${PAUSE_ON_FAIL}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read -r a - [ "$a" =3D "q" ] && exit 1 - fi - fi + log_test_expected "$1" "$2" "$3" } =20 print_log_test_results() diff --git a/tools/testing/selftests/net/srv6_end_dt46_l3vpn_test.sh b/tool= s/testing/selftests/net/srv6_end_dt46_l3vpn_test.sh index 50e37d3217ea..900a2ae42335 100755 --- a/tools/testing/selftests/net/srv6_end_dt46_l3vpn_test.sh +++ b/tools/testing/selftests/net/srv6_end_dt46_l3vpn_test.sh @@ -208,24 +208,7 @@ PAUSE_ON_FAIL=3D${PAUSE_ON_FAIL:=3Dno} =20 log_test() { - local rc=3D$1 - local expected=3D$2 - local msg=3D"$3" - - if [ ${rc} -eq ${expected} ]; then - nsuccess=3D$((nsuccess+1)) - printf "\n TEST: %-60s [ OK ]\n" "${msg}" - else - ret=3D1 - nfail=3D$((nfail+1)) - printf "\n TEST: %-60s [FAIL]\n" "${msg}" - if [ "${PAUSE_ON_FAIL}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi - fi + log_test_expected "$1" "$2" "$3" } =20 print_log_test_results() diff --git a/tools/testing/selftests/net/srv6_end_dt4_l3vpn_test.sh b/tools= /testing/selftests/net/srv6_end_dt4_l3vpn_test.sh index 037e5fe1da2a..260170dc8443 100755 --- a/tools/testing/selftests/net/srv6_end_dt4_l3vpn_test.sh +++ b/tools/testing/selftests/net/srv6_end_dt4_l3vpn_test.sh @@ -177,24 +177,7 @@ PAUSE_ON_FAIL=3D${PAUSE_ON_FAIL:=3Dno} =20 log_test() { - local rc=3D$1 - local expected=3D$2 - local msg=3D"$3" - - if [ ${rc} -eq ${expected} ]; then - nsuccess=3D$((nsuccess+1)) - printf "\n TEST: %-60s [ OK ]\n" "${msg}" - else - ret=3D1 - nfail=3D$((nfail+1)) - printf "\n TEST: %-60s [FAIL]\n" "${msg}" - if [ "${PAUSE_ON_FAIL}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi - fi + log_test_expected "$1" "$2" "$3" } =20 print_log_test_results() diff --git a/tools/testing/selftests/net/srv6_end_dt6_l3vpn_test.sh b/tools= /testing/selftests/net/srv6_end_dt6_l3vpn_test.sh index 9a29e0d6c912..6d4d6a23ecc4 100755 --- a/tools/testing/selftests/net/srv6_end_dt6_l3vpn_test.sh +++ b/tools/testing/selftests/net/srv6_end_dt6_l3vpn_test.sh @@ -178,24 +178,7 @@ PAUSE_ON_FAIL=3D${PAUSE_ON_FAIL:=3Dno} =20 log_test() { - local rc=3D$1 - local expected=3D$2 - local msg=3D"$3" - - if [ ${rc} -eq ${expected} ]; then - nsuccess=3D$((nsuccess+1)) - printf "\n TEST: %-60s [ OK ]\n" "${msg}" - else - ret=3D1 - nfail=3D$((nfail+1)) - printf "\n TEST: %-60s [FAIL]\n" "${msg}" - if [ "${PAUSE_ON_FAIL}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi - fi + log_test_expected "$1" "$2" "$3" } =20 print_log_test_results() diff --git a/tools/testing/selftests/net/srv6_end_dx4_netfilter_test.sh b/t= ools/testing/selftests/net/srv6_end_dx4_netfilter_test.sh index e23210aa547f..aeddbef536d6 100755 --- a/tools/testing/selftests/net/srv6_end_dx4_netfilter_test.sh +++ b/tools/testing/selftests/net/srv6_end_dx4_netfilter_test.sh @@ -111,8 +111,8 @@ # +---------------------------------------------------+ # =20 -# Kselftest framework requirement - SKIP code is 4. -ksft_skip=3D4 +# shellcheck source=3Dlib.sh +source lib.sh =20 readonly IPv6_RT_NETWORK=3D2001:11 readonly IPv4_HS_NETWORK=3D10.0.0 @@ -126,24 +126,7 @@ PAUSE_ON_FAIL=3D${PAUSE_ON_FAIL:=3Dno} =20 log_test() { - local rc=3D$1 - local expected=3D$2 - local msg=3D"$3" - - if [ ${rc} -eq ${expected} ]; then - nsuccess=3D$((nsuccess+1)) - printf "\n TEST: %-60s [ OK ]\n" "${msg}" - else - ret=3D1 - nfail=3D$((nfail+1)) - printf "\n TEST: %-60s [FAIL]\n" "${msg}" - if [ "${PAUSE_ON_FAIL}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi - fi + log_test_expected "$1" "$2" "$3" } =20 print_log_test_results() diff --git a/tools/testing/selftests/net/srv6_end_dx6_netfilter_test.sh b/t= ools/testing/selftests/net/srv6_end_dx6_netfilter_test.sh index 9e69a2ed5bc3..8fbeda1372e1 100755 --- a/tools/testing/selftests/net/srv6_end_dx6_netfilter_test.sh +++ b/tools/testing/selftests/net/srv6_end_dx6_netfilter_test.sh @@ -111,8 +111,8 @@ # +---------------------------------------------------+ # =20 -# Kselftest framework requirement - SKIP code is 4. -ksft_skip=3D4 +# shellcheck source=3Dlib.sh +source lib.sh =20 readonly IPv6_RT_NETWORK=3D2001:11 readonly IPv6_HS_NETWORK=3Dcafe @@ -126,24 +126,7 @@ PAUSE_ON_FAIL=3D${PAUSE_ON_FAIL:=3Dno} =20 log_test() { - local rc=3D$1 - local expected=3D$2 - local msg=3D"$3" - - if [ ${rc} -eq ${expected} ]; then - nsuccess=3D$((nsuccess+1)) - printf "\n TEST: %-60s [ OK ]\n" "${msg}" - else - ret=3D1 - nfail=3D$((nfail+1)) - printf "\n TEST: %-60s [FAIL]\n" "${msg}" - if [ "${PAUSE_ON_FAIL}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi - fi + log_test_expected "$1" "$2" "$3" } =20 print_log_test_results() diff --git a/tools/testing/selftests/net/srv6_end_flavors_test.sh b/tools/t= esting/selftests/net/srv6_end_flavors_test.sh index 318487eda671..30a939392eea 100755 --- a/tools/testing/selftests/net/srv6_end_flavors_test.sh +++ b/tools/testing/selftests/net/srv6_end_flavors_test.sh @@ -194,8 +194,8 @@ # after the IPv6 header. At this point, the packet with IPv6 DA=3Dcafe::1 = is sent # to the destination, i.e. hs-1. =20 -# Kselftest framework requirement - SKIP code is 4. -readonly ksft_skip=3D4 +# shellcheck source=3Dlib.sh +source lib.sh =20 readonly RDMSUFF=3D"$(mktemp -u XXXXXXXX)" readonly DUMMY_DEVNAME=3D"dum0" @@ -224,24 +224,7 @@ nfail=3D0 =20 log_test() { - local rc=3D"$1" - local expected=3D"$2" - local msg=3D"$3" - - if [ "${rc}" -eq "${expected}" ]; then - nsuccess=3D$((nsuccess+1)) - printf "\n TEST: %-60s [ OK ]\n" "${msg}" - else - ret=3D1 - nfail=3D$((nfail+1)) - printf "\n TEST: %-60s [FAIL]\n" "${msg}" - if [ "${PAUSE_ON_FAIL}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi - fi + log_test_expected "$1" "$2" "$3" } =20 print_log_test_results() diff --git a/tools/testing/selftests/net/srv6_end_next_csid_l3vpn_test.sh b= /tools/testing/selftests/net/srv6_end_next_csid_l3vpn_test.sh index 4bc135e5c22c..2e2ae21974ae 100755 --- a/tools/testing/selftests/net/srv6_end_next_csid_l3vpn_test.sh +++ b/tools/testing/selftests/net/srv6_end_next_csid_l3vpn_test.sh @@ -323,24 +323,7 @@ nfail=3D0 =20 log_test() { - local rc=3D"$1" - local expected=3D"$2" - local msg=3D"$3" - - if [ "${rc}" -eq "${expected}" ]; then - nsuccess=3D$((nsuccess+1)) - printf "\n TEST: %-60s [ OK ]\n" "${msg}" - else - ret=3D1 - nfail=3D$((nfail+1)) - printf "\n TEST: %-60s [FAIL]\n" "${msg}" - if [ "${PAUSE_ON_FAIL}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi - fi + log_test_expected "$1" "$2" "$3" } =20 print_log_test_results() diff --git a/tools/testing/selftests/net/srv6_end_x_next_csid_l3vpn_test.sh= b/tools/testing/selftests/net/srv6_end_x_next_csid_l3vpn_test.sh index 34b781a2ae74..b492a7f0297f 100755 --- a/tools/testing/selftests/net/srv6_end_x_next_csid_l3vpn_test.sh +++ b/tools/testing/selftests/net/srv6_end_x_next_csid_l3vpn_test.sh @@ -368,24 +368,7 @@ nfail=3D0 =20 log_test() { - local rc=3D"$1" - local expected=3D"$2" - local msg=3D"$3" - - if [ "${rc}" -eq "${expected}" ]; then - nsuccess=3D$((nsuccess+1)) - printf "\n TEST: %-60s [ OK ]\n" "${msg}" - else - ret=3D1 - nfail=3D$((nfail+1)) - printf "\n TEST: %-60s [FAIL]\n" "${msg}" - if [ "${PAUSE_ON_FAIL}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi - fi + log_test_expected "$1" "$2" "$3" } =20 print_log_test_results() diff --git a/tools/testing/selftests/net/srv6_hencap_red_l3vpn_test.sh b/to= ols/testing/selftests/net/srv6_hencap_red_l3vpn_test.sh index cd7d061e21f8..64ea4e2308b6 100755 --- a/tools/testing/selftests/net/srv6_hencap_red_l3vpn_test.sh +++ b/tools/testing/selftests/net/srv6_hencap_red_l3vpn_test.sh @@ -197,24 +197,7 @@ HAS_TUNSRC=3Dfalse =20 log_test() { - local rc=3D"$1" - local expected=3D"$2" - local msg=3D"$3" - - if [ "${rc}" -eq "${expected}" ]; then - nsuccess=3D$((nsuccess+1)) - printf "\n TEST: %-60s [ OK ]\n" "${msg}" - else - ret=3D1 - nfail=3D$((nfail+1)) - printf "\n TEST: %-60s [FAIL]\n" "${msg}" - if [ "${PAUSE_ON_FAIL}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi - fi + log_test_expected "$1" "$2" "$3" } =20 print_log_test_results() diff --git a/tools/testing/selftests/net/srv6_hl2encap_red_l2vpn_test.sh b/= tools/testing/selftests/net/srv6_hl2encap_red_l2vpn_test.sh index 0979b5316fdf..31e41cc4922e 100755 --- a/tools/testing/selftests/net/srv6_hl2encap_red_l2vpn_test.sh +++ b/tools/testing/selftests/net/srv6_hl2encap_red_l2vpn_test.sh @@ -146,24 +146,7 @@ nfail=3D0 =20 log_test() { - local rc=3D"$1" - local expected=3D"$2" - local msg=3D"$3" - - if [ "${rc}" -eq "${expected}" ]; then - nsuccess=3D$((nsuccess+1)) - printf "\n TEST: %-60s [ OK ]\n" "${msg}" - else - ret=3D1 - nfail=3D$((nfail+1)) - printf "\n TEST: %-60s [FAIL]\n" "${msg}" - if [ "${PAUSE_ON_FAIL}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi - fi + log_test_expected "$1" "$2" "$3" } =20 print_log_test_results() diff --git a/tools/testing/selftests/net/test_bridge_backup_port.sh b/tools= /testing/selftests/net/test_bridge_backup_port.sh index 2a7224fe74f2..8bc76be2b2d3 100755 --- a/tools/testing/selftests/net/test_bridge_backup_port.sh +++ b/tools/testing/selftests/net/test_bridge_backup_port.sh @@ -56,37 +56,7 @@ PING_TIMEOUT=3D5 =20 log_test() { - local rc=3D$1 - local expected=3D$2 - local msg=3D"$3" - - if [ ${rc} -eq ${expected} ]; then - printf "TEST: %-60s [ OK ]\n" "${msg}" - nsuccess=3D$((nsuccess+1)) - else - ret=3D1 - nfail=3D$((nfail+1)) - printf "TEST: %-60s [FAIL]\n" "${msg}" - if [ "$VERBOSE" =3D "1" ]; then - echo " rc=3D$rc, expected $expected" - fi - - if [ "${PAUSE_ON_FAIL}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi - fi - - if [ "${PAUSE}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi - - [ "$VERBOSE" =3D "1" ] && echo + log_test_expected "$1" "$2" "$3" } =20 run_cmd() diff --git a/tools/testing/selftests/net/test_bridge_neigh_suppress.sh b/to= ols/testing/selftests/net/test_bridge_neigh_suppress.sh index e9ed0d750996..9d2dc0faf741 100755 --- a/tools/testing/selftests/net/test_bridge_neigh_suppress.sh +++ b/tools/testing/selftests/net/test_bridge_neigh_suppress.sh @@ -72,39 +72,7 @@ PAUSE=3Dno =20 log_test() { - local rc=3D$1 - local expected=3D$2 - local msg=3D"$3" - - if [ ${rc} -eq ${expected} ]; then - printf "TEST: %-60s [ OK ]\n" "${msg}" - nsuccess=3D$((nsuccess+1)) - else - # shellcheck disable=3DSC2154 - ret=3D$(ksft_exit_status_merge "$ret" "$ksft_fail") - nfail=3D$((nfail+1)) - printf "TEST: %-60s [FAIL]\n" "${msg}" - if [ "$VERBOSE" =3D "1" ]; then - echo " rc=3D$rc, expected $expected" - fi - - if [ "${PAUSE_ON_FAIL}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi - fi - - if [ "${PAUSE}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi - - [ "$VERBOSE" =3D "1" ] && echo - return 0 + log_test_expected "$1" "$2" "$3" } =20 run_cmd() diff --git a/tools/testing/selftests/net/test_vxlan_mdb.sh b/tools/testing/= selftests/net/test_vxlan_mdb.sh index f9600aabd4a2..2ebb4d8a3026 100755 --- a/tools/testing/selftests/net/test_vxlan_mdb.sh +++ b/tools/testing/selftests/net/test_vxlan_mdb.sh @@ -133,37 +133,7 @@ PAUSE=3Dno =20 log_test() { - local rc=3D$1 - local expected=3D$2 - local msg=3D"$3" - - if [ ${rc} -eq ${expected} ]; then - printf "TEST: %-60s [ OK ]\n" "${msg}" - nsuccess=3D$((nsuccess+1)) - else - ret=3D1 - nfail=3D$((nfail+1)) - printf "TEST: %-60s [FAIL]\n" "${msg}" - if [ "$VERBOSE" =3D "1" ]; then - echo " rc=3D$rc, expected $expected" - fi - - if [ "${PAUSE_ON_FAIL}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi - fi - - if [ "${PAUSE}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi - - [ "$VERBOSE" =3D "1" ] && echo + log_test_expected "$1" "$2" "$3" } =20 run_cmd() diff --git a/tools/testing/selftests/net/test_vxlan_nolocalbypass.sh b/tool= s/testing/selftests/net/test_vxlan_nolocalbypass.sh index b8805983b728..c51ca0b532dd 100755 --- a/tools/testing/selftests/net/test_vxlan_nolocalbypass.sh +++ b/tools/testing/selftests/net/test_vxlan_nolocalbypass.sh @@ -24,37 +24,7 @@ PAUSE=3Dno =20 log_test() { - local rc=3D$1 - local expected=3D$2 - local msg=3D"$3" - - if [ ${rc} -eq ${expected} ]; then - printf "TEST: %-60s [ OK ]\n" "${msg}" - nsuccess=3D$((nsuccess+1)) - else - ret=3D1 - nfail=3D$((nfail+1)) - printf "TEST: %-60s [FAIL]\n" "${msg}" - if [ "$VERBOSE" =3D "1" ]; then - echo " rc=3D$rc, expected $expected" - fi - - if [ "${PAUSE_ON_FAIL}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi - fi - - if [ "${PAUSE}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi - - [ "$VERBOSE" =3D "1" ] && echo + log_test_expected "$1" "$2" "$3" } =20 run_cmd() diff --git a/tools/testing/selftests/net/test_vxlan_vnifiltering.sh b/tools= /testing/selftests/net/test_vxlan_vnifiltering.sh index 8deacc565afa..6fb5af013dac 100755 --- a/tools/testing/selftests/net/test_vxlan_vnifiltering.sh +++ b/tools/testing/selftests/net/test_vxlan_vnifiltering.sh @@ -98,31 +98,7 @@ which ping6 > /dev/null 2>&1 && ping6=3D$(which ping6) |= | ping6=3D$(which ping) =20 log_test() { - local rc=3D$1 - local expected=3D$2 - local msg=3D"$3" - - if [ ${rc} -eq ${expected} ]; then - printf " TEST: %-60s [ OK ]\n" "${msg}" - nsuccess=3D$((nsuccess+1)) - else - ret=3D1 - nfail=3D$((nfail+1)) - printf " TEST: %-60s [FAIL]\n" "${msg}" - if [ "${PAUSE_ON_FAIL}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi - fi - - if [ "${PAUSE}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi + log_test_expected "$1" "$2" "$3" } =20 run_cmd() diff --git a/tools/testing/selftests/net/vrf-xfrm-tests.sh b/tools/testing/= selftests/net/vrf-xfrm-tests.sh index b64dd891699d..a4617e5dace7 100755 --- a/tools/testing/selftests/net/vrf-xfrm-tests.sh +++ b/tools/testing/selftests/net/vrf-xfrm-tests.sh @@ -35,24 +35,7 @@ which ping6 > /dev/null 2>&1 && ping6=3D$(which ping6) |= | ping6=3D$(which ping) # log_test() { - local rc=3D$1 - local expected=3D$2 - local msg=3D"$3" - - if [ ${rc} -eq ${expected} ]; then - printf "TEST: %-60s [ OK ]\n" "${msg}" - nsuccess=3D$((nsuccess+1)) - else - ret=3D1 - nfail=3D$((nfail+1)) - printf "TEST: %-60s [FAIL]\n" "${msg}" - if [ "${PAUSE_ON_FAIL}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi - fi + log_test_expected "$1" "$2" "$3" } =20 run_cmd_host1() diff --git a/tools/testing/selftests/net/vrf_route_leaking.sh b/tools/testi= ng/selftests/net/vrf_route_leaking.sh index ce34cb2e6e0b..abf106e0f0c0 100755 --- a/tools/testing/selftests/net/vrf_route_leaking.sh +++ b/tools/testing/selftests/net/vrf_route_leaking.sh @@ -99,24 +99,7 @@ log_section() =20 log_test() { - local rc=3D$1 - local expected=3D$2 - local msg=3D"$3" - - if [ "${rc}" -eq "${expected}" ]; then - printf "TEST: %-60s [ OK ]\n" "${msg}" - nsuccess=3D$((nsuccess+1)) - else - ret=3D1 - nfail=3D$((nfail+1)) - printf "TEST: %-60s [FAIL]\n" "${msg}" - if [ "${PAUSE_ON_FAIL}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read -r a - [ "$a" =3D "q" ] && exit 1 - fi - fi + log_test_expected "$1" "$2" "$3" } =20 run_cmd() diff --git a/tools/testing/selftests/net/vrf_strict_mode_test.sh b/tools/te= sting/selftests/net/vrf_strict_mode_test.sh index 01552b542544..7de1873362ba 100755 --- a/tools/testing/selftests/net/vrf_strict_mode_test.sh +++ b/tools/testing/selftests/net/vrf_strict_mode_test.sh @@ -16,24 +16,7 @@ TESTS=3D"init testns mix" =20 log_test() { - local rc=3D$1 - local expected=3D$2 - local msg=3D"$3" - - if [ ${rc} -eq ${expected} ]; then - nsuccess=3D$((nsuccess+1)) - printf "\n TEST: %-60s [ OK ]\n" "${msg}" - else - ret=3D1 - nfail=3D$((nfail+1)) - printf "\n TEST: %-60s [FAIL]\n" "${msg}" - if [ "${PAUSE_ON_FAIL}" =3D "yes" ]; then - echo - echo "hit enter to continue, 'q' to quit" - read a - [ "$a" =3D "q" ] && exit 1 - fi - fi + log_test_expected "$1" "$2" "$3" } =20 print_log_test_results() --- base-commit: 1643b81c38c92674ebceb66dd61211e4ef86b8fe change-id: 20260812-self_log_test-b76eaf73e23f Best regards, --=20 Hangbin Liu