Message ID | ld5vg3ytv252ceaymg4mnq5jpnmklfvt2xkoldg67vkjl4awba@w3gc24eqeoxc (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [kvm-unit-tests] arch-run: fix test skips when /dev/stderr does not point to /proc/self/fd/2 | expand |
On Thu Feb 27, 2025 at 2:07 PM CET, Andreas Grapentin wrote: > In configurations where /dev/stderr does not link to /proc/self/fd/2, > run_qemu in arch-run.bash leaks the stderr of the invoked qemu command > to /dev/stderr, instead of it being captured to the log variable in > premature_failure in runtime.bash. > > This causes all tests to be skipped since the output required for the > grep command in that function to indicate success is never present. > > As a possible fix, this patch gives stderr the same treatment as stdout > in run_qemu, producing a dedicated file descriptor and handing it into > the subshell. > > Signed-off-by: Andreas Grapentin <gra@linux.ibm.com> > --- > scripts/arch-run.bash | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash > index 2e4820c2..362aa1c5 100644 > --- a/scripts/arch-run.bash > +++ b/scripts/arch-run.bash > @@ -33,11 +33,13 @@ run_qemu () > [ "$ENVIRON_DEFAULT" = "yes" ] && echo -n " #" > echo " $INITRD" > > - # stdout to {stdout}, stderr to $errors and stderr > + # stdout to {stdout}, stderr to $errors and {stderr} > exec {stdout}>&1 > - errors=$("${@}" $INITRD </dev/null 2> >(tee /dev/stderr) > /dev/fd/$stdout) > + exec {stderr}>&2 For consistency, please add stderr as a local at the beginning of the function. With that fixed: Reviewed-by: Nico Boehr <nrb@linux.ibm.com>
diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash index 2e4820c2..362aa1c5 100644 --- a/scripts/arch-run.bash +++ b/scripts/arch-run.bash @@ -33,11 +33,13 @@ run_qemu () [ "$ENVIRON_DEFAULT" = "yes" ] && echo -n " #" echo " $INITRD" - # stdout to {stdout}, stderr to $errors and stderr + # stdout to {stdout}, stderr to $errors and {stderr} exec {stdout}>&1 - errors=$("${@}" $INITRD </dev/null 2> >(tee /dev/stderr) > /dev/fd/$stdout) + exec {stderr}>&2 + errors=$("${@}" $INITRD </dev/null 2> >(tee /dev/fd/$stderr) > /dev/fd/$stdout) ret=$? exec {stdout}>&- + exec {stderr}>&- [ $ret -eq 134 ] && echo "QEMU Aborted" >&2
In configurations where /dev/stderr does not link to /proc/self/fd/2, run_qemu in arch-run.bash leaks the stderr of the invoked qemu command to /dev/stderr, instead of it being captured to the log variable in premature_failure in runtime.bash. This causes all tests to be skipped since the output required for the grep command in that function to indicate success is never present. As a possible fix, this patch gives stderr the same treatment as stdout in run_qemu, producing a dedicated file descriptor and handing it into the subshell. Signed-off-by: Andreas Grapentin <gra@linux.ibm.com> --- scripts/arch-run.bash | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)