summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/runtime/cases/ping.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa/runtime/cases/ping.py')
-rw-r--r--meta/lib/oeqa/runtime/cases/ping.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/meta/lib/oeqa/runtime/cases/ping.py b/meta/lib/oeqa/runtime/cases/ping.py
index f6603f75ec..f72460e7f3 100644
--- a/meta/lib/oeqa/runtime/cases/ping.py
+++ b/meta/lib/oeqa/runtime/cases/ping.py
@@ -1,11 +1,15 @@
1# 1#
2# Copyright OpenEmbedded Contributors
3#
2# SPDX-License-Identifier: MIT 4# SPDX-License-Identifier: MIT
3# 5#
4 6
5from subprocess import Popen, PIPE 7from subprocess import Popen, PIPE
8from time import sleep
6 9
7from oeqa.runtime.case import OERuntimeTestCase 10from oeqa.runtime.case import OERuntimeTestCase
8from oeqa.core.decorator.oetimeout import OETimeout 11from oeqa.core.decorator.oetimeout import OETimeout
12from oeqa.core.exception import OEQATimeoutError
9 13
10class PingTest(OERuntimeTestCase): 14class PingTest(OERuntimeTestCase):
11 15
@@ -13,14 +17,19 @@ class PingTest(OERuntimeTestCase):
13 def test_ping(self): 17 def test_ping(self):
14 output = '' 18 output = ''
15 count = 0 19 count = 0
16 while count < 5: 20 self.assertNotEqual(len(self.target.ip), 0, msg="No target IP address set")
17 cmd = 'ping -c 1 %s' % self.target.ip 21 try:
18 proc = Popen(cmd, shell=True, stdout=PIPE) 22 while count < 5:
19 output += proc.communicate()[0].decode('utf-8') 23 cmd = 'ping -c 1 %s' % self.target.ip
20 if proc.poll() == 0: 24 proc = Popen(cmd, shell=True, stdout=PIPE)
21 count += 1 25 output += proc.communicate()[0].decode('utf-8')
22 else: 26 if proc.poll() == 0:
23 count = 0 27 count += 1
28 else:
29 count = 0
30 sleep(1)
31 except OEQATimeoutError:
32 self.fail("Ping timeout error for address %s, count %s, output: %s" % (self.target.ip, count, output))
24 msg = ('Expected 5 consecutive, got %d.\n' 33 msg = ('Expected 5 consecutive, got %d.\n'
25 'ping output is:\n%s' % (count,output)) 34 'ping output is:\n%s' % (count,output))
26 self.assertEqual(count, 5, msg = msg) 35 self.assertEqual(count, 5, msg = msg)