1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-02 13:29:49 +00:00

oeqa/runtime/cases: make date.DateTest.test_date more reliable

The test uses the broken out time and can only handle about 59s of delay,
use a UNIX timestamp to allow for up to a 300s delay.

[YOCTO #14463]

(From OE-Core rev: fd5387e8707e12b5c442bbe745c50a3e27085d02)

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit b705e9373acd4119da75af4eb96ec92cc964aa86)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Alexandre Belloni
2021-08-12 23:46:38 +02:00
committed by Richard Purdie
parent d6f40be29b
commit ae90e3876d
+4 -5
View File
@@ -28,14 +28,13 @@ class DateTest(OERuntimeTestCase):
self.assertEqual(status, 0, msg=msg) self.assertEqual(status, 0, msg=msg)
oldDate = output oldDate = output
sampleDate = '"2016-08-09 10:00:00"' sampleTimestamp = 1488800000
(status, output) = self.target.run("date -s %s" % sampleDate) (status, output) = self.target.run("date -s @%d" % sampleTimestamp)
self.assertEqual(status, 0, msg='Date set failed, output: %s' % output) self.assertEqual(status, 0, msg='Date set failed, output: %s' % output)
(status, output) = self.target.run("date -R") (status, output) = self.target.run('date +"%s"')
p = re.match('Tue, 09 Aug 2016 10:00:.. \+0000', output)
msg = 'The date was not set correctly, output: %s' % output msg = 'The date was not set correctly, output: %s' % output
self.assertTrue(p, msg=msg) self.assertTrue(int(output) - sampleTimestamp < 300, msg=msg)
(status, output) = self.target.run('date -s "%s"' % oldDate) (status, output) = self.target.run('date -s "%s"' % oldDate)
msg = 'Failed to reset date, output: %s' % output msg = 'Failed to reset date, output: %s' % output