sewardj | 8eb8bab | 2015-07-21 14:44:28 +0000 | [diff] [blame] | 1 | /* Basic syscall test for Solaris/x86 specific syscalls. */ |
| 2 | |
| 3 | #include "../solaris/scalar.h" |
| 4 | |
| 5 | #include <string.h> |
| 6 | #include <sys/fcntl.h> |
| 7 | #include <sys/statvfs.h> |
| 8 | |
| 9 | /* Helper functions. These are necessary if we've got two tests for a single |
| 10 | syscall. In that case, Memcheck can sometimes merge error messages. Doing |
| 11 | each test in its own function prevents that. */ |
| 12 | __attribute__((noinline)) |
| 13 | static void sys_openat64(void) |
| 14 | { |
| 15 | GO(SYS_openat64, "(3-args) 3s 1m"); |
| 16 | SY(SYS_openat64, x0 - 1, x0, x0); FAILx(EBADF); |
| 17 | } |
| 18 | |
| 19 | __attribute__((noinline)) |
| 20 | static void sys_openat642(void) |
| 21 | { |
| 22 | GO(SYS_openat64, "(4-args) 4s 1m"); |
| 23 | SY(SYS_openat64, x0 - 1, x0, x0 | O_CREAT, x0); FAILx(EBADF); |
| 24 | } |
| 25 | |
| 26 | __attribute__((noinline)) |
| 27 | static void sys_statvfs64(void) |
| 28 | { |
| 29 | GO(SYS_statvfs64, "2s 2m"); |
| 30 | SY(SYS_statvfs64, x0 + 1, x0 + 1); FAIL; |
| 31 | } |
| 32 | |
| 33 | __attribute__((noinline)) |
| 34 | static int sys_statvfs642(void) |
| 35 | { |
| 36 | const char path[] = "/"; |
| 37 | struct statvfs64 stats; |
| 38 | |
| 39 | GO(SYS_statvfs64, "4s 0m"); |
| 40 | SY(SYS_statvfs64, x0 + path, x0 + &stats); SUCC; |
| 41 | |
| 42 | size_t basetype_len = strlen(stats.f_basetype); |
| 43 | size_t fstr_len = strlen(stats.f_fstr); |
| 44 | |
| 45 | /* Now check that memory after the strings is reported uninitialized. */ |
| 46 | int x = 0; |
| 47 | if (stats.f_basetype[basetype_len + 2] != ' ') x = -1; else x = -2; |
| 48 | if (stats.f_fstr[fstr_len + 2] != ' ') x = -3; else x = -4; |
| 49 | return x; |
| 50 | } |
| 51 | |
| 52 | int main(void) |
| 53 | { |
| 54 | /* Uninitialised, but we know px[0] is 0x0. */ |
| 55 | long *px = malloc(sizeof(long)); |
| 56 | x0 = px[0]; |
| 57 | |
| 58 | /* SYS_fstatat64 67 */ |
| 59 | GO(SYS_fstatat64, "4s 2m"); |
| 60 | SY(SYS_fstatat64, x0 - 1, x0 + 1, x0, x0); FAILx(EBADF); |
| 61 | |
| 62 | /* SYS_openat64 69 */ |
| 63 | sys_openat64(); |
| 64 | sys_openat642(); |
| 65 | |
| 66 | /* SYS_llseek 175 */ |
Elliott Hughes | a0664b9 | 2017-04-18 17:46:52 -0700 | [diff] [blame] | 67 | GO(SYS_llseek, "4s 0m"); |
| 68 | SY(SYS_llseek, x0 - 1, x0, x0, x0); FAILx(EBADF); |
sewardj | 8eb8bab | 2015-07-21 14:44:28 +0000 | [diff] [blame] | 69 | |
| 70 | /* SYS_getdents64 213 */ |
| 71 | GO(SYS_getdents64, "3s 1m"); |
| 72 | SY(SYS_getdents64, x0, x0, x0 + 1); FAIL; |
| 73 | |
| 74 | /* SYS_mmap64 214 */ |
| 75 | GO(SYS_mmap64, "7s 0m"); |
| 76 | SY(SYS_mmap64, x0, x0, x0, x0, x0, x0, x0); FAILx(EINVAL); |
| 77 | |
| 78 | /* SYS_stat64 215 */ |
| 79 | /* Tested in x86-solaris/scalar_obsolete.c. */ |
| 80 | |
| 81 | /* SYS_lstat64 216 */ |
| 82 | /* Tested in x86-solaris/scalar_obsolete.c. */ |
| 83 | |
| 84 | /* SYS_fstat64 217 */ |
| 85 | /* Tested in x86-solaris/scalar_obsolete.c. */ |
| 86 | |
| 87 | /* SYS_statvfs64 218 */ |
| 88 | sys_statvfs64(); |
| 89 | sys_statvfs642(); |
| 90 | |
| 91 | /* SYS_fstatvfs64 219 */ |
| 92 | GO(SYS_fstatvfs64, "2s 1m"); |
| 93 | SY(SYS_fstatvfs64, x0 - 1, x0 + 1); FAILx(EBADF); |
| 94 | |
| 95 | /* SYS_setrlimit64 220 */ |
| 96 | GO(SYS_setrlimit64, "2s 1m"); |
| 97 | SY(SYS_setrlimit64, x0, x0); FAIL; |
| 98 | |
| 99 | /* SYS_getrlimit64 221 */ |
| 100 | GO(SYS_getrlimit64, "2s 1m"); |
| 101 | SY(SYS_getrlimit64, x0, x0); FAIL; |
| 102 | |
| 103 | /* SYS_pread64 222 */ |
| 104 | GO(SYS_pread64, "5s 1m"); |
| 105 | SY(SYS_pread64, x0 - 1, x0, x0 + 1, x0, x0); FAILx(EBADF); |
| 106 | |
| 107 | /* SYS_pwrite64 223 */ |
| 108 | GO(SYS_pwrite64, "5s 1m"); |
| 109 | SY(SYS_pwrite64, x0 - 1, x0, x0 + 1, x0, x0); FAILx(EBADF); |
| 110 | |
| 111 | /* SYS_open64 225 */ |
| 112 | /* Tested in x86-solaris/scalar_obsolete.c. */ |
| 113 | |
| 114 | return 0; |
| 115 | } |
| 116 | |