summaryrefslogtreecommitdiff
path: root/test/dlopen/nodelete1.c
blob: 720e37fd16aab2b35bb7c89099002b35ae732291 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>


int fini_ran;

#define LIBNAME1	"nodelmod1.so"

static int
do_test (void)
{
  /* Verify ability to reload RTLD_NODELETE libraries.
   */
  void *p;

  p = dlopen (LIBNAME1, RTLD_NOW);
  if (p == NULL)
  {
      printf ("failed to load "LIBNAME1": %s\n", dlerror ());
      exit (1);
  }

  if (dlclose (p) != 0)
  {
      puts ("failed to close "LIBNAME1"");
      exit (1);
  }

  p = dlopen (LIBNAME1, RTLD_LAZY);
  if (p == NULL)
  {
      printf ("failed to load "LIBNAME1": %s\n", dlerror ());
      exit (1);
  }

  if (dlclose (p) != 0)
  {
      puts ("failed to close "LIBNAME1"");
      exit (1);
  }

  p = dlopen ("nodelmod2.so", RTLD_LAZY);
  if (p == NULL)
  {
      printf ("failed to load \"nodelmod2.so\": %s\n", dlerror ());
      exit (1);
  }
  if (dlclose (p) != 0)
  {
      puts ("failed to close \"nodelmod2.so\"");
      exit (1);
  }

  return 0;
}

#define TEST_FUNCTION do_test ()
#include "../test-skeleton.c"