Commit 3e11bbeb authored by Marek Vavruša's avatar Marek Vavruša

tests: cleanup module loading to fix broken tests

parent 9079db0b
......@@ -30,9 +30,3 @@
/aclocal.m4
/ltmain.sh
/ylwrap
# CMake files
/CMakeCache.txt
/CMakeFiles
/Makefile
/cmake_install.cmake
......@@ -121,25 +121,27 @@ int kr_module_load(struct kr_module *module, const char *name, const char *path)
}
/* Load all symbols. */
module_api_cb *module_api = NULL;
auto_free char *module_prefix = kr_strcatdup(2, name, "_");
*(void **) (&module_api) = load_symbol(module->lib, module_prefix, "api");
auto_free char *module_prefix = kr_strcatdup(2, name, "_");
*(void **) (&module->init) = load_symbol(module->lib, module_prefix, "init");
*(void **) (&module->deinit) = load_symbol(module->lib, module_prefix, "deinit");
*(void **) (&module->config) = load_symbol(module->lib, module_prefix, "config");
*(void **) (&module->layer) = load_symbol(module->lib, module_prefix, "layer");
/* Module initializer not found, attempt to load as Go shared library. */
if (module_api == NULL) {
int ret = load_libgo(module, &module_api);
if (ret != 0) {
return ret;
/* API check for non-built-in libraries. */
if (module->lib != RTLD_DEFAULT) {
module_api_cb *module_api = NULL;
*(void **) (&module_api) = load_symbol(module->lib, module_prefix, "api");
if (module_api == NULL) {
int ret = load_libgo(module, &module_api);
if (ret != 0) {
return ret;
}
}
}
/* Check module API version (if declared). */
if (module_api && module_api() != KR_MODULE_API) {
return kr_error(ENOTSUP);
/* Check module API version (if declared). */
if (module_api && module_api() != KR_MODULE_API) {
return kr_error(ENOTSUP);
}
}
/* Initialize module */
......
......@@ -90,7 +90,7 @@ endef
# Find binary
define find_bin
ifeq ($$(strip $$($(1)_BIN)),)
HAS_$(1) := $(shell $(1) --version >/dev/null && echo yes || echo no)
HAS_$(1) := $(shell $(1) --version > /dev/null 2>&1 && echo yes || echo no)
else
HAS_$(1) := yes
$(1) := $$($(1)_BIN)
......
......@@ -52,7 +52,6 @@ static PyObject* init(PyObject* self, PyObject* args)
#define CACHE_SIZE 100*1024
mm_ctx_init(&global_mm);
kr_context_init(&global_context, &global_mm);
kr_context_register(&global_context, "hints");
kr_context_register(&global_context, "iterate");
kr_context_register(&global_context, "itercache");
global_tmpdir = test_tmpdir_create();
......
......@@ -42,9 +42,9 @@ $(eval $(call make_shared,_test_integration,tests))
# Preload mock library
insert_libs := tests/libmock_calls$(LIBEXT):modules/hints/hints$(LIBEXT)
ifeq ($(PLATFORM),Darwin)
preload_libs := @DYLD_FORCE_FLAT_NAMESPACE=1 DYLD_INSERT_LIBRARIES=$(insert_libs)
preload_libs := @DYLD_FORCE_FLAT_NAMESPACE=1 DYLD_INSERT_LIBRARIES="$(insert_libs)"
else
preload_libs := @LD_PRELOAD=$(insert_libs)
preload_libs := @LD_PRELOAD="$(subst :, ,$(insert_libs))"
endif
# Targets
......
Markdown is supported
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