FRDM K64F Metronome

Committer:
ram54288
Date:
Sun May 14 18:37:05 2017 +0000
Revision:
0:dbad57390bd1
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ram54288 0:dbad57390bd1 1 #
ram54288 0:dbad57390bd1 2 # Makefile for running unit tests
ram54288 0:dbad57390bd1 3 #
ram54288 0:dbad57390bd1 4 # List of subdirectories to build
ram54288 0:dbad57390bd1 5 TEST_FOLDER := ./test/
ram54288 0:dbad57390bd1 6
ram54288 0:dbad57390bd1 7 LIB = libmbed-client-mbedtls.a
ram54288 0:dbad57390bd1 8
ram54288 0:dbad57390bd1 9 # List of unit test directories for libraries
ram54288 0:dbad57390bd1 10 UNITTESTS := $(sort $(dir $(wildcard $(TEST_FOLDER)*/unittest/*)))
ram54288 0:dbad57390bd1 11 TESTDIRS := $(UNITTESTS:%=build-%)
ram54288 0:dbad57390bd1 12 CLEANTESTDIRS := $(UNITTESTS:%=clean-%)
ram54288 0:dbad57390bd1 13 COVERAGEFILE := ./lcov/coverage.info
ram54288 0:dbad57390bd1 14
ram54288 0:dbad57390bd1 15 include sources.mk
ram54288 0:dbad57390bd1 16 include include_dirs.mk
ram54288 0:dbad57390bd1 17
ram54288 0:dbad57390bd1 18 override CFLAGS += $(addprefix -I,$(INCLUDE_DIRS))
ram54288 0:dbad57390bd1 19 override CFLAGS += $(addprefix -D,$(FLAGS))
ram54288 0:dbad57390bd1 20 ifeq ($(DEBUG),1)
ram54288 0:dbad57390bd1 21 override CFLAGS += -DHAVE_DEBUG
ram54288 0:dbad57390bd1 22 endif
ram54288 0:dbad57390bd1 23
ram54288 0:dbad57390bd1 24 #
ram54288 0:dbad57390bd1 25 # Define compiler toolchain
ram54288 0:dbad57390bd1 26 #
ram54288 0:dbad57390bd1 27 include toolchain_rules.mk
ram54288 0:dbad57390bd1 28
ram54288 0:dbad57390bd1 29 $(eval $(call generate_rules,$(LIB),$(SRCS)))
ram54288 0:dbad57390bd1 30
ram54288 0:dbad57390bd1 31 # Extend default clean rule
ram54288 0:dbad57390bd1 32 clean: clean-extra
ram54288 0:dbad57390bd1 33
ram54288 0:dbad57390bd1 34 $(TESTDIRS):
ram54288 0:dbad57390bd1 35 @yotta target frdm-k64f-gcc
ram54288 0:dbad57390bd1 36 @yotta install mbed-client
ram54288 0:dbad57390bd1 37 @yotta install mbed-client-mbed-os
ram54288 0:dbad57390bd1 38 @make -C $(@:build-%=%)
ram54288 0:dbad57390bd1 39
ram54288 0:dbad57390bd1 40 $(CLEANDIRS):
ram54288 0:dbad57390bd1 41 @make -C $(@:clean-%=%) clean
ram54288 0:dbad57390bd1 42
ram54288 0:dbad57390bd1 43 $(CLEANTESTDIRS):
ram54288 0:dbad57390bd1 44 @make -C $(@:clean-%=%) clean
ram54288 0:dbad57390bd1 45
ram54288 0:dbad57390bd1 46 .PHONY: test
ram54288 0:dbad57390bd1 47 test: $(TESTDIRS)
ram54288 0:dbad57390bd1 48 @rm -rf ./lcov
ram54288 0:dbad57390bd1 49 @rm -rf ./coverage
ram54288 0:dbad57390bd1 50 @mkdir -p lcov
ram54288 0:dbad57390bd1 51 @mkdir -p lcov/results
ram54288 0:dbad57390bd1 52 @mkdir coverage
ram54288 0:dbad57390bd1 53 @find ./test -name '*.xml' | xargs cp -t ./lcov/results/
ram54288 0:dbad57390bd1 54 @rm -f lcov/index.xml
ram54288 0:dbad57390bd1 55 @./xsl_script.sh
ram54288 0:dbad57390bd1 56 @cp junit_xsl.xslt lcov/.
ram54288 0:dbad57390bd1 57 @xsltproc -o lcov/testresults.html lcov/junit_xsl.xslt lcov/index.xml
ram54288 0:dbad57390bd1 58 @rm -f lcov/junit_xsl.xslt
ram54288 0:dbad57390bd1 59 @rm -f lcov/index.xml
ram54288 0:dbad57390bd1 60 @find ./ -name '*.gcno' | xargs cp --backup=numbered -t ./coverage/
ram54288 0:dbad57390bd1 61 @find ./ -name '*.gcda' | xargs cp --backup=numbered -t ./coverage/
ram54288 0:dbad57390bd1 62 gcovr --object-directory ./coverage --exclude-unreachable-branches --exclude '/usr' --exclude '.*mbed-client-mbed-tls_unit_tests_master*.' --exclude '.*mbed-client-mbed-os*.' --exclude '.*common*.' --exclude '.*mbed-net-sockets.v0*.' --exclude '.*stub*.' --exclude '/yotta_modules/' -x -o ./lcov/gcovr.xml
ram54288 0:dbad57390bd1 63 @lcov -d test/. -c -o $(COVERAGEFILE)
ram54288 0:dbad57390bd1 64 @lcov -q -r $(COVERAGEFILE) "/usr*" -o $(COVERAGEFILE)
ram54288 0:dbad57390bd1 65 @lcov -q -r $(COVERAGEFILE) "/test*" -o $(COVERAGEFILE)
ram54288 0:dbad57390bd1 66 @lcov -q -r $(COVERAGEFILE) "/mbed-client/*" -o $(COVERAGEFILE)
ram54288 0:dbad57390bd1 67 @genhtml -q $(COVERAGEFILE) --show-details --output-directory lcov/html
ram54288 0:dbad57390bd1 68 @yotta uninstall mbed-client
ram54288 0:dbad57390bd1 69 @yotta uninstall mbed-client-mbed-os
ram54288 0:dbad57390bd1 70 @echo mbed-client-mbed-tls module unit tests built
ram54288 0:dbad57390bd1 71
ram54288 0:dbad57390bd1 72 clean-extra: $(CLEANDIRS) \
ram54288 0:dbad57390bd1 73 $(CLEANTESTDIRS)