From 0d4177598ce7e73f2b97ac58c21fb177343643e3 Mon Sep 17 00:00:00 2001 From: Julien Olivain Date: Tue, 29 Oct 2024 21:54:35 +0100 Subject: [PATCH] support/testing/infra/emulator.py: add build host dir to qemu search path The relevant qemu emulator is started with pexpect.spawn() with a default environment (and PATH). This will always use the qemu available on the host. When running in the reference Docker image, it is using an old Qemu v5.2.0. This version is getting too old to run with more recent components, like EDK2 or ATF. The main reason to use a qemu version preinstalled in the Docker image was to save some build time. Also, this behavior is opposite to the "start-qemu.sh" helper script [1], which tries to execute the Buildroot host-qemu first (and then fallback the the version on the host system, if available). An option was added in [2] to let the user have a better control on which version is used. Also, updating the Buildroot reference Docker image has a larger impact on the whole project (i.e. updating the image would bring a newer qemu version, but might break many other things, at a time which is not always convenient). We now need some kind of control in runtime tests, to choose between a "stock" qemu, and a more recent version with all the bells and whistles. This commit adds the Buildroot host build directory in the path. This will make the runtime test infrastructure to use a host-qemu, if selected by a runtime test configuration. For now, most of the test can continue to use the qemu version provided in the Docker image. Only the problematic tests relying on a recent version will select BR2_PACKAGE_HOST_QEMU=y. The host-qemu package is usually maintained to a recent version, so this should be sufficient. [1] https://gitlab.com/buildroot.org/buildroot/-/blob/master/board/qemu/start-qemu.sh.in [2] https://gitlab.com/buildroot.org/buildroot/-/commit/5de78f181acc53959b0a446a3fb116ecdec13577 Signed-off-by: Julien Olivain Reviewed-by: Romain Naour Signed-off-by: Romain Naour --- support/testing/infra/emulator.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/support/testing/infra/emulator.py b/support/testing/infra/emulator.py index 5318577cda..238e123302 100644 --- a/support/testing/infra/emulator.py +++ b/support/testing/infra/emulator.py @@ -44,6 +44,7 @@ class Emulator(object): def __init__(self, builddir, downloaddir, logtofile, timeout_multiplier): self.qemu = None self.repl = None + self.builddir = builddir self.downloaddir = downloaddir self.logfile = infra.open_log_file(builddir, "run", logtofile) # We use elastic runners on the cloud to runs our tests. Those runners @@ -116,11 +117,14 @@ class Emulator(object): self.logfile.write(f"> host loadavg: {ldavg_str}\n") self.logfile.write(f"> timeout multiplier: {self.timeout_multiplier}\n") self.logfile.write("> starting qemu with '%s'\n" % " ".join(qemu_cmd)) + host_bin = os.path.join(self.builddir, "host", "bin") + br_path = host_bin + os.pathsep + os.environ["PATH"] self.qemu = pexpect.spawn(qemu_cmd[0], qemu_cmd[1:], timeout=5 * self.timeout_multiplier, encoding='utf-8', codec_errors='replace', - env={"QEMU_AUDIO_DRV": "none"}) + env={"QEMU_AUDIO_DRV": "none", + "PATH": br_path}) # We want only stdout into the log to avoid double echo self.qemu.logfile_read = self.logfile