summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES1
-rw-r--r--Makefile.am7
-rwxr-xr-xconfigure.ac28
-rw-r--r--popt-vg.supp163
-rwxr-xr-xtestit.sh9
5 files changed, 204 insertions, 4 deletions
diff --git a/CHANGES b/CHANGES
index b752374..851f490 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,5 @@
1.17 -> 2.0:
+ - devzero2000: added --enable-valgrind autoconf option
- Fixed VPATH building with arbitrary directory structure
- devzero2000: some minor fix to autofu and also a minor portability problem on AIX
with the native compiler
diff --git a/Makefile.am b/Makefile.am
index 7f51445..3386862 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -32,7 +32,10 @@ test2_LDADD = $(top_builddir)/$(usrlib_LTLIBRARIES)
tdict_LDADD = $(top_builddir)/$(usrlib_LTLIBRARIES)
TESTS_ENVIRONMENT = top_srcdir=$(top_srcdir) testpoptrc="$(top_srcdir)/test-poptrc" PATH=.:../src:$$PATH \
- $(SHELL)
+ $(VALGRIND_ENVIRONMENT) \
+ $(SHELL)
+
+
TESTS = $(top_builddir)/testit.sh
include_HEADERS = popt.h
@@ -58,7 +61,7 @@ distclean-local:
rm -rf .ccache
clean-local:
- rm -rf doxygen *.gcda *.gcno lcov-result
+ rm -rf doxygen *.gcda *.gcno lcov-result popt-valgrind-result
if HAVE_SPLINT
lint:
diff --git a/configure.ac b/configure.ac
index 70bfb3b..ae197cb 100755
--- a/configure.ac
+++ b/configure.ac
@@ -103,6 +103,34 @@ popt_CFLAGS_ADD([-D_REENTRANT], [POPT_CFLAGS])
# Finally put an AC_SUBST for all the CFLAGS above
AC_SUBST([POPT_CFLAGS])
+# Support for running test cases using valgrind:
+
+use_valgrind=false
+VALGRIND_ENVIRONMENT=""
+AC_ARG_ENABLE(valgrind,
+[ --enable-valgrind Use valgrind when running unit tests. ],
+[ use_valgrind=true ])
+
+AS_IF([ test x"$use_valgrind" = x"true" ],
+ [
+ AC_CHECK_PROG(HAVE_VALGRIND, valgrind, yes, no)
+ AS_IF([ test x$HAVE_VALGRIND = no ],
+ [
+ AC_MSG_ERROR([You have asked for Valgrind support but Valgrind not found in PATH. ])
+ ],
+ [
+ AS_IF([ test x$enable_shared = xyes ],
+ [
+ VALGRIND_ENVIRONMENT="libtool --mode=execute "
+ ]
+ )
+ VALGRIND_ENVIRONMENT="$VALGRIND_ENVIRONMENT valgrind -q --error-exitcode=3 --leak-check=yes --leak-check=full --log-file=popt-valgrind-result --suppressions=\$(srcdir)/popt-vg.supp "
+ AC_SUBST([VALGRIND_ENVIRONMENT])
+ ])
+ ])
+
+AM_CONDITIONAL([USE_VALGRIND], [test x$use_valgrind != no])
+
# Checks for doxygen support.
AC_PATH_PROG(DOXYGEN, doxygen, NO_DOXYGEN)
AC_ARG_ENABLE(doxygen,
diff --git a/popt-vg.supp b/popt-vg.supp
new file mode 100644
index 0000000..c0ad927
--- /dev/null
+++ b/popt-vg.supp
@@ -0,0 +1,163 @@
+{
+ bashMemLeak1
+ Memcheck:Leak
+ fun:malloc
+ fun:xmalloc
+ fun:execute_command_internal
+ fun:parse_and_execute
+ fun:command_substitute
+ obj:/bin/bash
+ obj:/bin/bash
+ fun:expand_word_unsplit
+ obj:/bin/bash
+ fun:execute_command_internal
+ fun:execute_command
+ fun:execute_command_internal
+}
+{
+ bashMemLeak2
+ Memcheck:Leak
+ fun:malloc
+ fun:xmalloc
+ fun:execute_command_internal
+ fun:execute_command
+ obj:/bin/bash
+ fun:execute_command_internal
+ fun:execute_command
+ fun:reader_loop
+ fun:main
+}
+{
+ bashMemLeak3
+ Memcheck:Leak
+ fun:malloc
+ fun:xmalloc
+ obj:/bin/bash
+ fun:execute_command_internal
+ obj:/bin/bash
+ obj:/bin/bash
+ fun:execute_command_internal
+ fun:parse_and_execute
+ fun:command_substitute
+ obj:/bin/bash
+ obj:/bin/bash
+ fun:expand_string_assignment
+}
+{
+ bashMemLeak4
+ Memcheck:Leak
+ fun:malloc
+ fun:xmalloc
+ fun:execute_command_internal
+ fun:parse_and_execute
+ fun:command_substitute
+ obj:/bin/bash
+ obj:/bin/bash
+ fun:expand_word_unsplit
+ obj:/bin/bash
+ fun:execute_command_internal
+ fun:execute_command
+ fun:execute_command_internal
+}
+{
+ bashMemLeak5
+ Memcheck:Leak
+ fun:malloc
+ fun:xmalloc
+ fun:execute_command_internal
+ fun:execute_command
+ obj:/bin/bash
+ fun:execute_command_internal
+ fun:execute_command
+ fun:reader_loop
+ fun:main
+}
+{
+ bashMemLeak6
+ Memcheck:Leak
+ fun:malloc
+ fun:xmalloc
+ obj:/bin/bash
+ fun:execute_command_internal
+ obj:/bin/bash
+ obj:/bin/bash
+ fun:execute_command_internal
+ fun:parse_and_execute
+ fun:command_substitute
+ obj:/bin/bash
+ obj:/bin/bash
+ fun:expand_string_assignment
+}
+{
+ bashMemLeak7
+ Memcheck:Leak
+ fun:malloc
+ fun:xmalloc
+ fun:execute_command_internal
+ fun:parse_and_execute
+ fun:command_substitute
+ obj:/bin/bash
+ obj:/bin/bash
+ fun:expand_word_unsplit
+ obj:/bin/bash
+ fun:execute_command_internal
+ fun:execute_command
+ fun:execute_command_internal
+}
+{
+ bashMemLeak8
+ Memcheck:Leak
+ fun:malloc
+ fun:xmalloc
+ fun:execute_command_internal
+ fun:execute_command
+ obj:/bin/bash
+ fun:execute_command_internal
+ fun:execute_command
+ fun:reader_loop
+ fun:main
+}
+{
+ bashMemLeak9
+ Memcheck:Leak
+ fun:malloc
+ fun:xmalloc
+ obj:/bin/bash
+ fun:execute_command_internal
+ obj:/bin/bash
+ obj:/bin/bash
+ fun:execute_command_internal
+ fun:parse_and_execute
+ fun:command_substitute
+ obj:/bin/bash
+ obj:/bin/bash
+ fun:expand_string_assignment
+}
+{
+ bashMemLeak10
+ Memcheck:Leak
+ fun:malloc
+ fun:xmalloc
+ fun:execute_command_internal
+ fun:parse_and_execute
+ fun:command_substitute
+ obj:/bin/bash
+ obj:/bin/bash
+ fun:expand_word_unsplit
+ obj:/bin/bash
+ fun:execute_command_internal
+ fun:execute_command
+ fun:execute_command_internal
+}
+{
+ bashMemLeak11
+ Memcheck:Leak
+ fun:malloc
+ fun:xmalloc
+ obj:/bin/bash
+ fun:yyparse
+ fun:parse_command
+ fun:read_command
+ fun:reader_loop
+ fun:main
+}
diff --git a/testit.sh b/testit.sh
index c0788f5..50aea34 100755
--- a/testit.sh
+++ b/testit.sh
@@ -57,6 +57,7 @@ srcdir=$builddir
cd ${srcdir}
test1=${builddir}/test1
echo "Running tests in `pwd`"
+[ x${VALGRIND_ENVIRONMENT} != x ] && echo "Under Valgrind with parameter $VALGRIND_ENVIRONMENT"
#make -q testcases
@@ -190,7 +191,11 @@ Help options:
#run_diff test3 "test3 - 51" test3-data/01.input test3-data/01.answer
#run_diff test3 "test3 - 52" test3-data/02.input test3-data/02.answer
-#run_diff test3 "test3 - 53" test3-data/03.input test3-data/03.answer
+#run_diff test3 "test3 - 53" test3-data/03.input test3-data/03.answe
+
+# If called from VALGRIND_ENVIRONMENT
+[ -s $builddir/popt-valgrind-result ] && { echo "Some test fail under Valgrind. Check $builddir/popt-valgrind-result" && exit 1 ; }
+
+rm -f $builddir/popt-valgrind-result
-echo ""
echo "Passed."