From: Hangbin Liu <[email protected]>

fib_tests mixes use of $ret for both per-test return value and global exit
code. If an earlier subtest fails and a later function sets ret=0, the
script will exit with status 0 even though [FAIL] lines were printed.

Use RET as the per-test return value, as already defined in lib.sh. The
exit code ret will only be set in log_test().

Signed-off-by: Hangbin Liu <[email protected]>
---
Changes in v2:
- target to net-next since this doesn't fix a regression (Ido Schimmel)
- remove RET in fib_carrier_unicast_test which is not used (Ido Schimmel)
- Link to v1: 
https://lore.kernel.org/r/[email protected]
---
 tools/testing/selftests/net/fib_tests.sh | 40 +++++++++++++++-----------------
 1 file changed, 19 insertions(+), 21 deletions(-)

diff --git a/tools/testing/selftests/net/fib_tests.sh 
b/tools/testing/selftests/net/fib_tests.sh
index b338bfb196a2..47184d201d33 100755
--- a/tools/testing/selftests/net/fib_tests.sh
+++ b/tools/testing/selftests/net/fib_tests.sh
@@ -369,8 +369,6 @@ fib_carrier_local_test()
 
 fib_carrier_unicast_test()
 {
-       ret=0
-
        echo
        echo "Single path route carrier test"
 
@@ -685,12 +683,12 @@ fib6_notify_test()
 
        err=`cat errors.txt |grep "Message too long"`
        if [ -z "$err" ];then
-               ret=0
+               RET=0
        else
-               ret=1
+               RET=1
        fi
 
-       log_test $ret 0 "ipv6 route add notify"
+       log_test "$RET" 0 "ipv6 route add notify"
 
        kill_process %%
 
@@ -732,12 +730,12 @@ fib_notify_test()
 
        err=`cat errors.txt |grep "Message too long"`
        if [ -z "$err" ];then
-               ret=0
+               RET=0
        else
-               ret=1
+               RET=1
        fi
 
-       log_test $ret 0 "ipv4 route add notify"
+       log_test "$RET" 0 "ipv4 route add notify"
 
        kill_process %%
 
@@ -763,9 +761,9 @@ check_rt_num()
 
     if [ $num -ne $expected ]; then
        echo "FAIL: Expected $expected routes, got $num"
-       ret=1
+       RET=1
     else
-       ret=0
+       RET=0
     fi
 }
 
@@ -812,7 +810,7 @@ fib6_gc_test()
        sleep $GC_WAIT_TIME
        $NS_EXEC sysctl -wq net.ipv6.route.flush=1
        check_rt_num 0 $($IP -6 route list |grep expires|wc -l)
-       log_test $ret 0 "ipv6 route garbage collection"
+       log_test "$RET" 0 "ipv6 route garbage collection"
 
        reset_dummy_10
 
@@ -830,7 +828,7 @@ fib6_gc_test()
        # Wait for GC
        sleep $GC_WAIT_TIME
        check_rt_num 0 $($IP -6 route list |grep expires|wc -l)
-       log_test $ret 0 "ipv6 route garbage collection (with permanent routes)"
+       log_test "$RET" 0 "ipv6 route garbage collection (with permanent 
routes)"
 
        reset_dummy_10
 
@@ -848,7 +846,7 @@ fib6_gc_test()
        # Wait for GC
        sleep $GC_WAIT_TIME
        check_rt_num 0 $($IP -6 route list |grep expires|wc -l)
-       log_test $ret 0 "ipv6 route garbage collection (replace with expires)"
+       log_test "$RET" 0 "ipv6 route garbage collection (replace with expires)"
 
        reset_dummy_10
 
@@ -868,7 +866,7 @@ fib6_gc_test()
        # Wait for GC
        sleep $GC_WAIT_TIME
        check_rt_num 5 $($IP -6 route list |grep -v expires|grep 2001:20::|wc 
-l)
-       log_test $ret 0 "ipv6 route garbage collection (replace with permanent)"
+       log_test "$RET" 0 "ipv6 route garbage collection (replace with 
permanent)"
 
        # Delete dummy_10 and remove all routes
        $IP link del dev dummy_10
@@ -923,7 +921,7 @@ fib6_gc_test()
        # rt6_nh_dump_exceptions() just skips expired exceptions.
        $NS_EXEC sysctl -wq net.ipv6.route.flush=1
        check_rt_num 0 $($IP -6 route list cache | grep 2001:10:: | wc -l)
-       log_test $ret 0 "ipv6 route garbage collection (promote to permanent 
routes)"
+       log_test "$RET" 0 "ipv6 route garbage collection (promote to permanent 
routes)"
 
        $IP neigh del fe80:dead::3 lladdr 00:11:22:33:44:55 dev veth1 router
        $IP link del veth1
@@ -960,7 +958,7 @@ fib6_gc_test()
        # Wait for GC
        sleep $GC_WAIT_TIME
        check_rt_num 0 $($IP -6 route list |grep expires|wc -l)
-       log_test $ret 0 "ipv6 route garbage collection (RA message)"
+       log_test "$RET" 0 "ipv6 route garbage collection (RA message)"
 
        set +e
 
@@ -1589,7 +1587,7 @@ fib6_ra_to_static()
        # Expire is back, on-link route is now owned by RA again
        check_rt_num 2 $($IP -6 route list |grep expires|wc -l)
 
-       log_test $ret 0 "ipv6 promote RA route to static"
+       log_test "$RET" 0 "ipv6 promote RA route to static"
 
        # Prepare for RA route with gateway
        $NS_EXEC sysctl -wq net.ipv6.conf.veth1.accept_ra_rt_info_max_plen=64
@@ -1606,7 +1604,7 @@ fib6_ra_to_static()
 
        check_rt_num 2 "$($IP -6 route list | grep -c "nexthop via")"
 
-       log_test "$ret" 0 "ipv6 RA route with nexthop do not merge into ECMP 
with static"
+       log_test "$RET" 0 "ipv6 RA route with nexthop do not merge into ECMP 
with static"
 
        set +e
 
@@ -1651,18 +1649,18 @@ fib6_temp_addr_renewal() {
        # Restore it
        $NS_EXEC ra6 -i veth2 -s fe80::1 -d ff02::1 -P 
2001:12::/64\#LA\#3600\#3600 -e
 
-       ret=1
+       RET=1
        for i in $(seq 1 25); do
                sleep 1
                num_dep="$($IP -6 addr | grep -c "temporary deprecated" || 
true)"
                num_tot="$($IP -6 addr | grep -c "temporary" || true)"
 
                if [ "$num_dep" -eq 1 ] && [ "$num_tot" -ge 2 ]; then
-                       ret=0
+                       RET=0
                        break
                fi
        done
-       log_test "$ret" 0 "IPv6 temporary address cleanly deprecated and 
regenerated"
+       log_test "$RET" 0 "IPv6 temporary address cleanly deprecated and 
regenerated"
 
        set +e
 

---
base-commit: 8c2493eef43ab8592738a5398c74af268c0fefdf
change-id: 20260928-self_fib_tests-0d05f96eafbb

Best regards,
-- 
Hangbin Liu <[email protected]>


Reply via email to