|
Packit |
6c4009 |
#include <stdio.h>
|
|
Packit |
6c4009 |
#include <dlfcn.h>
|
|
Packit |
6c4009 |
#include <mcheck.h>
|
|
Packit |
6c4009 |
#include <stdlib.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
static int
|
|
Packit |
6c4009 |
do_test (void)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
void *h;
|
|
Packit |
6c4009 |
int ret = 0;
|
|
Packit |
6c4009 |
/* Carry out *one* failing call to dlopen before starting mtrace to
|
|
Packit |
6c4009 |
force any one-time inintialization that may happen to the
|
|
Packit |
6c4009 |
executable link map e.g. expansion and caching of $ORIGIN. */
|
|
Packit |
6c4009 |
h = dlopen ("$ORIGIN/tst-leaks1.o", RTLD_LAZY);
|
|
Packit |
6c4009 |
if (h != NULL)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
puts ("dlopen unexpectedly succeeded");
|
|
Packit |
6c4009 |
ret = 1;
|
|
Packit |
6c4009 |
dlclose (h);
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Start tracing and run each test 5 times to see if there are any
|
|
Packit |
6c4009 |
leaks in the failing dlopen. */
|
|
Packit |
6c4009 |
mtrace ();
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
for (int i = 0; i < 10; i++)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
h = dlopen (i < 5
|
|
Packit |
6c4009 |
? "./tst-leaks1.c"
|
|
Packit |
6c4009 |
: "$ORIGIN/tst-leaks1.o", RTLD_LAZY);
|
|
Packit |
6c4009 |
if (h != NULL)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
puts ("dlopen unexpectedly succeeded");
|
|
Packit |
6c4009 |
ret = 1;
|
|
Packit |
6c4009 |
dlclose (h);
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
return ret;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <support/test-driver.c>
|