1# 2# Copyright OpenEmbedded Contributors 3# 4# SPDX-License-Identifier: MIT 5# 6from oeqa.runtime.case import OERuntimeTestCase 7from oeqa.core.decorator.depends import OETestDepends 8from oeqa.core.decorator.data import skipIfQemu 9import threading 10import time 11 12class Suspend_Test(OERuntimeTestCase): 13 14 def test_date(self): 15 (status, output) = self.target.run('date') 16 self.assertEqual(status, 0, msg = 'Failed to run date command, output : %s' % output) 17 18 def test_ping(self): 19 t_thread = threading.Thread(target=self.target.run, args=("ping 8.8.8.8",)) 20 t_thread.start() 21 time.sleep(2) 22 23 status, output = self.target.run('pidof ping') 24 self.target.run('kill -9 %s' % output) 25 self.assertEqual(status, 0, msg = 'Not able to find process that runs ping, output : %s' % output) 26 27 def set_suspend(self): 28 (status, output) = self.target.run('sudo rtcwake -m mem -s 10') 29 self.assertEqual(status, 0, msg = 'Failed to suspends your system to RAM, output : %s' % output) 30 31 @skipIfQemu() 32 @OETestDepends(['ssh.SSHTest.test_ssh']) 33 def test_suspend(self): 34 self.test_date() 35 self.test_ping() 36 self.set_suspend() 37 self.test_date() 38 self.test_ping() 39