@@ -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
@@ -78,6 +78,7 @@ void puts(const char *s)
void exit(int code)
{
+ print_exit_line(code);
chr_testdev_exit(code);
halt(code);
}
@@ -77,4 +77,7 @@ do { \
abort(); \
} while (0)
+#define print_exit_line(code) \
+ printf("\nEXIT: STATUS=%d\n", ((code) << 1) | 1)
+
#endif
@@ -29,6 +29,7 @@ void puts(const char *s)
void exit(int code)
{
+ print_exit_line(code);
rtas_power_off();
halt(code);
}
@@ -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
+}
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(-)