From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PATCH kvm-unit-tests v2 02/12] run_tests: prepare for changes in scripts/mkstandalone Date: Thu, 17 Dec 2015 18:53:33 +0100 Message-ID: <1450374823-7648-3-git-send-email-rkrcmar@redhat.com> References: <1450374823-7648-1-git-send-email-rkrcmar@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Paolo Bonzini , Andrew Jones To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:45347 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751956AbbLQRyB (ORCPT ); Thu, 17 Dec 2015 12:54:01 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id EC8F28F512 for ; Thu, 17 Dec 2015 17:54:00 +0000 (UTC) In-Reply-To: <1450374823-7648-1-git-send-email-rkrcmar@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: mkstandalone has a different mechanism for running tests as well as a different handling of output and return codes. - create two shell function to capture test execution and logging - return the return value of unit-test - cope with empty $verbose in `run` Signed-off-by: Radim Kr=C4=8Dm=C3=A1=C5=99 --- v2: new (reused the bitshift and comment from v1) =20 run_tests.sh | 4 ++++ scripts/run.bash | 13 +++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/run_tests.sh b/run_tests.sh index 58949e39c38c..e09d410beaa4 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -28,7 +28,11 @@ specify the appropriate qemu binary for ARCH-run. EOF } =20 +__run() { ./$TEST_DIR-run "${@}"; } +__eval_log() { eval "${@}" >> test.log; } + echo > test.log + while getopts "g:hv" opt; do case $opt in g) diff --git a/scripts/run.bash b/scripts/run.bash index 0c5a2569d80e..243586c6d2fc 100644 --- a/scripts/run.bash +++ b/scripts/run.bash @@ -34,18 +34,23 @@ function run() fi done =20 - cmdline=3D"TESTNAME=3D$testname ACCEL=3D$accel ./$TEST_DIR-run $ke= rnel -smp $smp $opts" - if [ $verbose !=3D 0 ]; then + cmdline=3D"TESTNAME=3D$testname ACCEL=3D$accel __run $kernel -smp = $smp $opts" + if [ "$verbose" -a "$verbose" !=3D 0 ]; then echo $cmdline fi =20 # extra_params in the config file may contain backticks that need = to be # expanded, so use eval to start qemu - eval $cmdline >> test.log + __eval_log "$cmdline" + # The first bit of return value is too hard to use, just skip it. + # Unit-tests' return value is shifted by one. + ret=3D$(($? >> 1)) =20 - if [ $? -le 1 ]; then + if [ $ret -eq 0 ]; then echo -e "\e[32mPASS\e[0m $1" else echo -e "\e[31mFAIL\e[0m $1" fi + + return $ret } --=20 2.6.4