check.mak: add some more targets, like help, but also more intensive tests
[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 LOOPS = 10
16
17 # run any given test by running make test.check
18 %.check: %
19         @$(TESTS_ENVIRONMENT)                                   \
20         CK_DEFAULT_TIMEOUT=20                                   \
21         $*
22
23 # run any given test in a loop
24 %.torture: %
25         @for i in `seq 1 $(LOOPS)`; do                          \
26         $(TESTS_ENVIRONMENT)                                    \
27         CK_DEFAULT_TIMEOUT=20                                   \
28         $*; done
29
30 # run any given test in an infinite loop
31 %.forever: %
32         @while true; do                                         \
33         $(TESTS_ENVIRONMENT)                                    \
34         CK_DEFAULT_TIMEOUT=20                                   \
35         $*; done
36
37 # valgrind any given test by running make test.valgrind
38 %.valgrind: %
39         $(TESTS_ENVIRONMENT)                                    \
40         CK_DEFAULT_TIMEOUT=20                                   \
41         libtool --mode=execute                                  \
42         $(VALGRIND_PATH) -q --suppressions=$(SUPPRESSIONS)      \
43         --tool=memcheck --leak-check=yes --trace-children=yes   \
44         $* 2>&1 | tee valgrind.log
45         @if grep "tely lost" valgrind.log; then                 \
46             rm valgrind.log;                                    \
47             exit 1;                                             \
48         fi
49         @rm valgrind.log
50
51 # gdb any given test by running make test.gdb
52 %.gdb: %
53         $(REGISTRY_ENVIRONMENT)                                 \
54         CK_FORK=no                                              \
55         libtool --mode=execute                                  \
56         gdb $*
57
58 # torture tests
59 torture: $(TESTS)
60         @echo "Torturing tests ..."
61         for i in `seq 1 $(LOOPS)`; do                           \
62                 make check ||                                   \
63                 (echo "Failure after $$i runs"; exit 1) ||      \
64                 exit 1;                                         \
65         done
66
67
68 # valgrind all tests
69 valgrind: $(TESTS)
70         @echo "Valgrinding tests ..."
71         @failed=0;                                                      \
72         for t in $(filter-out $(VALGRIND_TESTS_DISABLE),$(TESTS)); do   \
73                 make $$t.valgrind;                                      \
74                 if test "$$?" -ne 0; then                               \
75                         echo "Valgrind error for test $$t";             \
76                         failed=`expr $$failed + 1`;                     \
77                         whicht="$$whicht $$t";                          \
78                 fi;                                                     \
79         done;                                                           \
80         if test "$$failed" -ne 0; then                                  \
81                 echo "$$failed tests had leaks under valgrind:";        \
82                 echo "$$whicht";                                        \
83                 false;                                                  \
84         fi
85
86 help:
87         @echo "make check                 -- run all checks"
88         @echo "make torture               -- run all checks $(LOOPS) times"
89         @echo "make (dir)/(test).check    -- run the given check once"
90         @echo "make (dir)/(test).forever  -- run the given check forever"
91         @echo "make (dir)/(test).torture  -- run the given check $(LOOPS) times"
92         @echo
93         @echo "make (dir)/(test).gdb      -- start up gdb for the given test"
94         @echo
95         @echo "make valgrind              -- valgrind all tests"
96         @echo "make (dir)/(test).valgrind -- valgrind the given test"