Back to index

glibc  2.9
Defines | Functions
tst-dlmopen2.c File Reference
#include <dlfcn.h>
#include <stdio.h>
#include <string.h>
#include <gnu/lib-names.h>
#include <ldsodefs.h>
#include "../test-skeleton.c"

Go to the source code of this file.

Defines

#define TEST_FUNCTION   do_test ()

Functions

static int do_test (void)

Define Documentation

#define TEST_FUNCTION   do_test ()

Definition at line 69 of file tst-dlmopen2.c.


Function Documentation

static int do_test ( void  ) [static]

Definition at line 9 of file tst-dlmopen2.c.

{
  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;
}

Here is the call graph for this function: