lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #include <dlfcn.h> |
| 2 | #include <stdio.h> |
| 3 | |
| 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 | |
| 20 | for (int i = 0; i < 20; i++) |
| 21 | { |
| 22 | int (*fp) (void) = (int (*) (void)) dlsym (h[i], "test"); |
| 23 | if (fp == NULL) |
| 24 | { |
| 25 | printf ("cannot find test in tst-tlsmod18a%d.so", i); |
| 26 | exit (1); |
| 27 | } |
| 28 | |
| 29 | if (fp ()) |
| 30 | exit (1); |
| 31 | } |
| 32 | |
| 33 | return 0; |
| 34 | } |
| 35 | |
| 36 | #define TEST_FUNCTION do_test () |
| 37 | #include "../test-skeleton.c" |