diff mbox series

[v5,03/20] test: Pass stderr to stdout

Message ID 20240828220846.1205813-4-sjg@chromium.org
State Changes Requested
Delegated to: Tom Rini
Headers show
Series labgrid: Provide an integration with Labgrid | expand

Commit Message

Simon Glass Aug. 28, 2024, 10:08 p.m. UTC
Some tests may output things to stderr. Ensure that this output is not
dropped, by redirecting it to stdout

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 test/py/u_boot_spawn.py | 2 ++
 1 file changed, 2 insertions(+)

Comments

Neil Armstrong Aug. 29, 2024, 2:22 p.m. UTC | #1
On 29/08/2024 00:08, Simon Glass wrote:
> Some tests may output things to stderr. Ensure that this output is not
> dropped, by redirecting it to stdout

Can't you make sure to output all labgrid output to stdout in the hook script instead ?

> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> 
> (no changes since v1)
> 
>   test/py/u_boot_spawn.py | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/test/py/u_boot_spawn.py b/test/py/u_boot_spawn.py
> index 97e95e07c80..81a09a9d639 100644
> --- a/test/py/u_boot_spawn.py
> +++ b/test/py/u_boot_spawn.py
> @@ -10,6 +10,7 @@ import re
>   import pty
>   import signal
>   import select
> +import sys
>   import time
>   import traceback
>   
> @@ -59,6 +60,7 @@ class Spawn:
>                   signal.signal(signal.SIGHUP, signal.SIG_DFL)
>                   if cwd:
>                       os.chdir(cwd)
> +                sys.stderr = sys.stdout
>                   os.execvp(args[0], args)
>               except:
>                   print('CHILD EXECEPTION:')
Simon Glass Aug. 29, 2024, 3:01 p.m. UTC | #2
Hi Neil,

On Thu, 29 Aug 2024 at 08:22, <neil.armstrong@linaro.org> wrote:
>
> On 29/08/2024 00:08, Simon Glass wrote:
> > Some tests may output things to stderr. Ensure that this output is not
> > dropped, by redirecting it to stdout
>
> Can't you make sure to output all labgrid output to stdout in the hook script instead ?

Possibly. Do you mean having the hook script redirect stderr to stdout?

>
> >
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > ---
> >
> > (no changes since v1)
> >
> >   test/py/u_boot_spawn.py | 2 ++
> >   1 file changed, 2 insertions(+)
> >
> > diff --git a/test/py/u_boot_spawn.py b/test/py/u_boot_spawn.py
> > index 97e95e07c80..81a09a9d639 100644
> > --- a/test/py/u_boot_spawn.py
> > +++ b/test/py/u_boot_spawn.py
> > @@ -10,6 +10,7 @@ import re
> >   import pty
> >   import signal
> >   import select
> > +import sys
> >   import time
> >   import traceback
> >
> > @@ -59,6 +60,7 @@ class Spawn:
> >                   signal.signal(signal.SIGHUP, signal.SIG_DFL)
> >                   if cwd:
> >                       os.chdir(cwd)
> > +                sys.stderr = sys.stdout
> >                   os.execvp(args[0], args)
> >               except:
> >                   print('CHILD EXECEPTION:')
>

Regards,
Simon
Tom Rini Aug. 29, 2024, 4:48 p.m. UTC | #3
On Thu, Aug 29, 2024 at 09:01:11AM -0600, Simon Glass wrote:
> Hi Neil,
> 
> On Thu, 29 Aug 2024 at 08:22, <neil.armstrong@linaro.org> wrote:
> >
> > On 29/08/2024 00:08, Simon Glass wrote:
> > > Some tests may output things to stderr. Ensure that this output is not
> > > dropped, by redirecting it to stdout
> >
> > Can't you make sure to output all labgrid output to stdout in the hook script instead ?
> 
> Possibly. Do you mean having the hook script redirect stderr to stdout?

This gets back to one of the points I was making. In this case, "some
tests" is what? And then, what's even going on? Are we missing output
that we should be parsing? Are we not catching errors? Or is this just
related to how today we have for say the filesystem tests so many
try/except things that we inadvertently need a series of failures?
Simon Glass Aug. 30, 2024, 1:06 a.m. UTC | #4
Hi Tom,

On Thu, 29 Aug 2024 at 10:48, Tom Rini <trini@konsulko.com> wrote:
>
> On Thu, Aug 29, 2024 at 09:01:11AM -0600, Simon Glass wrote:
> > Hi Neil,
> >
> > On Thu, 29 Aug 2024 at 08:22, <neil.armstrong@linaro.org> wrote:
> > >
> > > On 29/08/2024 00:08, Simon Glass wrote:
> > > > Some tests may output things to stderr. Ensure that this output is not
> > > > dropped, by redirecting it to stdout
> > >
> > > Can't you make sure to output all labgrid output to stdout in the hook script instead ?
> >
> > Possibly. Do you mean having the hook script redirect stderr to stdout?
>
> This gets back to one of the points I was making. In this case, "some
> tests" is what? And then, what's even going on? Are we missing output
> that we should be parsing? Are we not catching errors? Or is this just
> related to how today we have for say the filesystem tests so many
> try/except things that we inadvertently need a series of failures?

When Labgrid crashes for some reason, the output is currently lost, so
it is not clear what happened. I suppose Labgrid is not supposed to
crash, but...

As a starting point I have erred on the side of more output rather
than less. I have found that to be very helpful when developing it,
but I am sure we can refine it once it is stable.

Regards,
Simon
diff mbox series

Patch

diff --git a/test/py/u_boot_spawn.py b/test/py/u_boot_spawn.py
index 97e95e07c80..81a09a9d639 100644
--- a/test/py/u_boot_spawn.py
+++ b/test/py/u_boot_spawn.py
@@ -10,6 +10,7 @@  import re
 import pty
 import signal
 import select
+import sys
 import time
 import traceback
 
@@ -59,6 +60,7 @@  class Spawn:
                 signal.signal(signal.SIGHUP, signal.SIG_DFL)
                 if cwd:
                     os.chdir(cwd)
+                sys.stderr = sys.stdout
                 os.execvp(args[0], args)
             except:
                 print('CHILD EXECEPTION:')