Updated to fedora-glibc-20090416T1610
[glibc/history.git] / elf / tst-dlmopen2.c
blob05699972584dd32a91149a969018dbf12a472730
1 #include <dlfcn.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <gnu/lib-names.h>
5 #include <ldsodefs.h>
8 static int
9 do_test (void)
11 int result = 0;
13 for (int i = 1; i <= 10; ++i)
15 void *h[DL_NNS - 1];
16 char used[DL_NNS];
18 printf ("round %d\n", i);
20 memset (used, '\0', sizeof (used));
21 used[LM_ID_BASE] = 1;
23 for (int j = 0; j < DL_NNS - 1; ++j)
25 h[j] = dlmopen (LM_ID_NEWLM, "$ORIGIN/tst-dlmopen1mod.so",
26 RTLD_LAZY);
27 if (h[j] == NULL)
29 printf ("round %d, namespace %d: load failed: %s\n",
30 i, j, dlerror ());
31 return 1;
33 Lmid_t ns;
34 if (dlinfo (h[j], RTLD_DI_LMID, &ns) != 0)
36 printf ("round %d, namespace %d: dlinfo failed: %s\n",
37 i, j, dlerror ());
38 return 1;
40 if (ns < 0 || ns >= DL_NNS)
42 printf ("round %d, namespace %d: invalid namespace %ld",
43 i, j, (long int) ns);
44 result = 1;
46 else if (used[ns] != 0)
48 printf ("\
49 round %d, namespace %d: duplicate allocate of namespace %ld",
50 i, j, (long int) ns);
51 result = 1;
53 else
54 used[ns] = 1;
57 for (int j = 0; j < DL_NNS - 1; ++j)
58 if (dlclose (h[j]) != 0)
60 printf ("round %d, namespace %d: close failed: %s\n",
61 i, j, dlerror ());
62 return 1;
66 return result;
69 #define TEST_FUNCTION do_test ()
70 #include "../test-skeleton.c"