mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-12-08 12:45:22 -05:00
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>
This commit is contained in:
parent
c00078e729
commit
1ac492d6aa
30 changed files with 9949 additions and 398 deletions
|
|
@ -7,26 +7,37 @@ 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 += timers
|
||||
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 \
|
||||
.PHONY: all doc clean $(UNITS) directories coverage zero_coverage \
|
||||
run run_formatted run_col_formatted run_col libs execs lcov \
|
||||
help
|
||||
|
||||
all: doc coverage
|
||||
execs: $(UNITS)
|
||||
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)
|
||||
|
|
@ -35,72 +46,85 @@ doc:
|
|||
$(MAKE) -C doc all
|
||||
|
||||
clean:
|
||||
rm -rf build
|
||||
rm -rf $(BUILD_DIR)
|
||||
|
||||
help:
|
||||
@echo -e 'Usage: $$ make <unit>\n '
|
||||
@echo -e ' where <unit> is one of: $(UNITS) doc all run run_formatted run_col run_col_formatted coverage'
|
||||
@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
|
||||
mkdir -p $(LIB_DIR)
|
||||
$(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)/libunity.so : ${UNITY_SRC_DIR}/unity.c \
|
||||
${UNITY_SRC_DIR}/unity.h \
|
||||
Makefile
|
||||
mkdir -p $(LIB_DIR)
|
||||
${CC} -o $@ -shared -fPIC $<
|
||||
$(LIB_DIR)/libcexception.so: ${C_EXCEPTION_SRC_DIR}/CException.c \
|
||||
${C_EXCEPTION_SRC_DIR}/CException.h \
|
||||
Makefile | directories
|
||||
${CC} -o $@ -shared -fPIC $< ${INCLUDE_DIR}
|
||||
|
||||
$(LIB_DIR)/libunitymemory.so: ${UNITY_MEM_DIR}/unity_memory.c \
|
||||
${UNITY_MEM_DIR}/unity_memory.h \
|
||||
${LIB_DIR}/libunity.so \
|
||||
Makefile
|
||||
mkdir -p $(LIB_DIR)
|
||||
${CC} -o $@ -shared -fPIC $< ${INCLUDE_DIR}
|
||||
|
||||
$(LIB_DIR)/libcexception.so: ${C_EXCEPTION_SRC_DIR}/CException.c \
|
||||
${C_EXCEPTION_SRC_DIR}/CException.h
|
||||
mkdir -p $(LIB_DIR)
|
||||
${CC} -o $@ -shared -fPIC $< ${INCLUDE_DIR}
|
||||
|
||||
run : $(UNITS)
|
||||
mkdir -p $(BUILD_DIR)
|
||||
rm -f $(BUILD_DIR)/unit_test_report.txt
|
||||
for f in $(BIN_DIR)/*; do \
|
||||
$${f} | tee -a $(BUILD_DIR)/unit_test_report.txt; \
|
||||
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
|
||||
cd $(BUILD_DIR) && \
|
||||
ruby $(UNITY_BIN_DIR)/parse_output.rb \
|
||||
-xml $(BUILD_DIR)/unit_test_report.txt
|
||||
|
||||
run_col : $(UNITS) zero_coverage
|
||||
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
|
||||
for f in $(BIN_DIR)/*; do \
|
||||
$${f} > $(BUILD_DIR)/output; \
|
||||
ruby $(UNITY_BIN_DIR)/parse_output.rb $(BUILD_DIR)/output ; \
|
||||
ruby -r $(UNITY_BIN_DIR)/colour_reporter.rb -e "report('`$${f}`')"; \
|
||||
done
|
||||
|
||||
run_col_formatted : $(UNITS) zero_coverage
|
||||
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)')"; \
|
||||
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
|
||||
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 $(BUILD_DIR)/cmock_test.info
|
||||
genhtml $(BUILD_DIR)/cmock_test.info --branch-coverage \
|
||||
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)
|
||||
|
|
@ -113,6 +137,5 @@ $(COVINFO) : $(LCOV_LIST)
|
|||
$(LCOV_LIST) : zero_coverage
|
||||
make -C $(subst .info,,$(@F)) lcov
|
||||
|
||||
lcovhtml : $(COVINFO)
|
||||
mkdir -p $(COVERAGE_DIR)
|
||||
lcovhtml : $(COVINFO) | directories
|
||||
genhtml $(COVINFO) $(LCOV_OPTS) --output-directory $(COVERAGE_DIR) --quiet
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue