]> git.ipfire.org Git - thirdparty/glibc.git/blob - elf/tst-dlmopen1.c
iconv, localedef: avoid floating point rounding differences [BZ #24372]
[thirdparty/glibc.git] / elf / tst-dlmopen1.c
1 #include <dlfcn.h>
2 #include <stdio.h>
3 #include <gnu/lib-names.h>
4
5 #define TEST_SO "$ORIGIN/tst-dlmopen1mod.so"
6
7 static int
8 do_test (void)
9 {
10 void *h = dlopen (LIBC_SO, RTLD_LAZY|RTLD_NOLOAD);
11 if (h == NULL)
12 {
13 printf ("cannot get handle for %s: %s\n", LIBC_SO, dlerror ());
14 return 1;
15 }
16
17 Lmid_t ns = -10;
18 if (dlinfo (h, RTLD_DI_LMID, &ns) != 0)
19 {
20 printf ("dlinfo for %s in %s failed: %s\n",
21 LIBC_SO, __func__, dlerror ());
22 return 1;
23 }
24
25 if (ns != LM_ID_BASE)
26 {
27 printf ("namespace for %s not LM_ID_BASE\n", LIBC_SO);
28 return 1;
29 }
30
31 if (dlclose (h) != 0)
32 {
33 printf ("dlclose for %s in %s failed: %s\n",
34 LIBC_SO, __func__, dlerror ());
35 return 1;
36 }
37
38 h = dlmopen (LM_ID_NEWLM, TEST_SO, RTLD_LAZY);
39 if (h == NULL)
40 {
41 printf ("cannot get handle for %s: %s\n",
42 "tst-dlmopen1mod.so", dlerror ());
43 return 1;
44 }
45
46 ns = -10;
47 if (dlinfo (h, RTLD_DI_LMID, &ns) != 0)
48 {
49 printf ("dlinfo for %s in %s failed: %s\n",
50 "tst-dlmopen1mod.so", __func__, dlerror ());
51 return 1;
52 }
53
54 if (ns == LM_ID_BASE)
55 {
56 printf ("namespace for %s is LM_ID_BASE\n", TEST_SO);
57 return 1;
58 }
59
60 int (*fct) (Lmid_t) = dlsym (h, "foo");
61 if (fct == NULL)
62 {
63 printf ("could not find %s: %s\n", "foo", dlerror ());
64 return 1;
65 }
66
67 if (fct (ns) != 0)
68 return 1;
69
70 if (dlclose (h) != 0)
71 {
72 printf ("dlclose for %s in %s failed: %s\n",
73 TEST_SO, __func__, dlerror ());
74 return 1;
75 }
76
77 return 0;
78 }
79
80 #include <support/test-driver.c>