mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-09-09 07:51:59 -09:00
support/testing: set date in emulated machine
When time comes to check certificates, the date and time in the emulated machine should be close enough to the actual values, so that certificate validity can be checked. Some Qemu machines have an RTC (e.g. arm vexpress-a9 has a pl031), and the kernel needs a driver for those RTC. It is not guaranteed that the machine used for a test meets those two conditions; in such a case, the time in the machine starts way back in the past (1970-01-01T00:00:00Z on sysv, or the release date of systemd). This is the case with the default kernel, so such tests do not have the proper time. Set the date to the date of the host system. This is going to be accurate to the second, which is, by far, enough for our purpose. To avoid having to consider what combination of emulated machine and kernel configuration are being used, we always set the date, as this is a generic step that should be done by the infra (like login in as root is). The Emulator() class doesn't inherit from unittest.TestCase, so we can't call any of the usual self.assertXXX() methods; instead, we just raise a standard exception, like is done a few lines above to detect the login prompt. Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr> Cc: Ricardo Martincoski <ricardo.martincoski@datacom.com.br> Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Signed-off-by: Julien Olivain <ju.o@free.fr>
This commit is contained in:
committed by
Julien Olivain
parent
6dc177bee8
commit
cf8641b73e
@@ -5,6 +5,7 @@ import os
|
||||
|
||||
import pexpect
|
||||
import pexpect.replwrap
|
||||
import time
|
||||
|
||||
import infra
|
||||
|
||||
@@ -152,6 +153,10 @@ class Emulator(object):
|
||||
|
||||
self.connect_shell()
|
||||
|
||||
output, exit_code = self.run(f"date @{int(time.time())}")
|
||||
if exit_code:
|
||||
raise SystemError("Cannot set date in virtual machine")
|
||||
|
||||
def connect_shell(self):
|
||||
extra_init_cmd = " && ".join([
|
||||
'export PAGER=cat',
|
||||
|
||||
Reference in New Issue
Block a user