]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - elf/tst-dlopen-tlsmodid.h
Rename and split elf/tst-dlopen-aout collection of tests
[thirdparty/glibc.git] / elf / tst-dlopen-tlsmodid.h
similarity index 77%
rename from elf/tst-dlopen-aout.c
rename to elf/tst-dlopen-tlsmodid.h
index b86d082bc1c94d14ef4c16c8337353c5309e699b..c747cb14911c72faad2de504151afe136e103c84 100644 (file)
@@ -1,4 +1,5 @@
-/* Test case for BZ #16634 and BZ#24900.
+/* Common code for tst-dlopen-tlsmodid, tst-dlopen-tlsmodid-pie,
+   tst-dlopen-tlsmodid-container.
 
    Verify that incorrectly dlopen()ing an executable without
    __RTLD_OPENEXEC does not cause assertion in ld.so, and that it
@@ -21,6 +22,9 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+/* Before including this file, the macro TST_DLOPEN_TLSMODID_PATH must
+   be defined, to specify the path used for the open operation.  */
+
 #include <dlfcn.h>
 #include <pthread.h>
 #include <stdio.h>
@@ -38,14 +42,14 @@ fn (void *p)
   return p;
 }
 
-/* Call dlopen on PATH and check that fails with an error message
-   indicating an attempt to open an ET_EXEC or PIE object.  */
+/* Call dlopen and check that fails with an error message indicating
+   an attempt to open an ET_EXEC or PIE object.  */
 static void
-check_dlopen_failure (const char *path)
+check_dlopen_failure (void)
 {
-  void *handle = dlopen (path, RTLD_LAZY);
+  void *handle = dlopen (TST_DLOPEN_TLSMODID_PATH, RTLD_LAZY);
   if (handle != NULL)
-    FAIL_EXIT1 ("dlopen succeeded unexpectedly: %s", path);
+    FAIL_EXIT1 ("dlopen succeeded unexpectedly: %s", TST_DLOPEN_TLSMODID_PATH);
 
   const char *message = dlerror ();
   TEST_VERIFY_EXIT (message != NULL);
@@ -65,7 +69,7 @@ do_test (int argc, char *argv[])
     {
       pthread_t thr;
 
-      check_dlopen_failure (argv[0]);
+      check_dlopen_failure ();
 
       /* We create threads to force TLS allocation, which triggers
         the original bug i.e. running out of surplus slotinfo entries
@@ -74,9 +78,7 @@ do_test (int argc, char *argv[])
       xpthread_join (thr);
     }
 
-  /* The elf subdirectory (or $ORIGIN in the container case) is on the
-     library search path.  */
-  check_dlopen_failure ("tst-dlopen-aout");
+  check_dlopen_failure ();
 
   return 0;
 }