2018-05-26 06:58:01 +00:00
|
|
|
COMPONENT=fatfs
|
2018-05-17 08:19:29 +00:00
|
|
|
|
2018-05-26 06:58:01 +00:00
|
|
|
TEST_PROGRAM=test_$(COMPONENT)
|
2018-05-17 08:19:29 +00:00
|
|
|
|
2018-05-26 06:58:01 +00:00
|
|
|
#Expose as a library
|
|
|
|
COMPONENT_LIB=lib$(COMPONENT).a
|
|
|
|
|
|
|
|
#Use wear levelling and flash simulation
|
|
|
|
WEAR_LEVELLING=wear_levelling
|
|
|
|
WEAR_LEVELLING_DIR=../../$(WEAR_LEVELLING)
|
|
|
|
WEAR_LEVELLING_HOST_DIR=$(WEAR_LEVELLING_DIR)/test_wl_host
|
|
|
|
WEAR_LEVELLING_LIB=lib$(WEAR_LEVELLING).a
|
|
|
|
|
|
|
|
SPI_FLASH=spi_flash
|
|
|
|
SPI_FLASH_DIR=../../$(SPI_FLASH)
|
|
|
|
SPI_FLASH_SIM_DIR=$(SPI_FLASH_DIR)/sim
|
|
|
|
SPI_FLASH_LIB=lib$(SPI_FLASH).a
|
2018-05-17 10:56:52 +00:00
|
|
|
|
|
|
|
all: $(TEST_PROGRAM)
|
|
|
|
|
|
|
|
SOURCE_FILES = \
|
|
|
|
$(addprefix ../src/, \
|
|
|
|
diskio.c \
|
|
|
|
ff.c \
|
|
|
|
ffsystem.c \
|
2018-05-17 08:19:29 +00:00
|
|
|
ffunicode.c \
|
2018-06-08 12:09:00 +00:00
|
|
|
diskio_wl.c \
|
2018-05-17 08:19:29 +00:00
|
|
|
) \
|
|
|
|
$(addprefix ./stubs/, log/log.c)
|
2018-05-17 10:56:52 +00:00
|
|
|
|
2018-05-26 06:58:01 +00:00
|
|
|
TEST_SOURCE_FILES = \
|
|
|
|
test_fatfs.cpp \
|
|
|
|
main.cpp \
|
|
|
|
test_utils.c
|
|
|
|
|
2018-05-17 10:56:52 +00:00
|
|
|
INCLUDE_FLAGS = $(addprefix -I,\
|
|
|
|
../src \
|
2018-05-17 08:19:29 +00:00
|
|
|
. \
|
|
|
|
$(addprefix ./stubs/, \
|
|
|
|
driver/include \
|
|
|
|
freertos/include \
|
|
|
|
sdmmc/include \
|
|
|
|
log/include \
|
|
|
|
) \
|
2018-05-26 06:58:01 +00:00
|
|
|
$(SPI_FLASH_DIR)/include \
|
|
|
|
$(WEAR_LEVELLING_DIR)/include \
|
2018-05-17 08:19:29 +00:00
|
|
|
../../esp32/include \
|
|
|
|
../../../tools/catch \
|
2018-05-17 10:56:52 +00:00
|
|
|
)
|
|
|
|
|
2018-05-17 08:19:29 +00:00
|
|
|
GCOV ?= gcov
|
|
|
|
|
2018-05-26 06:58:01 +00:00
|
|
|
CPPFLAGS += $(INCLUDE_FLAGS) -D CONFIG_LOG_DEFAULT_LEVEL -g -m32
|
2018-05-17 08:19:29 +00:00
|
|
|
CFLAGS += -fprofile-arcs -ftest-coverage
|
|
|
|
CXXFLAGS += -std=c++11 -Wall -Werror -fprofile-arcs -ftest-coverage
|
|
|
|
LDFLAGS += -lstdc++ -fprofile-arcs -ftest-coverage
|
|
|
|
|
|
|
|
OBJ_FILES = $(filter %.o, $(SOURCE_FILES:.cpp=.o) $(SOURCE_FILES:.c=.o))
|
2018-05-26 06:58:01 +00:00
|
|
|
TEST_OBJ_FILES = $(filter %.o, $(TEST_SOURCE_FILES:.cpp=.o) $(TEST_SOURCE_FILES:.c=.o))
|
|
|
|
|
|
|
|
$(WEAR_LEVELLING_HOST_DIR)/$(WEAR_LEVELLING_LIB): force
|
|
|
|
$(MAKE) -C $(WEAR_LEVELLING_HOST_DIR) lib
|
|
|
|
|
|
|
|
$(SPI_FLASH_SIM_DIR)/$(SPI_FLASH_LIB): force
|
|
|
|
$(MAKE) -C $(SPI_FLASH_SIM_DIR) lib
|
|
|
|
|
|
|
|
force:
|
2018-05-17 08:19:29 +00:00
|
|
|
|
2018-05-26 06:58:01 +00:00
|
|
|
$(COMPONENT_LIB): $(OBJ_FILES)
|
|
|
|
$(AR) rcs $@ $^
|
2018-05-17 10:56:52 +00:00
|
|
|
|
2018-05-26 06:58:01 +00:00
|
|
|
lib: $(COMPONENT_LIB)
|
2018-05-17 10:56:52 +00:00
|
|
|
|
2018-05-26 06:58:01 +00:00
|
|
|
partition_table.bin: partition_table.csv
|
|
|
|
python ../../partition_table/gen_esp32part.py --verify $< $@
|
2018-05-17 10:56:52 +00:00
|
|
|
|
2018-05-26 06:58:01 +00:00
|
|
|
$(TEST_PROGRAM): lib $(TEST_OBJ_FILES) $(SPI_FLASH_SIM_DIR)/$(SPI_FLASH_LIB) $(WEAR_LEVELLING_HOST_DIR)/$(WEAR_LEVELLING_LIB) partition_table.bin
|
|
|
|
g++ $(LDFLAGS) -o $(TEST_PROGRAM) $(TEST_OBJ_FILES) -L$(abspath .) -l:$(COMPONENT_LIB) -L$(SPI_FLASH_SIM_DIR) -l:$(SPI_FLASH_LIB) -L$(WEAR_LEVELLING_HOST_DIR) -l:$(WEAR_LEVELLING_LIB) -g -m32
|
2018-05-17 10:56:52 +00:00
|
|
|
|
2018-05-22 08:47:30 +00:00
|
|
|
test: $(TEST_PROGRAM)
|
2018-05-17 10:56:52 +00:00
|
|
|
./$(TEST_PROGRAM)
|
|
|
|
|
2018-05-26 06:58:01 +00:00
|
|
|
COVERAGE_FILES = $(OBJ_FILES:.o=.gc*) $(TEST_OBJ_FILES:.o=.gc*)
|
2018-05-17 08:19:29 +00:00
|
|
|
|
2018-05-26 06:58:01 +00:00
|
|
|
$(COVERAGE_FILES): test
|
2018-05-17 08:19:29 +00:00
|
|
|
|
|
|
|
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-26 06:58:01 +00:00
|
|
|
rm -f $(OBJ_FILES) $(TEST_OBJ_FILES) $(TEST_PROGRAM) $(COMPONENT_LIB) partition_table.bin
|
|
|
|
$(MAKE) -C $(WEAR_LEVELLING_HOST_DIR) clean
|
|
|
|
$(MAKE) -C $(SPI_FLASH_SIM_DIR) clean
|
2018-05-17 08:19:29 +00:00
|
|
|
rm -f $(COVERAGE_FILES) *.gcov
|
|
|
|
rm -rf coverage_report/
|
|
|
|
rm -f coverage.info
|
2018-05-17 10:56:52 +00:00
|
|
|
|
2018-05-26 06:58:01 +00:00
|
|
|
.PHONY: clean all test lib
|