Initial release
[adaptation/ap_samsung/gst-plugins-s5pc2xx.git] / common / 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 # if the test fails, run it again at at least debug level 2
19 %.check: %
20         @$(TESTS_ENVIRONMENT)                                   \
21         CK_DEFAULT_TIMEOUT=20                                   \
22         $* ||                                                   \
23         $(TESTS_ENVIRONMENT)                                    \
24         GST_DEBUG=$$GST_DEBUG,*:2                               \
25         CK_DEFAULT_TIMEOUT=20                                   \
26         $*
27
28 # run any given test in a loop
29 %.torture: %
30         @for i in `seq 1 $(LOOPS)`; do                          \
31         $(TESTS_ENVIRONMENT)                                    \
32         CK_DEFAULT_TIMEOUT=20                                   \
33         $*; done
34
35 # run any given test in an infinite loop
36 %.forever: %
37         @while true; do                                         \
38         $(TESTS_ENVIRONMENT)                                    \
39         CK_DEFAULT_TIMEOUT=20                                   \
40         $* || break; done
41
42 # valgrind any given test by running make test.valgrind
43 %.valgrind: %
44         $(TESTS_ENVIRONMENT)                                    \
45         CK_DEFAULT_TIMEOUT=360                                  \
46         G_SLICE=always-malloc                                   \
47         libtool --mode=execute                                  \
48         $(VALGRIND_PATH) -q                                     \
49         $(foreach s,$(SUPPRESSIONS),--suppressions=$(s))        \
50         --tool=memcheck --leak-check=full --trace-children=yes  \
51         --leak-resolution=high --num-callers=20                 \
52         ./$* 2>&1 | tee valgrind.log
53         @if grep "==" valgrind.log > /dev/null 2>&1; then       \
54             rm valgrind.log;                                    \
55             exit 1;                                             \
56         fi
57         @rm valgrind.log
58         
59 # valgrind any given test and generate suppressions for it
60 %.valgrind.gen-suppressions: %
61         $(TESTS_ENVIRONMENT)                                    \
62         CK_DEFAULT_TIMEOUT=360                                  \
63         G_SLICE=always-malloc                                   \
64         libtool --mode=execute                                  \
65         $(VALGRIND_PATH) -q                                     \
66         $(foreach s,$(SUPPRESSIONS),--suppressions=$(s))        \
67         --tool=memcheck --leak-check=full --trace-children=yes  \
68         --leak-resolution=high --num-callers=20                 \
69         --gen-suppressions=all                                  \
70         ./$* 2>&1 | tee suppressions.log
71         
72 # valgrind any given test until failure by running make test.valgrind-forever
73 %.valgrind-forever: %
74         @while $(MAKE) $*.valgrind; do                          \
75           true; done
76
77 # gdb any given test by running make test.gdb
78 %.gdb: %
79         $(TESTS_ENVIRONMENT)                                    \
80         CK_FORK=no                                              \
81         libtool --mode=execute                                  \
82         gdb $*
83
84 # torture tests
85 torture: $(TESTS)
86         -rm test-registry.xml
87         @echo "Torturing tests ..."
88         for i in `seq 1 $(LOOPS)`; do                           \
89                 $(MAKE) check ||                                        \
90                 (echo "Failure after $$i runs"; exit 1) ||      \
91                 exit 1;                                         \
92         done
93         @banner="All $(LOOPS) loops passed";                    \
94         dashes=`echo "$$banner" | sed s/./=/g`;                 \
95         echo $$dashes; echo $$banner; echo $$dashes
96
97 # forever tests
98 forever: $(TESTS)
99         -rm test-registry.xml
100         @echo "Forever tests ..."
101         while true; do                                          \
102                 $(MAKE) check ||                                        \
103                 (echo "Failure"; exit 1) ||                     \
104                 exit 1;                                         \
105         done
106
107 # valgrind all tests
108 valgrind: $(TESTS)
109         @echo "Valgrinding tests ..."
110         @failed=0;                                                      \
111         for t in $(filter-out $(VALGRIND_TESTS_DISABLE),$(TESTS)); do   \
112                 $(MAKE) $$t.valgrind;                                   \
113                 if test "$$?" -ne 0; then                               \
114                         echo "Valgrind error for test $$t";             \
115                         failed=`expr $$failed + 1`;                     \
116                         whicht="$$whicht $$t";                          \
117                 fi;                                                     \
118         done;                                                           \
119         if test "$$failed" -ne 0; then                                  \
120                 echo "$$failed tests had leaks or errors under valgrind:";      \
121                 echo "$$whicht";                                        \
122                 false;                                                  \
123         fi
124
125 # inspect every plugin feature
126 GST_INSPECT = $(GST_TOOLS_DIR)/gst-inspect-$(GST_MAJORMINOR)
127 inspect:
128         @echo "Inspecting features ..."
129         for e in `$(TESTS_ENVIRONMENT) $(GST_INSPECT) | head -n -2      \
130           | cut -d: -f2`;                                               \
131           do echo Inspecting $$e;                                       \
132              $(GST_INSPECT) $$e > /dev/null 2>&1; done
133
134 help:
135         @echo "make check                         -- run all checks"
136         @echo "make torture                       -- run all checks $(LOOPS) times"
137         @echo "make (dir)/(test).check            -- run the given check once"
138         @echo "make (dir)/(test).forever          -- run the given check forever"
139         @echo "make (dir)/(test).torture          -- run the given check $(LOOPS) times"
140         @echo
141         @echo "make (dir)/(test).gdb              -- start up gdb for the given test"
142         @echo
143         @echo "make valgrind                      -- valgrind all tests"
144         @echo "make (dir)/(test).valgrind         -- valgrind the given test"
145         @echo "make (dir)/(test).valgrind-forever -- valgrind the given test forever"
146         @echo "make (dir)/(test).valgrind.gen-suppressions -- generate suppressions"
147         @echo "                                               and save to suppressions.log"
148         @echo "make inspect                       -- inspect all plugin features"
149