kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH] scripts/arch-run: print stderr immediately
@ 2016-11-02 20:50 Radim Krčmář
  2016-11-02 21:05 ` Andrew Jones
  0 siblings, 1 reply; 5+ messages in thread
From: Radim Krčmář @ 2016-11-02 20:50 UTC (permalink / raw)
  To: kvm; +Cc: Paolo Bonzini, Andrew Jones

Not doing so hid stderr output when the test was stuck and subsequently
killed with ^C.

Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
---
 scripts/arch-run.bash | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash
index 8e75c6ed6e17..326f59484e2b 100644
--- a/scripts/arch-run.bash
+++ b/scripts/arch-run.bash
@@ -30,12 +30,11 @@ run_qemu ()
 
 	# stdout to {stdout}, stderr to $errors
 	exec {stdout}>&1
-	errors=$("${@}" 2>&1 1>&${stdout})
+	errors=$("${@}" 2> >(tee >(cat) >&2) 1>&${stdout})
 	ret=$?
 	exec {stdout}>&-
 
 	if [ "$errors" ]; then
-		printf "%s\n" "$errors" >&2
 		sig=$(grep 'terminating on signal' <<<"$errors")
 		if [ "$sig" ]; then
 			sig=$(sed 's/.*terminating on signal \([0-9][0-9]*\).*/\1/' <<<"$sig")
-- 
2.10.1


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

* Re: [kvm-unit-tests PATCH] scripts/arch-run: print stderr immediately
  2016-11-02 20:50 [kvm-unit-tests PATCH] scripts/arch-run: print stderr immediately Radim Krčmář
@ 2016-11-02 21:05 ` Andrew Jones
  2016-11-03 12:38   ` Paolo Bonzini
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Jones @ 2016-11-02 21:05 UTC (permalink / raw)
  To: Radim Krčmář; +Cc: kvm, Paolo Bonzini

On Wed, Nov 02, 2016 at 09:50:29PM +0100, Radim Krčmář wrote:
> Not doing so hid stderr output when the test was stuck and subsequently
> killed with ^C.
> 
> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
> ---
>  scripts/arch-run.bash | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash
> index 8e75c6ed6e17..326f59484e2b 100644
> --- a/scripts/arch-run.bash
> +++ b/scripts/arch-run.bash
> @@ -30,12 +30,11 @@ run_qemu ()
>  
>  	# stdout to {stdout}, stderr to $errors
>  	exec {stdout}>&1
> -	errors=$("${@}" 2>&1 1>&${stdout})
> +	errors=$("${@}" 2> >(tee >(cat) >&2) 1>&${stdout})

Lovely...

The comment above could have been changed to

 # ... stderr to stdout and $errors

>  	ret=$?
>  	exec {stdout}>&-
>  
>  	if [ "$errors" ]; then
> -		printf "%s\n" "$errors" >&2
>  		sig=$(grep 'terminating on signal' <<<"$errors")
>  		if [ "$sig" ]; then
>  			sig=$(sed 's/.*terminating on signal \([0-9][0-9]*\).*/\1/' <<<"$sig")
> -- 
> 2.10.1

Reviewed-by: Andrew Jones <drjones@redhat.com>

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

* Re: [kvm-unit-tests PATCH] scripts/arch-run: print stderr immediately
  2016-11-02 21:05 ` Andrew Jones
@ 2016-11-03 12:38   ` Paolo Bonzini
  2016-11-03 12:53     ` Radim Krčmář
  0 siblings, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2016-11-03 12:38 UTC (permalink / raw)
  To: Andrew Jones, Radim Krčmář; +Cc: kvm



On 02/11/2016 22:05, Andrew Jones wrote:
> On Wed, Nov 02, 2016 at 09:50:29PM +0100, Radim Krčmář wrote:
>> Not doing so hid stderr output when the test was stuck and subsequently
>> killed with ^C.
>>
>> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
>> ---
>>  scripts/arch-run.bash | 3 +--
>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash
>> index 8e75c6ed6e17..326f59484e2b 100644
>> --- a/scripts/arch-run.bash
>> +++ b/scripts/arch-run.bash
>> @@ -30,12 +30,11 @@ run_qemu ()
>>  
>>  	# stdout to {stdout}, stderr to $errors
>>  	exec {stdout}>&1
>> -	errors=$("${@}" 2>&1 1>&${stdout})
>> +	errors=$("${@}" 2> >(tee >(cat) >&2) 1>&${stdout})

What about:

# preserve stdout and stderr output, but save stderr to $errors
exec {stdout}>&1 {stderr}>&2
errors=$("$@" 2> >(tee /dev/fd/$stderr) > /dev/fd/$stdout)
exec {stdout}>&- {stderr}>&-

(Tested in the shell but not in arch-run.bash).

Paolo

> 
> Lovely...
> 
> The comment above could have been changed to
> 
>  # ... stderr to stdout and $errors
> 
>>  	ret=$?
>>  	exec {stdout}>&-
>>  
>>  	if [ "$errors" ]; then
>> -		printf "%s\n" "$errors" >&2
>>  		sig=$(grep 'terminating on signal' <<<"$errors")
>>  		if [ "$sig" ]; then
>>  			sig=$(sed 's/.*terminating on signal \([0-9][0-9]*\).*/\1/' <<<"$sig")
>> -- 
>> 2.10.1
> 
> Reviewed-by: Andrew Jones <drjones@redhat.com>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

* Re: [kvm-unit-tests PATCH] scripts/arch-run: print stderr immediately
  2016-11-03 12:38   ` Paolo Bonzini
@ 2016-11-03 12:53     ` Radim Krčmář
  2016-11-03 13:32       ` Paolo Bonzini
  0 siblings, 1 reply; 5+ messages in thread
From: Radim Krčmář @ 2016-11-03 12:53 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Andrew Jones, kvm

2016-11-03 13:38+0100, Paolo Bonzini:
> On 02/11/2016 22:05, Andrew Jones wrote:
>> On Wed, Nov 02, 2016 at 09:50:29PM +0100, Radim Krčmář wrote:
>>> Not doing so hid stderr output when the test was stuck and subsequently
>>> killed with ^C.
>>>
>>> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
>>> ---
>>>  scripts/arch-run.bash | 3 +--
>>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>>
>>> diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash
>>> index 8e75c6ed6e17..326f59484e2b 100644
>>> --- a/scripts/arch-run.bash
>>> +++ b/scripts/arch-run.bash
>>> @@ -30,12 +30,11 @@ run_qemu ()
>>>  
>>>  	# stdout to {stdout}, stderr to $errors
>>>  	exec {stdout}>&1
>>> -	errors=$("${@}" 2>&1 1>&${stdout})
>>> +	errors=$("${@}" 2> >(tee >(cat) >&2) 1>&${stdout})
> 
> What about:
> 
> # preserve stdout and stderr output, but save stderr to $errors
> exec {stdout}>&1 {stderr}>&2
> errors=$("$@" 2> >(tee /dev/fd/$stderr) > /dev/fd/$stdout)
> exec {stdout}>&- {stderr}>&-
> 
> (Tested in the shell but not in arch-run.bash).

Using files looks nicer, but is there a problem in the redirection?
I would rather use /dev/stderr or /dev/fd/2 directly if not.

i.e.
  exec {stdout}>&1
  errors=$("$@" 2> >(tee /dev/stderr) > /dev/fd/$stdout)
  exec {stdout}>&-

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

* Re: [kvm-unit-tests PATCH] scripts/arch-run: print stderr immediately
  2016-11-03 12:53     ` Radim Krčmář
@ 2016-11-03 13:32       ` Paolo Bonzini
  0 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2016-11-03 13:32 UTC (permalink / raw)
  To: Radim Krčmář; +Cc: Andrew Jones, kvm



On 03/11/2016 13:53, Radim Krčmář wrote:
> 2016-11-03 13:38+0100, Paolo Bonzini:
>> On 02/11/2016 22:05, Andrew Jones wrote:
>>> On Wed, Nov 02, 2016 at 09:50:29PM +0100, Radim Krčmář wrote:
>>>> Not doing so hid stderr output when the test was stuck and subsequently
>>>> killed with ^C.
>>>>
>>>> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
>>>> ---
>>>>  scripts/arch-run.bash | 3 +--
>>>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>>>
>>>> diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash
>>>> index 8e75c6ed6e17..326f59484e2b 100644
>>>> --- a/scripts/arch-run.bash
>>>> +++ b/scripts/arch-run.bash
>>>> @@ -30,12 +30,11 @@ run_qemu ()
>>>>  
>>>>  	# stdout to {stdout}, stderr to $errors
>>>>  	exec {stdout}>&1
>>>> -	errors=$("${@}" 2>&1 1>&${stdout})
>>>> +	errors=$("${@}" 2> >(tee >(cat) >&2) 1>&${stdout})
>>
>> What about:
>>
>> # preserve stdout and stderr output, but save stderr to $errors
>> exec {stdout}>&1 {stderr}>&2
>> errors=$("$@" 2> >(tee /dev/fd/$stderr) > /dev/fd/$stdout)
>> exec {stdout}>&- {stderr}>&-
>>
>> (Tested in the shell but not in arch-run.bash).
> 
> Using files looks nicer, but is there a problem in the redirection?
> I would rather use /dev/stderr or /dev/fd/2 directly if not.
> 
> i.e.
>   exec {stdout}>&1
>   errors=$("$@" 2> >(tee /dev/stderr) > /dev/fd/$stdout)
>   exec {stdout}>&-

Yes, this works too.

Paolo

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

end of thread, other threads:[~2016-11-03 13:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-02 20:50 [kvm-unit-tests PATCH] scripts/arch-run: print stderr immediately Radim Krčmář
2016-11-02 21:05 ` Andrew Jones
2016-11-03 12:38   ` Paolo Bonzini
2016-11-03 12:53     ` Radim Krčmář
2016-11-03 13:32       ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).