[LTP] [PATCH 1/2] ip_tests.sh: Iprove grep count

Petr Vorel pvorel@suse.cz
Tue Dec 17 15:50:40 CET 2024


Some systems have already defined another route with src 127.0.0.1,
therefore more exact pattern is needed.

Also 1) escape '.' (dot) in regex 2) use '-q' instead of redirecting
stdout to /dev/null.

Reported-by: Petr Cervinka <pcervinka@suse.com>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/network/iproute/ip_tests.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/testcases/network/iproute/ip_tests.sh b/testcases/network/iproute/ip_tests.sh
index ee9768073f..0b1d5a85e6 100755
--- a/testcases/network/iproute/ip_tests.sh
+++ b/testcases/network/iproute/ip_tests.sh
@@ -179,7 +179,7 @@ test5()
 $ip4_addr via 127.0.0.1 dev lo
 	EOF
 
-	ip route show | grep "$ip4_addr via 127.0.0.1 dev lo" > tst_ip.out 2>&1
+	ip route show | grep "$ip4_addr via 127\.0\.0\.1 dev lo" > tst_ip\.out 2>&1
 	if [ $? -ne 0 ]; then
 		tst_res TFAIL "'ip route show' command failed"
 		return
@@ -195,7 +195,7 @@ $ip4_addr via 127.0.0.1 dev lo
 
 	ROD ip route del $ip4_addr via 127.0.0.1
 
-	ip route show | grep 127.0.0.1 > /dev/null
+	ip route show | grep -q "$ip4_addr via 127\.0\.0\.1 dev lo"
 	if [ $? -eq 0 ]; then
 		tst_res TFAIL "route not deleted"
 		return
-- 
2.47.1



More information about the ltp mailing list