blob: dcee3311f78dde89ccd7a55239a714bc962052e4 [file] [log] [blame]
Brad Bishop6dbb3162019-11-25 09:41:34 -05001#
Patrick Williams92b42cb2022-09-03 06:53:57 -05002# Copyright OpenEmbedded Contributors
3#
Brad Bishop6dbb3162019-11-25 09:41:34 -05004# SPDX-License-Identifier: MIT
5#
6
7from subprocess import Popen, PIPE
8import time
9
10from oeqa.runtime.case import OERuntimeTestCase
11from oeqa.core.decorator.depends import OETestDepends
12from oeqa.core.decorator.oetimeout import OETimeout
13from oeqa.core.decorator.data import skipIfQemu
14
15class BootTest(OERuntimeTestCase):
16
17 @OETimeout(120)
Patrick Williams45852732022-04-02 08:58:32 -050018 @skipIfQemu()
Brad Bishop6dbb3162019-11-25 09:41:34 -050019 @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)