diff options
Diffstat (limited to 'meta/lib/oeqa/runtime/cases/date.py')
-rw-r--r-- | meta/lib/oeqa/runtime/cases/date.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/meta/lib/oeqa/runtime/cases/date.py b/meta/lib/oeqa/runtime/cases/date.py index fdd2a6ae58..a2523de67a 100644 --- a/meta/lib/oeqa/runtime/cases/date.py +++ b/meta/lib/oeqa/runtime/cases/date.py | |||
@@ -1,4 +1,6 @@ | |||
1 | # | 1 | # |
2 | # Copyright OpenEmbedded Contributors | ||
3 | # | ||
2 | # SPDX-License-Identifier: MIT | 4 | # SPDX-License-Identifier: MIT |
3 | # | 5 | # |
4 | 6 | ||
@@ -13,12 +15,12 @@ class DateTest(OERuntimeTestCase): | |||
13 | def setUp(self): | 15 | def setUp(self): |
14 | if self.tc.td.get('VIRTUAL-RUNTIME_init_manager') == 'systemd': | 16 | if self.tc.td.get('VIRTUAL-RUNTIME_init_manager') == 'systemd': |
15 | self.logger.debug('Stopping systemd-timesyncd daemon') | 17 | self.logger.debug('Stopping systemd-timesyncd daemon') |
16 | self.target.run('systemctl disable --now systemd-timesyncd') | 18 | self.target.run('systemctl disable --now --runtime systemd-timesyncd') |
17 | 19 | ||
18 | def tearDown(self): | 20 | def tearDown(self): |
19 | if self.tc.td.get('VIRTUAL-RUNTIME_init_manager') == 'systemd': | 21 | if self.tc.td.get('VIRTUAL-RUNTIME_init_manager') == 'systemd': |
20 | self.logger.debug('Starting systemd-timesyncd daemon') | 22 | self.logger.debug('Starting systemd-timesyncd daemon') |
21 | self.target.run('systemctl enable --now systemd-timesyncd') | 23 | self.target.run('systemctl enable --now --runtime systemd-timesyncd') |
22 | 24 | ||
23 | @OETestDepends(['ssh.SSHTest.test_ssh']) | 25 | @OETestDepends(['ssh.SSHTest.test_ssh']) |
24 | @OEHasPackage(['coreutils', 'busybox']) | 26 | @OEHasPackage(['coreutils', 'busybox']) |
@@ -28,14 +30,13 @@ class DateTest(OERuntimeTestCase): | |||
28 | self.assertEqual(status, 0, msg=msg) | 30 | self.assertEqual(status, 0, msg=msg) |
29 | oldDate = output | 31 | oldDate = output |
30 | 32 | ||
31 | sampleDate = '"2016-08-09 10:00:00"' | 33 | sampleTimestamp = 1488800000 |
32 | (status, output) = self.target.run("date -s %s" % sampleDate) | 34 | (status, output) = self.target.run("date -s @%d" % sampleTimestamp) |
33 | self.assertEqual(status, 0, msg='Date set failed, output: %s' % output) | 35 | self.assertEqual(status, 0, msg='Date set failed, output: %s' % output) |
34 | 36 | ||
35 | (status, output) = self.target.run("date -R") | 37 | (status, output) = self.target.run('date +"%s"') |
36 | p = re.match('Tue, 09 Aug 2016 10:00:.. \+0000', output) | ||
37 | msg = 'The date was not set correctly, output: %s' % output | 38 | msg = 'The date was not set correctly, output: %s' % output |
38 | self.assertTrue(p, msg=msg) | 39 | self.assertTrue(int(output) - sampleTimestamp < 300, msg=msg) |
39 | 40 | ||
40 | (status, output) = self.target.run('date -s "%s"' % oldDate) | 41 | (status, output) = self.target.run('date -s "%s"' % oldDate) |
41 | msg = 'Failed to reset date, output: %s' % output | 42 | msg = 'Failed to reset date, output: %s' % output |