From 8014643b9e85eea148cf1706bad5d3a46d3bb1e7 Mon Sep 17 00:00:00 2001 From: Ming-Hung Tsai Date: Wed, 2 Jun 2021 18:03:50 +0800 Subject: [PATCH] [build] Allow running tests without the --enable-testing configuration - Make the test targets always available (test, unit-test, functional-test) - Cleanup include paths, and bring back the CPPFLAGS in commit 3e24cff that was overwritten by the merge ca8f6df (PR #60) - Introduce the dev-tools target for building testing/dbg tools individually - Leave the --enable-testing option for backward compatibility --- Makefile.in | 45 ++++++++++++++++++++---------------------- unit-tests/Makefile.in | 4 ++-- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/Makefile.in b/Makefile.in index 38879dd..b29551d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -20,15 +20,18 @@ V=@ PROGRAMS=\ bin/pdata_tools - -ifeq ("@TESTING@", "yes") -PROGRAMS += bin/pdata_tools_dev +DEV_TOOLS=\ + bin/pdata_tools_dev TESTLIBS=\ lib/libft.so -endif -.PHONY: all -all: $(PROGRAMS) $(TESTLIBS) +.PHONY: all dev-tools +all: $(PROGRAMS) +dev-tools: $(DEV_TOOLS) + +ifeq ("@TESTING@", "yes") +all += $(TESTLIB) +endif include contrib/Makefile @@ -185,7 +188,8 @@ CXXFLAGS+=@CXXOPTIMISE_FLAG@ CXXFLAGS+=@CXXDEBUG_FLAG@ CXXFLAGS+=@CXX_STRERROR_FLAG@ CXXFLAGS+=@LFS_FLAGS@ -INCLUDES+=-I$(TOP_BUILDDIR) -I$(TOP_DIR) -I$(TOP_DIR)/thin-provisioning +CPPFLAGS?=@CPPFLAGS@ +CPPFLAGS+=-I$(TOP_BUILDDIR) -I$(TOP_DIR) LIBS:=-laio -lexpat -lboost_iostreams -ldl DEV_LIBS:=-lncurses @@ -211,30 +215,21 @@ INSTALL_DIR = $(INSTALL) -m 755 -d INSTALL_PROGRAM = $(INSTALL) -m 755 INSTALL_DATA = $(INSTALL) -p -m 644 -ifeq ("@TESTING@", "yes") -TEST_INCLUDES=\ - -I$(TOP_DIR) \ - -Igoogletest/googlemock/include \ - -Igoogletest/googletest/include -else -TEST_INCLUDES= -endif - .SUFFIXES: .d .txt .8 %.o: %.cc @echo " [CXX] $<" @mkdir -p $(dir $@) - $(V) $(CXX) -c $(INCLUDES) $(CXXFLAGS) -o $@ $< - $(V) $(CXX) -MM -MT $(subst .cc,.o,$<) $(INCLUDES) $(TEST_INCLUDES) $(CXXFLAGS) $< > $*.$$$$; \ + $(V) $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) -o $@ $< + $(V) $(CXX) -MM -MT $(subst .cc,.o,$<) $(CPPFLAGS) $(CXXFLAGS) $< > $*.$$$$; \ sed 's,\([^ :]*\)\.o[ :]*,\1.o \1.gmo $* : Makefile ,g' < $*.$$$$ > $*.d; \ $(RM) $*.$$$$ %.o: %.c @echo " [CC] $<" @mkdir -p $(dir $@) - $(V) $(CC) -c $(INCLUDES) $(CFLAGS) -o $@ $< - $(V) $(CC) -MM -MT $(subst .cc,.o,$<) $(INCLUDES) $(TEST_INCLUDES) $(CFLAGS) $< > $*.$$$$; \ + $(V) $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $< + $(V) $(CC) -MM -MT $(subst .cc,.o,$<) $(CPPFLAGS) $(CFLAGS) $< > $*.$$$$; \ sed 's,\([^ :]*\)\.o[ :]*,\1.o \1.gmo $* : Makefile ,g' < $*.$$$$ > $*.d; \ $(RM) $*.$$$$ @@ -275,7 +270,7 @@ clean: find . -name \*.o -delete find . -name \*.gmo -delete find . -name \*.d -delete - $(RM) $(PROGRAMS) lib/*.a lib/*.so + $(RM) $(PROGRAMS) $(DEV_TOOLS) lib/*.a lib/*.so distclean: clean $(RM) config.cache config.log config.status configure.h version.h Makefile unit-tests/Makefile @@ -360,7 +355,8 @@ install-rust-tools: man8/thin_metadata_pack.8 man8/thin_metadata_unpack.8 rust-t $(INSTALL_DATA) man8/thin_metadata_pack.8 $(MANPATH)/man8 $(INSTALL_DATA) man8/thin_metadata_unpack.8 $(MANPATH)/man8 -ifeq ("@TESTING@", "yes") +#---------------------------------------------------------------- + include unit-tests/Makefile LIBFT_SOURCE=\ @@ -376,10 +372,11 @@ lib/libft.so: $(LIBFT_OBJECTS) .PHONEY: functional-test unit-test -functional-test: $(PROGRAMS) $(TESTLIBS) +functional-test: $(PROGRAMS) $(DEV_TOOLS) $(TESTLIBS) cd functional-tests && ./run-tests run test: functional-test unit-test -endif + +#---------------------------------------------------------------- -include $(DEPEND_FILES) diff --git a/unit-tests/Makefile.in b/unit-tests/Makefile.in index a8f1c8c..336c6a7 100644 --- a/unit-tests/Makefile.in +++ b/unit-tests/Makefile.in @@ -81,9 +81,9 @@ TEST_OBJECTS=$(subst .cc,.gmo,$(TEST_SOURCE)) %.gmo: %.cc @echo " [CXX] $<" @mkdir -p $(dir $@) - $(V) $(CXX) -c $(TEST_INCLUDES) $(CPPFLAGS) $(GMOCK_INCLUDES) $(CXXFLAGS) $(GMOCK_FLAGS) -o $@ $< + $(V) $(CXX) -c $(CPPFLAGS) $(GMOCK_INCLUDES) $(CXXFLAGS) $(GMOCK_FLAGS) -o $@ $< @echo " [DEP] $<" - $(V) $(CXX) -MM -MT $(subst .cc,.o,$<) $(TEST_INCLUDES) $(CPPFLAGS) $(GMOCK_INCLUDES) $(CXXFLAGS) $(GMOCK_FLAGS) $< > $*.$$$$; \ + $(V) $(CXX) -MM -MT $(subst .cc,.o,$<) $(CPPFLAGS) $(GMOCK_INCLUDES) $(CXXFLAGS) $(GMOCK_FLAGS) $< > $*.$$$$; \ sed 's,\([^ :]*\)\.o[ :]*,\1.o \1.gmo $* : Makefile ,g' < $*.$$$$ > $*.d; \ $(RM) $*.$$$$