2006-03-19 07:48:05 +00:00
|
|
|
#include <stdio.h>
|
2006-03-15 19:26:13 +00:00
|
|
|
#include <dlfcn.h>
|
|
|
|
#include <mcheck.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2015-07-09 15:29:17 +00:00
|
|
|
static int
|
|
|
|
do_test (void)
|
2006-03-15 19:26:13 +00:00
|
|
|
{
|
2017-12-13 04:35:05 +00:00
|
|
|
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. */
|
2006-03-15 19:26:13 +00:00
|
|
|
mtrace ();
|
|
|
|
|
|
|
|
for (int i = 0; i < 10; i++)
|
|
|
|
{
|
2017-12-13 04:35:05 +00:00
|
|
|
h = dlopen (i < 5
|
|
|
|
? "./tst-leaks1.c"
|
|
|
|
: "$ORIGIN/tst-leaks1.o", RTLD_LAZY);
|
2006-03-15 19:26:13 +00:00
|
|
|
if (h != NULL)
|
|
|
|
{
|
|
|
|
puts ("dlopen unexpectedly succeeded");
|
|
|
|
ret = 1;
|
|
|
|
dlclose (h);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2015-07-09 15:29:17 +00:00
|
|
|
|
2017-04-05 13:34:39 +00:00
|
|
|
#include <support/test-driver.c>
|