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