Brad Bishop | 6dbb316 | 2019-11-25 09:41:34 -0500 | [diff] [blame] | 1 | # |
| 2 | # SPDX-License-Identifier: MIT |
| 3 | # |
| 4 | |
| 5 | from subprocess import Popen, PIPE |
| 6 | import time |
| 7 | |
| 8 | from oeqa.runtime.case import OERuntimeTestCase |
| 9 | from oeqa.core.decorator.depends import OETestDepends |
| 10 | from oeqa.core.decorator.oetimeout import OETimeout |
| 11 | from oeqa.core.decorator.data import skipIfQemu |
| 12 | |
| 13 | class BootTest(OERuntimeTestCase): |
| 14 | |
| 15 | @OETimeout(120) |
| 16 | @skipIfQemu('qemuall', 'Test only runs on real hardware') |
| 17 | @OETestDepends(['ssh.SSHTest.test_ssh']) |
| 18 | def test_reboot(self): |
| 19 | output = '' |
| 20 | count = 0 |
| 21 | (status, output) = self.target.run('reboot -h') |
| 22 | while count < 5: |
| 23 | time.sleep(5) |
| 24 | cmd = 'ping -c 1 %s' % self.target.ip |
| 25 | proc = Popen(cmd, shell=True, stdout=PIPE) |
| 26 | output += proc.communicate()[0].decode('utf-8') |
| 27 | if proc.poll() == 0: |
| 28 | count += 1 |
| 29 | else: |
| 30 | count = 0 |
| 31 | msg = ('Expected 5 consecutive, got %d.\n' |
| 32 | 'ping output is:\n%s' % (count,output)) |
| 33 | self.assertEqual(count, 5, msg = msg) |