Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add very simplistic leak test

  • Loading branch information...
commit 966cf423562247c9c1d07612887b903ee4264136 1 parent f038046
@lutter authored
Showing with 58 additions and 2 deletions.
  1. +1 −0  .gitignore
  2. +11 −2 tests/Makefile.am
  3. +46 −0 tests/leak.c
View
1  .gitignore
@@ -36,6 +36,7 @@ src/lexer.[ch]
src/augtool
src/augparse
tests/fatest
+tests/leak
tests/lens-*.sh
tests/test-api
tests/test-xpath
View
13 tests/Makefile.am
@@ -4,12 +4,16 @@ GNULIB_CFLAGS= -I $(top_srcdir)/gnulib/lib
AM_CFLAGS = $(AUGEAS_CFLAGS) $(WARN_CFLAGS) $(GNULIB_CFLAGS) \
$(LIBXML_CFLAGS) -I $(top_builddir)/src
+VALGRIND=libtool --mode=execute valgrind --quiet --leak-check=full
valgrind:
make check \
- VALGRIND="libtool --mode=execute valgrind --quiet --leak-check=full" \
+ VALGRIND="$(VALGRIND)" \
AUGPARSE=$(abs_top_builddir)/src/augparse \
AUGTOOL=$(abs_top_builddir)/src/augtool
- libtool --mode=execute valgrind --quiet --leak-check=full ./fatest
+ $(VALGRIND) ./fatest
+
+valgrind-leak: leak
+ $(TESTS_ENVIRONMENT) $(VALGRIND) ./leak
lens_tests = \
lens-sudoers.sh \
@@ -178,6 +182,8 @@ EXTRA_DIST = \
noinst_SCRIPTS = $(check_SCRIPTS)
+noinst_PROGRAMS = leak
+
check_PROGRAMS = fatest test-xpath test-load test-save test-api test-run
TESTS_ENVIRONMENT = \
@@ -208,6 +214,9 @@ test_api_LDADD = $(top_builddir)/src/libaugeas.la $(LIBXML_LIBS) $(GNULIB)
test_run_SOURCES = test-run.c cutest.c cutest.h $(top_srcdir)/src/memory.c $(top_srcdir)/src/memory.h
test_run_LDADD = $(top_builddir)/src/libaugeas.la $(LIBXML_LIBS) $(GNULIB)
+leak_SOURCES = leak.c
+leak_LDADD = $(top_builddir)/src/libaugeas.la $(LIBXML_LIBS) $(GNULIB)
+
FAILMALLOC_START ?= 1
FAILMALLOC_REP ?= 20
FAILMALLOC_PROG ?= ./fatest
View
46 tests/leak.c
@@ -0,0 +1,46 @@
+#include <config.h>
+#include "augeas.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+
+const char *abs_top_srcdir;
+const char *abs_top_builddir;
+char *root = NULL, *src_root = NULL, *lensdir = NULL;
+struct augeas *aug = NULL;
+
+
+#define die(msg) \
+ do { \
+ fprintf(stderr, "%s:%d: Fatal error: %s\n", __FILE__, __LINE__, msg); \
+ exit(EXIT_FAILURE); \
+ } while(0)
+
+
+int main (void)
+{
+ abs_top_srcdir = getenv("abs_top_srcdir");
+ if (abs_top_srcdir == NULL)
+ die("env var abs_top_srcdir must be set");
+
+ abs_top_builddir = getenv("abs_top_builddir");
+ if (abs_top_builddir == NULL)
+ die("env var abs_top_builddir must be set");
+
+ if (asprintf(&src_root, "%s/tests/root", abs_top_srcdir) < 0) {
+ die("failed to set src_root");
+ }
+
+ if (asprintf(&lensdir, "%s/lenses", abs_top_srcdir) < 0)
+ die("asprintf lensdir failed");
+
+
+ aug = aug_init (src_root, lensdir, AUG_NO_STDINC);
+ if (!aug) { perror ("aug_init"); exit (1); }
+ aug_close (aug);
+
+ free(root);
+ free(src_root);
+ free(lensdir);
+ return 0;
+}

0 comments on commit 966cf42

Please sign in to comment.
Something went wrong with that request. Please try again.