@@ -46,17 +46,4 @@ command="$(migration_cmd) $(timeout_cmd) $command"
# to fixup the fixup below by parsing the true exit code from the output.
# The second fixup is also a FIXME, because once we add chr-testdev
# support for powerpc, we won't need the second fixup.
-lines=$(run_qemu $command "$@")
-ret=$?
-echo "$lines"
-if [ $ret -eq 1 ]; then
- testret=$(grep '^EXIT: ' <<<"$lines" | sed 's/.*STATUS=\([0-9][0-9]*\).*/\1/')
- if [ "$testret" ]; then
- if [ $testret -eq 1 ]; then
- ret=0
- else
- ret=$testret
- fi
- fi
-fi
-exit $ret
+run_qemu_status $command "$@"
@@ -38,17 +38,4 @@ command+=" -kernel"
command="$(timeout_cmd) $command"
# We return the exit code via stdout, not via the QEMU return code
-lines=$(run_qemu $command "$@")
-ret=$?
-echo "$lines"
-if [ $ret -eq 1 ]; then
- testret=$(grep '^EXIT: ' <<<"$lines" | sed 's/.*STATUS=\([0-9][0-9]*\).*/\1/')
- if [ "$testret" ]; then
- if [ $testret -eq 1 ]; then
- ret=0
- else
- ret=$testret
- fi
- fi
-fi
-exit $ret
+run_qemu_status $command "$@"
@@ -69,6 +69,29 @@ run_qemu ()
return $ret
}
+run_qemu_status ()
+{
+ local stdout ret
+
+ exec {stdout}>&1
+ lines=$(run_qemu "$@" > >(tee /dev/fd/$stdout))
+ ret=$?
+ exec {stdout}>&-
+
+ if [ $ret -eq 1 ]; then
+ testret=$(grep '^EXIT: ' <<<"$lines" | sed 's/.*STATUS=\([0-9][0-9]*\).*/\1/')
+ if [ "$testret" ]; then
+ if [ $testret -eq 1 ]; then
+ ret=0
+ else
+ ret=$testret
+ fi
+ fi
+ fi
+
+ return $ret
+}
+
timeout_cmd ()
{
if [ "$TIMEOUT" ] && [ "$TIMEOUT" != "0" ]; then
If the test is hanging, then using arch/run would produce no output, because of caching in a temporary variable. Use the `tee` trick to save the output while passing it through. They were also using the very same code. Signed-off-by: Radim Krčmář <rkrcmar@redhat.com> --- powerpc/run | 15 +-------------- s390x/run | 15 +-------------- scripts/arch-run.bash | 23 +++++++++++++++++++++++ 3 files changed, 25 insertions(+), 28 deletions(-)