Last change
on this file was 2036, checked in by bird, 20 years ago |
Initial revision
|
-
Property cvs2svn:cvs-rev
set to
1.1
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
-
Property svn:keywords
set to
Author Date Id Revision
|
File size:
1.0 KB
|
Line | |
---|
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 |
|
---|
9 | static const char unknown[] = "a-file-with-this-name-does-not-exist";
|
---|
10 | static const char exists[] = "failtestmod.so";
|
---|
11 |
|
---|
12 |
|
---|
13 | int
|
---|
14 | main (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 |
|
---|
55 | extern void foo (void);
|
---|
56 |
|
---|
57 | void
|
---|
58 | foo (void)
|
---|
59 | {
|
---|
60 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.