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 <daniel.verkamp@intel.com>
This commit is contained in:
Daniel Verkamp 2016-09-30 15:55:22 -07:00
parent b827279285
commit d31df7042a
4 changed files with 10 additions and 40 deletions

View File

@ -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"

1
test/cpp_headers/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.cpp

View File

@ -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

View File

@ -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"
}