summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2019-06-28 13:20:54 +0200
committerPatrick Steinhardt <ps@pks.im>2019-07-20 19:10:10 +0200
commitd827b11b670f3331e5d924eadfe35c497b08035a (patch)
treeb3dc2ce4d2d31cc7f3d1e831b0c02721083dc552 /script
parentfe3b5da3ec9bfbca9f2d17ab6d3eddf39516c9c7 (diff)
downloadlibgit2-d827b11b670f3331e5d924eadfe35c497b08035a.tar.gz
tests: execute leak checker via CTest directly
Right now, we have an awful hack in our test CI setup that extracts the test command from CTest's output and then prepends the leak checker. This is dependent on non-machine-parseable output from CMake and also breaks on various ocassions, like for example when we have spaces in the current path or when the path contains backslashes. Both conditions may easily be triggered on Win32 systems, and in fact they do break our Azure Pipelines builds. Remove the awful hack in favour of a new CMake build option "USE_LEAK_CHECKER". If specifying e.g. "-DUSE_LEAK_CHECKER=valgrind", then we will set up all tests to be run under valgrind. Like this, we can again simply execute ctest without needing to rely on evil sourcery.
Diffstat (limited to 'script')
-rwxr-xr-xscript/leaks.sh6
-rwxr-xr-xscript/valgrind.sh2
-rw-r--r--script/valgrind.supp114
3 files changed, 122 insertions, 0 deletions
diff --git a/script/leaks.sh b/script/leaks.sh
new file mode 100755
index 000000000..efeead516
--- /dev/null
+++ b/script/leaks.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+export MallocStackLogging=1
+export MallocScribble=1
+export MallocLogFile=/dev/null
+export CLAR_AT_EXIT="leaks -quiet \$PPID"
+exec "$@"
diff --git a/script/valgrind.sh b/script/valgrind.sh
new file mode 100755
index 000000000..b5deed2b0
--- /dev/null
+++ b/script/valgrind.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+exec valgrind --leak-check=full --show-reachable=yes --error-exitcode=125 --num-callers=50 --suppressions="$(dirname "${BASH_SOURCE[0]}")/valgrind.supp" "$@"
diff --git a/script/valgrind.supp b/script/valgrind.supp
new file mode 100644
index 000000000..b74791974
--- /dev/null
+++ b/script/valgrind.supp
@@ -0,0 +1,114 @@
+{
+ ignore-zlib-errors-cond
+ Memcheck:Cond
+ obj:*libz.so*
+}
+
+{
+ ignore-giterror-set-leak
+ Memcheck:Leak
+ ...
+ fun:giterror_set
+}
+
+{
+ ignore-git-global-state-leak
+ Memcheck:Leak
+ ...
+ fun:git__global_state
+}
+
+{
+ ignore-openssl-ssl-leak
+ Memcheck:Leak
+ ...
+ obj:*libssl.so*
+ ...
+}
+
+{
+ ignore-openssl-crypto-leak
+ Memcheck:Leak
+ ...
+ obj:*libcrypto.so*
+ ...
+}
+
+{
+ ignore-openssl-crypto-cond
+ Memcheck:Cond
+ obj:*libcrypto.so*
+ ...
+}
+
+{
+ ignore-glibc-getaddrinfo-cache
+ Memcheck:Leak
+ ...
+ fun:__check_pf
+}
+
+{
+ ignore-curl-global-init
+ Memcheck:Leak
+ ...
+ fun:curl_global_init
+}
+
+{
+ ignore-libssh2-gcrypt-control-leak
+ Memcheck:Leak
+ ...
+ fun:gcry_control
+ obj:*libssh2.so*
+}
+
+{
+ ignore-libssh2-gcrypt-mpinew-leak
+ Memcheck:Leak
+ ...
+ fun:gcry_mpi_new
+ obj:*libssh2.so*
+}
+
+{
+ ignore-libssh2-gcrypt-mpiscan-leak
+ Memcheck:Leak
+ ...
+ fun:gcry_mpi_scan
+ obj:*libssh2.so*
+}
+
+{
+ ignore-libssh2-gcrypt-randomize-leak
+ Memcheck:Leak
+ ...
+ fun:gcry_randomize
+ obj:*libssh2.so*
+}
+
+{
+ ignore-libssh2-gcrypt-sexpfindtoken-leak
+ Memcheck:Leak
+ ...
+ fun:gcry_sexp_find_token
+ obj:*libssh2.so*
+}
+
+{
+ ignore-libssh2-gcrypt-pksign-leak
+ Memcheck:Leak
+ ...
+ fun:gcry_pk_sign
+ obj:*libssh2.so*
+}
+
+{
+ ignore-noai6ai_cached-double-free
+ Memcheck:Free
+ fun:free
+ fun:__libc_freeres
+ ...
+ fun:exit
+ ...
+}