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