diff options
| -rw-r--r-- | meta/lib/oeqa/runtime/cases/boot.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/meta/lib/oeqa/runtime/cases/boot.py b/meta/lib/oeqa/runtime/cases/boot.py new file mode 100644 index 0000000000..2142f400a0 --- /dev/null +++ b/meta/lib/oeqa/runtime/cases/boot.py | |||
| @@ -0,0 +1,33 @@ | |||
| 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) | ||
