[PATCH 3/6] Enable memory checking during unit testing

Alan Coopersmith alan.coopersmith at oracle.com
Fri Oct 28 17:34:35 PDT 2011


Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 configure.ac         |   16 ++++++++++++++++
 test/Makefile.am     |    1 +
 test/xi2/Makefile.am |    1 +
 3 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/configure.ac b/configure.ac
index 63d59f9..2d35046 100644
--- a/configure.ac
+++ b/configure.ac
@@ -93,6 +93,22 @@ if  test "x$GCC" = xyes ; then
     XSERVER_CFLAGS="$XSERVER_CFLAGS -fno-strict-aliasing"
 fi
 
+# Memory checking support (used in unit tests)
+case $host_os in
+     solaris*)
+        AC_CHECK_LIB([umem], [umem_alloc],
+            [MALLOC_DEBUG_ENV='LD_PRELOAD=libumem.so UMEM_DEBUG=default'])
+        ;;
+     *-gnu*) # GNU libc - Value is used as a single byte bit pattern,
+        # both directly and inverted, so should not be 0 or 255.
+        MALLOC_DEBUG_ENV='MALLOC_PERTURB_=15'
+        ;;
+     *bsd*|darwin*)
+        MALLOC_DEBUG_ENV='MallocPreScribble=1 MallocScribble=1'
+        ;;
+esac
+AC_SUBST([MALLOC_DEBUG_ENV])
+
 dnl Check for dtrace program (needed to build Xserver dtrace probes)
 dnl Also checks for <sys/sdt.h>, since some Linux distros have an 
 dnl ISDN trace program named dtrace
diff --git a/test/Makefile.am b/test/Makefile.am
index 689dd7f..6c6ca9a 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -5,6 +5,7 @@ noinst_PROGRAMS = xkb input xtest list misc fixes xfree86
 check_LTLIBRARIES = libxservertest.la
 
 TESTS=$(noinst_PROGRAMS)
+TESTS_ENVIRONMENT = $(MALLOC_DEBUG_ENV)
 
 AM_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@
 INCLUDES = $(XORG_INCS) -I$(top_srcdir)/hw/xfree86/parser \
diff --git a/test/xi2/Makefile.am b/test/xi2/Makefile.am
index b15d8ba..1d0db73 100644
--- a/test/xi2/Makefile.am
+++ b/test/xi2/Makefile.am
@@ -13,6 +13,7 @@ noinst_PROGRAMS =  \
         protocol-eventconvert
 
 TESTS=$(noinst_PROGRAMS)
+TESTS_ENVIRONMENT = $(MALLOC_DEBUG_ENV)
 
 AM_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@
 INCLUDES = @XORG_INCS@
-- 
1.7.3.2



More information about the xorg-devel mailing list