components/nvs: fix host build with GCC 4.9, add coverage report generation

This commit is contained in:
Ivan Grokhotkov 2016-08-22 14:16:21 +08:00
parent 7998b6ca2e
commit a65e019451
4 changed files with 29 additions and 12 deletions

View File

@ -1 +1,7 @@
test/test_nvs test/test_nvs
test/coverage
test/coverage.info
*.gcno
*.gcda
*.gcov
*.o

View File

@ -1,5 +1,5 @@
TEST_PROGRAM=test_nvs TEST_PROGRAM=test_nvs
all: test all: $(TEST_PROGRAM)
SOURCE_FILES = \ SOURCE_FILES = \
$(addprefix ../src/, \ $(addprefix ../src/, \
@ -14,15 +14,18 @@ SOURCE_FILES = \
test_spi_flash_emulation.cpp \ test_spi_flash_emulation.cpp \
test_intrusive_list.cpp \ test_intrusive_list.cpp \
test_nvs.cpp \ test_nvs.cpp \
crc.cpp \ crc.cpp \
main.cpp main.cpp
CPPFLAGS += -I../include -I../src -I./ -I../../esp32/include -I ../../spi_flash/include CPPFLAGS += -I../include -I../src -I./ -I../../esp32/include -I ../../spi_flash/include -fprofile-arcs -ftest-coverage
CFLAGS += -fprofile-arcs -ftest-coverage
CXXFLAGS += -std=c++11 -Wall -Werror CXXFLAGS += -std=c++11 -Wall -Werror
LDFLAGS += -lstdc++ LDFLAGS += -lstdc++ -Wall -fprofile-arcs -ftest-coverage
OBJ_FILES = $(SOURCE_FILES:.cpp=.o) OBJ_FILES = $(SOURCE_FILES:.cpp=.o)
COVERAGE_FILES = $(OBJ_FILES:.o=.gc*)
$(OBJ_FILES): %.o: %.cpp $(OBJ_FILES): %.o: %.cpp
$(TEST_PROGRAM): $(OBJ_FILES) $(TEST_PROGRAM): $(OBJ_FILES)
@ -34,7 +37,20 @@ $(OUTPUT_DIR):
test: $(TEST_PROGRAM) test: $(TEST_PROGRAM)
./$(TEST_PROGRAM) ./$(TEST_PROGRAM)
$(COVERAGE_FILES): $(TEST_PROGRAM) test
coverage.info: $(COVERAGE_FILES)
find ../src/ -name "*.gcno" -exec gcov -r -pb {} +
lcov --capture --directory ../src --no-external --output-file coverage.info
coverage_report: coverage.info
genhtml coverage.info --output-directory coverage_report
@echo "Coverage report is in coverage_report/index.html"
clean: clean:
rm -f $(OBJ_FILES) $(TEST_PROGRAM) rm -f $(OBJ_FILES) $(TEST_PROGRAM)
rm -f $(COVERAGE_FILES) *.gcov
rm -rf coverage_report/
rm -f coverage.info
.PHONY: clean all test .PHONY: clean all test

View File

@ -74,7 +74,7 @@ public:
return false; return false;
} }
if (mFailCountdown != SIZE_T_MAX && mFailCountdown-- == 0) { if (mFailCountdown != SIZE_MAX && mFailCountdown-- == 0) {
return false; return false;
} }
@ -108,7 +108,7 @@ public:
return false; return false;
} }
if (mFailCountdown != SIZE_T_MAX && mFailCountdown-- == 0) { if (mFailCountdown != SIZE_MAX && mFailCountdown-- == 0) {
return false; return false;
} }
@ -203,7 +203,7 @@ protected:
size_t mLowerSectorBound = 0; size_t mLowerSectorBound = 0;
size_t mUpperSectorBound = 0; size_t mUpperSectorBound = 0;
size_t mFailCountdown = SIZE_T_MAX; size_t mFailCountdown = SIZE_MAX;
}; };

View File

@ -554,11 +554,6 @@ public:
static_assert(nKeys == sizeof(types) / sizeof(types[0]), ""); static_assert(nKeys == sizeof(types) / sizeof(types[0]), "");
static_assert(nKeys == sizeof(values) / sizeof(values[0]), ""); static_assert(nKeys == sizeof(values) / sizeof(values[0]), "");
auto generateRandomString = [](char* dst, size_t size) {
size_t len = 0;
};
auto randomRead = [&](size_t index) -> esp_err_t { auto randomRead = [&](size_t index) -> esp_err_t {
switch (types[index]) { switch (types[index]) {
case ItemType::I32: case ItemType::I32: