runfvp: pass-through environment variables need for GUI applications

Since 820a55d3 the environment that the FVPs run in is limited, however
this broke the use of GUI applications for the terminals.

Passthrough DISPLAY and WAYLAND_DISPLAY automatically so these continue
to work.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Jon Mason <jon.mason@arm.com>
This commit is contained in:
Ross Burton authored and Jon Mason committed 2022-09-29 11:22:54 -04:00
1 parent 3f59a344e6
commit aa89fe3f08
2 files changed
+31 -1

No files matched your search

+9 -1
View File
@@ -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)
@@ -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"})