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.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/meta/lib/oeqa/runtime/cases/ping.py b/meta/lib/oeqa/runtime/cases/ping.py
index f6603f75ec..498f80d0a5 100644
--- a/meta/lib/oeqa/runtime/cases/ping.py
+++ b/meta/lib/oeqa/runtime/cases/ping.py
@@ -6,6 +6,7 @@ from subprocess import Popen, PIPE
6 6
7from oeqa.runtime.case import OERuntimeTestCase 7from oeqa.runtime.case import OERuntimeTestCase
8from oeqa.core.decorator.oetimeout import OETimeout 8from oeqa.core.decorator.oetimeout import OETimeout
9from oeqa.core.exception import OEQATimeoutError
9 10
10class PingTest(OERuntimeTestCase): 11class PingTest(OERuntimeTestCase):
11 12
@@ -13,14 +14,17 @@ class PingTest(OERuntimeTestCase):
13 def test_ping(self): 14 def test_ping(self):
14 output = '' 15 output = ''
15 count = 0 16 count = 0
16 while count < 5: 17 try:
17 cmd = 'ping -c 1 %s' % self.target.ip 18 while count < 5:
18 proc = Popen(cmd, shell=True, stdout=PIPE) 19 cmd = 'ping -c 1 %s' % self.target.ip
19 output += proc.communicate()[0].decode('utf-8') 20 proc = Popen(cmd, shell=True, stdout=PIPE)
20 if proc.poll() == 0: 21 output += proc.communicate()[0].decode('utf-8')
21 count += 1 22 if proc.poll() == 0:
22 else: 23 count += 1
23 count = 0 24 else:
25 count = 0
26 except OEQATimeoutError:
27 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' 28 msg = ('Expected 5 consecutive, got %d.\n'
25 'ping output is:\n%s' % (count,output)) 29 'ping output is:\n%s' % (count,output))
26 self.assertEqual(count, 5, msg = msg) 30 self.assertEqual(count, 5, msg = msg)