From patchwork Sun Jan 1 10:34:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 9492875 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CAF2460453 for ; Sun, 1 Jan 2017 10:35:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B012724B44 for ; Sun, 1 Jan 2017 10:35:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A514D2679B; Sun, 1 Jan 2017 10:35:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 598CE24B44 for ; Sun, 1 Jan 2017 10:35:22 +0000 (UTC) Received: from localhost ([::1]:52810 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cNdU1-0006hg-Fd for patchwork-qemu-devel@patchwork.kernel.org; Sun, 01 Jan 2017 05:35:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cNdTe-0006gm-P2 for qemu-devel@nongnu.org; Sun, 01 Jan 2017 05:35:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cNdTd-0002Zh-Tx for qemu-devel@nongnu.org; Sun, 01 Jan 2017 05:34:58 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51770) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cNdTd-0002Yx-Oa for qemu-devel@nongnu.org; Sun, 01 Jan 2017 05:34:57 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E2217C057FA9; Sun, 1 Jan 2017 10:34:57 +0000 (UTC) Received: from pxdev.xzpeter.org (vpn1-4-41.pek2.redhat.com [10.72.4.41]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v01AYloj011327; Sun, 1 Jan 2017 05:34:53 -0500 From: Peter Xu To: qemu-devel@nongnu.org, kvm@vger.kernel.org Date: Sun, 1 Jan 2017 18:34:45 +0800 Message-Id: <1483266886-25050-2-git-send-email-peterx@redhat.com> In-Reply-To: <1483266886-25050-1-git-send-email-peterx@redhat.com> References: <1483266886-25050-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Sun, 01 Jan 2017 10:34:57 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [kvm-unit-tests PATCH 1/2] run_tests: provide RUNTIME_log_file X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Andrew Jones , peterx@redhat.com, =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Prepare that we may use different log file for different tests in the future (i.e., to run tests in parallel). Added another new file (scripts/global.bash) to store future global vars and function clips. Signed-off-by: Peter Xu --- run_tests.sh | 13 +++++++------ scripts/functions.bash | 9 +++++++-- scripts/global.bash | 1 + 3 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 scripts/global.bash diff --git a/run_tests.sh b/run_tests.sh index 254129d..a04bfce 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -7,6 +7,7 @@ if [ ! -f config.mak ]; then exit 1 fi source config.mak +source scripts/global.bash source scripts/functions.bash function usage() @@ -46,17 +47,17 @@ while getopts "g:hv" opt; do esac done -RUNTIME_log_stderr () { cat >> test.log; } +# RUNTIME_log_file will be configured later +RUNTIME_log_stderr () { cat >> $RUNTIME_log_file; } RUNTIME_log_stdout () { if [ "$PRETTY_PRINT_STACKS" = "yes" ]; then - ./scripts/pretty_print_stacks.py $1 >> test.log + ./scripts/pretty_print_stacks.py $1 >> $RUNTIME_log_file else - cat >> test.log + cat >> $RUNTIME_log_file fi } - config=$TEST_DIR/unittests.cfg -rm -f test.log -printf "BUILD_HEAD=$(cat build-head)\n\n" > test.log +rm -f $ut_default_log_file +printf "BUILD_HEAD=$(cat build-head)\n\n" > $ut_default_log_file for_each_unittest $config run diff --git a/scripts/functions.bash b/scripts/functions.bash index ee9143c..90daed4 100644 --- a/scripts/functions.bash +++ b/scripts/functions.bash @@ -1,3 +1,8 @@ +function run_task() +{ + RUNTIME_log_file=$ut_default_log_file + "$@" +} function for_each_unittest() { @@ -17,7 +22,7 @@ function for_each_unittest() while read -u $fd line; do if [[ "$line" =~ ^\[(.*)\]$ ]]; then - "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout" + run_task "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout" testname=${BASH_REMATCH[1]} smp=1 kernel="" @@ -45,6 +50,6 @@ function for_each_unittest() timeout=${BASH_REMATCH[1]} fi done - "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout" + run_task "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout" exec {fd}<&- } diff --git a/scripts/global.bash b/scripts/global.bash new file mode 100644 index 0000000..9076785 --- /dev/null +++ b/scripts/global.bash @@ -0,0 +1 @@ +: ${ut_default_log_file:=test.log}