diff options
Diffstat (limited to 'meta/lib/oeqa/runtime/cases/rtc.py')
-rw-r--r-- | meta/lib/oeqa/runtime/cases/rtc.py | 40 |
1 files changed, 40 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..39f4d29f23 --- /dev/null +++ b/meta/lib/oeqa/runtime/cases/rtc.py | |||
@@ -0,0 +1,40 @@ | |||
1 | from oeqa.runtime.case import OERuntimeTestCase | ||
2 | from oeqa.core.decorator.depends import OETestDepends | ||
3 | from oeqa.core.decorator.data import skipIfFeature | ||
4 | from oeqa.runtime.decorator.package import OEHasPackage | ||
5 | |||
6 | import re | ||
7 | |||
8 | class RTCTest(OERuntimeTestCase): | ||
9 | |||
10 | def setUp(self): | ||
11 | if self.tc.td.get('VIRTUAL-RUNTIME_init_manager') == 'systemd': | ||
12 | self.logger.debug('Stopping systemd-timesyncd daemon') | ||
13 | self.target.run('systemctl disable --now --runtime systemd-timesyncd') | ||
14 | |||
15 | def tearDown(self): | ||
16 | if self.tc.td.get('VIRTUAL-RUNTIME_init_manager') == 'systemd': | ||
17 | self.logger.debug('Starting systemd-timesyncd daemon') | ||
18 | self.target.run('systemctl enable --now --runtime systemd-timesyncd') | ||
19 | |||
20 | @skipIfFeature('read-only-rootfs', | ||
21 | 'Test does not work with read-only-rootfs in IMAGE_FEATURES') | ||
22 | @OETestDepends(['ssh.SSHTest.test_ssh']) | ||
23 | @OEHasPackage(['coreutils', 'busybox']) | ||
24 | def test_rtc(self): | ||
25 | (status, output) = self.target.run('hwclock -r') | ||
26 | self.assertEqual(status, 0, msg='Failed to get RTC time, output: %s' % output) | ||
27 | |||
28 | (status, current_datetime) = self.target.run('date +"%m%d%H%M%Y"') | ||
29 | self.assertEqual(status, 0, msg='Failed to get system current date & time, output: %s' % current_datetime) | ||
30 | |||
31 | example_datetime = '062309452008' | ||
32 | (status, output) = self.target.run('date %s ; hwclock -w ; hwclock -r' % example_datetime) | ||
33 | check_hwclock = re.search('2008-06-23 09:45:..', output) | ||
34 | self.assertTrue(check_hwclock, msg='The RTC time was not set correctly, output: %s' % output) | ||
35 | |||
36 | (status, output) = self.target.run('date %s' % current_datetime) | ||
37 | self.assertEqual(status, 0, msg='Failed to reset system date & time, output: %s' % output) | ||
38 | |||
39 | (status, output) = self.target.run('hwclock -w') | ||
40 | self.assertEqual(status, 0, msg='Failed to reset RTC time, output: %s' % output) | ||