Skip to contentSkip to conversation

tests: add gcov target

PATCH Superseded Blue Swirl 2 participants 2 messages Dec 28, 2012 – Jan 3, 2013 Kbuild

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Blue Swirl

author
#0 lore raw

PATCH v2 1/1 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'.

---
v2:
update to HEAD: report coverage for more files
improve gcov invocation and use foo-y Makefile magic for GCOV_FILES

---
 Makefile.objs  |    2 ++
 configure      |   19 ++++++++++++++++++-
 tests/Makefile |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 66 insertions(+), 1 deletions(-)
Makefile.objs +2 -0
index 3a3a402..a3eab4b 100644
@@ -31,6 +31,8 @@ oslib-obj-$(CONFIG_POSIX) += oslib-posix.o qemu-thread-posix.o
 # coroutines
 coroutine-obj-y = qemu-coroutine.o qemu-coroutine-lock.o qemu-coroutine-io.o
 coroutine-obj-y += qemu-coroutine-sleep.o
+
+# If you change this logic, please also check tests/Makefile
 ifeq ($(CONFIG_UCONTEXT_COROUTINE),y)
 coroutine-obj-$(CONFIG_POSIX) += coroutine-ucontext.o
 else
configure +18 -1
index 99c1ec3..ed801ad 100755
@@ -176,6 +176,8 @@ strip_opt="yes"
 tcg_interpreter="no"
 bigendian="no"
 mingw32="no"
+gcov="no"
+gcov_tool="gcov"
 EXESUF=""
 prefix="/usr/local"
 mandir="\${prefix}/share/man"
@@ -599,6 +601,8 @@ for opt do
   ;;
   --python=*) python="$optarg"
   ;;
+  --gcov=*) gcov_tool="$optarg"
+  ;;
   --smbd=*) smbd="$optarg"
   ;;
   --extra-cflags=*)
@@ -619,6 +623,8 @@ for opt do
   ;;
   --enable-gprof) gprof="yes"
   ;;
+  --enable-gcov) gcov="yes"
+  ;;
   --static)
     static="yes"
     LDFLAGS="-static $LDFLAGS"
@@ -1130,6 +1136,8 @@ echo "  --with-coroutine=BACKEND coroutine backend. Supported options:"
 echo "                           gthread, ucontext, sigaltstack, windows"
 echo "  --enable-glusterfs       enable GlusterFS backend"
 echo "  --disable-glusterfs      disable GlusterFS backend"
+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
@@ -3090,10 +3098,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 -D_FORTIFY_SOURCE=2 $CFLAGS"
 fi
 
+
 # Disable zero malloc errors for official releases unless explicitly told to
 # enable/disable
 if test -z "$zero_malloc" ; then
@@ -3274,6 +3286,8 @@ echo "build guest agent $guest_agent"
 echo "seccomp support   $seccomp"
 echo "coroutine backend $coroutine_backend"
 echo "GlusterFS support $glusterfs"
+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"
@@ -3697,6 +3711,9 @@ echo "EXESUF=$EXESUF" >> $config_host_mak
 echo "LIBS_QGA+=$libs_qga" >> $config_host_mak
 echo "POD2MAN=$POD2MAN" >> $config_host_mak
 echo "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
+if test "$gcov" = "yes" ; then
+  echo "GCOV=$gcov_tool" >> $config_host_mak
+fi
 
 # generate list of library paths for linker script
 
tests/Makefile +46 -0

97 lines not on this page · raw message

Signature · 1 line
1.7.2.5
Nacked-by on v2 1/1 NAK
#1 lore raw

Hi,

This is an automated message generated from the QEMU Patches. Thank you for submitting this patch. This patch no longer applies to qemu.git.

This may have occurred due to:

1) Changes in mainline requiring your patch to be rebased and re-tested.

2) Sending the mail using a tool other than git-send-email. Please use git-send-email to send patches to QEMU.

3) Basing this patch off of a branch that isn't tracking the QEMU master branch. If that was done purposefully, please include the name of the tree in the subject line in the future to prevent this message.

For instance: "[PATCH block-next 1/10] qcow3: add fancy new feature"

4) You no longer wish for this patch to be applied to QEMU. No additional action is required on your part.

Below is the output from git-am:

Applying: tests: add gcov target
Using index info to reconstruct a base tree...
M configure
Falling back to patching base and 3-way merge... Auto-merging configure
CONFLICT (content): Merge conflict in configure
Failed to merge in the changes.
Patch failed at 0001 tests: add gcov target
The copy of the patch that failed is found in:
/home/aliguori/patches/qemu.git/.git/rebase-apply/patch
When you have resolved this problem run "git am --resolved". If you would prefer to skip this patch, instead run "git am --skip". To restore the original branch and stop patching run "git am --abort".