From patchwork Tue May 1 18:49:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Blue Swirl X-Patchwork-Id: 156179 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 18C48B6FAB for ; Wed, 2 May 2012 04:50:03 +1000 (EST) Received: from localhost ([::1]:55174 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPI9A-0006QN-QP for incoming@patchwork.ozlabs.org; Tue, 01 May 2012 14:50:00 -0400 Received: from eggs.gnu.org ([208.118.235.92]:33569) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPI8t-0006LV-Kl for qemu-devel@nongnu.org; Tue, 01 May 2012 14:49:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SPI8q-00050O-VB for qemu-devel@nongnu.org; Tue, 01 May 2012 14:49:43 -0400 Received: from mail-yw0-f45.google.com ([209.85.213.45]:53893) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPI8q-00050F-My for qemu-devel@nongnu.org; Tue, 01 May 2012 14:49:40 -0400 Received: by yhoo21 with SMTP id o21so3314338yho.4 for ; Tue, 01 May 2012 11:49:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=Vop5Ig3x+Yr3QBo8W7iueduIj1xqpCpKO7nWWKeUUSE=; b=pcuykV7oDaf0tdh620hUeMmvSq+/Ux9+tJMsmmdrCZ3b67bsNJl0f4IDXABFlXH/ZN rtSfO4EJBIpx3Ybw+rbjDaR1wD30pso5RuNRyDvM4H2nV5IZaaOv5Omiz3zM2tFq6NfI PFbmL3VHbw7R9QW1p65kd+XZpEqwlGtxASDzYKY1cRvgJ/LPEUgvHkfkrPo2YZnzE/Fa sN8G/dchhpRu560wy1mM7F03ndUj/J6F+lLmKhiIxnO9g1NDEifawY/C24ndZeJpTpm2 YsK3X4tVX/nXJRkeEDng35wd3Cs/Oj3mwmfMj6wFsMQrKGjE0kewrhiQX62uozKj8jKe Xxug== Received: by 10.50.6.166 with SMTP id c6mr2822308iga.65.1335898178864; Tue, 01 May 2012 11:49:38 -0700 (PDT) MIME-Version: 1.0 Received: by 10.50.197.194 with HTTP; Tue, 1 May 2012 11:49:18 -0700 (PDT) From: Blue Swirl Date: Tue, 1 May 2012 18:49:18 +0000 Message-ID: To: Anthony Liguori , qemu-devel X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.213.45 Subject: [Qemu-devel] [PATCH] 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'. Add LDFLAGS (which may include GCOV flags) to libcacard Makefile to avoid a build breakage. Signed-off-by: Blue Swirl --- configure | 18 ++++++++++++++++++ libcacard/Makefile | 2 +- tests/Makefile | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) @@ -87,6 +113,7 @@ 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 @echo "Please note that HTML reports do not regenerate if the unit tests" @echo "has not changed." @@ -126,6 +153,12 @@ 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 +gcov: + $(GCOV) -n $(GCOV_FILES) + (cd i386-softmmu; $(GCOV) -n $(GCOV_I386_SOFTMMU_FILES)) + (cd libhw64; $(GCOV) -n $(GCOV_LIBHW64_FILES)) + (cd qapi; $(GCOV) -n $(GCOV_QAPI_FILES)) # Other tests From c5f46706b0a023968f88378b5a3009155aca3958 Mon Sep 17 00:00:00 2001 Message-Id: From: Blue Swirl Date: Tue, 1 May 2012 18:45:39 +0000 Subject: [PATCH] tests: add gcov target Add support for compiling for GCOV test coverage, enabled with '--enable-gcov' during configure. After tests, test coverage can be reported with 'make gcov'. Add LDFLAGS (which may include GCOV flags) to libcacard Makefile to avoid a build breakage. Signed-off-by: Blue Swirl --- configure | 18 ++++++++++++++++++ libcacard/Makefile | 2 +- tests/Makefile | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 1 deletions(-) diff --git a/configure b/configure index 3c72fa0..dfea46a 100755 --- a/configure +++ b/configure @@ -152,6 +152,8 @@ strip_opt="yes" tcg_interpreter="no" bigendian="no" mingw32="no" +gcov="no" +gcov_tool="gcov" EXESUF="" prefix="/usr/local" mandir="\${prefix}/share/man" @@ -556,6 +558,8 @@ for opt do ;; --python=*) python="$optarg" ;; + --gcov=*) gcov_tool="$optarg" + ;; --smbd=*) smbd="$optarg" ;; --extra-cflags=*) @@ -576,6 +580,8 @@ for opt do ;; --enable-gprof) gprof="yes" ;; + --enable-gcov) gcov="yes" + ;; --static) static="yes" LDFLAGS="-static $LDFLAGS" @@ -1110,6 +1116,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 @@ -2883,6 +2891,11 @@ if test "$mingw32" = "yes" ; then done fi +if test "$gcov" = "yes" ; then + QEMU_CFLAGS="-fprofile-arcs -ftest-coverage $QEMU_CFLAGS" + LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS" +fi + qemu_confdir=$sysconfdir$confsuffix qemu_datadir=$datadir$confsuffix @@ -3008,6 +3021,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" @@ -3412,6 +3427,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/libcacard/Makefile b/libcacard/Makefile index c6a896a..47a5eb1 100644 --- a/libcacard/Makefile +++ b/libcacard/Makefile @@ -18,7 +18,7 @@ QEMU_CFLAGS+=-I../ libcacard.lib-y=$(addsuffix .lo,$(basename $(libcacard-y))) vscclient: $(libcacard-y) $(QEMU_OBJS) vscclient.o - $(call quiet-command,$(CC) -o $@ $^ $(libcacard_libs) $(LIBS)," LINK $@") + $(call quiet-command,$(CC) $(LDFLAGS) -o $@ $^ $(libcacard_libs) $(LIBS)," LINK $@") clean: rm -f *.o */*.o *.d */*.d *.a */*.a *~ */*~ vscclient *.lo .libs/* *.la *.pc diff --git a/tests/Makefile b/tests/Makefile index 9988681..a316180 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,18 +1,42 @@ export SRC_PATH check-unit-y = tests/check-qdict$(EXESUF) +GCOV_FILES = qdict.c check-unit-y += tests/check-qfloat$(EXESUF) +GCOV_FILES += qfloat.c check-unit-y += tests/check-qint$(EXESUF) +GCOV_FILES += qint.c check-unit-y += tests/check-qstring$(EXESUF) +GCOV_FILES += qstring.c check-unit-y += tests/check-qlist$(EXESUF) +GCOV_FILES += qlist.c check-unit-y += tests/check-qjson$(EXESUF) +GCOV_FILES += qjson.c check-unit-y += tests/test-qmp-output-visitor$(EXESUF) +GCOV_QAPI_FILES += qapi/qmp-output-visitor.c check-unit-y += tests/test-qmp-input-visitor$(EXESUF) +GCOV_QAPI_FILES += 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 += qapi/qmp-dispatch.c check-unit-y += tests/test-string-input-visitor$(EXESUF) +GCOV_QAPI_FILES += qapi/string-input-visitor.c check-unit-y += tests/test-string-output-visitor$(EXESUF) +GCOV_QAPI_FILES += qapi/string-output-visitor.c check-unit-y += tests/test-coroutine$(EXESUF) +ifeq ($(CONFIG_WIN32),y) +GCOV_FILES += coroutine-win32.c +else +ifeq ($(CONFIG_UCONTEXT_COROUTINE),y) +GCOV_FILES += coroutine-ucontext.c +else +ifeq ($(CONFIG_SIGALTSTACK_COROUTINE),y) +GCOV_FILES += coroutine-sigaltstack.c +else +GCOV_FILES += coroutine-gthread.c +endif +endif +endif check-block-$(CONFIG_POSIX) += tests/qemu-iotests-quick.sh @@ -20,8 +44,10 @@ check-block-$(CONFIG_POSIX) += tests/qemu-iotests-quick.sh # really in libqtest, not in the testcases themselves. check-qtest-i386-y = tests/rtc-test check-qtest-x86_64-y = $(check-qtest-i386-y) +GCOV_I386_SOFTMMU_FILES += hw/mc146818rtc.c check-qtest-sparc-y = tests/m48t59-test$(EXESUF) check-qtest-sparc64-y = tests/m48t59-test$(EXESUF) +GCOV_LIBHW64_FILES += hw/m48t59.c GENERATED_HEADERS += tests/test-qapi-types.h tests/test-qapi-visit.h tests/test-qmp-commands.h @@ -87,6 +113,7 @@ 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 @echo "Please note that HTML reports do not regenerate if the unit tests" @echo "has not changed." @@ -126,6 +153,12 @@ 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 +gcov: + $(GCOV) -n $(GCOV_FILES) + (cd i386-softmmu; $(GCOV) -n $(GCOV_I386_SOFTMMU_FILES)) + (cd libhw64; $(GCOV) -n $(GCOV_LIBHW64_FILES)) + (cd qapi; $(GCOV) -n $(GCOV_QAPI_FILES)) # Other tests -- 1.7.2.5