Commit e6a89c28 authored by Marek Vavruša's avatar Marek Vavruša

lib/module: use RTLD_NODELETE as a workaround for buggy dlclose

parent a1eae53e
......@@ -38,7 +38,9 @@ static int load_library(struct kr_module *module, const char *name, const char *
return kr_error(ENOMEM);
}
module->lib = dlopen(lib_path, RTLD_LAZY);
/* Workaround for buggy _fini/__attribute__((destructor)) and dlclose(),
* this keeps the library mapped until the program finishes though. */
module->lib = dlopen(lib_path, RTLD_NOW | RTLD_NODELETE);
if (module->lib) {
return kr_ok();
}
......
......@@ -19,8 +19,6 @@
#include "lib/module.h"
mm_ctx_t global_mm;
static void test_module_params(void **state)
{
struct kr_module module;
......@@ -45,15 +43,13 @@ static void test_module_c(void **state)
static void test_module_go(void **state)
{
/* Mock Go module fails on version check. */
struct kr_module module;
assert_int_equal(kr_module_load(&module, "mock_gomodule", "tests"), kr_error(ENOTSUP));
kr_module_unload(&module);
}
int main(void)
{
test_mm_ctx_init(&global_mm);
const UnitTest tests[] = {
unit_test(test_module_params),
unit_test(test_module_builtin),
......
......@@ -58,7 +58,7 @@ $(eval $(call make_shared,_test_integration,tests))
# Targets
.PHONY: check-integration check-unit tests tests-clean
check-integration: check-unit libmock_calls _test_integration
check-integration: libmock_calls _test_integration
$(call preload_LIBS) tests/test_integration.py tests/testdata
check-unit: $(foreach test,$(tests_BIN),$(test)-run)
tests: check-unit check-integration
......
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