From cc7f3feed5d4db5af52287ad26b1b977a03f4db0 Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Tue, 19 Dec 2017 10:01:07 +0000 Subject: [PATCH] Build and run tests with sanitizers enabled. --- mconfig | 2 ++ src/tests/Makefile | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/mconfig b/mconfig index 48c8e98..b9a65e2 100644 --- a/mconfig +++ b/mconfig @@ -4,12 +4,14 @@ CXX=g++ CXXOPTS=-D_GLIBCXX_USE_CXX11_ABI=1 -std=gnu++11 -Os -Wall -Wno-invalid-offsetof -fno-rtti EXTRA_LIBS= BUILD_SHUTDOWN=yes +SANITIZEOPTS=-fsanitize=address,undefined # OpenBSD, tested with GCC 4.9.3 and gmake: #CXX=clang++ #CXXOPTS=-std=gnu++11 -Os -Wall -fno-rtti #EXTRA_LIBS= #BUILD_SHUTDOWN=no +#SANITIZEOPTS= # (shutdown command not available for OpenBSD yet). # MacOS: use Linux settings, but don't build shutdown: diff --git a/src/tests/Makefile b/src/tests/Makefile index b9f4da7..ad2cfca 100644 --- a/src/tests/Makefile +++ b/src/tests/Makefile @@ -1,7 +1,7 @@ -include ../../mconfig objects = tests.o -parent_objs = ../service.o ../control.o ../dinit-log.o ../load_service.o ../dinit.o +parent_objs = service.o control.o dinit-log.o load_service.o dinit.o check: build-tests ./tests @@ -9,10 +9,13 @@ check: build-tests build-tests: tests tests: $(objects) $(parent_objs) - $(CXX) -o tests tests.o $(parent_objs) $(EXTRA_LIBS) + $(CXX) $(SANITIZEOPTS) -o tests tests.o $(parent_objs) $(EXTRA_LIBS) $(objects): %.o: %.cc - $(CXX) $(CXXOPTS) -I.. -I../dasynq -c $< -o $@ + $(CXX) $(CXXOPTS) $(SANITIZEOPTS) -I.. -I../dasynq -c $< -o $@ + +$(parent_objs): %.o: ../%.cc + $(CXX) $(CXXOPTS) $(SANITIZEOPTS) -I.. -I../dasynq -c $< -o $@ clean: rm -f *.o *.d -- 2.25.1