Repository navigation
Expand file tree
/
Copy pathMakefile.test
More file actions
70 lines (59 loc) · 2.67 KB
/
Copy pathMakefile.test
File metadata and controls
70 lines (59 loc) · 2.67 KB
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
# Are we running a specific module's tests or just the core tests?
ifndef module
module=core
endif
# A module carries its suite as test/opensips.cfg plus a mod_tests() export, so
# the config doubles as the marker for "this module has unit tests". An
# excluded module drops out along with its suite, as nothing built its .so.
test_module_paths=$(filter $(enabled_module_paths), \
$(patsubst %/test/opensips.cfg,%, \
$(foreach d,$(MODULE_DIRS),$(wildcard $(d)/*/test/opensips.cfg))))
test_module_targets=$(addprefix test-,$(notdir $(test_module_paths)))
.PHONY: test unit_tests system_tests test-modules $(test_module_targets)
ifneq (,$(findstring UNIT_TESTS,$(DEFS)))
include Makefile.openssl
misclibs=lib/digest_auth/libdigest_auth.a
UNIT_TESTS=1
endif
ensure_test_defs:
ifndef UNIT_TESTS
@! grep -q '^DEFS+= -DUNIT_TESTS' Makefile.conf && \
echo '\nDEFS+= -DUNIT_TESTS' >> Makefile.conf && \
echo "-DUNIT_TESTS was not enabled in Makefile.conf," \
"run 'make test' again." && exit 1 || true
else
@true
endif
unit_tests: ensure_test_defs $(NAME)
-@echo " ============= Start Unit Tests ============="
./$(NAME) -dd -T $(module) -w .
-@echo " ================================================"
-@echo " ======== Passed All Tests! ᕦ(ò_óˇ)ᕤ ========"
-@echo " ================================================"
# One target per module suite. The module is a prerequisite because `make all`
# builds only the modules/ collection (Makefile:113), leaving a contrib module
# with no .so for its suite to load -- and so are the other contrib modules
# its config loads.
test_cfg_contrib_modules=$(filter $(enabled_module_paths), \
$(wildcard $(addprefix modules-contrib/, \
$(shell sed -n 's/^loadmodule "\(.*\)\.so".*/\1/p' \
$(1)/test/opensips.cfg))))
# A module whose optional library is missing builds no .so (its Makefile
# skips itself, e.g. the NATS modules without libnats): there is nothing to
# load, so its suite is skipped rather than failed.
define module_test_rule
test-$(notdir $(1)): ensure_test_defs $$(NAME) $(1) $(call test_cfg_contrib_modules,$(1))
-@echo " ==== $(notdir $(1)) ===="
@if [ ! -f $(1)/$(notdir $(1)).so ]; then \
echo " skipped: $(notdir $(1)).so was not built"; \
else \
./$$(NAME) -dd -T $(notdir $(1)) -w .; \
fi
endef
$(foreach m,$(test_module_paths),$(eval $(call module_test_rule,$(m))))
# Every module suite. Add -k to keep going past a failing one and still exit
# non-zero; the suites share udp:localhost:5059, so they cannot run under -j.
test-modules: $(test_module_targets)
system_tests:
$(MAKE) -C test/ all
test: unit_tests #system_tests #TODO: bring these up to date!