diff options
Diffstat (limited to 'meta/lib/oeqa/runtime/cases/ping.py')
| -rw-r--r-- | meta/lib/oeqa/runtime/cases/ping.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/meta/lib/oeqa/runtime/cases/ping.py b/meta/lib/oeqa/runtime/cases/ping.py new file mode 100644 index 0000000000..02f580abee --- /dev/null +++ b/meta/lib/oeqa/runtime/cases/ping.py | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | from subprocess import Popen, PIPE | ||
| 2 | |||
| 3 | from oeqa.runtime.case import OERuntimeTestCase | ||
| 4 | from oeqa.core.decorator.oeid import OETestID | ||
| 5 | from oeqa.core.decorator.oetimeout import OETimeout | ||
| 6 | |||
| 7 | class 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) | ||
