From 1d39aa348c7a98489aa5713d528eec12301eb86f Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Tue, 19 Dec 2017 11:20:38 +0100 Subject: [PATCH] Add valgrind to travis configuration and check for leaks --- .travis.yml | 3 ++- .valgrind.suppressions | 10 ++++++++++ Makefile | 12 +++++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 .valgrind.suppressions diff --git a/.travis.yml b/.travis.yml index 5c6aa5d..cdea5b9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,13 +12,14 @@ addons: - libcairo2-dev - libnotify-dev - libgtk-3-dev + - valgrind dist: trusty sudo: false language: c before_install: - pip install --user cpp-coveralls script: - - CFLAGS="-fprofile-arcs -ftest-coverage -Werror" make all dunstify test + - CFLAGS="-fprofile-arcs -ftest-coverage -Werror" make all dunstify test-valgrind - coveralls compiler: - gcc diff --git a/.valgrind.suppressions b/.valgrind.suppressions new file mode 100644 index 0000000..de42697 --- /dev/null +++ b/.valgrind.suppressions @@ -0,0 +1,10 @@ +{ + xdgBaseDir_leak + # see https://github.com/devnev/libxdg-basedir/pull/6 + Memcheck:Leak + fun:malloc + ... + fun:xdgInitHandle + ... + fun:main +} diff --git a/Makefile b/Makefile index e37a978..c9bd3e9 100644 --- a/Makefile +++ b/Makefile @@ -44,10 +44,20 @@ dunst: ${OBJ} main.o dunstify: dunstify.o ${CC} ${CFLAGS} -o $@ dunstify.o ${LDFLAGS} -.PHONY: test +.PHONY: test test-valgrind test: test/test cd test && ./test +test-valgrind: test/test + cd ./test \ + && valgrind \ + --suppressions=../.valgrind.suppressions \ + --leak-check=full \ + --show-leak-kinds=definite \ + --errors-for-leak-kinds=definite \ + --error-exitcode=123 \ + ./test + test/test: ${OBJ} ${TEST_OBJ} ${CC} ${CFLAGS} -o $@ ${TEST_OBJ} ${OBJ} ${LDFLAGS}