]> git.ipfire.org Git - thirdparty/glibc.git/blame - dlfcn/failtest.c
Fix implicit-fallthrough warnings in tst-setjmp.c.
[thirdparty/glibc.git] / dlfcn / failtest.c
CommitLineData
d743ba1e
UD
1#include <dlfcn.h>
2#include <stdio.h>
3
4
5/* Number of rounds we perform the test. */
6#define TEST_ROUNDS 10
7
8
9static const char unknown[] = "a-file-with-this-name-does-not-exist";
10static const char exists[] = "failtestmod.so";
11
12
13int
14main (void)
15{
16 int i;
17
18 setvbuf (stdout, NULL, _IONBF, 0);
19
20 for (i = 0; i < TEST_ROUNDS; ++i)
21 {
22 void *dsc;
23
24 printf ("Round %d: Try loading \"%s\"\n", i, unknown);
25
26 dsc = dlopen (unknown, RTLD_NOW);
27 if (dsc != NULL)
28 {
29 printf ("We found a file of name \"%s\": this should not happen\n",
30 unknown);
31 return 1;
32 }
33
34 printf ("Round %d: loading \"%s\" failed\n", i, unknown);
35
36 /* Don't use `dlerror', just load an existing file. */
37 dsc = dlopen (exists, RTLD_NOW);
38 if (dsc == NULL)
39 {
40 printf ("Could not load \"%s\": %s\n", exists, dlerror ());
41 return 1;
42 }
43
44 printf ("Round %d: Loaded \"%s\"\n", i, exists);
45
46 dlclose (dsc);
47
48 printf ("Round %d: Unloaded \"%s\"\n", i, exists);
49 }
50
51 return 0;
52}
53
54
ed073f0e
AJ
55extern void foo (void);
56
d743ba1e
UD
57void
58foo (void)
59{
60}