Initial release including wifi display based on gst-rtsp-server-1.4.1
[platform/upstream/gstreamer.git] / common / check.mak
1 # keep target around, since it's referenced in the modules' Makefiles
2 clean-local-check:
3         @echo
4
5 if HAVE_VALGRIND
6 # hangs spectacularly on some machines, so let's not do this by default yet
7 check-valgrind:
8         $(MAKE) valgrind
9 else
10 check-valgrind:
11         @true
12 endif
13
14 LOOPS ?= 10
15
16 # run any given test by running make test.check
17 # if the test fails, run it again at at least debug level 2
18 %.check: %
19         @$(TESTS_ENVIRONMENT)                                   \
20         CK_DEFAULT_TIMEOUT=20                                   \
21         $* ||                                                   \
22         $(TESTS_ENVIRONMENT)                                    \
23         GST_DEBUG=$$GST_DEBUG,*:2                               \
24         CK_DEFAULT_TIMEOUT=20                                   \
25         $*
26
27 # just like 'check', but don't run it again if it fails (useful for debugging)
28 %.check-norepeat: %
29         @$(TESTS_ENVIRONMENT)                                   \
30         CK_DEFAULT_TIMEOUT=20                                   \
31         $*
32
33 # run any given test in a loop
34 %.torture: %
35         @for i in `seq 1 $(LOOPS)`; do                          \
36         $(TESTS_ENVIRONMENT)                                    \
37         CK_DEFAULT_TIMEOUT=20                                   \
38         $*; done
39
40 # run any given test in an infinite loop
41 %.forever: %
42         @while true; do                                         \
43         $(TESTS_ENVIRONMENT)                                    \
44         CK_DEFAULT_TIMEOUT=20                                   \
45         $* || break; done
46
47 # valgrind any given test by running make test.valgrind
48 %.valgrind: %
49         @$(TESTS_ENVIRONMENT)                                   \
50         CK_DEFAULT_TIMEOUT=360                                  \
51         G_SLICE=always-malloc                                   \
52         $(LIBTOOL) --mode=execute                               \
53         $(VALGRIND_PATH) -q                                     \
54         $(foreach s,$(SUPPRESSIONS),--suppressions=$(s))        \
55         --tool=memcheck --leak-check=full --trace-children=yes  \
56         --show-possibly-lost=no                                 \
57         --leak-resolution=high --num-callers=20                 \
58         ./$* 2>&1 | tee valgrind.log
59         @if grep "==" valgrind.log > /dev/null 2>&1; then       \
60             rm valgrind.log;                                    \
61             exit 1;                                             \
62         fi
63         @rm valgrind.log
64
65 # valgrind any given test and generate suppressions for it
66 %.valgrind.gen-suppressions: %
67         @$(TESTS_ENVIRONMENT)                                   \
68         CK_DEFAULT_TIMEOUT=360                                  \
69         G_SLICE=always-malloc                                   \
70         $(LIBTOOL) --mode=execute                               \
71         $(VALGRIND_PATH) -q                                     \
72         $(foreach s,$(SUPPRESSIONS),--suppressions=$(s))        \
73         --tool=memcheck --leak-check=full --trace-children=yes  \
74         --show-possibly-lost=no                                 \
75         --leak-resolution=high --num-callers=20                 \
76         --gen-suppressions=all                                  \
77         ./$* 2>&1 | tee suppressions.log
78
79 # valgrind torture any given test
80 %.valgrind-torture: %
81         @for i in `seq 1 $(LOOPS)`; do                          \
82                 $(MAKE) $*.valgrind ||                          \
83                 (echo "Failure after $$i runs"; exit 1) ||      \
84                 exit 1;                                         \
85         done
86         @banner="All $(LOOPS) loops passed";                    \
87         dashes=`echo "$$banner" | sed s/./=/g`;                 \
88         echo $$dashes; echo $$banner; echo $$dashes
89
90 # valgrind any given test until failure by running make test.valgrind-forever
91 %.valgrind-forever: %
92         @while $(MAKE) $*.valgrind; do                          \
93           true; done
94
95 # gdb any given test by running make test.gdb
96 %.gdb: %
97         @$(TESTS_ENVIRONMENT)                                   \
98         CK_FORK=no                                              \
99         $(LIBTOOL) --mode=execute                               \
100         gdb $*
101
102 %.lcov-reset:
103         $(MAKE) $*.lcov-run
104         $(MAKE) $*.lcov-report
105
106 %.lcov: %
107         $(MAKE) $*.lcov-reset
108
109 if GST_GCOV_ENABLED
110 %.lcov-clean:
111         $(MAKE) -C $(top_builddir) lcov-clean
112
113 %.lcov-run:
114         $(MAKE) $*.lcov-clean
115         $(MAKE) $*.check
116
117 %.lcov-report:
118         $(MAKE) -C $(top_builddir) lcov-report
119 else
120 %.lcov-run:
121         echo "Need to reconfigure with --enable-gcov"
122
123 %.lcov-report:
124         echo "Need to reconfigure with --enable-gcov"
125 endif
126
127 # torture tests
128 torture: $(TESTS)
129         -rm test-registry.*
130         @echo "Torturing tests ..."
131         @for i in `seq 1 $(LOOPS)`; do                          \
132                 $(MAKE) check ||                                \
133                 (echo "Failure after $$i runs"; exit 1) ||      \
134                 exit 1;                                         \
135         done
136         @banner="All $(LOOPS) loops passed";                    \
137         dashes=`echo "$$banner" | sed s/./=/g`;                 \
138         echo $$dashes; echo $$banner; echo $$dashes
139
140 # forever tests
141 forever: $(TESTS)
142         -rm test-registry.*
143         @echo "Forever tests ..."
144         @while true; do                                         \
145                 $(MAKE) check ||                                \
146                 (echo "Failure"; exit 1) ||                     \
147                 exit 1;                                         \
148         done
149
150 # valgrind all tests
151 valgrind: $(TESTS)
152         @echo "Valgrinding tests ..."
153         @failed=0;                                                      \
154         for t in $(filter-out $(VALGRIND_TESTS_DISABLE),$(TESTS)); do   \
155                 $(MAKE) $$t.valgrind;                                   \
156                 if test "$$?" -ne 0; then                               \
157                         echo "Valgrind error for test $$t";             \
158                         failed=`expr $$failed + 1`;                     \
159                         whicht="$$whicht $$t";                          \
160                 fi;                                                     \
161         done;                                                           \
162         if test "$$failed" -ne 0; then                                  \
163                 echo "$$failed tests had leaks or errors under valgrind:";      \
164                 echo "$$whicht";                                        \
165                 false;                                                  \
166         fi
167
168 # valgrind all tests until failure
169 valgrind-forever: $(TESTS)
170         -rm test-registry.*
171         @echo "Forever valgrinding tests ..."
172         @while true; do                                         \
173                 $(MAKE) valgrind ||                             \
174                 (echo "Failure"; exit 1) ||                     \
175                 exit 1;                                         \
176         done
177
178 # valgrind torture all tests
179 valgrind-torture: $(TESTS)
180         -rm test-registry.*
181         @echo "Torturing and valgrinding tests ..."
182         @for i in `seq 1 $(LOOPS)`; do                          \
183                 $(MAKE) valgrind ||                             \
184                 (echo "Failure after $$i runs"; exit 1) ||      \
185                 exit 1;                                         \
186         done
187         @banner="All $(LOOPS) loops passed";                    \
188         dashes=`echo "$$banner" | sed s/./=/g`;                 \
189         echo $$dashes; echo $$banner; echo $$dashes
190
191 # valgrind all tests and generate suppressions
192 valgrind.gen-suppressions: $(TESTS)
193         @echo "Valgrinding tests ..."
194         @failed=0;                                                      \
195         for t in $(filter-out $(VALGRIND_TESTS_DISABLE),$(TESTS)); do   \
196                 $(MAKE) $$t.valgrind.gen-suppressions;                  \
197                 if test "$$?" -ne 0; then                               \
198                         echo "Valgrind error for test $$t";             \
199                         failed=`expr $$failed + 1`;                     \
200                         whicht="$$whicht $$t";                          \
201                 fi;                                                     \
202         done;                                                           \
203         if test "$$failed" -ne 0; then                                  \
204                 echo "$$failed tests had leaks or errors under valgrind:";      \
205                 echo "$$whicht";                                        \
206                 false;                                                  \
207         fi
208
209 # inspect every plugin feature
210 GST_INSPECT = $(GST_TOOLS_DIR)/gst-inspect-$(GST_API_VERSION)
211 inspect:
212         @echo "Inspecting features ..."
213         @for e in `$(TESTS_ENVIRONMENT) $(GST_INSPECT) | head -n -2     \
214           | cut -d: -f2`;                                               \
215           do echo Inspecting $$e;                                       \
216              $(GST_INSPECT) $$e > /dev/null 2>&1; done
217
218 help:
219         @echo
220         @echo "make check                         -- run all checks"
221         @echo "make torture                       -- run all checks $(LOOPS) times"
222         @echo "make (dir)/(test).check            -- run the given check once, repeat with GST_DEBUG=*:2 if it fails"
223         @echo "make (dir)/(test).check-norepeat   -- run the given check once, but don't run it again if it fails"
224         @echo "make (dir)/(test).forever          -- run the given check forever"
225         @echo "make (dir)/(test).torture          -- run the given check $(LOOPS) times"
226         @echo
227         @echo "make (dir)/(test).gdb              -- start up gdb for the given test"
228         @echo
229         @echo "make valgrind                      -- valgrind all tests"
230         @echo "make valgrind-forever              -- valgrind all tests forever"
231         @echo "make valgrind-torture              -- valgrind all tests $(LOOPS) times"
232         @echo "make valgrind.gen-suppressions     -- generate suppressions for all tests"
233         @echo "                                      and save to suppressions.log"
234         @echo "make (dir)/(test).valgrind         -- valgrind the given test"
235         @echo "make (dir)/(test).valgrind-forever -- valgrind the given test forever"
236         @echo "make (dir)/(test).valgrind-torture -- valgrind the given test $(LOOPS) times"
237         @echo "make (dir)/(test).valgrind.gen-suppressions -- generate suppressions"
238         @echo "                                               and save to suppressions.log"
239         @echo "make inspect                       -- inspect all plugin features"
240         @echo
241         @echo
242         @echo "Additionally, you can use the GST_CHECKS environment variable to"
243         @echo "specify which test(s) should be run. This is useful if you are"
244         @echo "debugging a failure in one particular test, or want to reproduce"
245         @echo "a race condition in a single test."
246         @echo
247         @echo "Examples:"
248         @echo
249         @echo "  GST_CHECKS=test_this,test_that  make element/foobar.check"
250         @echo "  GST_CHECKS=test_many_threads    make element/foobar.forever"
251         @echo
252