-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodtest.c
More file actions
48 lines (41 loc) · 983 Bytes
/
modtest.c
File metadata and controls
48 lines (41 loc) · 983 Bytes
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
#include <stdio.h>
#include "ucdl.h"
int called = 0;
void callme (int param)
{
if (param != 0xdeadc0de) {
fprintf (stderr, "F (%x)\n", param);
exit (5);
} else fprintf (stderr, "P");
called++;
}
int main(int argc, char **argv)
{
void *handle;
int (*modtest)() = 0;
if (!uCdl_init (argv[0])) {
fprintf (stderr, "F\n");
exit (1);
} else fprintf (stderr, "P");
if (!(handle = uCdl_open ("testmod.o"))) {
fprintf (stderr, "F\n");
exit (2);
} else fprintf (stderr, "P");
modtest = uCdl_sym (handle, "modtest");
if (!modtest) {
fprintf (stderr, "F\n");
exit (3);
} else fprintf (stderr, "P");
if ((*modtest)() != 0xc0de4242) {
fprintf (stderr, "F\n");
exit (4);
} else fprintf (stderr, "P");
if (called != 1) {
fprintf (stderr, "F (%d)\n", called);
exit (6);
} else fprintf (stderr, "P");
uCdl_close (handle);
fprintf (stderr, "P\n");
fprintf (stderr, "All tests passed.\n");
return 0;
}