tests: add gcov support
Add support for compiling for GCOV test coverage, enabled with '--enable-gcov' during configure. Test coverage will be reported after each test. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
parent
549db5c32b
commit
1d728c3946
|
@ -31,6 +31,8 @@ oslib-obj-$(CONFIG_POSIX) += oslib-posix.o qemu-thread-posix.o
|
||||||
# coroutines
|
# coroutines
|
||||||
coroutine-obj-y = qemu-coroutine.o qemu-coroutine-lock.o qemu-coroutine-io.o
|
coroutine-obj-y = qemu-coroutine.o qemu-coroutine-lock.o qemu-coroutine-io.o
|
||||||
coroutine-obj-y += qemu-coroutine-sleep.o
|
coroutine-obj-y += qemu-coroutine-sleep.o
|
||||||
|
|
||||||
|
# If you change this logic, please also check tests/Makefile
|
||||||
ifeq ($(CONFIG_UCONTEXT_COROUTINE),y)
|
ifeq ($(CONFIG_UCONTEXT_COROUTINE),y)
|
||||||
coroutine-obj-$(CONFIG_POSIX) += coroutine-ucontext.o
|
coroutine-obj-$(CONFIG_POSIX) += coroutine-ucontext.o
|
||||||
else
|
else
|
||||||
|
|
|
@ -176,6 +176,8 @@ strip_opt="yes"
|
||||||
tcg_interpreter="no"
|
tcg_interpreter="no"
|
||||||
bigendian="no"
|
bigendian="no"
|
||||||
mingw32="no"
|
mingw32="no"
|
||||||
|
gcov="no"
|
||||||
|
gcov_tool="gcov"
|
||||||
EXESUF=""
|
EXESUF=""
|
||||||
prefix="/usr/local"
|
prefix="/usr/local"
|
||||||
mandir="\${prefix}/share/man"
|
mandir="\${prefix}/share/man"
|
||||||
|
@ -600,6 +602,8 @@ for opt do
|
||||||
;;
|
;;
|
||||||
--python=*) python="$optarg"
|
--python=*) python="$optarg"
|
||||||
;;
|
;;
|
||||||
|
--gcov=*) gcov_tool="$optarg"
|
||||||
|
;;
|
||||||
--smbd=*) smbd="$optarg"
|
--smbd=*) smbd="$optarg"
|
||||||
;;
|
;;
|
||||||
--extra-cflags=*)
|
--extra-cflags=*)
|
||||||
|
@ -620,6 +624,8 @@ for opt do
|
||||||
;;
|
;;
|
||||||
--enable-gprof) gprof="yes"
|
--enable-gprof) gprof="yes"
|
||||||
;;
|
;;
|
||||||
|
--enable-gcov) gcov="yes"
|
||||||
|
;;
|
||||||
--static)
|
--static)
|
||||||
static="yes"
|
static="yes"
|
||||||
LDFLAGS="-static $LDFLAGS"
|
LDFLAGS="-static $LDFLAGS"
|
||||||
|
@ -1134,6 +1140,8 @@ echo " --with-coroutine=BACKEND coroutine backend. Supported options:"
|
||||||
echo " gthread, ucontext, sigaltstack, windows"
|
echo " gthread, ucontext, sigaltstack, windows"
|
||||||
echo " --enable-glusterfs enable GlusterFS backend"
|
echo " --enable-glusterfs enable GlusterFS backend"
|
||||||
echo " --disable-glusterfs disable 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 ""
|
||||||
echo "NOTE: The object files are built at the place where configure is launched"
|
echo "NOTE: The object files are built at the place where configure is launched"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -3120,10 +3128,14 @@ fi
|
||||||
# End of CC checks
|
# End of CC checks
|
||||||
# After here, no more $cc or $ld runs
|
# 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"
|
CFLAGS="-O2 -D_FORTIFY_SOURCE=2 $CFLAGS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Disable zero malloc errors for official releases unless explicitly told to
|
# Disable zero malloc errors for official releases unless explicitly told to
|
||||||
# enable/disable
|
# enable/disable
|
||||||
if test -z "$zero_malloc" ; then
|
if test -z "$zero_malloc" ; then
|
||||||
|
@ -3305,6 +3317,8 @@ echo "seccomp support $seccomp"
|
||||||
echo "coroutine backend $coroutine_backend"
|
echo "coroutine backend $coroutine_backend"
|
||||||
echo "GlusterFS support $glusterfs"
|
echo "GlusterFS support $glusterfs"
|
||||||
echo "virtio-blk-data-plane $virtio_blk_data_plane"
|
echo "virtio-blk-data-plane $virtio_blk_data_plane"
|
||||||
|
echo "gcov $gcov_tool"
|
||||||
|
echo "gcov enabled $gcov"
|
||||||
|
|
||||||
if test "$sdl_too_old" = "yes"; then
|
if test "$sdl_too_old" = "yes"; then
|
||||||
echo "-> Your SDL version is too old - please upgrade to have SDL support"
|
echo "-> Your SDL version is too old - please upgrade to have SDL support"
|
||||||
|
@ -3738,6 +3752,10 @@ echo "EXESUF=$EXESUF" >> $config_host_mak
|
||||||
echo "LIBS_QGA+=$libs_qga" >> $config_host_mak
|
echo "LIBS_QGA+=$libs_qga" >> $config_host_mak
|
||||||
echo "POD2MAN=$POD2MAN" >> $config_host_mak
|
echo "POD2MAN=$POD2MAN" >> $config_host_mak
|
||||||
echo "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
|
echo "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
|
||||||
|
if test "$gcov" = "yes" ; then
|
||||||
|
echo "CONFIG_GCOV=y" >> $config_host_mak
|
||||||
|
echo "GCOV=$gcov_tool" >> $config_host_mak
|
||||||
|
fi
|
||||||
|
|
||||||
# generate list of library paths for linker script
|
# generate list of library paths for linker script
|
||||||
|
|
||||||
|
|
|
@ -1,33 +1,65 @@
|
||||||
export SRC_PATH
|
export SRC_PATH
|
||||||
|
|
||||||
check-unit-y = tests/check-qdict$(EXESUF)
|
check-unit-y = tests/check-qdict$(EXESUF)
|
||||||
|
gcov-files-check-qdict-y = qdict.c
|
||||||
check-unit-y += tests/check-qfloat$(EXESUF)
|
check-unit-y += tests/check-qfloat$(EXESUF)
|
||||||
|
gcov-files-check-qfloat-y = qfloat.c
|
||||||
check-unit-y += tests/check-qint$(EXESUF)
|
check-unit-y += tests/check-qint$(EXESUF)
|
||||||
|
gcov-files-check-qint-y = qint.c
|
||||||
check-unit-y += tests/check-qstring$(EXESUF)
|
check-unit-y += tests/check-qstring$(EXESUF)
|
||||||
|
gcov-files-check-qstring-y = qstring.c
|
||||||
check-unit-y += tests/check-qlist$(EXESUF)
|
check-unit-y += tests/check-qlist$(EXESUF)
|
||||||
|
gcov-files-check-qlist-y = qlist.c
|
||||||
check-unit-y += tests/check-qjson$(EXESUF)
|
check-unit-y += tests/check-qjson$(EXESUF)
|
||||||
|
gcov-files-check-qjson-y = qjson.c
|
||||||
check-unit-y += tests/test-qmp-output-visitor$(EXESUF)
|
check-unit-y += tests/test-qmp-output-visitor$(EXESUF)
|
||||||
|
gcov-files-test-qmp-output-visitor-y = qapi/qmp-output-visitor.c
|
||||||
check-unit-y += tests/test-qmp-input-visitor$(EXESUF)
|
check-unit-y += tests/test-qmp-input-visitor$(EXESUF)
|
||||||
|
gcov-files-test-qmp-input-visitor-y = qapi/qmp-input-visitor.c
|
||||||
check-unit-y += tests/test-qmp-input-strict$(EXESUF)
|
check-unit-y += tests/test-qmp-input-strict$(EXESUF)
|
||||||
check-unit-y += tests/test-qmp-commands$(EXESUF)
|
check-unit-y += tests/test-qmp-commands$(EXESUF)
|
||||||
|
gcov-files-test-qmp-commands-y = qapi/qmp-dispatch.c
|
||||||
check-unit-y += tests/test-string-input-visitor$(EXESUF)
|
check-unit-y += tests/test-string-input-visitor$(EXESUF)
|
||||||
|
gcov-files-test-string-input-visitor-y = qapi/string-input-visitor.c
|
||||||
check-unit-y += tests/test-string-output-visitor$(EXESUF)
|
check-unit-y += tests/test-string-output-visitor$(EXESUF)
|
||||||
|
gcov-files-test-string-output-visitor-y = qapi/string-output-visitor.c
|
||||||
check-unit-y += tests/test-coroutine$(EXESUF)
|
check-unit-y += tests/test-coroutine$(EXESUF)
|
||||||
|
ifeq ($(CONFIG_WIN32),y)
|
||||||
|
gcov-files-test-coroutine-y = coroutine-win32.c
|
||||||
|
else
|
||||||
|
ifeq ($(CONFIG_UCONTEXT_COROUTINE),y)
|
||||||
|
gcov-files-test-coroutine-y = coroutine-ucontext.c
|
||||||
|
else
|
||||||
|
ifeq ($(CONFIG_SIGALTSTACK_COROUTINE),y)
|
||||||
|
gcov-files-test-coroutine-y = coroutine-sigaltstack.c
|
||||||
|
else
|
||||||
|
gcov-files-test-coroutine-y = coroutine-gthread.c
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
check-unit-y += tests/test-visitor-serialization$(EXESUF)
|
check-unit-y += tests/test-visitor-serialization$(EXESUF)
|
||||||
check-unit-y += tests/test-iov$(EXESUF)
|
check-unit-y += tests/test-iov$(EXESUF)
|
||||||
|
gcov-files-test-iov-y = iov.c
|
||||||
check-unit-y += tests/test-aio$(EXESUF)
|
check-unit-y += tests/test-aio$(EXESUF)
|
||||||
|
gcov-files-test-aio-$(CONFIG_WIN32) = aio-win32.c
|
||||||
|
gcov-files-test-aio-$(CONFIG_POSIX) = aio-posix.c
|
||||||
check-unit-y += tests/test-thread-pool$(EXESUF)
|
check-unit-y += tests/test-thread-pool$(EXESUF)
|
||||||
|
gcov-files-test-thread-pool-y = thread-pool.c
|
||||||
|
|
||||||
check-block-$(CONFIG_POSIX) += tests/qemu-iotests-quick.sh
|
check-block-$(CONFIG_POSIX) += tests/qemu-iotests-quick.sh
|
||||||
|
|
||||||
# All QTests for now are POSIX-only, but the dependencies are
|
# All QTests for now are POSIX-only, but the dependencies are
|
||||||
# really in libqtest, not in the testcases themselves.
|
# really in libqtest, not in the testcases themselves.
|
||||||
check-qtest-i386-y = tests/fdc-test$(EXESUF)
|
check-qtest-i386-y = tests/fdc-test$(EXESUF)
|
||||||
|
gcov-files-i386-y = hw/fdc.c
|
||||||
check-qtest-i386-y += tests/hd-geo-test$(EXESUF)
|
check-qtest-i386-y += tests/hd-geo-test$(EXESUF)
|
||||||
|
gcov-files-i386-y += hw/hd-geometry.c
|
||||||
check-qtest-i386-y += tests/rtc-test$(EXESUF)
|
check-qtest-i386-y += tests/rtc-test$(EXESUF)
|
||||||
check-qtest-x86_64-y = $(check-qtest-i386-y)
|
check-qtest-x86_64-y = $(check-qtest-i386-y)
|
||||||
|
gcov-files-i386-y += i386-softmmu/hw/mc146818rtc.c
|
||||||
check-qtest-sparc-y = tests/m48t59-test$(EXESUF)
|
check-qtest-sparc-y = tests/m48t59-test$(EXESUF)
|
||||||
check-qtest-sparc64-y = tests/m48t59-test$(EXESUF)
|
check-qtest-sparc64-y = tests/m48t59-test$(EXESUF)
|
||||||
|
gcov-files-sparc-y += hw/m48t59.c
|
||||||
|
|
||||||
GENERATED_HEADERS += tests/test-qapi-types.h tests/test-qapi-visit.h tests/test-qmp-commands.h
|
GENERATED_HEADERS += tests/test-qapi-types.h tests/test-qapi-visit.h tests/test-qmp-commands.h
|
||||||
|
|
||||||
|
@ -108,17 +140,28 @@ check-help:
|
||||||
|
|
||||||
SPEED = quick
|
SPEED = quick
|
||||||
GTESTER_OPTIONS = -k $(if $(V),--verbose,-q)
|
GTESTER_OPTIONS = -k $(if $(V),--verbose,-q)
|
||||||
|
GCOV_OPTIONS = -n $(if $(V),-f,)
|
||||||
|
|
||||||
# gtester tests, possibly with verbose output
|
# gtester tests, possibly with verbose output
|
||||||
|
|
||||||
.PHONY: $(patsubst %, check-qtest-%, $(QTEST_TARGETS))
|
.PHONY: $(patsubst %, check-qtest-%, $(QTEST_TARGETS))
|
||||||
$(patsubst %, check-qtest-%, $(QTEST_TARGETS)): check-qtest-%: $(check-qtest-y)
|
$(patsubst %, check-qtest-%, $(QTEST_TARGETS)): check-qtest-%: $(check-qtest-y)
|
||||||
|
$(if $(CONFIG_GCOV),@rm -f *.gcda */*.gcda */*/*.gcda */*/*/*.gcda,)
|
||||||
$(call quiet-command,QTEST_QEMU_BINARY=$*-softmmu/qemu-system-$* \
|
$(call quiet-command,QTEST_QEMU_BINARY=$*-softmmu/qemu-system-$* \
|
||||||
gtester $(GTESTER_OPTIONS) -m=$(SPEED) $(check-qtest-$*-y),"GTESTER $@")
|
gtester $(GTESTER_OPTIONS) -m=$(SPEED) $(check-qtest-$*-y),"GTESTER $@")
|
||||||
|
$(if $(CONFIG_GCOV),@for f in $(gcov-files-$*-y); do \
|
||||||
|
echo Gcov report for $$f:;\
|
||||||
|
$(GCOV) $(GCOV_OPTIONS) $$f -o `dirname $$f`; \
|
||||||
|
done,)
|
||||||
|
|
||||||
.PHONY: $(patsubst %, check-%, $(check-unit-y))
|
.PHONY: $(patsubst %, check-%, $(check-unit-y))
|
||||||
$(patsubst %, check-%, $(check-unit-y)): check-%: %
|
$(patsubst %, check-%, $(check-unit-y)): check-%: %
|
||||||
|
$(if $(CONFIG_GCOV),@rm -f *.gcda */*.gcda */*/*.gcda */*/*/*.gcda,)
|
||||||
$(call quiet-command,gtester $(GTESTER_OPTIONS) -m=$(SPEED) $*,"GTESTER $*")
|
$(call quiet-command,gtester $(GTESTER_OPTIONS) -m=$(SPEED) $*,"GTESTER $*")
|
||||||
|
$(if $(CONFIG_GCOV),@for f in $(gcov-files-$(subst tests/,,$*)-y); do \
|
||||||
|
echo Gcov report for $$f:;\
|
||||||
|
$(GCOV) $(GCOV_OPTIONS) $$f -o `dirname $$f`; \
|
||||||
|
done,)
|
||||||
|
|
||||||
# gtester tests with XML output
|
# gtester tests with XML output
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue