aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorJohn Levon <john.levon@nutanix.com>2021-05-25 15:09:03 +0100
committerGitHub <noreply@github.com>2021-05-25 15:09:03 +0100
commitdf72df510f4696fb4835fd42e8f4de2dcb7cf428 (patch)
tree52f70c075cf9d1794a5c480535fffb091d23e094 /Makefile
parent6e8ffd28978f068741122f7894780f614e85ff12 (diff)
downloadlibvfio-user-df72df510f4696fb4835fd42e8f4de2dcb7cf428.zip
libvfio-user-df72df510f4696fb4835fd42e8f4de2dcb7cf428.tar.gz
libvfio-user-df72df510f4696fb4835fd42e8f4de2dcb7cf428.tar.bz2
add a gcov target (#498)
"make gcov" is sufficient to run the tests in DEBUG mode and generate gcov output for each .c file in lib/, to give us some idea of our coverage. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile29
1 files changed, 22 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index aae9071..f3b7779 100644
--- a/Makefile
+++ b/Makefile
@@ -43,6 +43,11 @@ ifdef WITH_ASAN
LDFLAGS += -fsanitize=address
endif
+ifeq ($(MAKECMDGOALS), gcov)
+ CFLAGS += --coverage
+ LDFLAGS += --coverage
+endif
+
ifeq ($(VERBOSE),)
MAKEFLAGS += -s
endif
@@ -54,10 +59,10 @@ BUILD_DIR = $(BUILD_DIR_BASE)/$(BUILD_TYPE)
INSTALL_PREFIX ?= /usr/local
-PHONY_TARGETS := all pytest pytest-valgrind test pre-push realclean buildclean force_cmake tags
-.PHONY: $(PHONY_TARGETS)
+.PHONY: all test pytest pytest-valgrind
+.PHONY: pre-push clean realclean tags gcov
-all $(filter-out $(PHONY_TARGETS), $(MAKECMDGOALS)): $(BUILD_DIR)/Makefile
+all: $(BUILD_DIR)/Makefile
+$(MAKE) -C $(BUILD_DIR) $@
#
@@ -106,7 +111,11 @@ pytest-valgrind: all
endif
+ifdef WITH_GCOV
+test: all pytest
+else
test: all pytest
+endif
cd $(BUILD_DIR)/test; ctest --verbose
pre-push: realclean
@@ -119,13 +128,16 @@ pre-push: realclean
make test CC=gcc
make pytest-valgrind
-realclean:
- rm -rf $(BUILD_DIR_BASE)
+GCOVS=$(patsubst %.c,%.c.gcov, $(wildcard lib/*.c))
+
+gcov: realclean test $(GCOVS)
-buildclean:
+clean:
rm -rf $(BUILD_DIR)
-force_cmake: $(BUILD_DIR)/Makefile
+realclean:
+ rm -rf $(BUILD_DIR_BASE)
+ rm -rf $(GCOVS)
$(BUILD_DIR)/Makefile:
mkdir -p $(BUILD_DIR)
@@ -139,3 +151,6 @@ $(BUILD_DIR)/Makefile:
tags:
ctags -R --exclude=$(BUILD_DIR)
+
+lib/%.c.gcov: lib/%.c
+ cd lib && gcov -o ../build/$(BUILD_TYPE)/lib/CMakeFiles/$*.dir/$*.gcno $<