diff --git a/meta-arm/lib/fvp/runner.py b/meta-arm/lib/fvp/runner.py index 8c6b4cad..c5c795dd 100644 --- a/meta-arm/lib/fvp/runner.py +++ b/meta-arm/lib/fvp/runner.py @@ -59,11 +59,19 @@ class FVPRunner: async def start(self, config, extra_args=[], terminal_choice="none"): cli = cli_from_config(config, terminal_choice) cli += extra_args + + # Pass through environment variables needed for GUI applications, such + # as xterm, to work. + env = config['env'] + for name in ('DISPLAY', 'WAYLAND_DISPLAY'): + if name in os.environ: + env[name] = os.environ[name] + self._logger.debug(f"Constructed FVP call: {cli}") self._fvp_process = await asyncio.create_subprocess_exec( *cli, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, - env=config['env']) + env=env) def detect_terminals(line): m = re.match(r"^(\S+): Listening for serial connection on port (\d+)$", line) diff --git a/meta-arm/lib/oeqa/selftest/cases/runfvp.py b/meta-arm/lib/oeqa/selftest/cases/runfvp.py index e1bf2040..cf8a3c53 100644 --- a/meta-arm/lib/oeqa/selftest/cases/runfvp.py +++ b/meta-arm/lib/oeqa/selftest/cases/runfvp.py @@ -107,3 +107,25 @@ class RunnerTests(OESelftestTestCase): stdout=unittest.mock.ANY, stderr=unittest.mock.ANY, env={"FOO":"BAR"}) + + @unittest.mock.patch.dict(os.environ, {"DISPLAY": ":42", "WAYLAND_DISPLAY": "wayland-42"}) + def test_env_passthrough(self): + from fvp import runner + with self.create_mock() as m: + fvp = runner.FVPRunner(self.logger) + asyncio.run(fvp.start({ + "fvp-bindir": "/usr/bin", + "exe": "FVP_Binary", + "parameters": {}, + "data": [], + "applications": {}, + "terminals": {}, + "args": [], + "env": {"FOO": "BAR"} + })) + + m.assert_called_once_with('/usr/bin/FVP_Binary', + stdin=unittest.mock.ANY, + stdout=unittest.mock.ANY, + stderr=unittest.mock.ANY, + env={"DISPLAY":":42", "FOO": "BAR", "WAYLAND_DISPLAY": "wayland-42"})