From patchwork Thu Jan 12 03:36:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 714225 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tzXld3tjFz9rxl for ; Thu, 12 Jan 2017 15:26:53 +1100 (AEDT) Received: from localhost ([::1]:59541 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cRWyR-0000hr-5N for incoming@patchwork.ozlabs.org; Wed, 11 Jan 2017 23:26:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33336) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cRWBw-0008GL-KO for qemu-devel@nongnu.org; Wed, 11 Jan 2017 22:36:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cRWBv-00023K-M4 for qemu-devel@nongnu.org; Wed, 11 Jan 2017 22:36:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48778) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cRWBv-000237-De for qemu-devel@nongnu.org; Wed, 11 Jan 2017 22:36:43 -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 853A280B56; Thu, 12 Jan 2017 03:36:43 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-8-25.pek2.redhat.com [10.72.8.25]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v0C3aUOf022851; Wed, 11 Jan 2017 22:36:40 -0500 From: Peter Xu To: qemu-devel@nongnu.org, kvm@vger.kernel.org Date: Thu, 12 Jan 2017 11:36:21 +0800 Message-Id: <1484192182-13760-3-git-send-email-peterx@redhat.com> In-Reply-To: <1484192182-13760-1-git-send-email-peterx@redhat.com> References: <1484192182-13760-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.28]); Thu, 12 Jan 2017 03:36:43 +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 v6 2/3] run_tests: put logs into per-test 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" We were using test.log before to keep all the test logs. This patch creates one log file per test case under logs/ directory with name "TESTNAME.log". Meanwhile, we will keep the last time log into logs.old/. Renaming scripts/functions.bash into scripts/common.bash to store some more global variables. Signed-off-by: Peter Xu Reviewed-by: Andrew Jones --- .gitignore | 3 ++- Makefile | 5 ++--- run_tests.sh | 19 ++++++++++++------- scripts/{functions.bash => common.bash} | 13 +++++++++++-- scripts/mkstandalone.sh | 2 +- 5 files changed, 28 insertions(+), 14 deletions(-) rename scripts/{functions.bash => common.bash} (75%) diff --git a/.gitignore b/.gitignore index 3155418..2213b9b 100644 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,8 @@ cscope.* /lib/asm /config.mak /*-run -/test.log /msr.out /tests /build-head +/logs/ +/logs.old/ diff --git a/Makefile b/Makefile index a32333b..844bacc 100644 --- a/Makefile +++ b/Makefile @@ -94,9 +94,8 @@ libfdt_clean: $(LIBFDT_objdir)/.*.d distclean: clean libfdt_clean - $(RM) lib/asm config.mak $(TEST_DIR)-run test.log msr.out cscope.* \ - build-head - $(RM) -r tests + $(RM) lib/asm config.mak $(TEST_DIR)-run msr.out cscope.* build-head + $(RM) -r tests logs logs.old cscope: cscope_dirs = lib lib/libfdt lib/linux $(TEST_DIR) $(ARCH_LIBDIRS) lib/asm-generic cscope: diff --git a/run_tests.sh b/run_tests.sh index 2cfa365..afd3d95 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -7,7 +7,7 @@ if [ ! -f config.mak ]; then exit 1 fi source config.mak -source scripts/functions.bash +source scripts/common.bash function usage() { @@ -46,17 +46,22 @@ 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 -rf $unittest_log_dir.old +[ -d $unittest_log_dir ] && mv $unittest_log_dir $unittest_log_dir.old +mkdir $unittest_log_dir || exit 2 + +echo "BUILD_HEAD=$(cat build-head)" > $unittest_log_dir/SUMMARY + for_each_unittest $config run diff --git a/scripts/functions.bash b/scripts/common.bash similarity index 75% rename from scripts/functions.bash rename to scripts/common.bash index ee9143c..2dd7360 100644 --- a/scripts/functions.bash +++ b/scripts/common.bash @@ -1,3 +1,12 @@ +: ${unittest_log_dir:=logs} + +function run_task() +{ + local testname="$2" + + RUNTIME_log_file="${unittest_log_dir}/${testname}.log" + "$@" +} function for_each_unittest() { @@ -17,7 +26,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 +54,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/mkstandalone.sh b/scripts/mkstandalone.sh index d2bae19..3c1938e 100755 --- a/scripts/mkstandalone.sh +++ b/scripts/mkstandalone.sh @@ -5,7 +5,7 @@ if [ ! -f config.mak ]; then exit 1 fi source config.mak -source scripts/functions.bash +source scripts/common.bash escape () {