tst-leaks: raise timeout to 5 seconds
[glibc.git] / elf / tst-unique1.c
blob46d41d9ff401095fe4fa1bb66567150936d7e809
1 #include <config.h>
2 #include <dlfcn.h>
3 #include <stdio.h>
4 #include <sys/mman.h>
6 static int
7 do_test (void)
9 #ifdef HAVE_ASM_UNIQUE_OBJECT
10 void *h1 = dlopen ("tst-unique1mod1.so", RTLD_LAZY);
11 if (h1 == NULL)
13 puts ("cannot load tst-unique1mod1");
14 return 1;
16 int *(*f1) (void) = dlsym (h1, "f");
17 if (f1 == NULL)
19 puts ("cannot locate f in tst-unique1mod1");
20 return 1;
22 void *h2 = dlopen ("tst-unique1mod2.so", RTLD_LAZY);
23 if (h2 == NULL)
25 puts ("cannot load tst-unique1mod2");
26 return 1;
28 int (*f2) (int *) = dlsym (h2, "f");
29 if (f2 == NULL)
31 puts ("cannot locate f in tst-unique1mod2");
32 return 1;
34 if (f2 (f1 ()))
36 puts ("f from tst-unique1mod2 failed");
37 return 1;
39 dlclose (h2);
40 dlclose (h1);
41 mmap (NULL, 1024 * 1024 * 16, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
42 h2 = dlopen ("tst-unique1mod2.so", RTLD_LAZY);
43 if (h2 == NULL)
45 puts ("cannot load tst-unique1mod2");
46 return 1;
48 f2 = dlsym (h2, "f");
49 if (f2 == NULL)
51 puts ("cannot locate f in tst-unique1mod2");
52 return 1;
54 h1 = dlopen ("tst-unique1mod1.so", RTLD_LAZY);
55 if (h1 == NULL)
57 puts ("cannot load tst-unique1mod1");
58 return 1;
60 f1 = dlsym (h1, "f");
61 if (f1 == NULL)
63 puts ("cannot locate f in tst-unique1mod1");
64 return 1;
66 if (f2 (f1 ()))
68 puts ("f from tst-unique1mod2 failed");
69 return 1;
71 #endif
72 return 0;
75 #define TEST_FUNCTION do_test ()
76 #include "../test-skeleton.c"