blob: 02f580abeedfc522f3d29a5fb747b5755c334776 [file] [log] [blame]
Brad Bishop6e60e8b2018-02-01 10:27:11 -05001from subprocess import Popen, PIPE
2
3from oeqa.runtime.case import OERuntimeTestCase
4from oeqa.core.decorator.oeid import OETestID
5from oeqa.core.decorator.oetimeout import OETimeout
6
7class PingTest(OERuntimeTestCase):
8
9 @OETimeout(30)
10 @OETestID(964)
11 def test_ping(self):
12 output = ''
13 count = 0
14 while count < 5:
15 cmd = 'ping -c 1 %s' % self.target.ip
16 proc = Popen(cmd, shell=True, stdout=PIPE)
17 output += proc.communicate()[0].decode('utf-8')
18 if proc.poll() == 0:
19 count += 1
20 else:
21 count = 0
22 msg = ('Expected 5 consecutive, got %d.\n'
23 'ping output is:\n%s' % (count,output))
24 self.assertEqual(count, 5, msg = msg)