[kvm-unit-tests PATCH 3/5] s390+powerpc/run: improve output handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 powerpc/run           | 15 +--------------
 s390x/run             | 15 +--------------
 scripts/arch-run.bash | 23 +++++++++++++++++++++++
 3 files changed, 25 insertions(+), 28 deletions(-)

diff --git a/powerpc/run b/powerpc/run
index 3fd5a91aeffb..3f69386c642a 100755
--- a/powerpc/run
+++ b/powerpc/run
@@ -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 "$@"
diff --git a/s390x/run b/s390x/run
index 89210f4fb6b6..6df348a93783 100755
--- a/s390x/run
+++ b/s390x/run
@@ -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 "$@"
diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash
index 8ad37e4ebf97..6e429a8748f4 100644
--- a/scripts/arch-run.bash
+++ b/scripts/arch-run.bash
@@ -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
-- 
2.13.2




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux