parse output of valgrind and check for definitely lost, and error out; somehow I...
[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         $* > valgrind.log 2>&1
27         @if grep "tely lost" valgrind.log; then                 \
28             cat valgrind.log;                                   \
29             rm valgrind.log;                                    \
30             exit 1;                                             \
31         fi
32         rm valgrind.log
33
34 # valgrind all tests
35 valgrind: $(TESTS)
36         @echo "Valgrinding tests ..."
37         $(TESTS_ENVIRONMENT) $(GST_TOOLS_DIR)/gst-register-@GST_MAJORMINOR@
38         @failed=0;                                                      \
39         for t in $(filter-out $(VALGRIND_TESTS_DISABLE),$(TESTS)); do   \
40                 make $$t.valgrind;                                      \
41                 if test "$$?" -ne 0; then                               \
42                         echo "Valgrind error for test $$t";             \
43                         failed=`expr $$failed + 1`;                     \
44                         whicht="$$whicht $$t";                          \
45                 fi;                                                     \
46         done;                                                           \
47         if test "$$failed" -ne 0; then                                  \
48                 echo "$$failed tests had leaks under valgrind:";        \
49                 echo "$$whicht";                                        \
50                 false;                                                  \
51         fi