blob: e1ad88a17443ef1e76613903b1532bc90ad13b08 [file] [log] [blame]
Brad Bishop6dbb3162019-11-25 09:41:34 -05001#
2# SPDX-License-Identifier: MIT
3#
4
5from subprocess import Popen, PIPE
6import time
7
8from oeqa.runtime.case import OERuntimeTestCase
9from oeqa.core.decorator.depends import OETestDepends
10from oeqa.core.decorator.oetimeout import OETimeout
11from oeqa.core.decorator.data import skipIfQemu
12
13class BootTest(OERuntimeTestCase):
14
15 @OETimeout(120)
Patrick Williams45852732022-04-02 08:58:32 -050016 @skipIfQemu()
Brad Bishop6dbb3162019-11-25 09:41:34 -050017 @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)