]> git.ipfire.org Git - thirdparty/glibc.git/blob - elf/tst-dlmopen1mod.c
nptl/tst-cancel25 needs to be an internal test
[thirdparty/glibc.git] / elf / tst-dlmopen1mod.c
1 #include <dlfcn.h>
2 #include <stdio.h>
3 #include <gnu/lib-names.h>
4
5
6 static int cnt;
7
8 static void
9 __attribute ((constructor))
10 constr (void)
11 {
12 ++cnt;
13 }
14
15
16 int
17 foo (Lmid_t ns2)
18 {
19 void *h = dlopen (LIBC_SO, RTLD_LAZY|RTLD_NOLOAD);
20 if (h == NULL)
21 {
22 printf ("cannot get handle for %s: %s\n", LIBC_SO, dlerror ());
23 return 1;
24 }
25
26 Lmid_t ns = -10;
27 if (dlinfo (h, RTLD_DI_LMID, &ns) != 0)
28 {
29 printf ("dlinfo for %s in %s failed: %s\n",
30 LIBC_SO, __func__, dlerror ());
31 return 1;
32 }
33
34 if (ns != ns2)
35 {
36 printf ("namespace for %s not LM_ID_BASE\n", LIBC_SO);
37 return 1;
38 }
39
40 if (dlclose (h) != 0)
41 {
42 printf ("dlclose for %s in %s failed: %s\n",
43 LIBC_SO, __func__, dlerror ());
44 return 1;
45 }
46
47 if (cnt == 0)
48 {
49 puts ("constructor did not run");
50 return 1;
51 }
52 else if (cnt != 1)
53 {
54 puts ("constructor did not run exactly once");
55 return 1;
56 }
57
58 return 0;
59 }