aboutsummaryrefslogtreecommitdiff
path: root/ccan/Makefile.check
blob: 767b33810dd187ffb9ee5e6ca74e0cc945ccc7d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
CCAN_TEST_SRC := $(wildcard ccan/*/test/run*.c)

LCOV_EXCLUDE += $(CCAN_TEST_SRC) ccan/list/test/helper.c

CCAN_TEST := $(CCAN_TEST_SRC:%.c=%)


.PHONY: $(CCAN_TEST:%=%-gcov-run) ccan-check

ccan-check: $(CCAN_TEST:%=%-check)

check: ccan-check $(CCAN_TEST:%=%-gcov-run)

.PHONY: ccan-coverage

coverage: ccan-coverage

ccan-coverage: $(CCAN_TEST:%=%-gcov-run)

$(CCAN_TEST:%=%-gcov-run) : %-run: %
	$(eval	LCOV_DIRS += -d $(dir $<) )
	$(call Q, TEST-COVERAGE , (cd $(dir $<); GCOV_PREFIX_STRIP=`(c=0; while [ "\`pwd\`" != '/' ]; do cd ..; c=\`expr 1 + $$c\`; done; echo $$c)` ./$(notdir $<) ), $< )

$(CCAN_TEST:%=%-check) : %-check: %
	$(call Q, RUN-TEST , $(VALGRIND) $<, $<)

$(CCAN_TEST) : % : %.c
	$(call Q, HOSTCC ,$(HOSTCC) $(HOSTCFLAGS) -O0 -g -I . -Iccan/ -o $@ $<,$<)

$(CCAN_TEST:%=%-gcov): %-gcov : %.c
	$(call Q, HOSTCC , (cd $(dir $<); $(HOSTCC) $(HOSTCFLAGS) -fprofile-arcs -ftest-coverage -O0 -g -I $(shell pwd) -I$(shell pwd)/./ccan/ -pg -o $(notdir $@) $(notdir $<) ), $<)

-include $(wildcard ccan/*/test/*.d)

clean: ccan-test-clean

ccan-test-clean:
	$(RM) -f $(CCAN_TEST) \
		$(CCAN_TEST:%=%-gcov) \
		$(CCAN_TEST:%=%.d) \
		$(CCAN_TEST:%=%.o) \
		$(CCAN_TEST:%=%-gcov.gcda) \
		$(CCAN_TEST:%=%-gcov.gcno)