[LTP] [PATCH v7 1/3] lib/test_net.sh: add tst_ping() to check icmp connectivity
Hangbin Liu
haliu@redhat.com
Wed Apr 27 04:29:28 CEST 2016
Signed-off-by: Hangbin Liu <haliu@redhat.com>
---
testcases/lib/test_net.sh | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/testcases/lib/test_net.sh b/testcases/lib/test_net.sh
index 418fed3..57728c9 100644
--- a/testcases/lib/test_net.sh
+++ b/testcases/lib/test_net.sh
@@ -314,3 +314,33 @@ tst_netload()
return $ret
}
+
+# tst_ping [IFACE] [DST ADDR] [MESSAGE SIZE ARREY]
+# Check icmp connectivity
+# IFACE: source interface name
+# DST ADDR: destination IPv4 or IPv6 address
+# MESSAGE SIZE ARREY: message size arrey
+tst_ping()
+{
+ # The max number of ICMP echo request
+ PING_MAX=${PING_MAX:-"10"}
+
+ local src_iface=${1:-"$(tst_iface)"}
+ local dst_addr=${2:-"$(tst_ipaddr rhost)"}
+ local msg_sizes=${@:3}
+ local ret=0
+
+ # ping cmd use 56 as default message size
+ for size in ${msg_sizes:-"56"}; do
+ ping$TST_IPV6 -I $src_iface -c $PING_MAX $dst_addr \
+ -s $size > /dev/null 2>&1
+ ret=$?
+ if [ $ret -eq 0 ]; then
+ tst_resm TINFO "tst_ping IPv${TST_IPV6:-4} msg_size $size pass"
+ else
+ tst_resm TINFO "tst_ping IPv${TST_IPV6:-4} msg_size $size fail"
+ break
+ fi
+ done
+ return $ret
+}
--
2.5.5
More information about the ltp
mailing list