diff mbox series

[v3,1/2] arm/lib: pass the PATH to fvp runner

Message ID 20230408081158.7575-1-peron.clem@gmail.com
State New
Headers show
Series [v3,1/2] arm/lib: pass the PATH to fvp runner | expand

Commit Message

Clément Péron April 8, 2023, 8:11 a.m. UTC
When running an FVP machine the model executable need to be found
in the PATH environement.

At the moment the script doesn't provide any PATH to the subprocess.

Add PATH to the allowed environement variable to be forwaded.

Signed-off-by: Clément Péron <peron.clem@gmail.com>
---
 meta-arm/lib/fvp/runner.py                 | 2 +-
 meta-arm/lib/oeqa/selftest/cases/runfvp.py | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

Comments

Jon Mason April 10, 2023, 7:21 p.m. UTC | #1
On Sat, Apr 08, 2023 at 10:11:57AM +0200, Cl�ment P�ron wrote:
> When running an FVP machine the model executable need to be found
> in the PATH environement.
> 
> At the moment the script doesn't provide any PATH to the subprocess.
> 
> Add PATH to the allowed environement variable to be forwaded.
> 
> Signed-off-by: Cl�ment P�ron <peron.clem@gmail.com>
> ---
>  meta-arm/lib/fvp/runner.py                 | 2 +-
>  meta-arm/lib/oeqa/selftest/cases/runfvp.py | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/meta-arm/lib/fvp/runner.py b/meta-arm/lib/fvp/runner.py
> index c52cdc1c..d957e780 100644
> --- a/meta-arm/lib/fvp/runner.py
> +++ b/meta-arm/lib/fvp/runner.py
> @@ -91,7 +91,7 @@ class FVPRunner:
>          # Pass through environment variables needed for GUI applications, such
>          # as xterm, to work.
>          env = config['env']
> -        for name in ('DISPLAY', 'WAYLAND_DISPLAY', 'XAUTHORITY'):
> +        for name in ('DISPLAY', 'PATH', 'WAYLAND_DISPLAY', 'XAUTHORITY'):
>              if name in os.environ:
>                  env[name] = os.environ[name]
>  
> diff --git a/meta-arm/lib/oeqa/selftest/cases/runfvp.py b/meta-arm/lib/oeqa/selftest/cases/runfvp.py
> index 5cc8660f..7e0d7808 100644
> --- a/meta-arm/lib/oeqa/selftest/cases/runfvp.py
> +++ b/meta-arm/lib/oeqa/selftest/cases/runfvp.py
> @@ -108,7 +108,7 @@ class RunnerTests(OESelftestTestCase):
>                  stderr=unittest.mock.ANY,
>                  env={"FOO":"BAR"})

This is failing CI selftest on the line above.  You can see the error
at https://gitlab.com/jonmason00/meta-arm/-/jobs/4087128645
If I add a wildcard-like change for PATH to the env, everything is
happy.  For example:
-                env={"FOO":"BAR"})
+                env={"FOO":"BAR", "PATH" : unittest.mock.ANY })

I'm not sure it is a valid way to test this, as I think it ignores
your hacking of the paths to test it.  Since PATH is always in the env
now, there is no other way to get around it being present but not
matching what we expect.  I'm hoping someone has a better way than
ignoring it.

Thoughts?  Anyone?

Thanks,
Jon


>  
> -    @unittest.mock.patch.dict(os.environ, {"DISPLAY": ":42", "WAYLAND_DISPLAY": "wayland-42"})
> +    @unittest.mock.patch.dict(os.environ, {"DISPLAY": ":42", "WAYLAND_DISPLAY": "wayland-42", "PATH": "/path-42:/usr/sbin:/usr/bin:/sbin:/bin"})
>      def test_env_passthrough(self):
>          from fvp import runner
>          with self.create_mock() as m:
> @@ -128,4 +128,4 @@ class RunnerTests(OESelftestTestCase):
>                  stdin=unittest.mock.ANY,
>                  stdout=unittest.mock.ANY,
>                  stderr=unittest.mock.ANY,
> -                env={"DISPLAY":":42", "FOO": "BAR", "WAYLAND_DISPLAY": "wayland-42"})
> +                env={"DISPLAY":":42", "FOO": "BAR", "WAYLAND_DISPLAY": "wayland-42", "PATH": "/path-42:/usr/sbin:/usr/bin:/sbin:/bin"})
> -- 
> 2.34.1
> 
>
Clément Péron May 17, 2023, 9:40 a.m. UTC | #2
Hi Jon,

On Mon, 10 Apr 2023 at 21:21, Jon Mason <jdmason@kudzu.us> wrote:
>
> On Sat, Apr 08, 2023 at 10:11:57AM +0200, Clément Péron wrote:
> > When running an FVP machine the model executable need to be found
> > in the PATH environement.
> >
> > At the moment the script doesn't provide any PATH to the subprocess.
> >
> > Add PATH to the allowed environement variable to be forwaded.
> >
> > Signed-off-by: Clément Péron <peron.clem@gmail.com>
> > ---
> >  meta-arm/lib/fvp/runner.py                 | 2 +-
> >  meta-arm/lib/oeqa/selftest/cases/runfvp.py | 4 ++--
> >  2 files changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/meta-arm/lib/fvp/runner.py b/meta-arm/lib/fvp/runner.py
> > index c52cdc1c..d957e780 100644
> > --- a/meta-arm/lib/fvp/runner.py
> > +++ b/meta-arm/lib/fvp/runner.py
> > @@ -91,7 +91,7 @@ class FVPRunner:
> >          # Pass through environment variables needed for GUI applications, such
> >          # as xterm, to work.
> >          env = config['env']
> > -        for name in ('DISPLAY', 'WAYLAND_DISPLAY', 'XAUTHORITY'):
> > +        for name in ('DISPLAY', 'PATH', 'WAYLAND_DISPLAY', 'XAUTHORITY'):
> >              if name in os.environ:
> >                  env[name] = os.environ[name]
> >
> > diff --git a/meta-arm/lib/oeqa/selftest/cases/runfvp.py b/meta-arm/lib/oeqa/selftest/cases/runfvp.py
> > index 5cc8660f..7e0d7808 100644
> > --- a/meta-arm/lib/oeqa/selftest/cases/runfvp.py
> > +++ b/meta-arm/lib/oeqa/selftest/cases/runfvp.py
> > @@ -108,7 +108,7 @@ class RunnerTests(OESelftestTestCase):
> >                  stderr=unittest.mock.ANY,
> >                  env={"FOO":"BAR"})
>
> This is failing CI selftest on the line above.  You can see the error
> at https://gitlab.com/jonmason00/meta-arm/-/jobs/4087128645
> If I add a wildcard-like change for PATH to the env, everything is
> happy.  For example:
> -                env={"FOO":"BAR"})
> +                env={"FOO":"BAR", "PATH" : unittest.mock.ANY })
>
> I'm not sure it is a valid way to test this, as I think it ignores
> your hacking of the paths to test it.  Since PATH is always in the env
> now, there is no other way to get around it being present but not
> matching what we expect.  I'm hoping someone has a better way than
> ignoring it.
>
> Thoughts?  Anyone?

I will resend a version with the os.environ mocked.

Regards,
Clement


>
> Thanks,
> Jon
>
>
> >
> > -    @unittest.mock.patch.dict(os.environ, {"DISPLAY": ":42", "WAYLAND_DISPLAY": "wayland-42"})
> > +    @unittest.mock.patch.dict(os.environ, {"DISPLAY": ":42", "WAYLAND_DISPLAY": "wayland-42", "PATH": "/path-42:/usr/sbin:/usr/bin:/sbin:/bin"})
> >      def test_env_passthrough(self):
> >          from fvp import runner
> >          with self.create_mock() as m:
> > @@ -128,4 +128,4 @@ class RunnerTests(OESelftestTestCase):
> >                  stdin=unittest.mock.ANY,
> >                  stdout=unittest.mock.ANY,
> >                  stderr=unittest.mock.ANY,
> > -                env={"DISPLAY":":42", "FOO": "BAR", "WAYLAND_DISPLAY": "wayland-42"})
> > +                env={"DISPLAY":":42", "FOO": "BAR", "WAYLAND_DISPLAY": "wayland-42", "PATH": "/path-42:/usr/sbin:/usr/bin:/sbin:/bin"})
> > --
> > 2.34.1
> >
> >
Jon Mason May 25, 2023, 12:51 a.m. UTC | #3
On Sat, 8 Apr 2023 10:11:57 +0200, Clément Péron wrote:
> When running an FVP machine the model executable need to be found
> in the PATH environement.
> 
> At the moment the script doesn't provide any PATH to the subprocess.
> 
> Add PATH to the allowed environement variable to be forwaded.

Applied, thanks!

[1/2] arm/lib: pass the PATH to fvp runner
      commit: fa598021fb387e98bdb80861f245cc15acde4ca5
[2/2] scripts/runfvp: Fix KeyError exception when there is no FVP_CONSOLE provided
      commit: 316e02c0f13b473e916cd779e59f0d55d48e4962

Best regards,
diff mbox series

Patch

diff --git a/meta-arm/lib/fvp/runner.py b/meta-arm/lib/fvp/runner.py
index c52cdc1c..d957e780 100644
--- a/meta-arm/lib/fvp/runner.py
+++ b/meta-arm/lib/fvp/runner.py
@@ -91,7 +91,7 @@  class FVPRunner:
         # Pass through environment variables needed for GUI applications, such
         # as xterm, to work.
         env = config['env']
-        for name in ('DISPLAY', 'WAYLAND_DISPLAY', 'XAUTHORITY'):
+        for name in ('DISPLAY', 'PATH', 'WAYLAND_DISPLAY', 'XAUTHORITY'):
             if name in os.environ:
                 env[name] = os.environ[name]
 
diff --git a/meta-arm/lib/oeqa/selftest/cases/runfvp.py b/meta-arm/lib/oeqa/selftest/cases/runfvp.py
index 5cc8660f..7e0d7808 100644
--- a/meta-arm/lib/oeqa/selftest/cases/runfvp.py
+++ b/meta-arm/lib/oeqa/selftest/cases/runfvp.py
@@ -108,7 +108,7 @@  class RunnerTests(OESelftestTestCase):
                 stderr=unittest.mock.ANY,
                 env={"FOO":"BAR"})
 
-    @unittest.mock.patch.dict(os.environ, {"DISPLAY": ":42", "WAYLAND_DISPLAY": "wayland-42"})
+    @unittest.mock.patch.dict(os.environ, {"DISPLAY": ":42", "WAYLAND_DISPLAY": "wayland-42", "PATH": "/path-42:/usr/sbin:/usr/bin:/sbin:/bin"})
     def test_env_passthrough(self):
         from fvp import runner
         with self.create_mock() as m:
@@ -128,4 +128,4 @@  class RunnerTests(OESelftestTestCase):
                 stdin=unittest.mock.ANY,
                 stdout=unittest.mock.ANY,
                 stderr=unittest.mock.ANY,
-                env={"DISPLAY":":42", "FOO": "BAR", "WAYLAND_DISPLAY": "wayland-42"})
+                env={"DISPLAY":":42", "FOO": "BAR", "WAYLAND_DISPLAY": "wayland-42", "PATH": "/path-42:/usr/sbin:/usr/bin:/sbin:/bin"})