From b787b6e2dc94b4a3cda47ce35e4e91fac9885b07 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Wed, 30 Apr 2014 11:43:24 +0200 Subject: [PATCH] integration tests: Run all invocations through valgrind's memcheck. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit … covering, both, sysdb and sysdbd. For that to work, copy the binaries and libraries to the temp directory and change the rpath to point to the temp directory. This ensures the test is independent of any configure flags and installation directories. Let the tests fail if a leak (or other error) was detected by valgrind. --- .travis.yml | 1 + t/integration/simple_config.sh | 4 ++-- t/integration/simple_query.sh | 2 +- t/integration/test_lib.sh | 14 ++++++++++++-- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 87badb6..f91c75f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ before_install: install: - sudo apt-get install -qq check flex bison libtool libltdl-dev - sudo apt-get install -qq libdbi-dev libedit-dev libreadline-dev + - sudo apt-get install -qq valgrind chrpath - sudo pip install cpp-coveralls - pip show cpp-coveralls script: ./t/cibuild.sh diff --git a/t/integration/simple_config.sh b/t/integration/simple_config.sh index ce3c4eb..e6daddc 100755 --- a/t/integration/simple_config.sh +++ b/t/integration/simple_config.sh @@ -37,7 +37,7 @@ cat < "$SYSDBD_CONF" Listen "invalid://address" EOF -if "$SYSDBD" -D -C "$SYSDBD_CONF"; then +if $SYSDBD -D -C "$SYSDBD_CONF"; then echo 'SysDBd accepted invalid listen address; expected: failure' >&2 exit 1 fi @@ -46,7 +46,7 @@ cat < "$SYSDBD_CONF" Listen "$SOCKET_FILE" EOF -"$SYSDBD" -D -C "$SYSDBD_CONF" & +$SYSDBD -D -C "$SYSDBD_CONF" & sysdbd_pid=$! wait_for_sysdbd diff --git a/t/integration/simple_query.sh b/t/integration/simple_query.sh index 7c62775..76b54d6 100755 --- a/t/integration/simple_query.sh +++ b/t/integration/simple_query.sh @@ -43,7 +43,7 @@ LoadBackend mock_plugin EOF -"$SYSDBD" -D -C "$SYSDBD_CONF" & +$SYSDBD -D -C "$SYSDBD_CONF" & sysdbd_pid=$! wait_for_sysdbd diff --git a/t/integration/test_lib.sh b/t/integration/test_lib.sh index b91cb0c..482b8ae 100644 --- a/t/integration/test_lib.sh +++ b/t/integration/test_lib.sh @@ -35,13 +35,23 @@ trap "rm -rf '$TESTDIR'" EXIT mkdir "$TESTDIR/backend" cp "$TOP_SRCDIR/t/integration/.libs/mock_plugin.so" "$TESTDIR/backend" +cp src/.libs/sysdb src/.libs/sysdbd "$TESTDIR" +cp src/.libs/libsysdb*.so* "$TESTDIR" +chrpath -r "$TESTDIR" "$TESTDIR/sysdb" > /dev/null +chrpath -r "$TESTDIR" "$TESTDIR/sysdbd" > /dev/null + +MEMCHECK="valgrind --quiet --tool=memcheck --error-exitcode=1" +MEMCHECK="$MEMCHECK --trace-children=yes" +MEMCHECK="$MEMCHECK --track-fds=yes" +MEMCHECK="$MEMCHECK --leak-check=full" + SYSDBD_CONF="$TESTDIR/sysdbd.conf" SOCKET_FILE="$TESTDIR/sock" PLUGIN_DIR="$TESTDIR" -SYSDBD="$TOP_SRCDIR/src/sysdbd" -SYSDB="$TOP_SRCDIR/src/sysdb" +SYSDB="$MEMCHECK $TESTDIR/sysdb" +SYSDBD="$MEMCHECK $TESTDIR/sysdbd" function wait_for_sysdbd() { local i -- 2.30.2