diff options
author | Teoh Jay Shen <jay.shen.teoh@intel.com> | 2020-09-25 08:25:42 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-09-28 14:15:48 +0100 |
commit | c8bfb29d74676d30d7b551f09aa7279eca7e5d00 (patch) | |
tree | f41129ef5e3ba6dd5d3b2da0070e6f6237427960 /meta | |
parent | fd903cda434b2c1ee079457eda45ea6bd140b64e (diff) | |
download | poky-c8bfb29d74676d30d7b551f09aa7279eca7e5d00.tar.gz |
oeqa/runtime : add test for RTC(Real Time Clock)
This test is checking the functionality of the RTC(Real Time Clock). The Check_if_RTC_(Real_Time_Clock)_can_work_correctly manual test case from oeqa/manual/bsp-hw can be replace by this runtime test.
(From OE-Core rev: c6961c2fc04edbc5bc3827c7703997085d9c609e)
Signed-off-by: Teoh Jay Shen <jay.shen.teoh@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/lib/oeqa/runtime/cases/rtc.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/meta/lib/oeqa/runtime/cases/rtc.py b/meta/lib/oeqa/runtime/cases/rtc.py new file mode 100644 index 0000000000..a34c101a9d --- /dev/null +++ b/meta/lib/oeqa/runtime/cases/rtc.py | |||
@@ -0,0 +1,38 @@ | |||
1 | from oeqa.runtime.case import OERuntimeTestCase | ||
2 | from oeqa.core.decorator.depends import OETestDepends | ||
3 | from oeqa.runtime.decorator.package import OEHasPackage | ||
4 | |||
5 | import re | ||
6 | |||
7 | class RTCTest(OERuntimeTestCase): | ||
8 | |||
9 | def setUp(self): | ||
10 | if self.tc.td.get('VIRTUAL-RUNTIME_init_manager') == 'systemd': | ||
11 | self.logger.debug('Stopping systemd-timesyncd daemon') | ||
12 | self.target.run('systemctl disable --now systemd-timesyncd') | ||
13 | |||
14 | def tearDown(self): | ||
15 | if self.tc.td.get('VIRTUAL-RUNTIME_init_manager') == 'systemd': | ||
16 | self.logger.debug('Starting systemd-timesyncd daemon') | ||
17 | self.target.run('systemctl enable --now systemd-timesyncd') | ||
18 | |||
19 | @OETestDepends(['ssh.SSHTest.test_ssh']) | ||
20 | @OEHasPackage(['coreutils', 'busybox']) | ||
21 | def test_rtc(self): | ||
22 | (status, output) = self.target.run('hwclock -r') | ||
23 | self.assertEqual(status, 0, msg='Failed to get RTC time, output: %s' % output) | ||
24 | |||
25 | (status, current_datetime) = self.target.run('date +"%m%d%H%M%Y"') | ||
26 | self.assertEqual(status, 0, msg='Failed to get system current date & time, output: %s' % current_datetime) | ||
27 | |||
28 | example_datetime = '062309452008' | ||
29 | (status, output) = self.target.run('date %s ; hwclock -w ; hwclock -r' % example_datetime) | ||
30 | check_hwclock = re.search('2008-06-23 09:45:..', output) | ||
31 | self.assertTrue(check_hwclock, msg='The RTC time was not set correctly, output: %s' % output) | ||
32 | |||
33 | (status, output) = self.target.run('date %s' % current_datetime) | ||
34 | self.assertEqual(status, 0, msg='Failed to reset system date & time, output: %s' % output) | ||
35 | |||
36 | (status, output) = self.target.run('hwclock -w') | ||
37 | self.assertEqual(status, 0, msg='Failed to reset RTC time, output: %s' % output) | ||
38 | |||