FreeRTOS-Kernel/FreeRTOS/Test/CMock/Makefile
alfred gedeon 1ac492d6aa
Kernel timers.c tasks.c Unit Test (#539)
* Test: add multi config ability to build system

* Remove Tests that are not implemented yet from the makefile

* Fix header check

* Test: Unit Test tasks.c

* UnitTest: tasks.c Save progress

* saving some work 70% coverage

* coverage 77%

* tasks.c coverage 90%

* tasks.c coverage 95%

* Cleanup and common header

* Cover some extra branches, no_mutex +stack growth

* Fix Makefile not to use modified version of c-preprocessor

* Remove c-preprocessor errros

* Rebase and add some tests

* Fortify_source=1 and O0 are mutually exclusive

* Style: Uncrustify code

* Style: Fix indent

* Fix Header checks

* Add prototypes

* Build: use unifdef instead of the c-preprocessor to generate different configurations

* Build: fix makefile cflags

* Fix UT after upgrading kernel version

* Resolve conflicts and test failures

* Comment fix version number

* Fix build error

* Update FreeRTOS/Test/CMock/Makefile

Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com>

Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com>
2022-08-16 14:38:26 -07:00

141 lines
5.7 KiB
Makefile

# indent with spaces
.RECIPEPREFIX := $(.RECIPEPREFIX) $(.RECIPEPREFIX)
include makefile.in
# Change to match installed location
export CC ?= /usr/local/bin/gcc
export LD ?= /usr/local/bin/ld
# Add units here when adding a new unit test directory with the same name
UNITS := timers
UNITS += tasks
UNITS += list
UNITS += queue
UNITS += stream_buffer
UNITS += message_buffer
UNITS += event_groups
.PHONY: makefile.in
UNITY_OPTIONS := -DUNITY_USE_COMMAND_LINE_ARGS
UNITY_OPTIONS += -DUNITY_OUTPUT_COLOR -DUNITY_INCLUDE_PRINT_FORMATTED
COVINFO := $(BUILD_DIR)/cmock_test.info
LCOV_LIST := $(foreach unit,$(UNITS),$(GENERATED_DIR)/$(unit).info )
.PHONY: all doc clean $(UNITS) directories coverage zero_coverage \
run run_formatted run_col_formatted run_col libs execs lcov \
help
include makefile.in
all: doc coverage | directories
execs: $(UNITS) | directories
$(UNITS) : libs | directories
$(MAKE) -C $@
Makefile : ;
makefile.in : ;
SHARED_LIBS := $(addprefix $(LIB_DIR)/,$(addsuffix .so,$(LIBS)))
libs : $(SHARED_LIBS)
doc:
$(MAKE) -C doc all
clean:
rm -rf $(BUILD_DIR)
help:
@echo -e 'Usage: $$ make <target>\n '
@echo -e ' where <target> is one of: $(UNITS) doc all run run_formatted run_col run_col_formatted coverage'
@echo -e ''
@echo -e '$(UNITS) : will build the corresponding test including all its configuration'
@echo -e 'doc : will generate doxygen docs in $(BUILD_DIR)/doc/index.html'
@echo -e 'run : will build and run all $(UNITS) and their various configurations.'
@echo -e ' It will also generate a test report in the JUnit format in $(BUILD_DIR)/report.xml'
@echo -e 'run_col : same as run but the results are in colors(pass: green, fail: red)'
@echo -e 'run_formatted : will show test case results in a formatted way'
@echo -e 'run_col_formatted : same as formatted but will show the results in colors'
@echo -e 'coverage : will run code coverage and generate html docs in $(BUILD_DIR)/coverage/index.html'
@echo -e 'all : will build documentations and coverage, which builds and runs all tests'
$(LIB_DIR)/libcmock.so : $(CMOCK_SRC_DIR)/cmock.c \
$(CMOCK_SRC_DIR)/cmock.h \
$(LIB_DIR)/libunity.so \
Makefile | directories
$(CC) -o $@ -shared -fPIC $< $(INCLUDE_DIR)
$(LIB_DIR)/libunity.so : $(UNITY_SRC_DIR)/unity.c \
$(UNITY_SRC_DIR)/unity.h \
Makefile | directories
${CC} -o $@ $(UNITY_OPTIONS) -shared -fPIC $<
$(LIB_DIR)/libunitymemory.so: ${UNITY_MEM_DIR}/unity_memory.c \
${UNITY_MEM_DIR}/unity_memory.h \
${LIB_DIR}/libunity.so \
Makefile | directories
${CC} -o $@ -shared -fPIC $< ${INCLUDE_DIR}
$(LIB_DIR)/libcexception.so: ${C_EXCEPTION_SRC_DIR}/CException.c \
${C_EXCEPTION_SRC_DIR}/CException.h \
Makefile | directories
${CC} -o $@ -shared -fPIC $< ${INCLUDE_DIR}
run : $(UNITS) | directories
-rm -f $(BUILD_DIR)/unit_test_report.txt
for f in $(BIN_DIR)/*; do \
$${f} | tee -a $(BUILD_DIR)/unit_test_report.txt ; \
done
cd $(BUILD_DIR) && \
ruby $(UNITY_BIN_DIR)/parse_output.rb \
-xml $(BUILD_DIR)/unit_test_report.txt
run_col : $(UNITS) zero_coverage | directories
for f in $(BIN_DIR)/*; do \
ruby -r $(UNITY_BIN_DIR)/colour_reporter.rb -e "report('`$${f}`')"; \
done
run_formatted : $(UNITS) zero_coverage | directories
for f in $(BIN_DIR)/*; do \
$${f} > $(BUILD_DIR)/output; \
ruby $(UNITY_BIN_DIR)/parse_output.rb $(BUILD_DIR)/output ; \
done
run_col_formatted : $(UNITS) zero_coverage | directories
for f in $(BIN_DIR)/*; do \
$${f} > $(BUILD_DIR)/output; \
ruby -r $(UNITY_BIN_DIR)/colour_reporter.rb \
-e "report('$$(ruby $(UNITY_BIN_DIR)/parse_output.rb \
$(BUILD_DIR)/output)')"; \
done
directories:
-mkdir -p $(BUILD_DIR)
-mkdir -p $(LIB_DIR)
-mkdir -p $(COVERAGE_DIR)
-mkdir -p $(BIN_DIR)
zero_coverage :
lcov --zerocounters --directory $(BUILD_DIR) --config-file $(UT_ROOT_DIR)/lcovrc
coverage : run_col
lcov --base-directory $(KERNEL_DIR) --directory $(BUILD_DIR) --capture \
--config-file $(UT_ROOT_DIR)/lcovrc -o $(COVINFO)
genhtml $(COVINFO) --branch-coverage \
--config-file $(UT_ROOT_DIR)/lcovrc --output-directory $(COVERAGE_DIR)
lcov : $(COVINFO)
# Combine lcov from each test bin into one lcov info file for the suite
$(COVINFO) : $(LCOV_LIST)
lcov $(LCOV_OPTS) -o $@ $(foreach cov,$(LCOV_LIST),--add-tracefile $(cov) )
# Generate lcov for each suite
$(LCOV_LIST) : zero_coverage
make -C $(subst .info,,$(@F)) lcov
lcovhtml : $(COVINFO) | directories
genhtml $(COVINFO) $(LCOV_OPTS) --output-directory $(COVERAGE_DIR) --quiet