All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] test: Include /sbin to the PATH when creating ext4 disk image
@ 2021-02-03 15:31 Andy Shevchenko
  2021-02-05  3:17 ` Simon Glass
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2021-02-03 15:31 UTC (permalink / raw)
  To: u-boot

On some distributions the mkfs.ext4 is under /sbin and /sbin is not set
for mere users. Include /sbin to the PATH when creating ext4 disk image,
so that users won't get a scary traceback from Python.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 test/py/tests/test_env.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py
index 940279651da0..536467320e06 100644
--- a/test/py/tests/test_env.py
+++ b/test/py/tests/test_env.py
@@ -414,6 +414,9 @@ def mk_env_ext4(state_test_env):
     if os.path.exists(persistent):
         c.log.action('Disk image file ' + persistent + ' already exists')
     else:
+        root_path = os.path.abspath('.').split(os.path.sep)[0] + os.path.sep
+        sbin_path = os.path.join(root_path, 'sbin')
+        os.environ["PATH"] += os.pathsep + sbin_path
         try:
             u_boot_utils.run_and_log(c, 'dd if=/dev/zero of=%s bs=1M count=16' % persistent)
             u_boot_utils.run_and_log(c, 'mkfs.ext4 %s' % persistent)
-- 
2.30.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v1] test: Include /sbin to the PATH when creating ext4 disk image
  2021-02-03 15:31 [PATCH v1] test: Include /sbin to the PATH when creating ext4 disk image Andy Shevchenko
@ 2021-02-05  3:17 ` Simon Glass
  2021-02-05 17:29   ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Simon Glass @ 2021-02-05  3:17 UTC (permalink / raw)
  To: u-boot

Hi Andy,

On Wed, 3 Feb 2021 at 08:32, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On some distributions the mkfs.ext4 is under /sbin and /sbin is not set
> for mere users. Include /sbin to the PATH when creating ext4 disk image,
> so that users won't get a scary traceback from Python.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  test/py/tests/test_env.py | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py
> index 940279651da0..536467320e06 100644
> --- a/test/py/tests/test_env.py
> +++ b/test/py/tests/test_env.py
> @@ -414,6 +414,9 @@ def mk_env_ext4(state_test_env):
>      if os.path.exists(persistent):
>          c.log.action('Disk image file ' + persistent + ' already exists')
>      else:
> +        root_path = os.path.abspath('.').split(os.path.sep)[0] + os.path.sep

Is it not enough to do os.path.abspath('.') ? I think it would be good
to have a comment as to what we need this gymnastics.

> +        sbin_path = os.path.join(root_path, 'sbin')
> +        os.environ["PATH"] += os.pathsep + sbin_path
>          try:
>              u_boot_utils.run_and_log(c, 'dd if=/dev/zero of=%s bs=1M count=16' % persistent)
>              u_boot_utils.run_and_log(c, 'mkfs.ext4 %s' % persistent)
> --
> 2.30.0
>

Regards,
Simon

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v1] test: Include /sbin to the PATH when creating ext4 disk image
  2021-02-05  3:17 ` Simon Glass
@ 2021-02-05 17:29   ` Andy Shevchenko
  2021-02-05 19:40     ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2021-02-05 17:29 UTC (permalink / raw)
  To: u-boot

On Thu, Feb 04, 2021 at 08:17:23PM -0700, Simon Glass wrote:
> On Wed, 3 Feb 2021 at 08:32, Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:

...

> >      if os.path.exists(persistent):
> >          c.log.action('Disk image file ' + persistent + ' already exists')
> >      else:
> > +        root_path = os.path.abspath('.').split(os.path.sep)[0] + os.path.sep
> 
> Is it not enough to do os.path.abspath('.') ? I think it would be good
> to have a comment as to what we need this gymnastics.

It's just a portable code. Of course we can simple use abspath() on *nix OSes.
My preference is to have portable code, though. What's yours?

> > +        sbin_path = os.path.join(root_path, 'sbin')
> > +        os.environ["PATH"] += os.pathsep + sbin_path
> >          try:
> >              u_boot_utils.run_and_log(c, 'dd if=/dev/zero of=%s bs=1M count=16' % persistent)
> >              u_boot_utils.run_and_log(c, 'mkfs.ext4 %s' % persistent)

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v1] test: Include /sbin to the PATH when creating ext4 disk image
  2021-02-05 17:29   ` Andy Shevchenko
@ 2021-02-05 19:40     ` Andy Shevchenko
  2021-02-05 23:57       ` Simon Glass
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2021-02-05 19:40 UTC (permalink / raw)
  To: u-boot

On Fri, Feb 05, 2021 at 07:29:40PM +0200, Andy Shevchenko wrote:
> On Thu, Feb 04, 2021 at 08:17:23PM -0700, Simon Glass wrote:
> > On Wed, 3 Feb 2021 at 08:32, Andy Shevchenko
> > <andriy.shevchenko@linux.intel.com> wrote:
> 
> ...
> 
> > >      if os.path.exists(persistent):
> > >          c.log.action('Disk image file ' + persistent + ' already exists')
> > >      else:
> > > +        root_path = os.path.abspath('.').split(os.path.sep)[0] + os.path.sep
> > 
> > Is it not enough to do os.path.abspath('.') ? I think it would be good
> > to have a comment as to what we need this gymnastics.
> 
> It's just a portable code. Of course we can simple use abspath() on *nix OSes.
> My preference is to have portable code, though. What's yours?
> 
> > > +        sbin_path = os.path.join(root_path, 'sbin')
> > > +        os.environ["PATH"] += os.pathsep + sbin_path
> > >          try:
> > >              u_boot_utils.run_and_log(c, 'dd if=/dev/zero of=%s bs=1M count=16' % persistent)
> > >              u_boot_utils.run_and_log(c, 'mkfs.ext4 %s' % persistent)

Since below we have /dev/zero explicitly I will replace the above to simple
'/sbin'.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v1] test: Include /sbin to the PATH when creating ext4 disk image
  2021-02-05 19:40     ` Andy Shevchenko
@ 2021-02-05 23:57       ` Simon Glass
  0 siblings, 0 replies; 5+ messages in thread
From: Simon Glass @ 2021-02-05 23:57 UTC (permalink / raw)
  To: u-boot

Hi Andy,

On Fri, 5 Feb 2021 at 12:40, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Fri, Feb 05, 2021 at 07:29:40PM +0200, Andy Shevchenko wrote:
> > On Thu, Feb 04, 2021 at 08:17:23PM -0700, Simon Glass wrote:
> > > On Wed, 3 Feb 2021 at 08:32, Andy Shevchenko
> > > <andriy.shevchenko@linux.intel.com> wrote:
> >
> > ...
> >
> > > >      if os.path.exists(persistent):
> > > >          c.log.action('Disk image file ' + persistent + ' already exists')
> > > >      else:
> > > > +        root_path = os.path.abspath('.').split(os.path.sep)[0] + os.path.sep
> > >
> > > Is it not enough to do os.path.abspath('.') ? I think it would be good
> > > to have a comment as to what we need this gymnastics.
> >
> > It's just a portable code. Of course we can simple use abspath() on *nix OSes.
> > My preference is to have portable code, though. What's yours?

Portable to what? Can you add a comment as to what it is for?

> >
> > > > +        sbin_path = os.path.join(root_path, 'sbin')
> > > > +        os.environ["PATH"] += os.pathsep + sbin_path
> > > >          try:
> > > >              u_boot_utils.run_and_log(c, 'dd if=/dev/zero of=%s bs=1M count=16' % persistent)
> > > >              u_boot_utils.run_and_log(c, 'mkfs.ext4 %s' % persistent)
>
> Since below we have /dev/zero explicitly I will replace the above to simple
> '/sbin'.

OK

Regards,
Simon

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-02-05 23:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-03 15:31 [PATCH v1] test: Include /sbin to the PATH when creating ext4 disk image Andy Shevchenko
2021-02-05  3:17 ` Simon Glass
2021-02-05 17:29   ` Andy Shevchenko
2021-02-05 19:40     ` Andy Shevchenko
2021-02-05 23:57       ` Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.