add check-valgrind target
[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-valgrind:
9         make valgrind
10 else
11 check-valgrind:
12         @true
13 endif
14
15 # run any given test by running make test.check
16 %.check:
17         @$(TESTS_ENVIRONMENT)                                   \
18         CK_DEFAULT_TIMEOUT=20                                   \
19         $*
20
21 # valgrind any given test by running make test.valgrind
22 %.valgrind:
23         $(REGISTRY_ENVIRONMENT)                                 \
24         CK_DEFAULT_TIMEOUT=20                                   \
25         libtool --mode=execute                                  \
26         $(VALGRIND_PATH) -q --suppressions=$(SUPPRESSIONS)      \
27         --tool=memcheck --leak-check=yes --trace-children=yes   \
28         $* 2>&1 | tee valgrind.log
29         @if grep "tely lost" valgrind.log; then                 \
30             rm valgrind.log;                                    \
31             exit 1;                                             \
32         fi
33         @rm valgrind.log
34
35 # gdb any given test by running make test.gdb
36 %.gdb: %
37         $(REGISTRY_ENVIRONMENT)                                 \
38         CK_FORK=no                                              \
39         libtool --mode=execute                                  \
40         gdb $*
41
42
43 # valgrind all tests
44 valgrind: $(TESTS)
45         @echo "Valgrinding tests ..."
46         @failed=0;                                                      \
47         for t in $(filter-out $(VALGRIND_TESTS_DISABLE),$(TESTS)); do   \
48                 make $$t.valgrind;                                      \
49                 if test "$$?" -ne 0; then                               \
50                         echo "Valgrind error for test $$t";             \
51                         failed=`expr $$failed + 1`;                     \
52                         whicht="$$whicht $$t";                          \
53                 fi;                                                     \
54         done;                                                           \
55         if test "$$failed" -ne 0; then                                  \
56                 echo "$$failed tests had leaks under valgrind:";        \
57                 echo "$$whicht";                                        \
58                 false;                                                  \
59         fi