Skip to content

Commit

Permalink
ip_tests.sh: Improve grep count
Browse files Browse the repository at this point in the history
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.

Link: https://lore.kernel.org/ltp/[email protected]/
Reported-by: Petr Cervinka <[email protected]>
Reviewed-by: Avinesh Kumar <[email protected]>
Reviewed-by: Wei Gao <[email protected]>
Signed-off-by: Petr Vorel <[email protected]>
  • Loading branch information
pevik committed Dec 19, 2024
1 parent 9c38a4e commit 57fb6b2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions testcases/network/iproute/ip_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 57fb6b2

Please sign in to comment.