Skip to content

Commit

Permalink
test/cpp_headers: autogenerate header test files
Browse files Browse the repository at this point in the history
Rather than requiring changes to a static list of header files, use the
GNU Make wildcard function to generate a .cpp file per header.

This also tests whether each header includes all of the system headers
for the types it uses.

Change-Id: I05b82510b194533672568019e138d7d1aad2e86b
Signed-off-by: Daniel Verkamp <[email protected]>
  • Loading branch information
danielverkamp committed Oct 3, 2016
1 parent b827279 commit d31df70
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 40 deletions.
2 changes: 1 addition & 1 deletion scripts/check_format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if hash astyle; then
rm -f astyle.log
touch astyle.log
astyle --options=.astylerc "*.c" >> astyle.log
astyle --options=.astylerc "*.cpp" >> astyle.log
astyle --options=.astylerc --exclude=test/cpp_headers "*.cpp" >> astyle.log
astyle --options=.astylerc "*.h" >> astyle.log
if grep -q "^Formatted" astyle.log; then
echo " errors detected"
Expand Down
1 change: 1 addition & 0 deletions test/cpp_headers/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.cpp
11 changes: 8 additions & 3 deletions test/cpp_headers/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,16 @@
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk

CXX_SRCS := cpp_headers.cpp
HEADERS := $(wildcard $(SPDK_ROOT_DIR)/include/spdk/*.h)
CXX_SRCS := $(patsubst %.h,%.cpp,$(notdir $(HEADERS)))

all : cpp_headers.o
%.cpp: $(SPDK_ROOT_DIR)/include/spdk/%.h
$(Q)echo " TEST_HEADER include/spdk/$(notdir $<)"; \
echo '#include "spdk/$(notdir $<)"' > $@

all : $(CXX_SRCS) $(OBJS)

clean :
$(CLEAN_C)
$(CLEAN_C) $(CXX_SRCS)

include $(SPDK_ROOT_DIR)/mk/spdk.deps.mk
36 changes: 0 additions & 36 deletions test/cpp_headers/cpp_headers.cpp

This file was deleted.

0 comments on commit d31df70

Please sign in to comment.