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