mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-22 09:58:09 +00:00
make: update target to measure code coverage
This patch updates Makefile for measuring code coverage in CRIU. criu binary should be compiled with option --coverage and linked with -lgcov option. lcov utility creates HTML pages containing the source code annotated with coverage information. make GCOV=1 make test make gcov Look at gcov/html/index.html Changes: - disable optimization on compilation for gathering coverage data - mention an option for coverage in help - cleanup the files produced for code coverage - make path to coverage files produced by tests in ns independent on environment - add an option lcov_branch_coverage as branch coverage disabled by default Signed-off-by: Sergey Bronnikov <sergeyb@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This commit is contained in:
parent
4ea3acb03c
commit
a57fba056e
28
Makefile
28
Makefile
@ -77,6 +77,12 @@ ifeq ($(ARCH),ia32)
|
|||||||
export PROTOUFIX ldflags-y
|
export PROTOUFIX ldflags-y
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(GCOV),1)
|
||||||
|
LDFLAGS += -lgcov
|
||||||
|
DEBUG = 1 # disable optimization if we want to measure code coverage
|
||||||
|
%.o $(PROGRAM): override CFLAGS += --coverage -fno-exceptions -fno-inline
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(shell echo $(ARCH) | sed -e 's/arm.*/arm/'),arm)
|
ifeq ($(shell echo $(ARCH) | sed -e 's/arm.*/arm/'),arm)
|
||||||
ARMV := $(shell echo $(ARCH) | sed -nr 's/armv([[:digit:]]).*/\1/p; t; i7')
|
ARMV := $(shell echo $(ARCH) | sed -nr 's/armv([[:digit:]]).*/\1/p; t; i7')
|
||||||
SRCARCH := arm
|
SRCARCH := arm
|
||||||
@ -196,10 +202,6 @@ PROGRAM := criu
|
|||||||
.PHONY: all zdtm test rebuild clean distclean tags cscope \
|
.PHONY: all zdtm test rebuild clean distclean tags cscope \
|
||||||
docs help pie protobuf $(ARCH_DIR) clean-built lib crit
|
docs help pie protobuf $(ARCH_DIR) clean-built lib crit
|
||||||
|
|
||||||
ifeq ($(GCOV),1)
|
|
||||||
%.o $(PROGRAM): override CFLAGS += --coverage
|
|
||||||
endif
|
|
||||||
|
|
||||||
all: config pie $(VERSION_HEADER) $(CRIU-LIB)
|
all: config pie $(VERSION_HEADER) $(CRIU-LIB)
|
||||||
$(Q) $(MAKE) $(PROGRAM)
|
$(Q) $(MAKE) $(PROGRAM)
|
||||||
$(Q) $(MAKE) crit
|
$(Q) $(MAKE) crit
|
||||||
@ -277,7 +279,7 @@ clean: clean-built
|
|||||||
$(Q) $(RM) ./*.img
|
$(Q) $(RM) ./*.img
|
||||||
$(Q) $(RM) ./*.out
|
$(Q) $(RM) ./*.out
|
||||||
$(Q) $(RM) ./*.bin
|
$(Q) $(RM) ./*.bin
|
||||||
$(Q) $(RM) ./*.gcov ./*.gcda ./*.gcno
|
$(Q) $(RM) ./*.{gcda,gcno,gcov} ./test/`pwd`/*.{gcda,gcno,gcov} ./pie/*.{gcda,gcno,gcov}
|
||||||
$(Q) $(RM) -r ./gcov
|
$(Q) $(RM) -r ./gcov
|
||||||
$(Q) $(RM) protobuf-desc-gen.h
|
$(Q) $(RM) protobuf-desc-gen.h
|
||||||
$(Q) $(MAKE) -C test $@
|
$(Q) $(MAKE) -C test $@
|
||||||
@ -356,17 +358,19 @@ help:
|
|||||||
@echo ' cscope - Generate cscope database'
|
@echo ' cscope - Generate cscope database'
|
||||||
@echo ' rebuild - Force-rebuild of [*] targets'
|
@echo ' rebuild - Force-rebuild of [*] targets'
|
||||||
@echo ' test - Run zdtm test-suite'
|
@echo ' test - Run zdtm test-suite'
|
||||||
|
@echo ' gcov - Make code coverage report'
|
||||||
|
|
||||||
gcov:
|
gcov:
|
||||||
$(E) " GCOV"
|
$(E) " GCOV"
|
||||||
$(Q) mkdir gcov && \
|
$(Q) test -d gcov || mkdir gcov && \
|
||||||
|
cp *.{gcno,c} test/`pwd`/ && \
|
||||||
|
geninfo --output-filename gcov/crtools.h.info --no-recursion . && \
|
||||||
|
geninfo --output-filename gcov/crtools.ns.info --no-recursion test/`pwd`/ && \
|
||||||
|
sed -i 's#/test/`pwd`##' gcov/crtools.ns.info && \
|
||||||
cd gcov && \
|
cd gcov && \
|
||||||
cp ../*.gcno ../*.c ../test/root/crtools/ && \
|
lcov --rc lcov_branch_coverage=1 --add-tracefile crtools.h.info --add-tracefile crtools.ns.info --output-file criu.info && \
|
||||||
geninfo --no-checksum --output-filename crtools.l.info --no-recursion .. && \
|
genhtml --rc lcov_branch_coverage=1 --output-directory html criu.info
|
||||||
geninfo --no-checksum --output-filename crtools.ns.info --no-recursion ../test/root/crtools && \
|
@echo "Code coverage report is in `pwd`/gcov/html/ directory."
|
||||||
sed -i 's#/test/root/crtools##' crtools.ns.info && \
|
|
||||||
lcov -a crtools.l.info -a crtools.ns.info -o crtools.info && \
|
|
||||||
genhtml -o html crtools.info
|
|
||||||
.PHONY: gcov
|
.PHONY: gcov
|
||||||
|
|
||||||
docker-build:
|
docker-build:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user