1 #include "../../../include/vki/vki-scnums-x86-linux.h"
2 
3 #include <assert.h>
4 #include <errno.h>
5 #include <fcntl.h>
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <sys/syscall.h>
9 #include <sys/stat.h>
10 #include <sys/ptrace.h>
11 #include <sys/types.h>
12 #include <sys/mman.h>
13 
14 // Since we use vki_unistd.h, we can't include <unistd.h>.  So we have to
15 // declare this ourselves.
16 extern long int syscall (long int __sysno, ...) __THROW;
17 
18 // Thorough syscall scalar arg checking.  Also serves as thorough checking
19 // for (very) basic syscall use.  Generally not trying to do anything
20 // meaningful with the syscalls.
21 
22 #define GO(__NR_xxx, s) \
23    fprintf(stderr, "-----------------------------------------------------\n"  \
24                    "%3d:%20s %s\n"                                            \
25                    "-----------------------------------------------------\n", \
26                    __NR_xxx, #__NR_xxx, s);
27 
28 #define SY  res = syscall
29 
30 #define FAIL  assert(-1 == res);
31 #define SUCC  assert(-1 != res);
32 #define SUCC_OR_FAIL    /* no test */
33 
34 #define FAILx(E) \
35    do { \
36       int myerrno = errno; \
37       if (-1 == res) { \
38          if (E == myerrno) { \
39             /* as expected */ \
40          } else { \
41          fprintf(stderr, "Expected error %s (%d), got %d\n", #E, E, myerrno); \
42          exit(1); \
43          } \
44       } else { \
45          fprintf(stderr, "Expected error %s (%d), got success\n", #E, E); \
46          exit(1); \
47       } \
48    } while (0);
49 
50 #define SUCC_OR_FAILx(E) \
51    do { \
52       int myerrno = errno; \
53       if (-1 == res) { \
54          if (E == myerrno) { \
55             /* as expected */ \
56          } else { \
57          fprintf(stderr, "Expected error %s (%d), got %d\n", #E, E, myerrno); \
58          exit(1); \
59          } \
60       } \
61    } while (0);
62