Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 1 | # |
| 2 | # SPDX-License-Identifier: MIT |
| 3 | # |
| 4 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 5 | from subprocess import Popen, PIPE |
| 6 | |
| 7 | from oeqa.runtime.case import OERuntimeTestCase |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 8 | from oeqa.core.decorator.oetimeout import OETimeout |
| 9 | |
| 10 | class PingTest(OERuntimeTestCase): |
| 11 | |
| 12 | @OETimeout(30) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 13 | 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) |