Compare commits
1 Commits
862ebe5fae
...
cd66f01149
Author | SHA1 | Date | |
---|---|---|---|
|
cd66f01149 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
bin/
|
||||
obj/
|
||||
coverage/
|
||||
test.info
|
||||
|
4
.vscode/tasks.json
vendored
4
.vscode/tasks.json
vendored
@ -74,7 +74,7 @@
|
||||
{
|
||||
"label": "exec_unit_test",
|
||||
"type":"shell",
|
||||
"command": "make exec_unit_test -j1",
|
||||
"command": "make exec_unit_test",
|
||||
"problemMatcher": {
|
||||
"base": "$gcc",
|
||||
"owner": "gcc",
|
||||
@ -91,7 +91,7 @@
|
||||
{
|
||||
"label": "coverage",
|
||||
"type":"shell",
|
||||
"command": "make coverage -j1",
|
||||
"command": "make coverage",
|
||||
"problemMatcher": {
|
||||
"base": "$gcc",
|
||||
"owner": "gcc",
|
||||
|
33
Makefile
33
Makefile
@ -6,12 +6,10 @@ CC = $(CROSS_COMPILE)gcc
|
||||
CPP = $(CROSS_COMPILE)cpp
|
||||
CHECK = cppcheck
|
||||
LCOV = lcov
|
||||
GENHTML = genhtml
|
||||
|
||||
SRC_DIR = src
|
||||
OBJ_DIR = obj
|
||||
BIN_DIR = bin
|
||||
COVERAGE_DIR = coverage
|
||||
UNIT_TEST_SRC_DIR = test/unit
|
||||
UNIT_TEST_OBJ_DIR = $(OBJ_DIR)/$(UNIT_TEST_SRC_DIR)
|
||||
|
||||
@ -20,10 +18,8 @@ INCLUDES += /usr/include/libftdi1
|
||||
|
||||
ifneq "$(findstring $(MAKECMDGOALS), build_unit_test exec_unit_test coverage)" ""
|
||||
INCLUDES += test/inc
|
||||
|
||||
C_FLAGS += --coverage
|
||||
L_FLAGS += --coverage
|
||||
|
||||
C_FLAGS += -fprofile-arcs -ftest-coverage
|
||||
L_FLAGS += -fprofile-arcs -ftest-coverage
|
||||
else
|
||||
LIBS := ftdi1
|
||||
endif
|
||||
@ -49,23 +45,16 @@ THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST))
|
||||
all: $(TARGET)
|
||||
|
||||
.PHONY: coverage
|
||||
coverage: _cov_genhtml
|
||||
$(eval COVERAGE:=$(shell grep 'lines' .coverage.tmp | egrep -o '[0-9]+.[0-9]+%'))
|
||||
coverage: $(UNIT_TEST_TARGET)
|
||||
$(UNIT_TEST_TARGET)
|
||||
@rm -f $(UNIT_TEST_OBJ_DIR)/*.gcda
|
||||
@rm -f $(UNIT_TEST_OBJ_DIR)/*.gcno
|
||||
$(LCOV) -c -d obj -d bin/test/unit/ -d src/ -d test/unit/ -o test.info --no-external
|
||||
$(eval COVERAGE:=$(shell genhtml -o coverage/html test.info | grep 'lines' | egrep -o '[0-9]+.[0-9]+%'))
|
||||
@echo
|
||||
@echo Line coverage: $(COVERAGE)
|
||||
@echo
|
||||
@rm -f .coverage.tmp
|
||||
|
||||
.PHONY: _cov_lcov
|
||||
_cov_lcov: exec_unit_test
|
||||
@rm -f $(UNIT_TEST_OBJ_DIR)/*.gcda
|
||||
@rm -f $(UNIT_TEST_OBJ_DIR)/*.gcno
|
||||
@mkdir -p $(COVERAGE_DIR)
|
||||
$(LCOV) -c -d $(OBJ_DIR) -o $(COVERAGE_DIR)/coverage.info
|
||||
|
||||
.PHONY: _cov_genhtml
|
||||
_cov_genhtml: _cov_lcov
|
||||
$(GENHTML) -o $(COVERAGE_DIR)/html $(COVERAGE_DIR)/coverage.info > .coverage.tmp
|
||||
|
||||
.PHONY: unit_test
|
||||
build_unit_test: $(UNIT_TEST_TARGET)
|
||||
@ -106,10 +95,8 @@ $(UNIT_TEST_OBJ_DIR)/%.o: $(UNIT_TEST_SRC_DIR)/%.c $(UNIT_TEST_OBJ_DIR)/%.d
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f $(OBJS) $(patsubst %.o,%.d,$(OBJS)) $(TARGET)
|
||||
rm -f $(UNIT_TEST_OBJS) $(patsubst %.o,%.d,$(UNIT_TEST_OBJS)) $(UNIT_TEST_TARGET)
|
||||
rm -f $(OBJ_DIR)/*.gcda $(OBJ_DIR)/*.gcno
|
||||
rm -fr $(COVERAGE_DIR)
|
||||
rm -rf $(OBJS) $(patsubst %.o,%.d,$(OBJS)) $(TARGET)
|
||||
rm -rf $(UNIT_TEST_OBJS) $(patsubst %.o,%.d,$(UNIT_TEST_OBJS)) $(UNIT_TEST_TARGET)
|
||||
|
||||
ifneq ($(MAKECMDGOALS),clean)
|
||||
-include $(patsubst %.o,%.d,$(OBJS))
|
||||
|
Loading…
Reference in New Issue
Block a user