diff mbox series

[SRU,Focal,1/1] UBUNTU: SAUCE: selftests/net: skipping tests for older ip command releases

Message ID 42bf5bc0c40051b815ff3220eabdb44769a71e25.1664999456.git.jose.ogando@canonical.com
State New
Headers show
Series Fix fib_nexthop_nongw running in bionic v5.4 | expand

Commit Message

Jose Ogando Oct. 5, 2022, 8:41 p.m. UTC
BugLink: https://bugs.launchpad.net/bugs/1990800

When running fib_nexthop_nongw from V5.4 on older releases (i.e.
Bionic) the nexthop ip subcommand is not available.
This patch queries ip capabilities beforehand, and will execute
or skip where aplicable.

Signed-off-by: Jose Ogando <jose.ogando@canonical.com>
---
 .../selftests/net/fib_nexthop_nongw.sh        | 20 +++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/fib_nexthop_nongw.sh b/tools/testing/selftests/net/fib_nexthop_nongw.sh
index b7b928b38ce4..6d79ed88b48b 100755
--- a/tools/testing/selftests/net/fib_nexthop_nongw.sh
+++ b/tools/testing/selftests/net/fib_nexthop_nongw.sh
@@ -108,12 +108,20 @@  do
 	esac
 done
 
-cleanup
-setup
+ip nexthop help 2>&1 | grep -q "unknown"
+if [ $? -eq 0 ]; then
+	echo "SKIP: ip nexthop: ip command too old"
+	ret=0
+else
 
-run_cmd ip -netns h1 route get 192.168.1.1
-log_test $? 0 "nexthop: get route with nexthop without gw"
-run_cmd ip netns exec h1 ping -c1 192.168.1.1
-log_test $? 0 "nexthop: ping through nexthop without gw"
+	cleanup
+	setup
+
+	run_cmd ip -netns h1 route get 192.168.1.1
+	log_test $? 0 "nexthop: get route with nexthop without gw"
+	run_cmd ip netns exec h1 ping -c1 192.168.1.1
+	log_test $? 0 "nexthop: ping through nexthop without gw"
+
+fi
 
 exit $ret