]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
tests/unit: run in parallel
authorMarek Vavruša <marek.vavrusa@nic.cz>
Wed, 11 Mar 2015 15:34:19 +0000 (16:34 +0100)
committerMarek Vavruša <marek.vavrusa@nic.cz>
Wed, 11 Mar 2015 15:34:19 +0000 (16:34 +0100)
tests/runtests [deleted file]
tests/tests.mk

diff --git a/tests/runtests b/tests/runtests
deleted file mode 100755 (executable)
index 960a26a..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/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
index fb31d95818cfb990d64bd71dddc26183f5d4b0d9..4402ada46bfcc109179e21afadfe901f23ba2f03 100644 (file)
@@ -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