Skip to content
Snippets Groups Projects
Commit a1eae53e authored by Marek Vavruša's avatar Marek Vavruša
Browse files

tests/unit: run in parallel

parent 61d5090b
Branches
Tags
No related merge requests found
#!/bin/sh
set -e
# Parse options
BASEDIR="."
eval set -- `getopt b: "$@"`
while [ $# -gt 0 ]; do
case "$1" in
-b) BASEDIR="$2"; shift;;
--) shift; break;;
esac
shift
done
# Process tests
while [ $# -gt 0 ]; do
${BASEDIR}/$1
shift
done
......@@ -20,12 +20,22 @@ $(eval $(call make_lib,mock_gomodule,tests))
tests_DEPEND := libkresolve cmocka mock_cmodule mock_gomodule
tests_LIBS := $(libkresolve_TARGET) $(libkresolve_LIBS) $(cmocka_LIBS)
# Preload mock library
preload_PATH := tests
ifeq ($(PLATFORM),Darwin)
preload_LIBS := @DYLD_FORCE_FLAT_NAMESPACE=1 DYLD_LIBRARY_PATH="$(preload_PATH):${DYLD_LIBRARY_PATH}"
else
preload_LIBS := @LD_LIBRARY_PATH="$(preload_PATH):${LD_LIBRARY_PATH}"
endif
# Make test binaries
define make_test
$(1)_SOURCES := tests/$(1).c
$(1)_LIBS := $(tests_LIBS)
$(1)_DEPEND := $(tests_DEPEND)
$(call make_bin,$(1),tests)
$(1)-run: $(1)
$(call preload_LIBS) tests/$$<
endef
$(foreach test,$(tests_BIN),$(eval $(call make_test,$(test))))
......@@ -42,23 +52,14 @@ $(eval $(call make_lib,libmock_calls,tests))
# Python module for tests
_test_integration_SOURCES := tests/test_integration.c
_test_integration_LIBS := -Wl,-rpath,tests -Ltests -lmock_calls $(libmock_calls_LIBS)
_test_integration_LIBS := -Ltests -lmock_calls $(libmock_calls_LIBS)
_test_integration_DEPEND := libmock_calls
$(eval $(call make_shared,_test_integration,tests))
# Preload mock library
preload_PATH := tests
ifeq ($(PLATFORM),Darwin)
preload_LIBS := @DYLD_FORCE_FLAT_NAMESPACE=1 DYLD_LIBRARY_PATH="$(preload_PATH):${DYLD_LIBRARY_PATH}"
else
preload_LIBS := @LD_LIBRARY_PATH="$(preload_PATH):${LD_LIBRARY_PATH}"
endif
# Targets
.PHONY: check-integration check-unit tests tests-clean
check-integration: libmock_calls _test_integration
check-integration: check-unit libmock_calls _test_integration
$(call preload_LIBS) tests/test_integration.py tests/testdata
check-unit: $(tests_BIN)
$(call preload_LIBS) tests/runtests -b tests $^
check-unit: $(foreach test,$(tests_BIN),$(test)-run)
tests: check-unit check-integration
tests-clean: $(foreach test,$(tests_BIN),$(test)-clean) libmock_calls-clean _test_integration-clean
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment