]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - elf/tst-leaks1.c
dlfcn: Remove remnants of caller sensitivity from dlinfo
[thirdparty/glibc.git] / elf / tst-leaks1.c
index 36e4aee9cf86f0cdd5a6e04cab5f21f69b82c4af..75bc92d25f99300b62363adfdb2db468276b84bd 100644 (file)
@@ -3,16 +3,31 @@
 #include <mcheck.h>
 #include <stdlib.h>
 
-int
-main (void)
+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");
@@ -23,3 +38,5 @@ main (void)
 
   return ret;
 }
+
+#include <support/test-driver.c>