summaryrefslogtreecommitdiffstats
path: root/tests/unit.mk
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 00:55:53 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 00:55:53 +0000
commit3d0386f27ca66379acf50199e1d1298386eeeeb8 (patch)
treef87bd4a126b3a843858eb447e8fd5893c3ee3882 /tests/unit.mk
parentInitial commit. (diff)
downloadknot-resolver-3d0386f27ca66379acf50199e1d1298386eeeeb8.tar.xz
knot-resolver-3d0386f27ca66379acf50199e1d1298386eeeeb8.zip
Adding upstream version 3.2.1.upstream/3.2.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--tests/unit.mk43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/unit.mk b/tests/unit.mk
new file mode 100644
index 0000000..6819fb0
--- /dev/null
+++ b/tests/unit.mk
@@ -0,0 +1,43 @@
+#
+# Unit tests
+#
+
+tests_BIN := \
+ test_array \
+ test_lru \
+ test_map \
+ test_module \
+ test_pack \
+ test_queue \
+ test_rplan \
+ test_set \
+ test_trie \
+ test_utils \
+ test_zonecut \
+ #test_cache TODO: re-consider how best to test cache
+
+mock_cmodule_CFLAGS := -fPIC
+mock_cmodule_SOURCES := tests/mock_cmodule.c
+$(eval $(call make_lib,mock_cmodule,tests))
+
+# Dependencies
+tests_DEPEND := $(libkres) $(mock_cmodule) $(mock_gomodule)
+tests_LIBS := $(libkres_TARGET) $(libkres_LIBS) $(cmocka_LIBS) $(lmdb_LIBS)
+
+# Make test binaries
+define make_test
+$(1)_CFLAGS := -fPIE
+$(1)_SOURCES := tests/$(1).c
+$(1)_LIBS := $(tests_LIBS)
+$(1)_DEPEND := $(tests_DEPEND)
+$(call make_bin,$(1),tests)
+$(1): $$($(1))
+ $(shell ./scripts/coverage_env.sh "$(TOPSRCDIR)" "$(COVERAGE_STATSDIR)/tests_unit" "$(1)") $(preload_syms) $(DEBUGGER) $$<
+.PHONY: $(1)
+endef
+
+# Targets
+$(foreach test,$(tests_BIN),$(eval $(call make_test,$(test))))
+check-unit: $(foreach test,$(tests_BIN),$(test))
+
+.PHONY: check-unit