unit.mk 984 Bytes
Newer Older
1 2 3 4 5
#
# Unit tests
#

tests_BIN := \
6
	test_array \
7
	test_lru \
8
	test_map \
9
	test_module \
10 11 12 13
	test_pack \
	test_queue \
	test_rplan \
	test_set \
14
	test_trie \
15
	test_utils \
16
	test_zonecut \
17
	#test_cache TODO: re-consider how best to test cache
18

19
mock_cmodule_CFLAGS := -fPIC
20 21 22 23
mock_cmodule_SOURCES := tests/mock_cmodule.c
$(eval $(call make_lib,mock_cmodule,tests))

# Dependencies
24
tests_DEPEND := $(libkres) $(mock_cmodule) $(mock_gomodule)
25
tests_LIBS :=  $(libkres_TARGET) $(libkres_LIBS) $(cmocka_LIBS) $(lmdb_LIBS)
26 27 28

# Make test binaries
define make_test
29
$(1)_CFLAGS := -fPIE
30 31 32 33
$(1)_SOURCES := tests/$(1).c
$(1)_LIBS := $(tests_LIBS)
$(1)_DEPEND := $(tests_DEPEND)
$(call make_bin,$(1),tests)
34
$(1): $$($(1))
35
	$(shell ./scripts/coverage_env.sh "$(TOPSRCDIR)" "$(COVERAGE_STATSDIR)/tests_unit" "$(1)") $(preload_syms) $(DEBUGGER) $$<
36
.PHONY: $(1)
37 38 39 40
endef

# Targets
$(foreach test,$(tests_BIN),$(eval $(call make_test,$(test))))
41
check-unit: $(foreach test,$(tests_BIN),$(test))
42 43

.PHONY: check-unit