#include <mcheck.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
/* How many load/unload operations do we do. */
#include <include/link.h>
-#define OUT \
- for (map = _r_debug.r_map; map != NULL; map = map->l_next) \
- if (map->l_type == lt_loaded) \
- printf ("name = \"%s\", opencount = %d\n", \
- map->l_name, (int) map->l_opencount); \
- fflush (stdout)
+#define MAPS ((struct link_map *) _r_debug.r_map)
+
+#define OUT \
+ do \
+ { \
+ for (map = MAPS; map != NULL; map = map->l_next) \
+ if (map->l_type == lt_loaded) \
+ printf ("name = \"%s\", direct_opencount = %d\n", \
+ map->l_name, (int) map->l_direct_opencount); \
+ fflush (stdout); \
+ } \
+ while (0)
int
testobjs[index].name, testobjs[index].handle);
testobjs[index].handle = NULL;
+
+ if (testobjs[0].handle == NULL
+ && testobjs[1].handle == NULL
+ && testobjs[5].handle == NULL)
+ {
+ /* In this case none of the objects above should be
+ present. */
+ for (map = MAPS; map != NULL; map = map->l_next)
+ if (map->l_type == lt_loaded
+ && (strstr (map->l_name, testobjs[0].name) != NULL
+ || strstr (map->l_name, testobjs[1].name) != NULL
+ || strstr (map->l_name, testobjs[5].name) != NULL))
+ {
+ printf ("`%s' is still loaded\n", map->l_name);
+ result = 1;
+ }
+ }
}
if (debug)
{
printf ("\nclose: %s: l_initfini = %p, l_versions = %p\n",
testobjs[count].name,
- ((struct link_map*)testobjs[count].handle)->l_initfini,
- ((struct link_map*)testobjs[count].handle)->l_versions);
+ ((struct link_map *) testobjs[count].handle)->l_initfini,
+ ((struct link_map *) testobjs[count].handle)->l_versions);
if (dlclose (testobjs[count].handle) != 0)
{
}
/* Check whether all files are unloaded. */
- for (map = _r_debug.r_map; map != NULL; map = map->l_next)
+ for (map = MAPS; map != NULL; map = map->l_next)
if (map->l_type == lt_loaded)
{
- printf ("name = \"%s\", opencount = %d\n",
- map->l_name, (int) map->l_opencount);
+ printf ("name = \"%s\", direct_opencount = %d\n",
+ map->l_name, (int) map->l_direct_opencount);
result = 1;
}