From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH v3 8/9] run_tests: print summary Date: Tue, 10 May 2016 13:45:53 +0200 Message-ID: <5731C9F1.80003@redhat.com> References: <1460753571-20732-1-git-send-email-rkrcmar@redhat.com> <1460753571-20732-9-git-send-email-rkrcmar@redhat.com> <20160419071947.3v6fjnbdln47ddno@hawk.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: kvm@vger.kernel.org To: Andrew Jones , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= Return-path: Received: from mail-wm0-f68.google.com ([74.125.82.68]:33573 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751434AbcEJLp4 (ORCPT ); Tue, 10 May 2016 07:45:56 -0400 Received: by mail-wm0-f68.google.com with SMTP id r12so2244083wme.0 for ; Tue, 10 May 2016 04:45:55 -0700 (PDT) In-Reply-To: <20160419071947.3v6fjnbdln47ddno@hawk.localdomain> Sender: kvm-owner@vger.kernel.org List-ID: On 19/04/2016 09:19, Andrew Jones wrote: > On Fri, Apr 15, 2016 at 10:52:50PM +0200, Radim Kr=C4=8Dm=C3=A1=C5=99= wrote: >> SUMMARY line is present if the test uses lib/report. Summary contai= ns >> some interesting information, so duplicating the output isn't that b= ig >> of a cost. Our log redirection got more complicated, though. >> >> Signed-off-by: Radim Kr=C4=8Dm=C3=A1=C5=99 >> --- >> run_tests.sh | 6 +++--- >> scripts/mkstandalone.sh | 3 +++ >> scripts/runtime.bash | 15 ++++++++++----- >> 3 files changed, 16 insertions(+), 8 deletions(-) >> >> diff --git a/run_tests.sh b/run_tests.sh >> index 7e0237f3aa11..2a0082163423 100755 >> --- a/run_tests.sh >> +++ b/run_tests.sh >> @@ -25,6 +25,7 @@ specify the appropriate qemu binary for ARCH-run. >> EOF >> } >> =20 >> +RUNTIME_log_stdout=3D"/dev/null" >> RUNTIME_arch_run=3D"./$TEST_DIR/run" >> source scripts/runtime.bash >> =20 >> @@ -47,12 +48,11 @@ while getopts "g:hv" opt; do >> done >> =20 >> if [ "$PRETTY_PRINT_STACKS" =3D "yes" ]; then >> - log_redir=3D"> >(./scripts/pretty_print_stacks.py \$kernel >> test= =2Elog)" >> + RUNTIME_log_stdout=3D'>(./scripts/pretty_print_stacks.py $kernel >= > test.log)' >> else >> - log_redir=3D">> test.log" >> + RUNTIME_log_stdout=3D'test.log' >> fi >> =20 >> -RUNTIME_arch_run=3D"./$TEST_DIR/run $log_redir" >> config=3D$TEST_DIR/unittests.cfg >> rm -f test.log >> printf "BUILD_HEAD=3D$(cat build-head)\n\n" > test.log >> diff --git a/scripts/mkstandalone.sh b/scripts/mkstandalone.sh >> index ef15bc88a22a..ee01fe0c7777 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_ar= ch_run >> =20 >> + echo "exec {stdout}>&1" >> + echo "RUNTIME_log_stdout=3D'>(cat >&\$stdout)'" >> + >> cat scripts/runtime.bash >> =20 >> echo "run ${args[@]}" >> diff --git a/scripts/runtime.bash b/scripts/runtime.bash >> index 59f0df080988..fc4be91d8727 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"; } >> =20 >> +extract_summary() >> +{ >> + tail -1 | grep '^SUMMARY: ' | sed 's/^SUMMARY: /(/;s/$/)/' >> +} >> + >> function run() >> { >> local testname=3D"$1" >> @@ -55,18 +60,18 @@ function run() >> fi >> =20 >> # extra_params in the config file may contain backticks that ne= ed to be >> - # expanded, so use eval to start qemu >> - eval $cmdline >> + # expanded, so use eval to start qemu. Same for $RUNTIME_log_s= tdout. >> + summary=3D$(eval $cmdline > >(eval "tee -a $RUNTIME_log_stdout"= | extract_summary)) >=20 > The depth of our stdout resolution is getting insane. Oh well, let's = see > how deep we can go before we throw our hands up and just rewrite all = these > bash scripts in python. Why not just use a pipe here? eval $cmdline 2>> $RUNTIME_log_stderr \ | eval tee -a "$RUNTIME_log_stdout" | extract_summary Anything I am missing? Paolo >> ret=3D$? >> =20 >> 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=3D$timeout)" >> else >> - echo "`FAIL` $1" >> + echo "`FAIL` $1 $summary" >> fi >> =20 >> return $ret >> --=20 >> 2.8.1 >> >=20 > Reviewed-by: Andrew Jones >=20