xref: /OK3568_Linux_fs/yocto/poky/meta/lib/oeqa/runtime/cases/suspend.py (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyunfrom oeqa.runtime.case import OERuntimeTestCase
2*4882a593Smuzhiyunfrom oeqa.core.decorator.depends import OETestDepends
3*4882a593Smuzhiyunfrom oeqa.core.decorator.data import skipIfQemu
4*4882a593Smuzhiyunimport threading
5*4882a593Smuzhiyunimport time
6*4882a593Smuzhiyun
7*4882a593Smuzhiyunclass Suspend_Test(OERuntimeTestCase):
8*4882a593Smuzhiyun
9*4882a593Smuzhiyun    def test_date(self):
10*4882a593Smuzhiyun        (status, output) = self.target.run('date')
11*4882a593Smuzhiyun        self.assertEqual(status, 0,  msg = 'Failed to run date command, output : %s' % output)
12*4882a593Smuzhiyun
13*4882a593Smuzhiyun    def test_ping(self):
14*4882a593Smuzhiyun        t_thread = threading.Thread(target=self.target.run, args=("ping 8.8.8.8",))
15*4882a593Smuzhiyun        t_thread.start()
16*4882a593Smuzhiyun        time.sleep(2)
17*4882a593Smuzhiyun
18*4882a593Smuzhiyun        status, output = self.target.run('pidof ping')
19*4882a593Smuzhiyun        self.target.run('kill -9 %s' % output)
20*4882a593Smuzhiyun        self.assertEqual(status, 0, msg = 'Not able to find process that runs ping, output : %s' % output)
21*4882a593Smuzhiyun
22*4882a593Smuzhiyun    def set_suspend(self):
23*4882a593Smuzhiyun        (status, output) = self.target.run('sudo rtcwake -m mem -s 10')
24*4882a593Smuzhiyun        self.assertEqual(status, 0,  msg = 'Failed to suspends your system to RAM, output : %s' % output)
25*4882a593Smuzhiyun
26*4882a593Smuzhiyun    @skipIfQemu()
27*4882a593Smuzhiyun    @OETestDepends(['ssh.SSHTest.test_ssh'])
28*4882a593Smuzhiyun    def test_suspend(self):
29*4882a593Smuzhiyun        self.test_date()
30*4882a593Smuzhiyun        self.test_ping()
31*4882a593Smuzhiyun        self.set_suspend()
32*4882a593Smuzhiyun        self.test_date()
33*4882a593Smuzhiyun        self.test_ping()
34