From d31df7042ae629b69e09c4dd289b3d811670ddb5 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Fri, 30 Sep 2016 15:55:22 -0700 Subject: [PATCH] test/cpp_headers: autogenerate header test files 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 --- scripts/check_format.sh | 2 +- test/cpp_headers/.gitignore | 1 + test/cpp_headers/Makefile | 11 +++++++--- test/cpp_headers/cpp_headers.cpp | 36 -------------------------------- 4 files changed, 10 insertions(+), 40 deletions(-) create mode 100644 test/cpp_headers/.gitignore delete mode 100644 test/cpp_headers/cpp_headers.cpp diff --git a/scripts/check_format.sh b/scripts/check_format.sh index 6151fbd4360..6563b19a200 100755 --- a/scripts/check_format.sh +++ b/scripts/check_format.sh @@ -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" diff --git a/test/cpp_headers/.gitignore b/test/cpp_headers/.gitignore new file mode 100644 index 00000000000..ce1da4c53c0 --- /dev/null +++ b/test/cpp_headers/.gitignore @@ -0,0 +1 @@ +*.cpp diff --git a/test/cpp_headers/Makefile b/test/cpp_headers/Makefile index d27d2692761..76e77469eee 100644 --- a/test/cpp_headers/Makefile +++ b/test/cpp_headers/Makefile @@ -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 diff --git a/test/cpp_headers/cpp_headers.cpp b/test/cpp_headers/cpp_headers.cpp deleted file mode 100644 index 4893dd1b17f..00000000000 --- a/test/cpp_headers/cpp_headers.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// Make sure all of the SPDK public headers compile as C++ - -extern "C" { -#include "spdk/assert.h" -#include "spdk/barrier.h" -#include "spdk/bdev.h" -#include "spdk/bit_array.h" -#include "spdk/conf.h" -#include "spdk/copy_engine.h" -#include "spdk/endian.h" -#include "spdk/event.h" -#include "spdk/fd.h" -#include "spdk/gpt_spec.h" -#include "spdk/ioat.h" -#include "spdk/ioat_spec.h" -#include "spdk/iscsi_spec.h" -#include "spdk/json.h" -#include "spdk/jsonrpc.h" -#include "spdk/likely.h" -#include "spdk/log.h" -#include "spdk/mmio.h" -#include "spdk/net.h" -#include "spdk/nvme.h" -#include "spdk/nvme_intel.h" -#include "spdk/nvme_spec.h" -#include "spdk/nvmf_spec.h" -#include "spdk/pci.h" -#include "spdk/pci_ids.h" -#include "spdk/queue.h" -#include "spdk/rpc.h" -#include "spdk/scsi.h" -#include "spdk/scsi_spec.h" -#include "spdk/string.h" -#include "spdk/trace.h" -#include "spdk/vtophys.h" -}