diff options
author | Paul Bartell <pbartell@amazon.com> | 2021-03-23 18:41:14 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-23 18:41:14 -0700 |
commit | 92aca6e91082fa708052a2f0437f77b1ffacb899 (patch) | |
tree | 890e44ff96f5f691ebe518982e1e6102fd979673 | |
parent | ada298638ce8644070e4550dc09ac090b60b3d12 (diff) | |
download | freertos-git-92aca6e91082fa708052a2f0437f77b1ffacb899.tar.gz |
Collect initial coverage data so that untagged functions are still included in the lcov report (#537)
Collect initial coverage data with lcov --initial and add this to coverage data to the combined coverage from each test binary.
This ensures that all functions in the target file(s) are included in coverage statistics, even if those functions are not tagged in a _utest.c file.
Note: Functions which are excluded by the preprocessor will not have initial coverage data generated for them.
-rw-r--r-- | FreeRTOS/Test/CMock/testdir.mk | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/FreeRTOS/Test/CMock/testdir.mk b/FreeRTOS/Test/CMock/testdir.mk index e832de60b..5ebc8fdcb 100644 --- a/FreeRTOS/Test/CMock/testdir.mk +++ b/FreeRTOS/Test/CMock/testdir.mk @@ -54,6 +54,8 @@ DEPS_OBJ_LIST := $(addprefix $(SCRATCH_DIR)/dep_,$(PROJECT_DEPS_SRC:.c=.o)) EXECS := $(addprefix $(EXEC_PREFIX)_,$(SUITE_UT_SRC:.c=)) EXEC_LIST := $(addprefix $(BIN_DIR)/,$(EXECS)) LCOV_LIST := $(addsuffix .info,$(addprefix $(SCRATCH_DIR)/,$(SUITE_UT_SRC:.c=))) +COVINFO_INITIAL := $(SCRATCH_DIR)/$(EXEC_PREFIX)_initial.info +COVINFO_COMBINE := $(SCRATCH_DIR)/$(EXEC_PREFIX)_combined.info COVINFO := $(abspath $(SCRATCH_DIR)/..)/$(EXEC_PREFIX).info LIBS_LIST := $(foreach lib, $(LIBS), $(LIB_DIR)/$(lib).so) @@ -171,6 +173,10 @@ $(EXEC_LIST) : $(BIN_DIR)/$(EXEC_PREFIX)_%_utest : $(SCRATCH_DIR)/%_utest.o $(CC) $< $(subst .o,_runner.o,$<) $(SF_OBJ_LIST) $(DEPS_OBJ_LIST) \ $(MOCK_OBJ_LIST) $(PROJ_OBJ_LIST) $(LDFLAGS) -o $@ +# Generate baseline inital coverage data from .gcno file +$(SCRATCH_DIR)/$(EXEC_PREFIX)_initial.info : $(PROJ_OBJ_LIST) + lcov $(LCOV_OPTS) --capture --initial --directory $(PROJ_DIR) -o $@ + # Run the test runner and genrate a filtered gcov.json.gz file $(SCRATCH_DIR)/%_utest.info : $(BIN_DIR)/$(EXEC_PREFIX)_%_utest \ $(PROJ_DIR)/callgraph.json @@ -197,5 +203,9 @@ $(SCRATCH_DIR)/%_utest.info : $(BIN_DIR)/$(EXEC_PREFIX)_%_utest \ rm -f $(PROJ_GCDA_LIST) # Combine lcov from each test bin into one lcov info file for the suite -$(COVINFO) : $(LCOV_LIST) - lcov $(LCOV_OPTS) -q -o $@ $(foreach cov,$(LCOV_LIST),--add-tracefile $(cov) ) +$(COVINFO_COMBINE) : $(LCOV_LIST) + lcov $(LCOV_OPTS) -o $@ $(foreach cov,$(LCOV_LIST),--add-tracefile $(cov) ) + +# Add baseline / initial coverage generated by gcc to point out untagged functions +$(COVINFO) : $(COVINFO_COMBINE) $(COVINFO_INITIAL) + lcov $(LCOV_OPTS) -o $@ --add-tracefile $(COVINFO_INITIAL) --add-tracefile $(COVINFO_COMBINE) |