tst-tls18.c 711 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include <dlfcn.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. static int
  5. do_test (void)
  6. {
  7. char modname[sizeof "tst-tlsmod18aXX.so"];
  8. void *h[20];
  9. for (int i = 0; i < 20; i++)
  10. {
  11. snprintf (modname, sizeof modname, "tst-tlsmod18a%d.so", i);
  12. h[i] = dlopen (modname, RTLD_LAZY);
  13. if (h[i] == NULL)
  14. {
  15. printf ("unexpectedly failed to open %s", modname);
  16. exit (1);
  17. }
  18. }
  19. for (int i = 0; i < 20; i++)
  20. {
  21. int (*fp) (void) = (int (*) (void)) dlsym (h[i], "test");
  22. if (fp == NULL)
  23. {
  24. printf ("cannot find test in tst-tlsmod18a%d.so", i);
  25. exit (1);
  26. }
  27. if (fp ())
  28. exit (1);
  29. }
  30. return 0;
  31. }
  32. #define TEST_FUNCTION do_test ()
  33. #include "../test-skeleton.c"