e354a5
commit d330f31af68f96dde82840d1e9343b479a8c179e
e354a5
Author: Carlos O'Donell <carlos@redhat.com>
e354a5
Date:   Thu Aug 30 11:01:33 2018 -0400
e354a5
e354a5
    Fix test failure with -DNDEBUG.
e354a5
    
e354a5
    The elf/tst-dlopen-aout.c test uses asserts to verify properties of the
e354a5
    test execution.  Instead of using assert it should use xpthread_create
e354a5
    and xpthread_join to catch errors starting the threads and fail the
e354a5
    test.  This shows up in Fedora 28 when building for i686-pc-linux-gnu
e354a5
    and using gcc 8.1.1.
e354a5
    
e354a5
    Tested on i686, and fixes a check failure with -DNDEBUG.
e354a5
    
e354a5
    Signed-off-by: Carlos O'Donell <carlos@redhat.com>
e354a5
e354a5
diff --git a/elf/tst-dlopen-aout.c b/elf/tst-dlopen-aout.c
e354a5
index 9038e2096add8798..b0264515cfe62276 100644
e354a5
--- a/elf/tst-dlopen-aout.c
e354a5
+++ b/elf/tst-dlopen-aout.c
e354a5
@@ -27,6 +27,7 @@
e354a5
 #include <dlfcn.h>
e354a5
 #include <stdio.h>
e354a5
 #include <pthread.h>
e354a5
+#include <support/xthread.h>
e354a5
 
e354a5
 __thread int x;
e354a5
 
e354a5
@@ -45,7 +46,6 @@ do_test (int argc, char *argv[])
e354a5
     {
e354a5
       pthread_t thr;
e354a5
       void *p;
e354a5
-      int rc;
e354a5
 
e354a5
       p = dlopen (argv[0], RTLD_LAZY);
e354a5
       if (p != NULL)
e354a5
@@ -53,11 +53,11 @@ do_test (int argc, char *argv[])
e354a5
           fprintf (stderr, "dlopen unexpectedly succeeded\n");
e354a5
           return 1;
e354a5
         }
e354a5
-      rc = pthread_create (&thr, NULL, fn, NULL);
e354a5
-      assert (rc == 0);
e354a5
-
e354a5
-      rc = pthread_join (thr, NULL);
e354a5
-      assert (rc == 0);
e354a5
+      /* We create threads to force TLS allocation, which triggers
e354a5
+	 the original bug i.e. running out of surplus slotinfo entries
e354a5
+	 for TLS.  */
e354a5
+      thr = xpthread_create (NULL, fn, NULL);
e354a5
+      xpthread_join (thr);
e354a5
     }
e354a5
 
e354a5
   return 0;