diff mbox series

runfvp: pass-through environment variables need for GUI applications

Message ID 20220929095820.1066279-1-ross.burton@arm.com
State New
Headers show
Series runfvp: pass-through environment variables need for GUI applications | expand

Commit Message

Ross Burton Sept. 29, 2022, 9:58 a.m. UTC
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>
---
 meta-arm/lib/fvp/runner.py                 | 10 +++++++++-
 meta-arm/lib/oeqa/selftest/cases/runfvp.py | 22 ++++++++++++++++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)

Comments

Jon Mason Sept. 29, 2022, 6:56 p.m. UTC | #1
On Thu, 29 Sep 2022 10:58:20 +0100, Ross Burton wrote:
> 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.

Applied, thanks!

[1/1] runfvp: pass-through environment variables need for GUI applications
      commit: aa89fe3f08cb8406f9f1082c683bd71cd04628fb

Best regards,
diff mbox series

Patch

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"})