summaryrefslogtreecommitdiff
path: root/elf/tst-leaks1.c
diff options
context:
space:
mode:
Diffstat (limited to 'elf/tst-leaks1.c')
-rw-r--r--elf/tst-leaks1.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/elf/tst-leaks1.c b/elf/tst-leaks1.c
index dcff28dafa..75bc92d25f 100644
--- a/elf/tst-leaks1.c
+++ b/elf/tst-leaks1.c
@@ -6,13 +6,28 @@
static int
do_test (void)
{
+ void *h;
+ int ret = 0;
+ /* Carry out *one* failing call to dlopen before starting mtrace to
+ force any one-time inintialization that may happen to the
+ executable link map e.g. expansion and caching of $ORIGIN. */
+ h = dlopen ("$ORIGIN/tst-leaks1.o", RTLD_LAZY);
+ if (h != NULL)
+ {
+ puts ("dlopen unexpectedly succeeded");
+ ret = 1;
+ dlclose (h);
+ }
+
+ /* Start tracing and run each test 5 times to see if there are any
+ leaks in the failing dlopen. */
mtrace ();
- int ret = 0;
for (int i = 0; i < 10; i++)
{
- void *h = dlopen (i < 5 ? "./tst-leaks1.c"
- : "$ORIGIN/tst-leaks1.o", RTLD_LAZY);
+ h = dlopen (i < 5
+ ? "./tst-leaks1.c"
+ : "$ORIGIN/tst-leaks1.o", RTLD_LAZY);
if (h != NULL)
{
puts ("dlopen unexpectedly succeeded");
@@ -24,5 +39,4 @@ do_test (void)
return ret;
}
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>