Build and run tests with sanitizers enabled.
authorDavin McCall <davmac@davmac.org>
Tue, 19 Dec 2017 10:01:07 +0000 (10:01 +0000)
committerDavin McCall <davmac@davmac.org>
Fri, 5 Jan 2018 07:29:45 +0000 (07:29 +0000)
mconfig
src/tests/Makefile

diff --git a/mconfig b/mconfig
index 48c8e984e9aa1751120b89527ae8a936a9af7682..b9a65e24fd757ecc068a58f8c2fa8504714c864c 100644 (file)
--- 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:
index b9f4da72f1e4f5a8fa33249563599d405e2b3109..ad2cfcad8ff2e6905f3f30a8a8dbc58aa6a9bf28 100644 (file)
@@ -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