Commit 134937bc authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

make: add ability to collect code coverage (v2)

gcc is executed with the option --coverage.
lcov creates HTML pages containing the source code annotated with
coverage information.

make GCOV=1
make test
make gcov
Look at gcov/html/index.html

v2: declare the weak __gcov_flush
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 162cb479
...@@ -124,6 +124,10 @@ DEPS := $(patsubst %.o,%.d,$(OBJS)) ...@@ -124,6 +124,10 @@ DEPS := $(patsubst %.o,%.d,$(OBJS))
.PHONY: all zdtm test rebuild clean distclean tags cscope \ .PHONY: all zdtm test rebuild clean distclean tags cscope \
docs help pie protobuf x86 docs help pie protobuf x86
ifeq ($(GCOV),1)
%.o $(PROGRAM): override CFLAGS += --coverage
endif
all: pie all: pie
$(Q) $(MAKE) $(PROGRAM) $(Q) $(MAKE) $(PROGRAM)
...@@ -180,6 +184,8 @@ clean: ...@@ -180,6 +184,8 @@ clean:
$(Q) $(RM) -f ./*.bin $(Q) $(RM) -f ./*.bin
$(Q) $(RM) -f ./$(PROGRAM) $(Q) $(RM) -f ./$(PROGRAM)
$(Q) $(RM) -rf ./test/dump/ $(Q) $(RM) -rf ./test/dump/
$(Q) $(RM) -f ./*.gcov ./*.gcda ./*.gcno
$(Q) $(RM) -rf ./gcov
$(Q) $(MAKE) -C protobuf/ clean $(Q) $(MAKE) -C protobuf/ clean
$(Q) $(MAKE) -C arch/x86/ clean $(Q) $(MAKE) -C arch/x86/ clean
$(Q) $(MAKE) -C pie/ clean $(Q) $(MAKE) -C pie/ clean
...@@ -218,6 +224,17 @@ help: ...@@ -218,6 +224,17 @@ help:
$(E) ' rebuild - Force-rebuild of [*] targets' $(E) ' rebuild - Force-rebuild of [*] targets'
$(E) ' test - Run zdtm test-suite' $(E) ' test - Run zdtm test-suite'
gcov:
$(E) " GCOV"
$(Q) mkdir gcov && \
cd gcov && \
cp ../*.gcno ../*.c ../test/root/crtools/ && \
geninfo --no-checksum --output-filename tproxyd.l.info --no-recursion .. && \
geninfo --no-checksum --output-filename tproxyd.ns.info --no-recursion ../test/root/crtools && \
sed -i 's#/test/root/crtools##' tproxyd.ns.info && \
lcov -a tproxyd.l.info -a tproxyd.ns.info -o tproxyd.info && \
genhtml -o html tproxyd.info
deps-targets := $(OBJS) $(patsubst %.o,%.s,$(OBJS)) $(patsubst %.o,%.i,$(OBJS)) $(PROGRAM) deps-targets := $(OBJS) $(patsubst %.o,%.s,$(OBJS)) $(patsubst %.o,%.i,$(OBJS)) $(PROGRAM)
.DEFAULT_GOAL := all .DEFAULT_GOAL := all
......
...@@ -1702,6 +1702,9 @@ static int sigreturn_prep_xsave_frame(struct thread_restore_args *args, CoreEntr ...@@ -1702,6 +1702,9 @@ static int sigreturn_prep_xsave_frame(struct thread_restore_args *args, CoreEntr
return 0; return 0;
} }
extern void __gcov_flush(void) __attribute__((weak));
void __gcov_flush(void) {}
static int sigreturn_restore(pid_t pid, CoreEntry *core) static int sigreturn_restore(pid_t pid, CoreEntry *core)
{ {
long restore_task_vma_len; long restore_task_vma_len;
...@@ -1962,6 +1965,8 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core) ...@@ -1962,6 +1965,8 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core)
close_image_dir(); close_image_dir();
__gcov_flush();
pr_info("task_args: %p\n" pr_info("task_args: %p\n"
"task_args->pid: %d\n" "task_args->pid: %d\n"
"task_args->nr_threads: %d\n" "task_args->nr_threads: %d\n"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment