From patchwork Mon Nov 6 15:59:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 33943 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F4E4C4167D for ; Mon, 6 Nov 2023 15:59:21 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.58439.1699286357536865986 for ; Mon, 06 Nov 2023 07:59:17 -0800 Authentication-Results: mx.groups.io; dkim=none (message not signed); spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ross.burton@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BD4B61FB; Mon, 6 Nov 2023 08:00:00 -0800 (PST) Received: from oss-tx204.lab.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 0AE4A3F703; Mon, 6 Nov 2023 07:59:15 -0800 (PST) From: ross.burton@arm.com To: meta-arm@lists.yoctoproject.org Cc: nd@arm.com Subject: [PATCH 1/3] arm/lib/fvp/runner: don't pass '' as cwd Date: Mon, 6 Nov 2023 15:59:12 +0000 Message-Id: <20231106155914.2552807-1-ross.burton@arm.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 06 Nov 2023 15:59:21 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/meta-arm/message/5209 From: Ross Burton Don't pass "" as the cwd as that fails, use None so the cwd doesn't get changed. Signed-off-by: Ross Burton --- meta-arm/lib/fvp/runner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta-arm/lib/fvp/runner.py b/meta-arm/lib/fvp/runner.py index 7ca3673d..e7c13585 100644 --- a/meta-arm/lib/fvp/runner.py +++ b/meta-arm/lib/fvp/runner.py @@ -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)}") From patchwork Mon Nov 6 15:59:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 33941 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A76EC4167B for ; Mon, 6 Nov 2023 15:59:21 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.57725.1699286358175457982 for ; Mon, 06 Nov 2023 07:59:18 -0800 Authentication-Results: mx.groups.io; dkim=none (message not signed); spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ross.burton@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6F238C15; Mon, 6 Nov 2023 08:00:01 -0800 (PST) Received: from oss-tx204.lab.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B19523F703; Mon, 6 Nov 2023 07:59:16 -0800 (PST) From: ross.burton@arm.com To: meta-arm@lists.yoctoproject.org Cc: nd@arm.com Subject: [PATCH 2/3] scripts/runfvp: exit code should be the FVP exit code Date: Mon, 6 Nov 2023 15:59:13 +0000 Message-Id: <20231106155914.2552807-2-ross.burton@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231106155914.2552807-1-ross.burton@arm.com> References: <20231106155914.2552807-1-ross.burton@arm.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 06 Nov 2023 15:59:21 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/meta-arm/message/5210 From: Ross Burton The __main__ body used the return value of runfvp() as the exit code, but this was never set. Signed-off-by: Ross Burton --- scripts/runfvp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/runfvp b/scripts/runfvp index 0ca3a1b5..135cf04d 100755 --- a/scripts/runfvp +++ b/scripts/runfvp @@ -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__": From patchwork Mon Nov 6 15:59:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 33942 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DF07C4332F for ; Mon, 6 Nov 2023 15:59:21 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.57726.1699286358223628403 for ; Mon, 06 Nov 2023 07:59:18 -0800 Authentication-Results: mx.groups.io; dkim=none (message not signed); spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ross.burton@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 187FADA7; Mon, 6 Nov 2023 08:00:02 -0800 (PST) Received: from oss-tx204.lab.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 646A23F703; Mon, 6 Nov 2023 07:59:17 -0800 (PST) From: ross.burton@arm.com To: meta-arm@lists.yoctoproject.org Cc: nd@arm.com Subject: [PATCH 3/3] arm/selftest: add test that DISPLAY is forwarded into the runfvp child Date: Mon, 6 Nov 2023 15:59:14 +0000 Message-Id: <20231106155914.2552807-3-ross.burton@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231106155914.2552807-1-ross.burton@arm.com> References: <20231106155914.2552807-1-ross.burton@arm.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 06 Nov 2023 15:59:21 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/meta-arm/message/5211 From: Ross Burton Add an optional env argument to the run_fvp() function, and check that DISPLAY is preserved. Signed-off-by: Ross Burton --- 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 diff --git a/meta-arm/lib/oeqa/selftest/cases/runfvp.py b/meta-arm/lib/oeqa/selftest/cases/runfvp.py index 61ce2ab9..c995f89e 100644 --- a/meta-arm/lib/oeqa/selftest/cases/runfvp.py +++ b/meta-arm/lib/oeqa/selftest/cases/runfvp.py @@ -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): diff --git a/meta-arm/lib/oeqa/selftest/cases/tests/mock-fvp.py b/meta-arm/lib/oeqa/selftest/cases/tests/mock-fvp.py index 2213c9f0..6cf8e454 100755 --- a/meta-arm/lib/oeqa/selftest/cases/tests/mock-fvp.py +++ b/meta-arm/lib/oeqa/selftest/cases/tests/mock-fvp.py @@ -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() diff --git a/meta-arm/lib/oeqa/selftest/cases/tests/test-environment.json b/meta-arm/lib/oeqa/selftest/cases/tests/test-environment.json new file mode 100644 index 00000000..6e23855b --- /dev/null +++ b/meta-arm/lib/oeqa/selftest/cases/tests/test-environment.json @@ -0,0 +1,4 @@ +{ + "fvp-bindir": ".", + "exe": "test-environment.py" +} diff --git a/meta-arm/lib/oeqa/selftest/cases/tests/test-environment.py b/meta-arm/lib/oeqa/selftest/cases/tests/test-environment.py new file mode 120000 index 00000000..c734eeca --- /dev/null +++ b/meta-arm/lib/oeqa/selftest/cases/tests/test-environment.py @@ -0,0 +1 @@ +mock-fvp.py \ No newline at end of file