X-Git-Url: https://git.liburcu.org/?p=lttng-tools.git;a=blobdiff_plain;f=tests%2Fregression%2Fust%2Fust-dl%2Fprog.c;h=e8e4b2641a1c6a0437c0e94ca6933eda741e30fc;hp=015eee6269830e8e6e2150c7d9dbf592bfd66e96;hb=d8ed06afceb2d0517633814f7f2a04f69ac71da6;hpb=6f698634fc3357dac77ea7e7ab9d07b7b8bf9270 diff --git a/tests/regression/ust/ust-dl/prog.c b/tests/regression/ust/ust-dl/prog.c index 015eee626..e8e4b2641 100644 --- a/tests/regression/ust/ust-dl/prog.c +++ b/tests/regression/ust/ust-dl/prog.c @@ -1,16 +1,72 @@ +/* _GNU_SOURCE is defined by config.h */ #include +#include +#include +#include +#include -int main() +/* + * libfoo has a direct dependency on libbar. + * libbar has a direct dependency on libzzz. + * This test is therefore a mix of dlopen/dlclose and dlmopen/dlclose of + * libfoo, and of its direct dependencies. + */ +int main(int argc, char **argv) { - void *handle; - int (*foo)(); + void *h0, *h1, *h2, *h3, *h4; + char *error; + int (*foo)(void); - handle = dlopen("libfoo.so", RTLD_LAZY); - foo = dlsym(handle, "foo"); + h0 = dlopen("libbar.so", RTLD_LAZY); + if (!h0) { + goto get_error; + } + h1 = dlmopen(LM_ID_BASE, "libfoo.so", RTLD_LAZY); + if (!h1) { + goto get_error; + } + h2 = dlopen("libzzz.so", RTLD_LAZY); + if (!h2) { + goto get_error; + } + h3 = dlopen("libfoo.so", RTLD_LAZY); + if (!h3) { + goto get_error; + } + h4 = dlopen("libfoo.so", RTLD_LAZY); + if (!h4) { + goto get_error; + } - (*foo)(); + foo = dlsym(h1, "foo"); + error = dlerror(); + if (error != NULL) { + goto error; + } - dlclose(handle); + foo(); - return 0; + if (dlclose(h0)) { + goto get_error; + } + if (dlclose(h1)) { + goto get_error; + } + if (dlclose(h2)) { + goto get_error; + } + if (dlclose(h3)) { + goto get_error; + } + if (dlclose(h4)) { + goto get_error; + } + + exit(EXIT_SUCCESS); + +get_error: + error = dlerror(); +error: + fprintf(stderr, "%s\n", error); + exit(EXIT_FAILURE); }