From: Zbigniew Jędrzejewski-Szmek Date: Tue, 18 Apr 2023 09:37:52 +0000 (+0200) Subject: test-dlopen: allow loading of multiple libraries X-Git-Tag: v254-rc1~335^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F27853%2Fhead;p=thirdparty%2Fsystemd.git test-dlopen: allow loading of multiple libraries This is useful for debugging, for example if we want to test multiple different dlls being loaded in the same namespace. --- diff --git a/src/test/test-dlopen.c b/src/test/test-dlopen.c index 35981ebc3b4..9c315373b4f 100644 --- a/src/test/test-dlopen.c +++ b/src/test/test-dlopen.c @@ -6,10 +6,14 @@ #include "macro.h" int main(int argc, char **argv) { - void *handle; + void *handles[argc - 1]; + int i; - assert_se(handle = dlopen(argv[1], RTLD_NOW)); - assert_se(dlclose(handle) == 0); + for (i = 0; i < argc - 1; i++) + assert_se(handles[i] = dlopen(argv[i + 1], RTLD_NOW)); + + for (i--; i >= 0; i--) + assert_se(dlclose(handles[i]) == 0); return EXIT_SUCCESS; }