diff mbox

[kvm-unit-tests,v4,09/13] run_tests: print SUMMARY line in summary

Message ID 1462983171-4208-10-git-send-email-rkrcmar@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Radim Krčmář May 11, 2016, 4:12 p.m. UTC
SUMMARY line is present if the test uses lib/report.  Summary contains
some interesting information, so duplicating the output isn't that big
of a cost.  Our log redirection got more complicated, though.

Signed-off-by: Radim Kr?má? <rkrcmar@redhat.com>
---
 v4:
 * less ev[ai]l [Paolo]
 * didn't include Drew's r-b

 run_tests.sh            | 14 ++++++++------
 scripts/mkstandalone.sh |  3 +++
 scripts/runtime.bash    | 15 ++++++++++-----
 3 files changed, 21 insertions(+), 11 deletions(-)

Comments

Andrew Jones May 11, 2016, 5:10 p.m. UTC | #1
On Wed, May 11, 2016 at 06:12:51PM +0200, Radim Kr?má? wrote:
> SUMMARY line is present if the test uses lib/report.  Summary contains
> some interesting information, so duplicating the output isn't that big
> of a cost.  Our log redirection got more complicated, though.
> 
> Signed-off-by: Radim Kr?má? <rkrcmar@redhat.com>
> ---
>  v4:
>  * less ev[ai]l [Paolo]
>  * didn't include Drew's r-b
> 
>  run_tests.sh            | 14 ++++++++------
>  scripts/mkstandalone.sh |  3 +++
>  scripts/runtime.bash    | 15 ++++++++++-----
>  3 files changed, 21 insertions(+), 11 deletions(-)

Reviewed-by: Andrew Jones <drjones@redhat.com>

> 
> diff --git a/run_tests.sh b/run_tests.sh
> index 7e0237f3aa11..b634e472a834 100755
> --- a/run_tests.sh
> +++ b/run_tests.sh
> @@ -46,13 +46,15 @@ while getopts "g:hv" opt; do
>      esac
>  done
>  
> -if [ "$PRETTY_PRINT_STACKS" = "yes" ]; then
> -	log_redir="> >(./scripts/pretty_print_stacks.py \$kernel >> test.log)"
> -else
> -	log_redir=">> test.log"
> -fi
> +RUNTIME_log_stdout () {
> +    if [ "$PRETTY_PRINT_STACKS" = "yes" ]; then
> +        ./scripts/pretty_print_stacks.py $1 >> test.log
> +    else
> +        cat >> 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 26094dfba373..77793fd64c76 100755
> --- a/scripts/mkstandalone.sh
> +++ b/scripts/mkstandalone.sh
> @@ -68,6 +68,9 @@ generate_test ()
>  	(echo "#!/bin/bash"
>  	 cat scripts/arch-run.bash "$TEST_DIR/run") | temp_file RUNTIME_arch_run
>  
> +	echo "exec {stdout}>&1"
> +	echo "RUNTIME_log_stdout () { cat >&\$stdout; }"
> +
>  	cat scripts/runtime.bash
>  
>  	echo "run ${args[@]}"
> diff --git a/scripts/runtime.bash b/scripts/runtime.bash
> index 8d374103a71c..6d9d8bffb82f 100644
> --- a/scripts/runtime.bash
> +++ b/scripts/runtime.bash
> @@ -6,6 +6,11 @@ PASS() { echo -ne "\e[32mPASS\e[0m"; }
>  SKIP() { echo -ne "\e[33mSKIP\e[0m"; }
>  FAIL() { echo -ne "\e[31mFAIL\e[0m"; }
>  
> +extract_summary()
> +{
> +    tail -1 | grep '^SUMMARY: ' | sed 's/^SUMMARY: /(/;s/$/)/'
> +}
> +
>  function run()
>  {
>      local testname="$1"
> @@ -49,18 +54,18 @@ function run()
>      fi
>  
>      # extra_params in the config file may contain backticks that need to be
> -    # expanded, so use eval to start qemu
> -    eval $cmdline
> +    # expanded, so use eval to start qemu.  Same for $RUNTIME_log_stdout.
> +    summary=$(eval $cmdline > >(tee >(RUNTIME_log_stdout $kernel) | extract_summary))
>      ret=$?
>  
>      if [ $ret -eq 0 ]; then
> -        echo "`PASS` $1"
> +        echo "`PASS` $1 $summary"
>      elif [ $ret -eq 77 ]; then
> -        echo "`SKIP` $1"
> +        echo "`SKIP` $1 $summary"
>      elif [ $ret -eq 124 ]; then
>          echo "`FAIL` $1 (timeout; duration=$timeout)"
>      else
> -        echo "`FAIL` $1"
> +        echo "`FAIL` $1 $summary"
>      fi
>  
>      return $ret
> -- 
> 2.8.2
> 
> --
> 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
--
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 May 17, 2016, 12:32 p.m. UTC | #2
On 11/05/2016 18:12, Radim Kr?má? wrote:
> +    # expanded, so use eval to start qemu.  Same for $RUNTIME_log_stdout.

Luckily the second part is not true anymore.  Fixed it myself.

Paolo

> +    summary=$(eval $cmdline > >(tee >(RUNTIME_log_stdout $kernel) | extract_summary))
--
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
Radim Krčmář May 25, 2016, 5:41 p.m. UTC | #3
2016-05-17 14:32+0200, Paolo Bonzini:
> On 11/05/2016 18:12, Radim Krčmář wrote:
>> +    # expanded, so use eval to start qemu.  Same for $RUNTIME_log_stdout.
> 
> Luckily the second part is not true anymore.  Fixed it myself.

Thanks.
--
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/run_tests.sh b/run_tests.sh
index 7e0237f3aa11..b634e472a834 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -46,13 +46,15 @@  while getopts "g:hv" opt; do
     esac
 done
 
-if [ "$PRETTY_PRINT_STACKS" = "yes" ]; then
-	log_redir="> >(./scripts/pretty_print_stacks.py \$kernel >> test.log)"
-else
-	log_redir=">> test.log"
-fi
+RUNTIME_log_stdout () {
+    if [ "$PRETTY_PRINT_STACKS" = "yes" ]; then
+        ./scripts/pretty_print_stacks.py $1 >> test.log
+    else
+        cat >> 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 26094dfba373..77793fd64c76 100755
--- a/scripts/mkstandalone.sh
+++ b/scripts/mkstandalone.sh
@@ -68,6 +68,9 @@  generate_test ()
 	(echo "#!/bin/bash"
 	 cat scripts/arch-run.bash "$TEST_DIR/run") | temp_file RUNTIME_arch_run
 
+	echo "exec {stdout}>&1"
+	echo "RUNTIME_log_stdout () { cat >&\$stdout; }"
+
 	cat scripts/runtime.bash
 
 	echo "run ${args[@]}"
diff --git a/scripts/runtime.bash b/scripts/runtime.bash
index 8d374103a71c..6d9d8bffb82f 100644
--- a/scripts/runtime.bash
+++ b/scripts/runtime.bash
@@ -6,6 +6,11 @@  PASS() { echo -ne "\e[32mPASS\e[0m"; }
 SKIP() { echo -ne "\e[33mSKIP\e[0m"; }
 FAIL() { echo -ne "\e[31mFAIL\e[0m"; }
 
+extract_summary()
+{
+    tail -1 | grep '^SUMMARY: ' | sed 's/^SUMMARY: /(/;s/$/)/'
+}
+
 function run()
 {
     local testname="$1"
@@ -49,18 +54,18 @@  function run()
     fi
 
     # extra_params in the config file may contain backticks that need to be
-    # expanded, so use eval to start qemu
-    eval $cmdline
+    # expanded, so use eval to start qemu.  Same for $RUNTIME_log_stdout.
+    summary=$(eval $cmdline > >(tee >(RUNTIME_log_stdout $kernel) | extract_summary))
     ret=$?
 
     if [ $ret -eq 0 ]; then
-        echo "`PASS` $1"
+        echo "`PASS` $1 $summary"
     elif [ $ret -eq 77 ]; then
-        echo "`SKIP` $1"
+        echo "`SKIP` $1 $summary"
     elif [ $ret -eq 124 ]; then
         echo "`FAIL` $1 (timeout; duration=$timeout)"
     else
-        echo "`FAIL` $1"
+        echo "`FAIL` $1 $summary"
     fi
 
     return $ret