-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathMakefile.test
89 lines (74 loc) · 2.78 KB
/
Makefile.test
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#
# Makefile.test for combined COAP library unit tests
#
# List of subdirectories to build
TEST_FOLDER := ./test/
# List of unit test directories for libraries
UNITTESTS := $(sort $(dir $(wildcard $(TEST_FOLDER)*/unittest/*)))
TESTDIRS := $(UNITTESTS:%=build-%)
CLEANTESTDIRS := $(UNITTESTS:%=clean-%)
COVERAGEFILE := ./lcov/coverage.info
TEST_MODULES = ./test_modules
TEST_MODULE_MBED_TRACE = $(TEST_MODULES)/mbed-trace
TEST_MODULE_NANOSTACK = $(TEST_MODULES)/nanostack-libservice
TEST_MODULE_RANDLIB = $(TEST_MODULES)/mbed-client-randlib
TEST_MODULE_CCPUTEST_VERSION = "v3.8"
TEST_MODULE_CPPUTEST = $(TEST_MODULES)/cpputest
TEST_MODULE_CPPUTEST_LIB = $(TEST_MODULE_CPPUTEST)/lib/libCppUTest.a
.PHONY: clone
clone:
if [ ! -d $(TEST_MODULES) ]; \
then mkdir $(TEST_MODULES); \
fi;
if [ ! -d $(TEST_MODULE_MBED_TRACE) ]; \
then git clone --depth 1 git@github.com:ARMmbed/mbed-trace.git $(TEST_MODULE_MBED_TRACE); \
fi;
if [ ! -d $(TEST_MODULE_NANOSTACK) ]; \
then git clone --depth 1 git@github.com:ARMmbed/nanostack-libservice.git $(TEST_MODULE_NANOSTACK); \
fi;
if [ ! -d $(TEST_MODULE_RANDLIB) ]; \
then git clone --depth 1 git@github.com:ARMmbed/mbed-client-randlib.git $(TEST_MODULE_RANDLIB); \
fi;
if [ ! -d $(TEST_MODULE_CPPUTEST) ]; \
then git clone --single-branch -b $(TEST_MODULE_CCPUTEST_VERSION) https://github.com/cpputest/cpputest.git $(TEST_MODULE_CPPUTEST); \
fi;
.PHONY: test
test: $(TEST_MODULE_CPPUTEST_LIB) $(TESTDIRS)
@rm -rf ./lcov
@rm -rf ./coverage
@rm -rf ./valgrind_logs
@mkdir -p lcov
@mkdir -p lcov/results
@mkdir coverage
@mkdir valgrind_logs
@find ./test -name '*.xml' | xargs cp -t ./lcov/results/
@rm -f lcov/index.xml
@./xsl_script.sh
@cp junit_xsl.xslt lcov/.
@xsltproc -o lcov/testresults.html lcov/junit_xsl.xslt lcov/index.xml
@rm -f lcov/junit_xsl.xslt
@rm -f lcov/index.xml
@gcovr -r . --filter='.*/sn_coap_builder.c' --filter='.*/sn_coap_protocol.c' --filter='.*/sn_coap_parser.c' --filter='.*/sn_coap_header_check.c' -x -o ./lcov/gcovr.xml
@lcov -q -d test/. -c -o $(COVERAGEFILE)
@lcov -q -r $(COVERAGEFILE) "/usr*" -o $(COVERAGEFILE)
@lcov -q -r $(COVERAGEFILE) "*unittest*" -o $(COVERAGEFILE)
@lcov -q -r $(COVERAGEFILE) "*test_modules*" -o $(COVERAGEFILE)
@genhtml -q $(COVERAGEFILE) --show-details --output-directory lcov/html
@find ./test -name \valgrind*.xml -print0 | xargs -0 cp --target-directory=./valgrind_logs/
@echo mbed-coap module unit tests built
$(TEST_MODULE_CPPUTEST_LIB):
cd $(TEST_MODULE_CPPUTEST) && \
./autogen.sh && \
./configure --disable-memory-leak-detection && \
make && \
cd $(CUR_DIR); \
$(TESTDIRS):
@make -C $(@:build-%=%)
$(CLEANDIRS):
@make -C $(@:clean-%=%) clean
$(CLEANTESTDIRS):
@make -C $(@:clean-%=%) clean
# Extend default clean rule
clean: clean-extra
clean-extra: $(CLEANDIRS) \
$(CLEANTESTDIRS)