Added gst-plugins-base-subtitles0.10-0.10.34 for Meego Harmattan 1.2
[mafwsubrenderer] / gst-plugins-base-subtitles0.10 / 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 # run any given test in a loop
28 %.torture: %
29         @for i in `seq 1 $(LOOPS)`; do                          \
30         $(TESTS_ENVIRONMENT)                                    \
31         CK_DEFAULT_TIMEOUT=20                                   \
32         $*; done
33
34 # run any given test in an infinite loop
35 %.forever: %
36         @while true; do                                         \
37         $(TESTS_ENVIRONMENT)                                    \
38         CK_DEFAULT_TIMEOUT=20                                   \
39         $* || break; done
40
41 # valgrind any given test by running make test.valgrind
42 %.valgrind: %
43         @$(TESTS_ENVIRONMENT)                                   \
44         CK_DEFAULT_TIMEOUT=360                                  \
45         G_SLICE=always-malloc                                   \
46         $(LIBTOOL) --mode=execute                               \
47         $(VALGRIND_PATH) -q                                     \
48         $(foreach s,$(SUPPRESSIONS),--suppressions=$(s))        \
49         --tool=memcheck --leak-check=full --trace-children=yes  \
50         --leak-resolution=high --num-callers=20                 \
51         ./$* 2>&1 | tee valgrind.log
52         @if grep "==" valgrind.log > /dev/null 2>&1; then       \
53             rm valgrind.log;                                    \
54             exit 1;                                             \
55         fi
56         @rm valgrind.log
57         
58 # valgrind any given test and generate suppressions for it
59 %.valgrind.gen-suppressions: %
60         @$(TESTS_ENVIRONMENT)                                   \
61         CK_DEFAULT_TIMEOUT=360                                  \
62         G_SLICE=always-malloc                                   \
63         $(LIBTOOL) --mode=execute                               \
64         $(VALGRIND_PATH) -q                                     \
65         $(foreach s,$(SUPPRESSIONS),--suppressions=$(s))        \
66         --tool=memcheck --leak-check=full --trace-children=yes  \
67         --leak-resolution=high --num-callers=20                 \
68         --gen-suppressions=all                                  \
69         ./$* 2>&1 | tee suppressions.log
70         
71 # valgrind any given test until failure by running make test.valgrind-forever
72 %.valgrind-forever: %
73         @while $(MAKE) $*.valgrind; do                          \
74           true; done
75
76 # gdb any given test by running make test.gdb
77 %.gdb: %
78         @$(TESTS_ENVIRONMENT)                                   \
79         CK_FORK=no                                              \
80         $(LIBTOOL) --mode=execute                               \
81         gdb $*
82
83 # torture tests
84 torture: $(TESTS)
85         -rm test-registry.xml
86         @echo "Torturing tests ..."
87         @for i in `seq 1 $(LOOPS)`; do                          \
88                 $(MAKE) check ||                                \
89                 (echo "Failure after $$i runs"; exit 1) ||      \
90                 exit 1;                                         \
91         done
92         @banner="All $(LOOPS) loops passed";                    \
93         dashes=`echo "$$banner" | sed s/./=/g`;                 \
94         echo $$dashes; echo $$banner; echo $$dashes
95
96 # forever tests
97 forever: $(TESTS)
98         -rm test-registry.xml
99         @echo "Forever tests ..."
100         @while true; do                                         \
101                 $(MAKE) check ||                                \
102                 (echo "Failure"; exit 1) ||                     \
103                 exit 1;                                         \
104         done
105
106 # valgrind all tests
107 valgrind: $(TESTS)
108         @echo "Valgrinding tests ..."
109         @failed=0;                                                      \
110         for t in $(filter-out $(VALGRIND_TESTS_DISABLE),$(TESTS)); do   \
111                 $(MAKE) $$t.valgrind;                                   \
112                 if test "$$?" -ne 0; then                               \
113                         echo "Valgrind error for test $$t";             \
114                         failed=`expr $$failed + 1`;                     \
115                         whicht="$$whicht $$t";                          \
116                 fi;                                                     \
117         done;                                                           \
118         if test "$$failed" -ne 0; then                                  \
119                 echo "$$failed tests had leaks or errors under valgrind:";      \
120                 echo "$$whicht";                                        \
121                 false;                                                  \
122         fi
123
124 # valgrind all tests and generate suppressions
125 valgrind.gen-suppressions: $(TESTS)
126         @echo "Valgrinding tests ..."
127         @failed=0;                                                      \
128         for t in $(filter-out $(VALGRIND_TESTS_DISABLE),$(TESTS)); do   \
129                 $(MAKE) $$t.valgrind.gen-suppressions;                  \
130                 if test "$$?" -ne 0; then                               \
131                         echo "Valgrind error for test $$t";             \
132                         failed=`expr $$failed + 1`;                     \
133                         whicht="$$whicht $$t";                          \
134                 fi;                                                     \
135         done;                                                           \
136         if test "$$failed" -ne 0; then                                  \
137                 echo "$$failed tests had leaks or errors under valgrind:";      \
138                 echo "$$whicht";                                        \
139                 false;                                                  \
140         fi
141
142 # inspect every plugin feature
143 GST_INSPECT = $(GST_TOOLS_DIR)/gst-inspect-$(GST_MAJORMINOR)
144 inspect:
145         @echo "Inspecting features ..."
146         @for e in `$(TESTS_ENVIRONMENT) $(GST_INSPECT) | head -n -2     \
147           | cut -d: -f2`;                                               \
148           do echo Inspecting $$e;                                       \
149              $(GST_INSPECT) $$e > /dev/null 2>&1; done
150
151 help:
152         @echo
153         @echo "make check                         -- run all checks"
154         @echo "make torture                       -- run all checks $(LOOPS) times"
155         @echo "make (dir)/(test).check            -- run the given check once"
156         @echo "make (dir)/(test).forever          -- run the given check forever"
157         @echo "make (dir)/(test).torture          -- run the given check $(LOOPS) times"
158         @echo
159         @echo "make (dir)/(test).gdb              -- start up gdb for the given test"
160         @echo
161         @echo "make valgrind                      -- valgrind all tests"
162         @echo "make valgrind.gen-suppressions     -- generate suppressions for all tests"
163         @echo "                                      and save to suppressions.log"
164         @echo "make (dir)/(test).valgrind         -- valgrind the given test"
165         @echo "make (dir)/(test).valgrind-forever -- valgrind the given test forever"
166         @echo "make (dir)/(test).valgrind.gen-suppressions -- generate suppressions"
167         @echo "                                               and save to suppressions.log"
168         @echo "make inspect                       -- inspect all plugin features"
169         @echo
170         @echo
171         @echo "Additionally, you can use the GST_CHECKS environment variable to"
172         @echo "specify which test(s) should be run. This is useful if you are"
173         @echo "debugging a failure in one particular test, or want to reproduce"
174         @echo "a race condition in a single test."
175         @echo
176         @echo "Examples:"
177         @echo
178         @echo "  GST_CHECKS=test_this,test_that  make element/foobar.check"
179         @echo "  GST_CHECKS=test_many_threads    make element/foobar.forever"
180         @echo
181