File: Makefile.tests.am

package info (click to toggle)
buzztrax 0.10.2-10
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 19,984 kB
  • sloc: ansic: 109,707; sh: 12,875; cpp: 10,882; xml: 6,081; makefile: 508; javascript: 338; asm: 116
file content (479 lines) | stat: -rw-r--r-- 15,984 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
if BUILD_CHECK_TESTS
  TESTS_BIN = bt_core bt_ic bt_gst bt_cmd bt_edit
else
  TESTS_BIN =
endif

if USE_ALSA
ALSA_C_TEST_FILES=tests/lib/ic/e-aseq-discoverer.c
else
ALSA_C_TEST_FILES=
endif

TESTS = \
  $(TESTS_BIN) \
  tests/bt-cmd-info.sh \
  tests/bt-cmd-cli.sh \
  tests/bt-dec-launch.sh \
  tests/bt-edit-cli.sh \
  tests/povalid.sh \
  tests/xmlvalid.sh

CHECK_REGISTRY = $(top_builddir)/tests/test-registry.reg

# prevent endless loops, this requires bash, see idea in bt-check.c
#   ulimit -St20;
#
# http://www.cynapses.org/tmp/gcc/malloc_perturb
#    MALLOC_PERTURB_=$(($RANDOM % 255 + 1))
#
# set theme (check which theme is used)
#    GTK2_RC_FILES=$HOME/.themes/Darkilouche/gtk-2.0/gtkrc
#
# hint alsa/pulseaudio to be quiet
#    PULSE_SINK=???
#    ALSA_CARD, ALSA_PCM_CARD, DISPLAY_ALSA_DEVICE, AUDIODEV
#
# for gtk/x11 issues
#    GDK_SYNCHRONIZE=1
#
TESTS_ENVIRONMENT = \
	CK_DEFAULT_TIMEOUT=20 \
	LANG=C \
	XDG_CACHE_HOME=$(abs_builddir) \
	GSETTINGS_BACKEND=memory \
	GSETTINGS_SCHEMA_DIR=$(abs_top_builddir) \
	NO_AT_BRIDGE=1 \
	GST_DEBUG_FILE=/dev/null \
	GST_REGISTRY_1_0=$(CHECK_REGISTRY) \
	GST_PLUGIN_SYSTEM_PATH_1_0= \
	GST_PLUGIN_PATH_1_0=$(top_builddir)/.libs:$(GST_PLUGINS_DIR) \
	$(LIBTOOL) --mode=execute

# This should make the icon theme look here for icons too, but instead it breaks tons of things
#	XDG_DATA_DIRS=$XDG_DATA_DIRS:$(abs_top_srcdir)

# the core dumps of some machines have PIDs appended, test registry and
# profiling data
# most of the files are there due to XDG_CACHE_HOME=$(abs_builddir)
CLEANFILES += core core.* *.gcno *.gcda bt_*.tar.bz2 \
  tests/test-registry.* fontconfig/*

if BUILD_CHECK_TESTS
noinst_PROGRAMS=$(TESTS_BIN)

/tmp/test.wav:
	$(AM_V_GEN) gst-launch-@GST_MAJORMINOR@ -q audiotestsrc num-buffers=10 ! wavenc ! filesink location=$@

gschemas.compiled: org.buzztrax.gschema.xml
	$(AM_V_GEN) $(GLIB_COMPILE_SCHEMAS) .

tests/bt-cmd-info.sh:
	gschemas.compiled
tests/bt-cmd-cli.sh:
	gschemas.compiled
tests/bt-edit-cli.sh:
	gschemas.compiled


check_LTLIBRARIES = \
  libbt-check.la \
  libbt-check-ui.la \
  libbtcore-check.la \
  libbtic-check.la \
  libbtgst-check.la \
  libbt-cmd-check.la \
  libbt-edit-check.la

libbt_check_la_LIBADD = \
	libbuzztrax-ic.la \
	libbuzztrax-core.la \
	$(BASE_DEPS_LIBS) $(BT_LIBS) $(CHECK_LIBS)
libbt_check_la_LDFLAGS = \
	-Wl,--rpath -Wl,$(abs_top_builddir)/.libs
libbt_check_la_SOURCES = \
	tests/bt-check.c tests/bt-check.h \
	tests/bt-test-application.c tests/bt-test-application.h \
	tests/bt-test-plugin.c tests/bt-test-plugin.h \
	tests/btic-test-device.c tests/btic-test-device.h
EXTRA_libbt_check_la_DEPENDENCIES = /tmp/test.wav gschemas.compiled

libbt_check_ui_la_LIBADD = \
  $(BASE_DEPS_LIBS) $(GUI_DEPS_LIBS) $(BT_LIBS)
libbt_check_ui_la_LDFLAGS = \
	-Wl,--rpath -Wl,$(abs_top_builddir)/.libs
libbt_check_ui_la_CFLAGS = $(GUI_DEPS_CFLAGS) $(CHECK_CFLAGS)
libbt_check_ui_la_SOURCES = \
	tests/bt-check-ui.c tests/bt-check-ui.h
  
bt_core_LDADD = \
	libbtcore-check.la \
	libbuzztrax-core.la \
	libbt-check.la $(BASE_DEPS_LIBS) $(BT_LIBS) $(LIBM) $(CHECK_LIBS)
bt_core_LDFLAGS =  \
	-Wl,--rpath -Wl,$(abs_top_builddir)/.libs
bt_core_SOURCES = \
	tests/m-bt-core.c

bt_ic_LDADD = \
	libbtic-check.la \
	libbuzztrax-ic.la \
	libbuzztrax-core.la \
	libbt-check.la $(BASE_DEPS_LIBS) $(BT_LIBS) $(LIBM) $(CHECK_LIBS)
bt_ic_LDFLAGS =  \
	-Wl,--rpath -Wl,$(abs_top_builddir)/.libs
bt_ic_SOURCES = \
	tests/m-bt-ic.c

bt_gst_LDADD = \
  libbtgst-check.la \
	libbuzztrax-gst.la \
	libbt-check.la $(BASE_DEPS_LIBS) $(CHECK_LIBS) $(LIBM)
bt_gst_LDFLAGS =  \
	-Wl,--rpath -Wl,$(abs_top_builddir)/.libs
bt_gst_SOURCES = \
  tests/m-bt-gst.c

bt_cmd_LDADD = \
	libbt-cmd-check.la \
	libbuzztrax-core.la \
	libbt-check.la $(BASE_DEPS_LIBS) $(BT_LIBS) $(LIBM) $(CHECK_LIBS)
bt_cmd_LDFLAGS =  \
	-Wl,--rpath -Wl,$(abs_top_builddir)/.libs
bt_cmd_SOURCES = \
	tests/m-bt-cmd.c

bt_edit_LDADD = \
	libbt-edit-check.la \
	libbuzztrax-core.la \
	libbuzztrax-ic.la \
	libbt-check.la libbt-check-ui.la \
	$(BASE_DEPS_LIBS) $(GUI_DEPS_LIBS) $(BT_LIBS) $(LIBM) $(CHECK_LIBS)
bt_edit_LDFLAGS =  \
	-Wl,--rpath -Wl,$(abs_top_builddir)/.libs
bt_edit_CFLAGS = $(GUI_DEPS_CFLAGS) $(CHECK_CFLAGS)
bt_edit_SOURCES = \
	tests/m-bt-edit.c

libbtcore_check_la_LIBADD = $(BASE_DEPS_LIBS)
libbtcore_check_la_CFLAGS = $(BASE_DEPS_CFLAGS) $(CHECK_CFLAGS)
libbtcore_check_la_SOURCES = tests/lib/core/m-bt-core.h \
	tests/lib/core/e-application.c \
	tests/lib/core/e-audio-session.c \
	tests/lib/core/e-cmd-pattern.c tests/lib/core/t-cmd-pattern.c \
	tests/lib/core/e-core.c tests/lib/core/t-core.c \
	tests/lib/core/e-machine.c tests/lib/core/t-machine.c \
	tests/lib/core/e-parameter-group.c tests/lib/core/t-parameter-group.c \
	tests/lib/core/e-pattern.c tests/lib/core/t-pattern.c \
	tests/lib/core/e-pattern-control-source.c tests/lib/core/t-pattern-control-source.c \
	tests/lib/core/e-processor-machine.c tests/lib/core/t-processor-machine.c \
	tests/lib/core/e-sequence.c tests/lib/core/t-sequence.c \
	tests/lib/core/e-settings.c \
	tests/lib/core/e-setup.c tests/lib/core/t-setup.c \
	tests/lib/core/e-sink-bin.c tests/lib/core/t-sink-bin.c \
	tests/lib/core/e-sink-machine.c tests/lib/core/t-sink-machine.c \
	tests/lib/core/e-song.c tests/lib/core/t-song.c \
	tests/lib/core/e-song-io.c tests/lib/core/t-song-io.c \
	tests/lib/core/e-song-io-native.c tests/lib/core/t-song-io-native.c \
	tests/lib/core/e-song-info.c tests/lib/core/t-song-info.c \
	tests/lib/core/e-source-machine.c tests/lib/core/t-source-machine.c \
	tests/lib/core/e-tools.c tests/lib/core/t-tools.c \
	tests/lib/core/e-value-group.c tests/lib/core/t-value-group.c \
	tests/lib/core/e-wave.c tests/lib/core/t-wave.c \
	tests/lib/core/e-wave-table.c tests/lib/core/t-wave-table.c \
	tests/lib/core/e-wire.c tests/lib/core/t-wire.c

libbtic_check_la_LIBADD = $(BASE_DEPS_LIBS)
libbtic_check_la_CFLAGS = $(BASE_DEPS_CFLAGS) $(CHECK_CFLAGS)
libbtic_check_la_SOURCES = tests/lib/ic/m-bt-ic.h \
	tests/lib/ic/e-device.c \
	tests/lib/ic/e-ic.c tests/lib/ic/t-ic.c \
	tests/lib/ic/e-learn.c \
	tests/lib/ic/e-registry.c \
	$(ALSA_C_TEST_FILES)

libbtgst_check_la_LIBADD = $(BASE_DEPS_LIBS) $(LIBM)
libbtgst_check_la_CFLAGS = $(BASE_DEPS_CFLAGS) $(CHECK_CFLAGS)
libbtgst_check_la_SOURCES = tests/lib/gst/m-bt-gst.h \
	tests/lib/gst/e-combine.c \
	tests/lib/gst/e-envelope-ad.c \
	tests/lib/gst/e-envelope-d.c \
	tests/lib/gst/e-filter-svf.c \
	tests/lib/gst/e-osc-synth.c \
	tests/lib/gst/e-toneconversion.c tests/lib/gst/t-toneconversion.c \
	tests/lib/gst/t-elements.c

libbt_cmd_check_la_LIBADD = \
	libbtcmd.la \
	$(BASE_DEPS_LIBS)
libbt_cmd_check_la_CFLAGS = $(GUI_DEPS_CFLAGS) $(CHECK_CFLAGS)
libbt_cmd_check_la_SOURCES = tests/ui/cmd/m-bt-cmd.h \
	tests/ui/cmd/e-cmd-application.c tests/ui/cmd/t-cmd-application.c

libbt_edit_check_la_LIBADD = \
	libbtedit.la \
	$(BASE_DEPS_LIBS) $(GUI_DEPS_LIBS)
libbt_edit_check_la_CFLAGS = $(GUI_DEPS_CFLAGS) $(CHECK_CFLAGS)
libbt_edit_check_la_SOURCES = tests/ui/edit/m-bt-edit.h \
	tests/ui/edit/e-about-dialog.c \
	tests/ui/edit/e-change-log.c tests/ui/edit/t-change-log.c \
	tests/ui/edit/e-crash-recover-dialog.c \
	tests/ui/edit/e-edit-application.c \
	tests/ui/edit/e-interaction-controller-menu.c \
	tests/ui/edit/e-machine-actions.c \
	tests/ui/edit/e-machine-canvas-item.c \
	tests/ui/edit/e-machine-list-model.c \
	tests/ui/edit/e-machine-preset-properties-dialog.c \
	tests/ui/edit/e-machine-preferences-dialog.c \
	tests/ui/edit/e-machine-properties-dialog.c \
	tests/ui/edit/e-machine-rename-dialog.c \
	tests/ui/edit/e-main-page-info.c \
	tests/ui/edit/e-main-page-machines.c \
	tests/ui/edit/e-main-page-patterns.c tests/ui/edit/t-main-page-patterns.c \
	tests/ui/edit/e-main-page-sequence.c \
	tests/ui/edit/t-main-page-waves.c \
	tests/ui/edit/e-main-pages.c \
	tests/ui/edit/e-main-window.c \
	tests/ui/edit/e-missing-framework-elements-dialog.c \
	tests/ui/edit/e-missing-song-elements-dialog.c \
	tests/ui/edit/e-object-list-model.c tests/ui/edit/t-object-list-model.c \
	tests/ui/edit/e-pattern-list-model.c \
	tests/ui/edit/e-pattern-properties-dialog.c \
	tests/ui/edit/e-render-dialog.c \
	tests/ui/edit/e-sequence-grid-model.c \
	tests/ui/edit/e-settings-dialog.c \
	tests/ui/edit/e-signal-analysis-dialog.c \
	tests/ui/edit/e-tip-dialog.c \
	tests/ui/edit/e-ui-resources.c \
	tests/ui/edit/e-wave-list-model.c \
	tests/ui/edit/e-wavelevel-list-model.c \
	tests/ui/edit/e-wire-canvas-item.c

else
noinst_PROGRAMS =
endif


noinst_PROGRAMS += bmltest_info bmltest_process

bmltest_info_SOURCES = tests/lib/bml/bmltest_info.c tests/lib/bml/bmltest_info.h
bmltest_info_CFLAGS = $(PTHREAD_CFLAGS) $(BML_CFLAGS)
bmltest_info_LDADD = $(LIBM) $(PTHREAD_LIBS) $(BML_LIBS) libbml.la

bmltest_process_SOURCES = tests/lib/bml/bmltest_process.c  tests/lib/bml/bmltest_process.h
bmltest_process_CFLAGS = $(PTHREAD_CFLAGS) $(BML_CFLAGS)
bmltest_process_LDADD = $(LIBM) $(PTHREAD_LIBS) $(BML_LIBS) libbml.la


songdatadir = $(datadir)/$(PACKAGE)/songs
songdata_DATA = \
	tests/songs/buzz1.xml \
	tests/songs/buzz2.xml \
	tests/songs/buzz3.xml \
	tests/songs/buzz4.xml \
	tests/songs/buzz5.xml \
	tests/songs/buzz6.xml \
	tests/songs/buzz7.xml \
	tests/songs/buzz8.xml \
	tests/songs/buzz9.xml \
	tests/songs/combi1.xml \
	tests/songs/combi2.xml \
	tests/songs/combi3.xml \
	tests/songs/melo1.xml \
	tests/songs/melo2.xml \
	tests/songs/melo3.xml \
	tests/songs/melo4.xml \
	tests/songs/melo5.xml \
	tests/songs/melo6.xml

noinst_songdata = \
	tests/songs/broken1.xml \
	tests/songs/broken1.bzt \
	tests/songs/broken2.xml \
	tests/songs/broken3.xml \
	tests/songs/broken4.xml \
	tests/songs/empty.xml \
	tests/songs/example.xml \
	tests/songs/legacy1.xml \
	tests/songs/samples1.bzt \
	tests/songs/samples2.bzt \
	tests/songs/simple1.xml \
	tests/songs/simple2.xml \
	tests/songs/simple3.xml \
	tests/songs/simple4.xml \
	tests/songs/simple5.xml \
	tests/songs/simple6.xml \
	tests/songs/simple1.bzt \
	tests/songs/simple2.bzt \
	tests/songs/simple3.bzt \
	tests/songs/simple4.bzt \
	tests/songs/simple5.bzt \
	tests/songs/test-simple0.xml \
	tests/songs/test-simple1.xml \
	tests/songs/test-simple2.xml \
	tests/songs/test-simple3.xml \
	tests/songs/test-simple4.xml \
	tests/songs/test-simple5.xml

EXTRA_DIST += \
	$(songdata_DATA) $(noinst_songdata) \
	tests/povalid.sh tests/xmlvalid.sh tests/shunit2 \
	tests/bt-cfg.sh.in tests/bt-cmd-info.sh tests/bt-cmd-encode.sh \
	tests/bt-cmd-cli.sh tests/bt-dec-launch.sh tests/bt-edit-cli.sh \
	tests/lib/bml/sorttable.js tests/lib/bml/testmachine.sh

test-clean-local:
	@rm -f \
	  $(top_builddir)/tests/songs/*.txt \
	  $(top_builddir)/tests/songs/*.ogg \
	  $(abs_builddir)/buzztrax/*.log \
	  $(top_builddir)/event-sound-cache.tdb.* \
	  $(top_builddir)/bt_*.tar.bz2 \
	  /tmp/test.wav;
	@rm -rf gstreamer-1.0;
	@if test -d $(abs_builddir)/buzztrax; then \
	  rmdir $(abs_builddir)/buzztrax; \
	fi;

# make check           -- run all checks
# make (test).check    -- run the given check once
#	make (test).check BT_CHECKS="test5*" -- run the given testcase(s) only
%.check: %
	@$(TESTS_ENVIRONMENT)	\
	./$*

LOOPS ?= 10
# make (test).loop     -- run the given check 10 times
# make (test).loop LOOPS=20 -- run the given check 20 times
%.loop: %
	@for i in `seq 1 $(LOOPS)`; do \
	$(TESTS_ENVIRONMENT) \
	./$*; done

# make (test).forever  -- run the given check indefinitely
%.forever: %
	@while true; do	\
	$(TESTS_ENVIRONMENT) \
	./$* || break; done

# make (test).gdb      -- start up gdb for the given test
%.gdb: %
	@CK_FORK=no		\
	$(TESTS_ENVIRONMENT)	\
	gdb ./$*

# make (test).refdbg   -- run test under refdbg
%.refdbg: %
	@CK_FORK=no		\
	$(TESTS_ENVIRONMENT)	\
	refdbg -c "btnum=20 ; logobjs=0 ; $(REFDBG_RULE)" \
	./$*

# make (test).strace  -- run test under strace
%.strace: %
	@CK_FORK=no		\
	$(TESTS_ENVIRONMENT)	\
	strace -e file -o /tmp/strace.log ./$*

## todo: check if code has been compiled using --enable-debug
##
##check-local:
##	echo "========================================"
##	echo "No check based tests will run"
##	echo "build with --enable-debug=yes"
##	echo "========================================"

.PHONY: \
  coverage class-coverage \
  valgrind test-status

# make coverage        -- generate coverage report from make check run
if USE_LCOV
coverage::
	$(MKDIR_P) ./coverage
	lcov --compat-libtool --directory . --zerocounters
	-$(MAKE) check
	lcov --compat-libtool --directory ./src --capture --output-file ./coverage/$(PACKAGE)_tmp.info
	lcov --compat-libtool --extract ./coverage/$(PACKAGE)_tmp.info "$(PWD)/src*" -o ./coverage/$(PACKAGE).info
	$(RM) ./coverage/$(PACKAGE)_tmp.info
	genhtml -o ./coverage --num-spaces 2 ./coverage/$(PACKAGE).info
endif
if USE_BCOV
## CK_FORK=no bcov -l../src/tests/lib/core/.libs/libbuzztrax-core.so ./.libs/bt_cmd
## CK_FORK=no bcov -l../src/tests/lib/core/.libs/libbuzztrax-core.so -l../src/tests/lib/ic/.libs/libbuzztrax-ic.so ./.libs/bt_core
## CK_FORK=no libtool --mode=execute bcov -l../src/tests/lib/core/.libs/libbuzztrax-core.so -l../src/tests/lib/ic/.libs/libbuzztrax-ic.so ./bt_core
## - we're missing the libs coverage, but it is not due to BSymbolic :/
coverage:: $(TESTS_BIN)
	echo "command make check" >.bcovdump.all; \
	echo "date "`date` >>.bcovdump.all; \
	for i in $^; do \
	  CK_FORK="no" $(TESTS_ENVIRONMENT) bcov \
	    -l$(top_builddir)/src/.libs/libbuzztrax-core.so \
	    -l$(top_builddir)/src/.libs/libbuzztrax-ic.so \
	    ./$$i; \
	  if test -f .bcovdump; then \
	    tail -n +5 .bcovdump >>.bcovdump.all; \
	    rm -f .bcovdump; \
	  fi \
	done; \
	$(MKDIR_P) coverage; \
	bcov-report -i $(top_abs_srcdir) .bcovdump.all coverage
endif

# make class-coverage  -- generate coverage report on class level
class-coverage::
	@for dir in lib/core/ lib/ic ui/cmd ui/edit; do \
	  (cd $(top_srcdir)/src/$$dir; ls -1 *.c) | egrep -v "(marshal|bt-edit|bt-cmd)" >/tmp/c1.txt; \
	  (cd $(top_srcdir)/tests/$$dir; ls -1 s-*.c | cut -c3-) >/tmp/c2.txt; \
	  total=`cat /tmp/c1.txt | wc -l`; \
	  done=`comm -1 -2 /tmp/c1.txt /tmp/c2.txt | wc -l`; \
	  percent=`echo "$${done}00/$$total" | bc`; \
	  echo "# $$percent % ($$done/$$total) $$dir"; \
	  comm -2 -3 /tmp/c1.txt /tmp/c2.txt | sed "s/^/  /g"; \
	done; \
	rm /tmp/c1.txt /tmp/c2.txt


if USE_VALGRIND

VALPREFIX = \
	CK_FORK=no CK_DEFAULT_TIMEOUT=500 \
	LANG=C XDG_CACHE_HOME=$(abs_builddir) \
	G_SLICE=always-malloc G_DEBUG=gc-friendly \
	GLIBCPP_FORCE_NEW=1 GLIBCXX_FORCE_NEW=1
VALDEFAULT = @VALGRIND@/bin/valgrind
VALSUPP = @VALGRIND@/lib/valgrind
VALSUPPRESSIONDEF = --suppressions=$(VALSUPP)/default.supp
VALSUPPRESSIONOWN = --suppressions=$(top_builddir)/buzztrax.supp \
	--suppressions=$(top_builddir)/gst.supp \
	--suppressions=$(top_builddir)/gtk.supp
VALSUPPRESSION = $(VALSUPPRESSIONDEF) $(VALSUPPRESSIONOWN)
VALOPTIONS = --trace-children=yes --num-callers=30 --read-var-info=yes \
  --tool=memcheck --leak-check=full --leak-resolution=high --track-origins=yes
VALCMD = $(VALPREFIX) $(VALDEFAULT) $(VALOPTIONS) $(VALSUPPRESSION)

## for file in /tmp/bt_core.valgrind.pid*; do grep -q "ERROR SUMMARY: 0 errors from 0 contexts" $file ; if test $? == 0; then rm $file; fi; done
## grep -H "ERROR SUMMARY: " /tmp/bt_core.valgrind.pid* | uniq

# make valgrind        -- valgrind all tests
valgrind:: $(TESTS_BIN)
	for i in $^; do \
	  rm -rf /tmp/$$i.valgrind.pid*; \
	  $(VALCMD) --log-file=/tmp/$$i.valgrind.pid%p ./$$i; \
	  grep -l "ERROR SUMMARY: 0 errors from 0 contexts" /tmp/$$i.valgrind.pid* | xargs rm; \
	done

# make (test).valgrind -- valgrind the given test"
%.valgrind: %
	rm -rf /tmp/$*.valgrind.pid*; \
	$(VALCMD) --log-file=/tmp/$*.valgrind.pid%p ./$*; \
	grep -l "ERROR SUMMARY: 0 errors from 0 contexts" /tmp/$*.valgrind.pid* | xargs rm;

endif

# make test-status     -- show info about disabled tests
test-status::
	@grep -r -A2 -B6 -Hn --include="*.c" "#ifdef __CHECK_DISABLED__" . | grep -e '\.c-[0-9][0-9]*-\(\/\/\|\/\*\|\ \*\|ST\)' 
	@echo "number of disabled tests"
	@grep -r -Hn --include="*.c" --color=auto "#ifdef __CHECK_DISABLED__" . | wc -l