]>
Commit | Line | Data |
---|---|---|
cafdfdb6 | 1 | #include <stdio.h> |
2e0fc40c UD |
2 | #include <dlfcn.h> |
3 | #include <mcheck.h> | |
4 | #include <stdlib.h> | |
5 | ||
0035851c AS |
6 | static int |
7 | do_test (void) | |
2e0fc40c | 8 | { |
93930ea9 CD |
9 | void *h; |
10 | int ret = 0; | |
11 | /* Carry out *one* failing call to dlopen before starting mtrace to | |
630da022 | 12 | force any one-time initialization that may happen to the |
93930ea9 CD |
13 | executable link map e.g. expansion and caching of $ORIGIN. */ |
14 | h = dlopen ("$ORIGIN/tst-leaks1.o", RTLD_LAZY); | |
15 | if (h != NULL) | |
16 | { | |
17 | puts ("dlopen unexpectedly succeeded"); | |
18 | ret = 1; | |
19 | dlclose (h); | |
20 | } | |
21 | ||
22 | /* Start tracing and run each test 5 times to see if there are any | |
23 | leaks in the failing dlopen. */ | |
2e0fc40c UD |
24 | mtrace (); |
25 | ||
2e0fc40c UD |
26 | for (int i = 0; i < 10; i++) |
27 | { | |
93930ea9 CD |
28 | h = dlopen (i < 5 |
29 | ? "./tst-leaks1.c" | |
30 | : "$ORIGIN/tst-leaks1.o", RTLD_LAZY); | |
2e0fc40c UD |
31 | if (h != NULL) |
32 | { | |
33 | puts ("dlopen unexpectedly succeeded"); | |
34 | ret = 1; | |
35 | dlclose (h); | |
36 | } | |
37 | } | |
38 | ||
39 | return ret; | |
40 | } | |
0035851c | 41 | |
36fe25fd | 42 | #include <support/test-driver.c> |