[augeas-devel] augeas: master - build: support for running with libfailmalloc preloaded

David Lutterkort lutter at fedoraproject.org
Thu Oct 1 00:23:13 UTC 2009


Gitweb:        http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=e5e7ee7ab6c88cb3e2a6ae4409f4ae4c1d5f4bd7
Commit:        e5e7ee7ab6c88cb3e2a6ae4409f4ae4c1d5f4bd7
Parent:        b32b2eb1baa0811d82f3e9a93f8fcb925a7b9000
Author:        David Lutterkort <lutter at redhat.com>
AuthorDate:    Sat Jan 10 21:32:24 2009 -0800
Committer:     David Lutterkort <lutter at redhat.com>
CommitterDate: Wed Sep 30 12:10:47 2009 -0700

build: support for running with libfailmalloc preloaded

Add --with-failmalloc=LIB configure option and failmalloc targets to run
select programs with failing allocations.
---
 Makefile.am       |    2 +-
 Makefile.inc      |   30 ++++++++++++++++++++++++++++++
 configure.ac      |    9 +++++++++
 src/Makefile.am   |    7 ++++++-
 tests/Makefile.am |   12 +++++++++---
 5 files changed, 55 insertions(+), 5 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 5a531f0..080a75b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -8,7 +8,7 @@ lenstestdir=$(datadir)/augeas/lenses/dist/tests
 dist_lens_DATA=$(wildcard lenses/*.aug)
 dist_lenstest_DATA=$(wildcard lenses/tests/*.aug)
 
-EXTRA_DIST=augeas.spec build/aux/move-if-change
+EXTRA_DIST=augeas.spec build/aux/move-if-change Makefile.am
 
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = augeas.pc
diff --git a/Makefile.inc b/Makefile.inc
new file mode 100644
index 0000000..a791ae5
--- /dev/null
+++ b/Makefile.inc
@@ -0,0 +1,30 @@
+# -*- Makefile-automake -*-
+#
+# Support for running programs with failmalloc preloaded. Include in other
+# automake files and make sure the following variables are set:
+#
+# FAILMALLOC_START - number of first FAILMALLOC_INTERVAL
+# FAILMALLOC_REP   - how often to repeat with increasing FAILMALLOC_INTERVAL
+# FAILMALLOC_PROG  - the program to run with linfailmalloc preloaded
+
+if WITH_FAILMALLOC
+failmalloc: failmalloc-run
+else
+failmalloc: failmalloc-error
+endif
+
+failmalloc-run: $(FAILMALLOC_PROG)
+	@(echo "Running $(FAILMALLOC_PROG) with failmalloc";    \
+      for i in $$(seq $(FAILMALLOC_START) $$(expr $(FAILMALLOC_START) + $(FAILMALLOC_REP) - 1)) ; do \
+	  resp=$$(libtool --mode=execute env LD_PRELOAD=$(LIBFAILMALLOC) FAILMALLOC_INTERVAL=$$i $(FAILMALLOC_PROG));        \
+	  status=$$?;                                          \
+	  if [ $$status -ne 0 -a $$status -ne 2 ] ;	then       \
+	    printf "%5d FAIL %3d %s\n" $$i $$status "$$resp" ; \
+	  elif [ x$(V) = x1 -o $$(( $$i % 100 )) -eq 0 ] ; then \
+	    printf "%5d PASS %s\n" $$i "$$resp" ;              \
+	  fi                                                   \
+	done)
+
+failmalloc-error:
+	@(echo "You need to turn on failmalloc support with --with-failmalloc"; \
+	  exit 1)
diff --git a/configure.ac b/configure.ac
index 4493779..4184785 100644
--- a/configure.ac
+++ b/configure.ac
@@ -46,6 +46,15 @@ AC_ARG_WITH([pdfdocs],
 AC_SUBST(PDFLATEX)
 AC_SUBST(PDFDOCS)
 
+dnl Support for memory tests with failmalloc
+AC_ARG_WITH([failmalloc],
+  [AS_HELP_STRING([--with-failmalloc=FAILMALLOC],
+     [enable failmalloc test targets and use the failmalloc library FAILMALLOC])],
+  [AC_SUBST([LIBFAILMALLOC], ["$with_failmalloc"])],
+  [with_failmalloc=no])
+
+AM_CONDITIONAL([WITH_FAILMALLOC], [test x$with_failmalloc != xno])
+
 dnl Version info in libtool's notation
 AC_SUBST([LIBAUGEAS_VERSION_INFO], [9:2:9])
 AC_SUBST([LIBFA_VERSION_INFO], [2:0:1])
diff --git a/src/Makefile.am b/src/Makefile.am
index e835e31..68d13cb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,3 @@
-
 GNULIB= ../gnulib/lib/libgnu.la
 GNULIB_CFLAGS= -I $(top_srcdir)/gnulib/lib
 
@@ -51,6 +50,12 @@ libfa_la_LDFLAGS = $(FA_VERSION_SCRIPT) -version-info $(LIBFA_VERSION_INFO)
 liblexer_la_SOURCES = lexer.l
 liblexer_la_CFLAGS = $(AM_CFLAGS) -Wno-error
 
+FAILMALLOC_START ?= 1
+FAILMALLOC_REP   ?= 20
+FAILMALLOC_PROG ?= ./augtool
+
+include $(top_srcdir)/Makefile.inc
+
 # Generate datadir.h. AUGEAS_LENS_DIR in internal.h depends on
 # the value of DATADIR
 internal.h: datadir.h
diff --git a/tests/Makefile.am b/tests/Makefile.am
index eab9db3..dc57dc8 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -117,14 +117,20 @@ TESTS = augtest $(check_SCRIPTS) $(check_PROGRAMS)
 
 INCLUDES = -I$(top_srcdir)/src
 
-fatest_SOURCES = fatest.c cutest.c cutest.h
+fatest_SOURCES = fatest.c cutest.c cutest.h $(top_srcdir)/src/memory.c $(top_srcdir)/src/memory.h
 fatest_LDADD = $(top_builddir)/src/libaugeas.la $(GNULIB)
 
 test_xpath_SOURCES = test-xpath.c $(top_srcdir)/src/memory.c
 test_xpath_LDADD = $(top_builddir)/src/libaugeas.la $(GNULIB)
 
-test_load_SOURCES = test-load.c cutest.c cutest.h
+test_load_SOURCES = test-load.c cutest.c cutest.h $(top_srcdir)/src/memory.c $(top_srcdir)/src/memory.h
 test_load_LDADD = $(top_builddir)/src/libaugeas.la $(GNULIB)
 
-test_save_SOURCES = test-save.c cutest.c cutest.h
+test_save_SOURCES = test-save.c cutest.c cutest.h $(top_srcdir)/src/memory.c $(top_srcdir)/src/memory.h
 test_save_LDADD = $(top_builddir)/src/libaugeas.la $(GNULIB)
+
+FAILMALLOC_START ?= 1
+FAILMALLOC_REP   ?= 20
+FAILMALLOC_PROG ?= ./fatest
+
+include $(top_srcdir)/Makefile.inc




More information about the augeas-devel mailing list