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.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2023-05-30 16:05:06 +02:00
parent 6483bcef54
commit 5ad6600364
+7 -3
View File
@@ -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;
}