2 /* The mmap test is useful, since syscalls with 6 arguments
3 * (as mmap) are done differently on various architectures.
13 #define SIZEOF_ARRAY(type) (sizeof(type)/sizeof(*type))
28 struct mmap_test tests
[] = {
33 .args
.prot
= PROT_READ
|PROT_WRITE
,
34 .args
.flags
= MAP_PRIVATE
|MAP_ANONYMOUS
,
40 #define err(fmt, args...) \
42 fprintf(stderr, fmt "\n" , ## args); \
45 #define errp(fmt, args...) err(fmt ": %s" , ## args , strerror(errno))
47 int main(int argc
, char **argv
)
52 for (i
=0; i
<SIZEOF_ARRAY(tests
); ++i
) {
56 t
->ret
= mmap(t
->args
.start
, t
->args
.length
, t
->args
.prot
,
57 t
->args
.flags
, t
->args
.fd
, t
->args
.offset
);
60 if (t
->ret
!= MAP_FAILED
)
61 err("mmap test %i should have failed, but gave us %p", i
, t
->ret
);
62 else if (t
->err
!= errno
)
63 errp("mmap test %i failed, but gave us wrong errno (got %i instead of %i)", i
, errno
, t
->err
);
65 if (t
->ret
== MAP_FAILED
)
66 errp("mmap test %i failed", i
);
67 else if (munmap(t
->ret
, t
->args
.length
) != 0)
68 errp("munmap test %i failed", i
);