diff options
author | Jakub Jelinek <jakub@redhat.com> | 2004-10-14 05:57:55 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2004-10-14 05:57:55 +0000 |
commit | 9869e6ec913e268748f510ab6ec64b8fd62531bc (patch) | |
tree | f3f8b9c049c73755d183cc1c1affd34ee8f9772b /elf/tst-dlmopen2.c | |
parent | 3ee87ca7d4c813087eeee8b9fd04b7836244a54a (diff) |
Updated to fedora-glibc-20041014T0548
Diffstat (limited to 'elf/tst-dlmopen2.c')
-rw-r--r-- | elf/tst-dlmopen2.c | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/elf/tst-dlmopen2.c b/elf/tst-dlmopen2.c new file mode 100644 index 0000000000..0569997258 --- /dev/null +++ b/elf/tst-dlmopen2.c @@ -0,0 +1,70 @@ +#include <dlfcn.h> +#include <stdio.h> +#include <string.h> +#include <gnu/lib-names.h> +#include <ldsodefs.h> + + +static int +do_test (void) +{ + int result = 0; + + for (int i = 1; i <= 10; ++i) + { + void *h[DL_NNS - 1]; + char used[DL_NNS]; + + printf ("round %d\n", i); + + memset (used, '\0', sizeof (used)); + used[LM_ID_BASE] = 1; + + for (int j = 0; j < DL_NNS - 1; ++j) + { + h[j] = dlmopen (LM_ID_NEWLM, "$ORIGIN/tst-dlmopen1mod.so", + RTLD_LAZY); + if (h[j] == NULL) + { + printf ("round %d, namespace %d: load failed: %s\n", + i, j, dlerror ()); + return 1; + } + Lmid_t ns; + if (dlinfo (h[j], RTLD_DI_LMID, &ns) != 0) + { + printf ("round %d, namespace %d: dlinfo failed: %s\n", + i, j, dlerror ()); + return 1; + } + if (ns < 0 || ns >= DL_NNS) + { + printf ("round %d, namespace %d: invalid namespace %ld", + i, j, (long int) ns); + result = 1; + } + else if (used[ns] != 0) + { + printf ("\ +round %d, namespace %d: duplicate allocate of namespace %ld", + i, j, (long int) ns); + result = 1; + } + else + used[ns] = 1; + } + + for (int j = 0; j < DL_NNS - 1; ++j) + if (dlclose (h[j]) != 0) + { + printf ("round %d, namespace %d: close failed: %s\n", + i, j, dlerror ()); + return 1; + } + } + + return result; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" |