From: Andrew Jones <drjones@redhat.com>
To: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org
Cc: dgibson@redhat.com, david@gibson.dropbear.id.au, agraf@suse.de,
thuth@redhat.com, lvivier@redhat.com, pbonzini@redhat.com
Subject: [kvm-unit-tests PATCH 12/14] scripts: add exit code snooper
Date: Mon, 03 Aug 2015 14:41:29 +0000 [thread overview]
Message-ID: <1438612891-3718-13-git-send-email-drjones@redhat.com> (raw)
In-Reply-To: <1438612891-3718-1-git-send-email-drjones@redhat.com>
Add a function that reads test output streams and just forwards it
on to stdout, except when a line is 'EXIT: STATUS=%d', at which
point it grabs the status to use as the exit code. Tests that
always exit with zero (due to how they inform QEMU to quit), can
now return other status codes. Run with
. scripts/functions.bash
$test_cmdline | snoop_exitcode
The unit test must call print_exit_line(code) before invoking
its method to quit QEMU. For arm and powerpc, we just add the
print_exit_line calls to their exit() functions right now.
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
configure | 5 ++++-
lib/arm/io.c | 1 +
lib/libcflat.h | 3 +++
lib/powerpc/io.c | 1 +
scripts/functions.bash | 11 +++++++++++
5 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/configure b/configure
index b2ad199da7873..e1f70bd79d4f7 100755
--- a/configure
+++ b/configure
@@ -10,6 +10,7 @@ ar=ar
arch=`uname -m | sed -e s/i.86/i386/ | sed -e 's/arm.*/arm/'`
host=$arch
cross_prefix+snooper
usage() {
cat <<-EOF
@@ -81,8 +82,9 @@ if [ "$arch" = "i386" ] || [ "$arch" = "x86_64" ]; then
testdir=x86
elif [ "$arch" = "arm" ] || [ "$arch" = "arm64" ]; then
testdir=arm
-elif [ "$arch" = "ppc64" ]; then
+elif [ "$arch" = "powerpc" ] || [ "$arch" = "ppc64" ]; then
testdir=powerpc
+ snooper=snoop_exitcode
else
testdir=$arch
fi
@@ -137,4 +139,5 @@ OBJDUMP=$cross_prefix$objdump
AR=$cross_prefix$ar
API=$api
TEST_DIR=$testdir
+SNOOPER="$snooper"
EOF
diff --git a/lib/arm/io.c b/lib/arm/io.c
index a08d394e4aa1c..487071d2edcd3 100644
--- a/lib/arm/io.c
+++ b/lib/arm/io.c
@@ -78,6 +78,7 @@ void puts(const char *s)
void exit(int code)
{
+ print_exit_line(code);
chr_testdev_exit(code);
halt(code);
}
diff --git a/lib/libcflat.h b/lib/libcflat.h
index 8411f6c5d92e3..c3d90a0af831a 100644
--- a/lib/libcflat.h
+++ b/lib/libcflat.h
@@ -77,4 +77,7 @@ do { \
abort(); \
} while (0)
+#define print_exit_line(code) \
+ printf("\nEXIT: STATUS=%d\n", ((code) << 1) | 1)
+
#endif
diff --git a/lib/powerpc/io.c b/lib/powerpc/io.c
index 25cdd0ad961ee..b68d33b9ef740 100644
--- a/lib/powerpc/io.c
+++ b/lib/powerpc/io.c
@@ -29,6 +29,7 @@ void puts(const char *s)
void exit(int code)
{
+ print_exit_line(code);
rtas_power_off();
halt(code);
}
diff --git a/scripts/functions.bash b/scripts/functions.bash
index 7ed5a517250bc..7b4a5e4e63c9b 100644
--- a/scripts/functions.bash
+++ b/scripts/functions.bash
@@ -40,3 +40,14 @@ function for_each_unittest()
"$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check"
exec {fd}<&-
}
+
+function snoop_exitcode()
+{
+ while read line; do
+ if [[ $line =~ ^EXIT:\ STATUS=(.*)$ ]]; then
+ code=${BASH_REMATCH[1]}
+ fi
+ echo $line
+ done
+ exit $code
+}
--
2.4.3
next prev parent reply other threads:[~2015-08-03 14:41 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-03 14:41 [kvm-unit-tests PATCH 00/14] ppc64: initial drop Andrew Jones
2015-08-03 14:41 ` [kvm-unit-tests PATCH 01/14] lib: asm-generic: add missing casts Andrew Jones
2015-08-03 14:41 ` [kvm-unit-tests PATCH 02/14] lib: share arm-selftest utility functions Andrew Jones
2015-08-03 14:41 ` [kvm-unit-tests PATCH 03/14] config: no need to mix arch makefiles Andrew Jones
2015-08-03 14:41 ` [kvm-unit-tests PATCH 04/14] powerpc/ppc64: start skeleton framework Andrew Jones
2015-08-03 14:41 ` [kvm-unit-tests PATCH 05/14] powerpc/pp64: ppc-ify makefiles and linker script Andrew Jones
2015-08-03 14:41 ` [kvm-unit-tests PATCH 06/14] powerpc/ppc64: add boot rom source Andrew Jones
2015-08-03 14:41 ` [kvm-unit-tests PATCH 07/14] powerpc/ppc64: add bootloader to bounce into memory Andrew Jones
2015-08-03 14:41 ` [kvm-unit-tests PATCH 08/14] powerpc/ppc64: add HV putchar Andrew Jones
2015-08-04 3:50 ` David Gibson
2015-08-04 7:33 ` Andrew Jones
2015-08-03 14:41 ` [kvm-unit-tests PATCH 09/14] powerpc/ppc64: adapt arm's setup Andrew Jones
2015-08-03 14:41 ` [kvm-unit-tests PATCH 10/14] powerpc/ppc64: relocate linker VMAs Andrew Jones
2015-08-04 3:53 ` David Gibson
2015-08-04 7:35 ` Andrew Jones
2015-08-03 14:41 ` [kvm-unit-tests PATCH 11/14] powerpc/ppc64: add rtas_power_off Andrew Jones
2015-08-03 17:08 ` Paolo Bonzini
2015-08-03 18:02 ` Andrew Jones
2015-08-03 22:27 ` Alexander Graf
2015-08-04 4:09 ` David Gibson
2015-08-04 7:47 ` Andrew Jones
2015-08-04 13:15 ` Paolo Bonzini
2015-08-04 13:21 ` Andrew Jones
2015-08-05 0:06 ` David Gibson
2015-08-04 4:03 ` David Gibson
2015-08-04 7:51 ` Andrew Jones
2015-08-04 4:11 ` David Gibson
2015-08-04 7:54 ` Andrew Jones
2015-08-05 0:12 ` David Gibson
2015-08-03 14:41 ` Andrew Jones [this message]
2015-08-03 14:41 ` [kvm-unit-tests PATCH 13/14] powerpc/ppc64: add run script and unittests.cfg Andrew Jones
2015-08-03 14:41 ` [kvm-unit-tests PATCH 14/14] mkstandalone: add support for powerpc Andrew Jones
2015-08-03 17:06 ` [kvm-unit-tests PATCH 00/14] ppc64: initial drop Paolo Bonzini
2015-11-03 7:08 ` Thomas Huth
2015-11-03 9:40 ` Paolo Bonzini
2015-11-03 14:56 ` Andrew Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1438612891-3718-13-git-send-email-drjones@redhat.com \
--to=drjones@redhat.com \
--cc=agraf@suse.de \
--cc=david@gibson.dropbear.id.au \
--cc=dgibson@redhat.com \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox