mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-24 19:42:27 +03:00
* Add valgrind and string tests to host_tests Valgrind identified an error that was causing intermittent failures in the host tests, and can check for subtle memory access and allocation bugs. Add it to the standard host_test suite, and any errors will cause test failure. Also start adding string tests, since two undefined behaviors have been found so far just by inspection. * Add additional String tests Looks like a possible bug in the concatenation operator, need to verify expected behavior. * Remove verbose from valgrind run No need to be so chatty on the test. Errors were a little hard to spot. Go to normal verbosity. * Add lcov and more string tests LCOV and genhtml can generate nice HTML coverage charts hilighting test coverage issues in a much simpler way than gcov text format. Generate these automatically from gcov output. Add additional string creation and comparison tests. * Move String coverage to >50% Additional string tests and checks * 66% test coverage in String * Add allocation-unit-sized strings test Ensure that strings that are right on the edge of the allocation size are handled properly and account for trailing 0.
126 lines
3.1 KiB
Makefile
126 lines
3.1 KiB
Makefile
BINARY_DIRECTORY := bin
|
|
LCOV_DIRECTORY := lcov
|
|
OUTPUT_BINARY := $(BINARY_DIRECTORY)/host_tests
|
|
CORE_PATH := ../../cores/esp8266
|
|
|
|
# I wasn't able to build with clang when -coverage flag is enabled, forcing GCC on OS X
|
|
ifeq ($(shell uname -s),Darwin)
|
|
CC ?= gcc
|
|
CXX ?= g++
|
|
endif
|
|
GCOV ?= gcov
|
|
VALGRIND ?= valgrind
|
|
LCOV ?= lcov
|
|
GENHTML ?= genhtml
|
|
|
|
CORE_CPP_FILES := $(addprefix $(CORE_PATH)/,\
|
|
StreamString.cpp \
|
|
Stream.cpp \
|
|
WString.cpp \
|
|
Print.cpp \
|
|
FS.cpp \
|
|
spiffs_api.cpp \
|
|
pgmspace.cpp \
|
|
MD5Builder.cpp \
|
|
)
|
|
|
|
CORE_C_FILES := $(addprefix $(CORE_PATH)/,\
|
|
core_esp8266_noniso.c \
|
|
spiffs/spiffs_cache.c \
|
|
spiffs/spiffs_check.c \
|
|
spiffs/spiffs_gc.c \
|
|
spiffs/spiffs_hydrogen.c \
|
|
spiffs/spiffs_nucleus.c \
|
|
)
|
|
|
|
MOCK_CPP_FILES := $(addprefix common/,\
|
|
Arduino.cpp \
|
|
spiffs_mock.cpp \
|
|
WMath.cpp \
|
|
)
|
|
|
|
MOCK_C_FILES := $(addprefix common/,\
|
|
md5.c \
|
|
noniso.c \
|
|
)
|
|
|
|
INC_PATHS += $(addprefix -I, \
|
|
common \
|
|
$(CORE_PATH) \
|
|
)
|
|
|
|
TEST_CPP_FILES := \
|
|
fs/test_fs.cpp \
|
|
core/test_pgmspace.cpp \
|
|
core/test_md5builder.cpp \
|
|
core/test_string.cpp
|
|
|
|
CXXFLAGS += -std=c++11 -Wall -Werror -coverage -O0 -fno-common -g
|
|
CFLAGS += -std=c99 -Wall -Werror -coverage -O0 -fno-common -g
|
|
LDFLAGS += -coverage -O0
|
|
VALGRINDFLAGS += --leak-check=full --track-origins=yes --error-limit=no --show-leak-kinds=all --error-exitcode=999
|
|
|
|
remduplicates = $(strip $(if $1,$(firstword $1) $(call remduplicates,$(filter-out $(firstword $1),$1))))
|
|
|
|
C_SOURCE_FILES = $(MOCK_C_FILES) $(CORE_C_FILES)
|
|
CPP_SOURCE_FILES = $(MOCK_CPP_FILES) $(CORE_CPP_FILES) $(TEST_CPP_FILES)
|
|
C_OBJECTS = $(C_SOURCE_FILES:.c=.c.o)
|
|
|
|
CPP_OBJECTS_CORE = $(MOCK_CPP_FILES:.cpp=.cpp.o) $(CORE_CPP_FILES:.cpp=.cpp.o)
|
|
CPP_OBJECTS_TESTS = $(TEST_CPP_FILES:.cpp=.cpp.o)
|
|
|
|
CPP_OBJECTS = $(CPP_OBJECTS_CORE) $(CPP_OBJECTS_TESTS)
|
|
|
|
OBJECTS = $(C_OBJECTS) $(CPP_OBJECTS)
|
|
COVERAGE_FILES = $(OBJECTS:.o=.gc*)
|
|
|
|
all: build-info $(OUTPUT_BINARY) valgrind test gcov
|
|
|
|
test: $(OUTPUT_BINARY)
|
|
$(OUTPUT_BINARY)
|
|
|
|
clean: clean-objects clean-coverage
|
|
rm -rf $(BINARY_DIRECTORY)
|
|
|
|
clean-objects:
|
|
rm -rf $(OBJECTS)
|
|
|
|
clean-coverage:
|
|
rm -rf $(COVERAGE_FILES) $(LCOV_DIRECTORY) *.gcov
|
|
|
|
gcov: test
|
|
find $(CORE_PATH) -name "*.gcno" -exec $(GCOV) -r -pb {} +
|
|
|
|
valgrind: $(OUTPUT_BINARY)
|
|
mkdir -p $(LCOV_DIRECTORY)
|
|
$(LCOV) --directory ../../cores/esp8266/ --zerocounters
|
|
$(VALGRIND) $(VALGRINDFLAGS) $(OUTPUT_BINARY)
|
|
$(LCOV) --directory $(CORE_PATH) --capture --output-file $(LCOV_DIRECTORY)/app.info
|
|
$(GENHTML) $(LCOV_DIRECTORY)/app.info -o $(LCOV_DIRECTORY)
|
|
|
|
build-info:
|
|
@echo "-------- build tools info --------"
|
|
@echo "CC: " $(CC)
|
|
$(CC) -v
|
|
@echo "CXX: " $(CXX)
|
|
$(CXX) -v
|
|
@echo "GCOV: " $(GCOV)
|
|
$(GCOV) -v
|
|
@echo "----------------------------------"
|
|
|
|
$(BINARY_DIRECTORY):
|
|
mkdir -p $@
|
|
|
|
$(C_OBJECTS): %.c.o: %.c
|
|
$(CC) $(CFLAGS) $(INC_PATHS) -c -o $@ $<
|
|
|
|
$(CPP_OBJECTS): %.cpp.o: %.cpp
|
|
$(CXX) $(CXXFLAGS) $(INC_PATHS) -c -o $@ $<
|
|
|
|
$(BINARY_DIRECTORY)/core.a: $(C_OBJECTS) $(CPP_OBJECTS_CORE)
|
|
ar -rcu $@ $(C_OBJECTS) $(CPP_OBJECTS_CORE)
|
|
ranlib -c $@
|
|
|
|
$(OUTPUT_BINARY): $(BINARY_DIRECTORY) $(CPP_OBJECTS_TESTS) $(BINARY_DIRECTORY)/core.a
|
|
$(CXX) $(LDFLAGS) $(CPP_OBJECTS_TESTS) $(BINARY_DIRECTORY)/core.a $(LIBS) -o $(OUTPUT_BINARY)
|