Reorder functions to not declare them on top
[empathy.git] / rules / check.mak
blobbbb9819f23a10bd31e8ca0c7fe3926aecf286362
1 LOOPS = 10
2 CLEANFILES += valgrind.*.log
4 # run any given test by running make test.check
5 # if the test fails, run it again at at least debug level 2
6 %.check: %
7 @$(TESTS_ENVIRONMENT) \
8 $* || \
9 $(TESTS_ENVIRONMENT) \
12 # run any given test in a loop
13 %.torture: %
14 @for i in `seq 1 $(LOOPS)`; do \
15 $(TESTS_ENVIRONMENT) \
16 $*; done
18 # run any given test in an infinite loop
19 %.forever: %
20 @while true; do \
21 $(TESTS_ENVIRONMENT) \
22 $* || break; done
24 # valgrind any given test by running make test.valgrind
25 %.valgrind: %
26 $(TESTS_ENVIRONMENT) \
27 CK_DEFAULT_TIMEOUT=360 \
28 G_SLICE=always-malloc \
29 G_DEBUG=gc-friendly \
30 libtool --mode=execute \
31 $(VALGRIND_PATH) -q \
32 $(foreach s,$(SUPPRESSIONS),--suppressions=$(s)) \
33 --tool=memcheck --leak-check=full --trace-children=yes \
34 --leak-resolution=high --num-callers=20 \
35 ./$* 2>&1 | tee "valgrind.$*.log"
36 @if grep "==" "valgrind.$*.log" > /dev/null 2>&1; then \
37 exit 1; \
40 # valgrind any given test and generate suppressions for it
41 %.valgrind.gen-suppressions: %
42 $(TESTS_ENVIRONMENT) \
43 CK_DEFAULT_TIMEOUT=360 \
44 G_SLICE=always-malloc \
45 G_DEBUG=gc-friendly \
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 --gen-suppressions=all \
52 ./$* 2>&1 | tee suppressions.log
54 # valgrind any given test until failure by running make test.valgrind-forever
55 %.valgrind-forever: %
56 @while $(MAKE) $*.valgrind; do \
57 true; done
59 # gdb any given test by running make test.gdb
60 %.gdb: %
61 $(TESTS_ENVIRONMENT) \
62 CK_FORK=no \
63 libtool --mode=execute \
64 gdb $*
66 # torture tests
67 torture: $(TESTS)
68 @echo "Torturing tests ..."
69 for i in `seq 1 $(LOOPS)`; do \
70 $(MAKE) check || \
71 (echo "Failure after $$i runs"; exit 1) || \
72 exit 1; \
73 done
74 @banner="All $(LOOPS) loops passed"; \
75 dashes=`echo "$$banner" | sed s/./=/g`; \
76 echo $$dashes; echo $$banner; echo $$dashes
78 # forever tests
79 forever: $(TESTS)
80 @echo "Forever tests ..."
81 while true; do \
82 $(MAKE) check || \
83 (echo "Failure"; exit 1) || \
84 exit 1; \
85 done
87 # valgrind all tests
88 valgrind: $(TESTS)
89 @echo "Valgrinding tests ..."
90 @failed=0; \
91 for t in $(filter-out $(VALGRIND_TESTS_DISABLE),$(TESTS)); do \
92 $(MAKE) $$t.valgrind; \
93 if test "$$?" -ne 0; then \
94 echo "Valgrind error for test $$t"; \
95 failed=`expr $$failed + 1`; \
96 whicht="$$whicht $$t"; \
97 fi; \
98 done; \
99 if test "$$failed" -ne 0; then \
100 echo "$$failed tests had leaks or errors under valgrind:"; \
101 echo "$$whicht"; \
102 false; \
105 help:
106 @echo "make check -- run all checks"
107 @echo "make torture -- run all checks $(LOOPS) times"
108 @echo "make (dir)/(test).check -- run the given check once"
109 @echo "make (dir)/(test).forever -- run the given check forever"
110 @echo "make (dir)/(test).torture -- run the given check $(LOOPS) times"
111 @echo
112 @echo "make (dir)/(test).gdb -- start up gdb for the given test"
113 @echo
114 @echo "make valgrind -- valgrind all tests"
115 @echo "make (dir)/(test).valgrind -- valgrind the given test"
116 @echo "make (dir)/(test).valgrind-forever -- valgrind the given test forever"
117 @echo "make (dir)/(test).valgrind.gen-suppressions -- generate suppressions"
118 @echo " and save to suppressions.log"
119 @echo "make inspect -- inspect all plugin features"