def test_icmp_ping(self):
"""test icmp ping - compare to icmping utilite"""
icmp_ping = Ping(IFACE, ICMP_NAME, TIMEOUT, False)
for ip in list(ipaddress.ip_network(TEST_NETWORK).hosts())[:5]:
try:
# need arping installed
with os.popen('ping -c {} -t {} {}'.format(COUNT,
TIMEOUT,
str(ip)), 'r'):
# get exit code
ec = os.wait()[1] & 0xFF00
res = icmp_ping.ping_host(str(ip))
except PermissionException:
print('Need root previlegies')
if res[STATUS_INDEX] == ONLINE:
self.assertTrue(ec == 0)
else:
self.assertFalse(ec == 0)
评论列表
文章目录