2017-04-10 10:06:35 -04:00
|
|
|
TEST_PROGRAM=test_wl
|
2018-05-17 06:56:52 -04:00
|
|
|
|
|
|
|
# Expose as a library for FS components that require wear_levelling
|
|
|
|
TEST_LIB=lib$(TEST_PROGRAM).a
|
|
|
|
|
|
|
|
# Use simulated block device
|
|
|
|
TEST_PARTITION_SIM_DIR=$(IDF_PATH)/components/spi_flash/sim
|
|
|
|
TEST_PARTITION_SIM_LIB=libpartition_sim.a
|
|
|
|
|
2017-04-10 10:06:35 -04:00
|
|
|
all: $(TEST_PROGRAM)
|
|
|
|
|
2018-05-17 06:56:52 -04:00
|
|
|
LIB_SOURCE_FILES = \
|
|
|
|
$(addprefix stubs/, \
|
|
|
|
newlib/lock.c \
|
|
|
|
log/log.c \
|
|
|
|
esp32/crc.cpp \
|
|
|
|
) \
|
2017-04-10 10:06:35 -04:00
|
|
|
$(addprefix ../, \
|
2018-05-17 06:56:52 -04:00
|
|
|
wear_levelling.cpp \
|
|
|
|
crc32.cpp \
|
|
|
|
WL_Flash.cpp \
|
|
|
|
Partition.cpp \
|
2017-04-10 10:06:35 -04:00
|
|
|
) \
|
|
|
|
|
2018-05-17 06:56:52 -04:00
|
|
|
TEST_SOURCE_FILES = \
|
|
|
|
test_wl.cpp \
|
|
|
|
main.cpp
|
2017-04-10 10:06:35 -04:00
|
|
|
|
|
|
|
INCLUDE_FLAGS = $(addprefix -I,\
|
2018-05-17 06:56:52 -04:00
|
|
|
. \
|
2017-04-10 10:06:35 -04:00
|
|
|
../ \
|
|
|
|
../include \
|
|
|
|
../private_include \
|
2018-05-17 06:56:52 -04:00
|
|
|
$(addprefix stubs/, \
|
|
|
|
esp32/include \
|
|
|
|
newlib/include \
|
|
|
|
log/include \
|
|
|
|
) \
|
2017-04-10 10:06:35 -04:00
|
|
|
../../esp32/include \
|
2018-05-17 06:56:52 -04:00
|
|
|
../../spi_flash/sim/include \
|
2017-04-10 10:06:35 -04:00
|
|
|
../../../tools/catch \
|
2018-05-17 06:56:52 -04:00
|
|
|
)
|
2017-04-10 10:06:35 -04:00
|
|
|
|
2017-04-10 09:41:19 -04:00
|
|
|
GCOV ?= gcov
|
|
|
|
|
2018-05-17 06:56:52 -04:00
|
|
|
CPPFLAGS += $(INCLUDE_FLAGS) -D CONFIG_LOG_DEFAULT_LEVEL -g
|
2017-04-10 10:06:35 -04:00
|
|
|
CFLAGS += -fprofile-arcs -ftest-coverage
|
|
|
|
CXXFLAGS += -std=c++11 -Wall -Werror -fprofile-arcs -ftest-coverage
|
2017-04-10 09:41:19 -04:00
|
|
|
LDFLAGS += -lstdc++ -fprofile-arcs -ftest-coverage
|
2017-04-10 10:06:35 -04:00
|
|
|
|
2018-05-17 06:56:52 -04:00
|
|
|
LIB_OBJ_FILES = $(filter %.o, $(LIB_SOURCE_FILES:.cpp=.o) $(LIB_SOURCE_FILES:.c=.o))
|
|
|
|
TEST_OBJ_FILES = $(filter %.o, $(TEST_SOURCE_FILES:.cpp=.o) $(TEST_SOURCE_FILES:.c=.o))
|
2017-04-10 10:06:35 -04:00
|
|
|
|
2018-05-17 06:56:52 -04:00
|
|
|
$(TEST_PARTITION_SIM_DIR)/$(TEST_PARTITION_SIM_LIB): force
|
|
|
|
$(MAKE) -C $(TEST_PARTITION_SIM_DIR) lib
|
2017-04-10 10:06:35 -04:00
|
|
|
|
2018-05-17 06:56:52 -04:00
|
|
|
$(TEST_LIB): $(LIB_OBJ_FILES)
|
|
|
|
$(AR) rcs $@ $^
|
2017-04-10 10:06:35 -04:00
|
|
|
|
2018-05-17 06:56:52 -04:00
|
|
|
lib: $(TEST_LIB)
|
2017-04-10 10:06:35 -04:00
|
|
|
|
2018-05-17 06:56:52 -04:00
|
|
|
$(TEST_PROGRAM): lib $(TEST_OBJ_FILES) $(TEST_PARTITION_SIM_DIR)/$(TEST_PARTITION_SIM_LIB)
|
|
|
|
g++ $(LDFLAGS) -o $@ $(TEST_OBJ_FILES) -L$(abspath .) -l:$(TEST_LIB) -L$(TEST_PARTITION_SIM_DIR) -l:$(TEST_PARTITION_SIM_LIB)
|
|
|
|
|
|
|
|
force:
|
2017-04-10 10:06:35 -04:00
|
|
|
|
|
|
|
test: $(TEST_PROGRAM)
|
|
|
|
./$(TEST_PROGRAM)
|
|
|
|
|
2018-05-17 06:56:52 -04:00
|
|
|
$(OUTPUT_DIR):
|
|
|
|
mkdir -p $(OUTPUT_DIR)
|
|
|
|
|
|
|
|
COVERAGE_FILES = $(LIB_OBJ_FILES:.o=.gc*) $(TEST_OBJ_FILES:.o=.gc*)
|
|
|
|
|
2017-04-10 10:06:35 -04:00
|
|
|
$(COVERAGE_FILES): $(TEST_PROGRAM) test
|
|
|
|
|
|
|
|
coverage.info: $(COVERAGE_FILES)
|
|
|
|
find ../ -name "*.gcno" -exec $(GCOV) -r -pb {} +
|
|
|
|
lcov --capture --directory ../ --no-external --output-file coverage.info --gcov-tool $(GCOV)
|
|
|
|
|
|
|
|
coverage_report: coverage.info
|
|
|
|
genhtml coverage.info --output-directory coverage_report
|
|
|
|
@echo "Coverage report is in coverage_report/index.html"
|
|
|
|
|
|
|
|
clean:
|
2018-05-17 06:56:52 -04:00
|
|
|
$(MAKE) -C $(TEST_PARTITION_SIM_DIR) clean
|
|
|
|
rm -f $(LIB_OBJ_FILES) $(TEST_OBJ_FILES) $(TEST_PROGRAM) $(TEST_LIB)
|
2017-04-10 10:06:35 -04:00
|
|
|
rm -f $(COVERAGE_FILES) *.gcov
|
|
|
|
rm -rf coverage_report/
|
|
|
|
rm -f coverage.info
|
|
|
|
|
2018-05-17 06:56:52 -04:00
|
|
|
.PHONY: clean all test lib
|