arm/lib/fvp/runner: don't pass '' as cwd
PATCH 1/3 arm/lib/fvp/runner: don't pass '' as cwd
From: Ross Burton <[email protected]>
Don't pass "" as the cwd as that fails, use None so the cwd doesn't get changed.
Signed-off-by Ross Burton <[email protected]>
--- meta-arm/lib/fvp/runner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta-arm/lib/fvp/runner.py +1 -1
@@ -100,7 +100,7 @@ class FVPRunner: env[name] = os.environ[name] # Allow filepath to be relative to fvp configuration file - cwd = os.path.dirname(fvpconf) + cwd = os.path.dirname(fvpconf) or None self._logger.debug(f"FVP call will be executed in working directory: {cwd}") self._logger.debug(f"Constructed FVP call: {shlex_join(cli)}")
Signature · 1 line
2.34.1
PATCH 2/3 scripts/runfvp: exit code should be the FVP exit code
From: Ross Burton <[email protected]>
The __main__ body used the return value of runfvp() as the exit code, but this was never set.
Signed-off-by Ross Burton <[email protected]>
--- scripts/runfvp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/runfvp +2 -2
@@ -79,7 +79,7 @@ def start_fvp(args, fvpconf, extra_args): print(line.strip().decode(errors='ignore')) finally: - fvp.stop() + return fvp.stop() def runfvp(cli_args):
@@ -88,7 +88,7 @@ def runfvp(cli_args): config_file = args.config else: config_file = conffile.find(args.config) - start_fvp(args, config_file, extra_args) + return start_fvp(args, config_file, extra_args) if __name__ == "__main__":
Signature · 1 line
2.34.1
PATCH 3/3 arm/selftest: add test that DISPLAY is forwarded into the runfvp child
In reply to [email protected]From: Ross Burton <[email protected]>
Add an optional env argument to the run_fvp() function, and check that DISPLAY is preserved.
Signed-off-by Ross Burton <[email protected]>
--- meta-arm/lib/oeqa/selftest/cases/runfvp.py | 9 ++++++--- meta-arm/lib/oeqa/selftest/cases/tests/mock-fvp.py | 7 +++++++ .../lib/oeqa/selftest/cases/tests/test-environment.json | 4 ++++ .../lib/oeqa/selftest/cases/tests/test-environment.py | 1 + 4 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 meta-arm/lib/oeqa/selftest/cases/tests/test-environment.json create mode 120000 meta-arm/lib/oeqa/selftest/cases/tests/test-environment.py
meta-arm/lib/oeqa/selftest/cases/runfvp.py +6 -3
@@ -1,4 +1,3 @@ -import asyncio import os import json import pathlib
@@ -17,7 +16,7 @@ class RunFVPTests(OESelftestTestCase): def setUpLocal(self): self.assertTrue(runfvp.exists()) - def run_fvp(self, *args, should_succeed=True): + def run_fvp(self, *args, env=None, should_succeed=True): """ Call runfvp passing any arguments. If check is True verify return stdout on exit code 0 or fail the test, otherwise return the CompletedProcess
@@ -26,7 +25,7 @@ class RunFVPTests(OESelftestTestCase): cli = [runfvp,] + list(args) print(f"Calling {cli}") # Set cwd to testdir so that any mock FVPs are found - ret = subprocess.run(cli, cwd=testdir, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True) + ret = subprocess.run(cli, cwd=testdir, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True) if should_succeed: self.assertEqual(ret.returncode, 0, f"runfvp exit {ret.returncode}, output: {ret.stdout}") return ret.stdout
@@ -53,6 +52,10 @@ class RunFVPTests(OESelftestTestCase): # test-parameter sets one argument, add another manually self.run_fvp(testdir / "test-parameter.json", "--", "--parameter", "board.dog=woof") + def test_fvp_environment(self): + output = self.run_fvp(testdir / "test-environment.json", env={"DISPLAY": "test_fvp_environment:42"}) + self.assertEqual(output.strip(), "Found expected DISPLAY") + @OETestTag("meta-arm") class ConfFileTests(OESelftestTestCase): def test_no_exe(self):
meta-arm/lib/oeqa/selftest/cases/tests/mock-fvp.py +7 -0
@@ -2,12 +2,19 @@ import argparse import sys +import os def do_test_parameters(args): if not args.parameter or set(args.parameter) != set(("board.cow=moo", "board.dog=woof")): print(f"Unexpected arguments: {args}") sys.exit(1) +def do_test_environment(args): + if os.environ.get("DISPLAY") == "test_fvp_environment:42": + print("Found expected DISPLAY") + else: + print("Got unexpected environment %s" % str(os.environ)) + sys.exit(1) if __name__ == "__main__": parser = argparse.ArgumentParser()
meta-arm/lib/oeqa/selftest/cases/tests/test-environment.json new file +4 -0
@@ -0,0 +1,4 @@ +{ + "fvp-bindir": ".", + "exe": "test-environment.py" +}
meta-arm/lib/oeqa/selftest/cases/tests/test-environment.py new file +1 -0
@@ -0,0 +1 @@ +mock-fvp.py
Signature · 1 line
2.34.1
Jon Mason
AppliedQuoted 4 lines · On Mon, 06 Nov 2023 15:59:12 +0000, [email protected] wrote:
Don't pass "" as the cwd as that fails, use None so the cwd doesn't get changed.
Applied, thanks!
[1/3] arm/lib/fvp/runner: don't pass '' as cwd
commit: 98e85b3a297dcf0c953ccfc29b539d3517dfc09b
[2/3] scripts/runfvp: exit code should be the FVP exit code
commit: 6fa5992471941b7cd55396b3a454ae85b9c4253a
[3/3] arm/selftest: add test that DISPLAY is forwarded into the runfvp child
commit: f923386a0dd5973ca28cca3127974c8eaf5e04c9Best regards,
Signature · 1 line
Jon Mason <[email protected]>