don't print stuff twice
[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         $* || break; 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=full --trace-children=yes  \
44         --leak-resolution=high                                  \
45         $* 2>&1 | tee valgrind.log
46         @if grep "==" valgrind.log > /dev/null 2>&1; then       \
47             rm valgrind.log;                                    \
48             exit 1;                                             \
49         fi
50         @rm valgrind.log
51
52 # gdb any given test by running make test.gdb
53 %.gdb: %
54         $(TESTS_ENVIRONMENT)                                    \
55         CK_FORK=no                                              \
56         libtool --mode=execute                                  \
57         gdb $*
58
59 # torture tests
60 torture: $(TESTS)
61         @echo "Torturing tests ..."
62         for i in `seq 1 $(LOOPS)`; do                           \
63                 make check ||                                   \
64                 (echo "Failure after $$i runs"; exit 1) ||      \
65                 exit 1;                                         \
66         done
67         @banner="All $(LOOPS) loops passed";                    \
68         dashes=`echo "$$banner" | sed s/./=/g`;                 \
69         echo $$dashes; echo $$banner; echo $$dashes
70
71 # valgrind all tests
72 valgrind: $(TESTS)
73         @echo "Valgrinding tests ..."
74         @failed=0;                                                      \
75         for t in $(filter-out $(VALGRIND_TESTS_DISABLE),$(TESTS)); do   \
76                 make $$t.valgrind;                                      \
77                 if test "$$?" -ne 0; then                               \
78                         echo "Valgrind error for test $$t";             \
79                         failed=`expr $$failed + 1`;                     \
80                         whicht="$$whicht $$t";                          \
81                 fi;                                                     \
82         done;                                                           \
83         if test "$$failed" -ne 0; then                                  \
84                 echo "$$failed tests had leaks under valgrind:";        \
85                 echo "$$whicht";                                        \
86                 false;                                                  \
87         fi
88
89 help:
90         @echo "make check                 -- run all checks"
91         @echo "make torture               -- run all checks $(LOOPS) times"
92         @echo "make (dir)/(test).check    -- run the given check once"
93         @echo "make (dir)/(test).forever  -- run the given check forever"
94         @echo "make (dir)/(test).torture  -- run the given check $(LOOPS) times"
95         @echo
96         @echo "make (dir)/(test).gdb      -- start up gdb for the given test"
97         @echo
98         @echo "make valgrind              -- valgrind all tests"
99         @echo "make (dir)/(test).valgrind -- valgrind the given test"