diff --git a/testing/leak-check.sh b/testing/leak-check.sh new file mode 100755 index 0000000000000000000000000000000000000000..b3f2d250be8618afb6e84b029f785c716ef79653 --- /dev/null +++ b/testing/leak-check.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# +# Script to run valgrind against the test suite for hunting memory leaks +# +# This assumes you run it in the Hammer base directory and have a debug build + +HAMMER_ROOT=. +VARIANT=debug +BUILD_PATH=$HAMMER_ROOT/build/$VARIANT +LD_LIBRARY_PATH=$BUILD_PATH/src:$LD_LIBRARY_PATH +VALGRIND=valgrind +VALGRIND_OPTS="-v --leak-check=full --leak-resolution=high --num-callers=40 --partial-loads-ok=no --show-leak-kinds=all --track-origins=yes --undef-value-errors=yes" +VALGRIND_SUPPRESSIONS="valgrind-glib.supp" + +for s in $VALGRIND_SUPPRESSIONS +do + VALGRIND_OPTS="$VALGRIND_OPTS --suppressions=$HAMMER_ROOT/testing/valgrind/$s" +done + +export LD_LIBRARY_PATH + +$VALGRIND $VALGRIND_OPTS $BUILD_PATH/src/test_suite $@ diff --git a/testing/valgrind/valgrind-glib.supp b/testing/valgrind/valgrind-glib.supp new file mode 100644 index 0000000000000000000000000000000000000000..9b35108f8f606aa7c3c9d8f85ffc6c51bff8f4d0 --- /dev/null +++ b/testing/valgrind/valgrind-glib.supp @@ -0,0 +1,40 @@ +{ + <g_test_add_vtable_supp> + Memcheck:Leak + match-leak-kinds: reachable + ... + fun:g_malloc + ... + fun:g_test_add_vtable + ... +} +{ + <g_test_init_malloc_supp> + Memcheck:Leak + match-leak-kinds: reachable + fun:malloc + ... + fun:g_test_init + ... +} +{ + <g_test_init_calloc_supp> + Memcheck:Leak + match-leak-kinds: reachable + fun:calloc + ... + fun:g_test_init + ... +} +{ + <g_rand_new_with_seed_array_supp> + Memcheck:Leak + match-leak-kinds: reachable + fun:calloc + fun:g_malloc0 + fun:g_rand_new_with_seed_array + ... + fun:g_test_run_suite + fun:g_test_run + ... +}