]> git.ipfire.org Git - thirdparty/glibc.git/blob - dlfcn/bug-atexit2.c
resolv: Enable full ICMP errors for UDP DNS sockets [BZ #24047]
[thirdparty/glibc.git] / dlfcn / bug-atexit2.c
1 /* Derived from a test case in
2 https://sourceware.org/bugzilla/show_bug.cgi?id=1158. */
3 #include <dlfcn.h>
4 #include <stdlib.h>
5 #include <stdio.h>
6 #include <unistd.h>
7
8 static int next = 3;
9
10 static void
11 f1 (void)
12 {
13 puts ("f1");
14 if (next-- != 1)
15 _exit (1);
16 }
17
18 static void
19 f2 (void)
20 {
21 puts ("f2");
22 if (next-- != 2)
23 _exit (1);
24 }
25
26 static void
27 f3 (void)
28 {
29 puts ("f3");
30 if (next-- != 3)
31 _exit (1);
32 }
33
34 static int
35 do_test (void)
36 {
37 atexit (f1);
38
39 void *dso = dlopen ("$ORIGIN/bug-atexit2-lib.so", RTLD_NOW);
40 void (*fn) (void) = (void (*) (void)) dlsym (dso, "foo");
41 fn ();
42
43 atexit (f2);
44
45 dlclose (dso);
46
47 atexit (f3);
48
49 return 0;
50 }
51
52 #define TEST_FUNCTION do_test ()
53 #include "../test-skeleton.c"