From: Ben Pfaff <blp@cs.stanford.edu>
Date: Thu, 17 Jan 2019 03:08:46 +0000 (-0800)
Subject: tests: Add valgrind and Leak Sanitizer suppression files.
X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f17f2c47873f53febefc6499710a8063f615ecc;p=pspp

tests: Add valgrind and Leak Sanitizer suppression files.

Otherwise any of the tests that use Cairo for PDF output end up with a
bunch of leaks due to libfontconfig weirdness.
---

diff --git a/tests/atlocal.in b/tests/atlocal.in
index 2a8a0eafbe..da7707139c 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -76,3 +76,7 @@ if test X"$RUNNER" = Xwine; then
         $pspp_diff -w  "$@"
     }
 fi
+
+# Enable leak suppressions for Address Sanitizer/Leak Sanitizer.
+LSAN_OPTIONS="suppressions=$abs_top_srcdir/tests/lsan.supp print_suppressions=0"
+export LSAN_OPTIONS
diff --git a/tests/automake.mk b/tests/automake.mk
index 116e32c217..50525848f0 100644
--- a/tests/automake.mk
+++ b/tests/automake.mk
@@ -468,9 +468,10 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac
 	} >'$(srcdir)/package.m4'
 
 check-valgrind:
-	$(MAKE) check RUNNER='$(SHELL) $(abs_top_builddir)/libtool --mode=execute valgrind --log-file=valgrind.%p --leak-check=full --num-callers=20' TESTSUITEFLAGS='$(TESTSUITEFLAGS) -d'
+	$(MAKE) check RUNNER='$(SHELL) $(abs_top_builddir)/libtool --mode=execute valgrind --log-file=valgrind.%p --leak-check=full --num-callers=20 --suppressions=$(abs_top_srcdir)/tests/valgrind.supp --read-inline-info=yes --read-var-info=yes' TESTSUITEFLAGS='$(TESTSUITEFLAGS) -d'
 	@echo
 	@echo '--------------------------------'
 	@echo 'Valgrind output is in:'
 	@echo 'tests/testsuite.dir/*/valgrind.*'
 	@echo '--------------------------------'
+EXTRA_DIST += tests/valgrind.supp tests/lsan.supp
diff --git a/tests/lsan.supp b/tests/lsan.supp
new file mode 100644
index 0000000000..8fceb61775
--- /dev/null
+++ b/tests/lsan.supp
@@ -0,0 +1 @@
+leak:libfontconfig
diff --git a/tests/valgrind.supp b/tests/valgrind.supp
new file mode 100644
index 0000000000..b2423bab84
--- /dev/null
+++ b/tests/valgrind.supp
@@ -0,0 +1,22 @@
+# libfontconfig uses offsets instead of pointers so valgrind doesn't
+# recognize when blocks are still in use
+{
+    fontconfig
+    Memcheck:Leak
+    ...
+    fun:FcFontRenderPrepare
+}
+{
+    fontconfig2
+    Memcheck:Leak
+    fun:realloc
+    obj:*libfontconfig.so.*
+}
+{
+    fontconfig3
+    Memcheck:Leak
+    fun:malloc
+    obj:*libfontconfig.so.*
+    ...
+    fun:XML_ParseBuffer
+}