diff mbox

[kvm-unit-tests,v7,5/5] scripts: automatically pretty print stacks

Message ID e0d998a8adabdb7a88c9b2c608911e0fc3260e36.1458689655.git.pfeiner@google.com (mailing list archive)
State New, archived
Headers show

Commit Message

Peter Feiner March 22, 2016, 11:35 p.m. UTC
Now run_tests.sh automatically pipes test output through
scripts/pretty_print_stacks.py. Can be disabled with
./configure --disable-pretty-print-stacks.

Pretty printing disabled on standalone tests because there's no
binary.

Signed-off-by: Peter Feiner <pfeiner@google.com>
Reviewed-By: Andrew Jones <drjones@redhat.com>
---
 configure               | 10 ++++++++++
 run_tests.sh            |  8 +++++++-
 scripts/mkstandalone.sh |  2 ++
 3 files changed, 19 insertions(+), 1 deletion(-)

Comments

Paolo Bonzini March 29, 2016, 11:13 a.m. UTC | #1
On 23/03/2016 00:35, Peter Feiner wrote:
> +if [ "$PRETTY_PRINT_STACKS" = "yes" ]; then
> +	log_redir="> >(./scripts/pretty_print_stacks.py \$kernel >> test.log)"

Isn't this the same as "| ./scripts/pretty_print_stack.py \$kernel >>
test.log"?

If so, perhaps

if [ "$PRETTY_PRINT_STACKS" = "yes" ]; then
  stack_filter="./scripts/pretty_print_stack.py \$kernel"
else
  stack_filter=cat

RUNTIME_arch_run="./$TEST_DIR/run | $stack_filter >> test.log"

... would be a bit easier to read.

Paolo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Peter Feiner March 31, 2016, 11:33 p.m. UTC | #2
On Tue, Mar 29, 2016 at 01:13:30PM +0200, Paolo Bonzini wrote:
> 
> 
> On 23/03/2016 00:35, Peter Feiner wrote:
> > +if [ "$PRETTY_PRINT_STACKS" = "yes" ]; then
> > +	log_redir="> >(./scripts/pretty_print_stacks.py \$kernel >> test.log)"
> 
> Isn't this the same as "| ./scripts/pretty_print_stack.py \$kernel >>
> test.log"?

Not the same. Consider scripts/runtime.bash's usage:

	cmdline="...$RUNTIME_arch_run $kernel -smp $smp $opts"

With your alternative, the command-line arguments after $RUNTIME_arch_run
are be passed to pretty_print_stacks.py instead of Qemu.

> If so, perhaps
> 
> if [ "$PRETTY_PRINT_STACKS" = "yes" ]; then
>   stack_filter="./scripts/pretty_print_stack.py \$kernel"
> else
>   stack_filter=cat
> 
> RUNTIME_arch_run="./$TEST_DIR/run | $stack_filter >> test.log"
> 
> ... would be a bit easier to read.

Yes, it's super ugly, but it works!

Peter
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Paolo Bonzini April 1, 2016, 8:38 a.m. UTC | #3
On 01/04/2016 01:33, Peter Feiner wrote:
>> > 
>> > On 23/03/2016 00:35, Peter Feiner wrote:
>>> > > +if [ "$PRETTY_PRINT_STACKS" = "yes" ]; then
>>> > > +	log_redir="> >(./scripts/pretty_print_stacks.py \$kernel >> test.log)"
>> > 
>> > Isn't this the same as "| ./scripts/pretty_print_stack.py \$kernel >>
>> > test.log"?
> Not the same. Consider scripts/runtime.bash's usage:
> 
> 	cmdline="...$RUNTIME_arch_run $kernel -smp $smp $opts"
> 
> With your alternative, the command-line arguments after $RUNTIME_arch_run
> are be passed to pretty_print_stacks.py instead of Qemu.

Ok, I'll add a comment then.

Paolo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/configure b/configure
index 958321d..ba6c55b 100755
--- a/configure
+++ b/configure
@@ -11,6 +11,7 @@  arch=`uname -m | sed -e 's/i.86/i386/;s/arm.*/arm/;s/ppc64.*/ppc64/'`
 host=$arch
 cross_prefix=
 endian=""
+pretty_print_stacks=yes
 
 usage() {
     cat <<-EOF
@@ -25,6 +26,8 @@  usage() {
 	    --prefix=PREFIX        where to install things ($prefix)
 	    --kerneldir=DIR        kernel build directory for kvm.h ($kerneldir)
 	    --endian=ENDIAN        endianness to compile for (little or big, ppc64 only)
+	    --[enable|disable]-pretty-print-stacks
+	                           enable or disable pretty stack printing (enabled by default)
 EOF
     exit 1
 }
@@ -61,6 +64,12 @@  while [[ "$1" = -* ]]; do
 	--ld)
 	    ld="$arg"
 	    ;;
+	--enable-pretty-print-stacks)
+	    pretty_print_stacks=yes
+	    ;;
+	--disable-pretty-print-stacks)
+	    pretty_print_stacks=no
+	    ;;
 	--help)
 	    usage
 	    ;;
@@ -149,4 +158,5 @@  API=$api
 TEST_DIR=$testdir
 FIRMWARE=$firmware
 ENDIAN=$endian
+PRETTY_PRINT_STACKS=$pretty_print_stacks
 EOF
diff --git a/run_tests.sh b/run_tests.sh
index 89e8f84..7e0237f 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -46,7 +46,13 @@  while getopts "g:hv" opt; do
     esac
 done
 
-RUNTIME_arch_run="./$TEST_DIR/run >> test.log"
+if [ "$PRETTY_PRINT_STACKS" = "yes" ]; then
+	log_redir="> >(./scripts/pretty_print_stacks.py \$kernel >> test.log)"
+else
+	log_redir=">> test.log"
+fi
+
+RUNTIME_arch_run="./$TEST_DIR/run $log_redir"
 config=$TEST_DIR/unittests.cfg
 rm -f test.log
 printf "BUILD_HEAD=$(cat build-head)\n\n" > test.log
diff --git a/scripts/mkstandalone.sh b/scripts/mkstandalone.sh
index 1d3a20d..ef15bc8 100755
--- a/scripts/mkstandalone.sh
+++ b/scripts/mkstandalone.sh
@@ -41,6 +41,8 @@  generate_test ()
 	echo "#!/bin/bash"
 	echo "export STANDALONE=yes"
 	echo "export HOST=\$(uname -m | sed -e s/i.86/i386/ | sed -e 's/arm.*/arm/')"
+	echo "export PRETTY_PRINT_STACKS=no"
+
 	config_export ARCH
 	config_export ARCH_NAME
 	config_export PROCESSOR