aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Levon <john.levon@nutanix.com>2021-02-04 10:07:53 +0000
committerGitHub <noreply@github.com>2021-02-04 10:07:53 +0000
commit02dda3178812eaca7384a88f078233067ca3a2f1 (patch)
tree26e98c60ce090bab4be25cc6bf25a001217b2da9
parent8f464f0f52ac4c10b1c10376d26eddc644492966 (diff)
downloadlibvfio-user-02dda3178812eaca7384a88f078233067ca3a2f1.zip
libvfio-user-02dda3178812eaca7384a88f078233067ca3a2f1.tar.gz
libvfio-user-02dda3178812eaca7384a88f078233067ca3a2f1.tar.bz2
add AddressSanitizer run (#291)
Run unit tests with -fsanitize-address too. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
-rw-r--r--Makefile9
-rwxr-xr-xtest/test-client-server.sh9
2 files changed, 17 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index f45d824..2baaee8 100644
--- a/Makefile
+++ b/Makefile
@@ -37,6 +37,12 @@ else
CMAKE_BUILD_TYPE = Release
endif
+ifdef WITH_ASAN
+ CC = clang
+ CFLAGS += -fsanitize=address
+ LDFLAGS += -fsanitize=address
+endif
+
ifeq ($(VERBOSE),)
MAKEFLAGS += -s
endif
@@ -63,6 +69,8 @@ pre-push: realclean
make realclean
make test CC=clang
make test CC=clang BUILD_TYPE=rel
+ make realclean
+ make test WITH_ASAN=1
realclean:
rm -rf $(BUILD_DIR_BASE)
@@ -75,6 +83,7 @@ force_cmake: $(BUILD_DIR)/Makefile
$(BUILD_DIR)/Makefile:
mkdir -p $(BUILD_DIR)
cd $(BUILD_DIR); $(CMAKE) \
+ -D "CMAKE_C_COMPILER:STRING=$(CC)" \
-D "CMAKE_C_FLAGS:STRING=$(CFLAGS)" \
-D "CMAKE_BUILD_TYPE:STRING=$(CMAKE_BUILD_TYPE)" \
-D "CMAKE_INSTALL_PREFIX=$(INSTALL_PREFIX)" \
diff --git a/test/test-client-server.sh b/test/test-client-server.sh
index bda91a2..866fd95 100755
--- a/test/test-client-server.sh
+++ b/test/test-client-server.sh
@@ -2,7 +2,14 @@
set -e
-valgrind="valgrind --quiet --trace-children=yes --error-exitcode=1 --leak-check=full"
+#
+# ASAN and valgrind, understandably, don't get along.
+#
+if [ "$WITH_ASAN" = 1 ]; then
+ valgrind=""
+else
+ valgrind="valgrind --quiet --trace-children=yes --error-exitcode=1 --leak-check=full"
+fi
sock="/tmp/vfio-user.sock"
rm -f ${sock}*