make forever fail on error
[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=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         @banner="All $(LOOPS) loops passed";                    \
67         dashes=`echo "$$banner" | sed s/./=/g`;                 \
68         echo $$dashes; echo $$banner; echo $$dashes
69
70 # valgrind all tests
71 valgrind: $(TESTS)
72         @echo "Valgrinding tests ..."
73         @failed=0;                                                      \
74         for t in $(filter-out $(VALGRIND_TESTS_DISABLE),$(TESTS)); do   \
75                 make $$t.valgrind;                                      \
76                 if test "$$?" -ne 0; then                               \
77                         echo "Valgrind error for test $$t";             \
78                         failed=`expr $$failed + 1`;                     \
79                         whicht="$$whicht $$t";                          \
80                 fi;                                                     \
81         done;                                                           \
82         if test "$$failed" -ne 0; then                                  \
83                 echo "$$failed tests had leaks under valgrind:";        \
84                 echo "$$whicht";                                        \
85                 false;                                                  \
86         fi
87
88 help:
89         @echo "make check                 -- run all checks"
90         @echo "make torture               -- run all checks $(LOOPS) times"
91         @echo "make (dir)/(test).check    -- run the given check once"
92         @echo "make (dir)/(test).forever  -- run the given check forever"
93         @echo "make (dir)/(test).torture  -- run the given check $(LOOPS) times"
94         @echo
95         @echo "make (dir)/(test).gdb      -- start up gdb for the given test"
96         @echo
97         @echo "make valgrind              -- valgrind all tests"
98         @echo "make (dir)/(test).valgrind -- valgrind the given test"