run valgrind with proper env
[platform/upstream/gst-common.git] / check.mak
1 clean-local-check:
2         for i in `find . -name ".libs" -type d`; do \
3           rm -rf $$i; \
4         done
5
6 if HAVE_VALGRIND
7 # hangs spectacularly on some machines, so let's not do this by default yet
8 check-local-disabled:
9         make valgrind
10 else
11 check-local-disabled:
12         @true
13 endif
14
15 # run any given test by running make test.check
16 %.check: % $(CHECK_REGISTRY)
17         @$(TESTS_ENVIRONMENT)                                   \
18         $*
19
20 # valgrind any given test by running make test.valgrind
21 %.valgrind: % $(CHECK_REGISTRY)
22         $(TESTS_ENVIRONMENT)                                    \
23         libtool --mode=execute                                  \
24         $(VALGRIND_PATH) -q --suppressions=$(SUPPRESSIONS)      \
25         --tool=memcheck --leak-check=yes --trace-children=yes   \
26         $* 2>&1 | tee valgrind.log
27         @if grep "tely lost" valgrind.log; then                 \
28             rm valgrind.log;                                    \
29             exit 1;                                             \
30         fi
31         @rm valgrind.log
32
33 # valgrind all tests
34 valgrind: $(TESTS) $(CHECK_REGISTRY)
35         @echo "Valgrinding tests ..."
36         @failed=0;                                                      \
37         for t in $(filter-out $(VALGRIND_TESTS_DISABLE),$(TESTS)); do   \
38                 make $$t.valgrind;                                      \
39                 if test "$$?" -ne 0; then                               \
40                         echo "Valgrind error for test $$t";             \
41                         failed=`expr $$failed + 1`;                     \
42                         whicht="$$whicht $$t";                          \
43                 fi;                                                     \
44         done;                                                           \
45         if test "$$failed" -ne 0; then                                  \
46                 echo "$$failed tests had leaks under valgrind:";        \
47                 echo "$$whicht";                                        \
48                 false;                                                  \
49         fi