From patchwork Sun Jun 10 13:04:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Blue Swirl X-Patchwork-Id: 163997 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 770D91007D1 for ; Sun, 10 Jun 2012 23:05:11 +1000 (EST) Received: from localhost ([::1]:60577 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SdhpM-00047k-9E for incoming@patchwork.ozlabs.org; Sun, 10 Jun 2012 09:05:08 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48035) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SdhpD-00045m-Pw for qemu-devel@nongnu.org; Sun, 10 Jun 2012 09:05:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SdhpB-00077x-LQ for qemu-devel@nongnu.org; Sun, 10 Jun 2012 09:04:59 -0400 Received: from mail-ey0-f173.google.com ([209.85.215.173]:53771) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SdhpB-000758-CW for qemu-devel@nongnu.org; Sun, 10 Jun 2012 09:04:57 -0400 Received: by mail-ey0-f173.google.com with SMTP id k12so1989097eaa.4 for ; Sun, 10 Jun 2012 06:04:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :in-reply-to:references; bh=UDV3kmm4cG3aE3PQpx1Ce9Zr9RZBC/UgsdmzIj8JQPo=; b=tGMI6NX03GTMBIEMP2/agrw5tLZr+PHWoJ87grjeeeRvkl/oAIXMBEql/aXDTuApIy MNOFXd6K90fYfxeiGhm+bYTcTJMeBldkTl7ltVeFAjzEtAJkqH1xGrgOo5rPxhL41ha3 jKox6AlUJBeXcGKkH/vrAGLFyz5Vdy3YWMotAtkYn3Xa2XzWeJg6lMT1XyCfcVwDVAv3 Q7h7C8BYi6QQz7J7Y30NjwFNplge9Lz/wW9+sXW4TPPHOaL5eL5PWwsapDFfpN1ZrXe4 JRU781TS0yWQzzTwZritRyaXhszkytKsoF/5yRdzKhPqTO5FRDBCH60Jvau/EKwdXk2G UFTw== Received: by 10.14.119.144 with SMTP id n16mr5118077eeh.187.1339333496257; Sun, 10 Jun 2012 06:04:56 -0700 (PDT) Received: from localhost.localdomain (blueswirl.broker.freenet6.net. [2001:5c0:1000:b::b867]) by mx.google.com with ESMTPS id y54sm41713586eef.10.2012.06.10.06.04.53 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 10 Jun 2012 06:04:55 -0700 (PDT) From: Blue Swirl To: qemu-devel@nongnu.org Date: Sun, 10 Jun 2012 13:04:33 +0000 Message-Id: X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <017b2d0961daf25d156270f69962fa82ba5be00c.1339333471.git.blauwirbel@gmail.com> References: <017b2d0961daf25d156270f69962fa82ba5be00c.1339333471.git.blauwirbel@gmail.com> In-Reply-To: <017b2d0961daf25d156270f69962fa82ba5be00c.1339333471.git.blauwirbel@gmail.com> References: <017b2d0961daf25d156270f69962fa82ba5be00c.1339333471.git.blauwirbel@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.215.173 Cc: Blue Swirl Subject: [Qemu-devel] [PATCH 2/2] tests: add gcov target X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add support for compiling for GCOV test coverage, enabled with '--enable-gcov' during configure. After tests, test coverage can be reported with 'make gcov'. Signed-off-by: Blue Swirl --- configure | 19 ++++++++++++++++++- tests/Makefile | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletions(-) diff --git a/configure b/configure index b4fb715..d773f4e 100755 --- a/configure +++ b/configure @@ -153,6 +153,8 @@ strip_opt="yes" tcg_interpreter="no" bigendian="no" mingw32="no" +gcov="no" +gcov_tool="gcov" EXESUF="" prefix="/usr/local" mandir="\${prefix}/share/man" @@ -557,6 +559,8 @@ for opt do ;; --python=*) python="$optarg" ;; + --gcov=*) gcov_tool="$optarg" + ;; --smbd=*) smbd="$optarg" ;; --extra-cflags=*) @@ -577,6 +581,8 @@ for opt do ;; --enable-gprof) gprof="yes" ;; + --enable-gcov) gcov="yes" + ;; --static) static="yes" LDFLAGS="-static $LDFLAGS" @@ -1111,6 +1117,8 @@ echo " --disable-guest-agent disable building of the QEMU Guest Agent" echo " --enable-guest-agent enable building of the QEMU Guest Agent" echo " --with-coroutine=BACKEND coroutine backend. Supported options:" echo " gthread, ucontext, sigaltstack, windows" +echo " --enable-gcov enable test coverage analysis with gcov" +echo " --gcov=GCOV use specified gcov [$gcov_tool]" echo "" echo "NOTE: The object files are built at the place where configure is launched" exit 1 @@ -2851,10 +2859,14 @@ fi # End of CC checks # After here, no more $cc or $ld runs -if test "$debug" = "no" ; then +if test "$gcov" = "yes" ; then + CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS" + LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS" +elif test "$debug" = "no" ; then CFLAGS="-O2 $CFLAGS" fi + # Consult white-list to determine whether to enable werror # by default. Only enable by default for git builds z_version=`cut -f3 -d. $source_path/VERSION` @@ -3033,6 +3045,8 @@ echo "OpenGL support $opengl" echo "libiscsi support $libiscsi" echo "build guest agent $guest_agent" echo "coroutine backend $coroutine_backend" +echo "gcov $gcov_tool" +echo "gcov enabled $gcov" if test "$sdl_too_old" = "yes"; then echo "-> Your SDL version is too old - please upgrade to have SDL support" @@ -3441,6 +3455,9 @@ echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak echo "EXESUF=$EXESUF" >> $config_host_mak echo "LIBS_QGA+=$libs_qga" >> $config_host_mak echo "POD2MAN=$POD2MAN" >> $config_host_mak +if test "$gcov" = "yes" ; then + echo "GCOV=$gcov_tool" >> $config_host_mak +fi # generate list of library paths for linker script diff --git a/tests/Makefile b/tests/Makefile index 2e754c3..d265daa 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,18 +1,42 @@ export SRC_PATH check-unit-y = tests/check-qdict$(EXESUF) +GCOV_FILES = $(SRC_PATH)/qdict.c check-unit-y += tests/check-qfloat$(EXESUF) +GCOV_FILES += $(SRC_PATH)/qfloat.c check-unit-y += tests/check-qint$(EXESUF) +GCOV_FILES += $(SRC_PATH)/qint.c check-unit-y += tests/check-qstring$(EXESUF) +GCOV_FILES += $(SRC_PATH)/qstring.c check-unit-y += tests/check-qlist$(EXESUF) +GCOV_FILES += $(SRC_PATH)/qlist.c check-unit-y += tests/check-qjson$(EXESUF) +GCOV_FILES += $(SRC_PATH)/qjson.c check-unit-y += tests/test-qmp-output-visitor$(EXESUF) +GCOV_QAPI_FILES += $(SRC_PATH)/qapi/qmp-output-visitor.c check-unit-y += tests/test-qmp-input-visitor$(EXESUF) +GCOV_QAPI_FILES += $(SRC_PATH)/qapi/qmp-input-visitor.c check-unit-y += tests/test-qmp-input-strict$(EXESUF) check-unit-y += tests/test-qmp-commands$(EXESUF) +GCOV_QAPI_FILES += $(SRC_PATH)/qapi/qmp-dispatch.c check-unit-y += tests/test-string-input-visitor$(EXESUF) +GCOV_QAPI_FILES += $(SRC_PATH)/qapi/string-input-visitor.c check-unit-y += tests/test-string-output-visitor$(EXESUF) +GCOV_QAPI_FILES += $(SRC_PATH)/qapi/string-output-visitor.c check-unit-y += tests/test-coroutine$(EXESUF) +ifeq ($(CONFIG_WIN32),y) +GCOV_FILES += $(SRC_PATH)/coroutine-win32.c +else +ifeq ($(CONFIG_UCONTEXT_COROUTINE),y) +GCOV_FILES += $(SRC_PATH)/coroutine-ucontext.c +else +ifeq ($(CONFIG_SIGALTSTACK_COROUTINE),y) +GCOV_FILES += $(SRC_PATH)/coroutine-sigaltstack.c +else +GCOV_FILES += $(SRC_PATH)/coroutine-gthread.c +endif +endif +endif check-block-$(CONFIG_POSIX) += tests/qemu-iotests-quick.sh @@ -21,8 +45,10 @@ check-block-$(CONFIG_POSIX) += tests/qemu-iotests-quick.sh check-qtest-i386-y = tests/fdc-test$(EXESUF) check-qtest-i386-y += tests/rtc-test$(EXESUF) check-qtest-x86_64-y = $(check-qtest-i386-y) +GCOV_I386_SOFTMMU_FILES += $(SRC_PATH)/hw/mc146818rtc.c check-qtest-sparc-y = tests/m48t59-test$(EXESUF) check-qtest-sparc64-y = tests/m48t59-test$(EXESUF) +GCOV_LIBHW64_FILES += $(SRC_PATH)/hw/m48t59.c GENERATED_HEADERS += tests/test-qapi-types.h tests/test-qapi-visit.h tests/test-qmp-commands.h @@ -88,6 +114,8 @@ check-help: @echo " make check-unit Run qobject tests" @echo " make check-block Run block tests" @echo " make check-report.html Generates an HTML test report" + @echo " make gcov Report test coverage" + @echo " make gcov-zerocounters Zero test coverage counters" @echo @echo "Please note that HTML reports do not regenerate if the unit tests" @echo "has not changed." @@ -95,6 +123,8 @@ check-help: @echo "The variable SPEED can be set to control the gtester speed setting." @echo "Default options are -k and (for make V=1) --verbose; they can be" @echo "changed with variable GTESTER_OPTIONS." + @echo + @echo "For test coverage, please run 'make gcov-zerocounters check gcov'." SPEED = quick GTESTER_OPTIONS = -k $(if $(V),--verbose,-q) @@ -127,6 +157,16 @@ check-report.xml: $(patsubst %,check-report-qtest-%.xml, $(QTEST_TARGETS)) check check-report.html: check-report.xml $(call quiet-command,gtester-report $< > $@, " GEN $@") +# Gcov test coverage +.PHONY: gcov gcov-zerocounters +gcov: + @$(GCOV) -n $(GCOV_FILES) + @(cd i386-softmmu/hw && $(GCOV) -n $(GCOV_I386_SOFTMMU_FILES)) + @(cd libhw64/hw && $(GCOV) -n $(GCOV_LIBHW64_FILES)) + @(cd qapi && $(GCOV) -n $(GCOV_QAPI_FILES)) + +gcov-zerocounters: + rm -f *.gcda */*.gcda */*/*.gcda */*/*/*.gcda # Other tests