tests/vg_regtest: Always evaluate prerequisite expressions with sh
[valgrind.git] / memcheck / tests / x86-solaris / scalar.c
blob3894d2f9d03c63d8d6fd13b95afb56a3c22f97e1
1 /* Basic syscall test for Solaris/x86 specific syscalls. */
3 #include "../solaris/scalar.h"
5 #include <string.h>
6 #include <sys/fcntl.h>
7 #include <sys/statvfs.h>
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)
15 GO(SYS_openat64, "(3-args) 3s 1m");
16 SY(SYS_openat64, x0 - 1, x0, x0); FAILx(EBADF);
19 __attribute__((noinline))
20 static void sys_openat642(void)
22 GO(SYS_openat64, "(4-args) 4s 1m");
23 SY(SYS_openat64, x0 - 1, x0, x0 | O_CREAT, x0); FAILx(EBADF);
26 __attribute__((noinline))
27 static void sys_statvfs64(void)
29 GO(SYS_statvfs64, "2s 2m");
30 SY(SYS_statvfs64, x0 + 1, x0 + 1); FAIL;
33 __attribute__((noinline))
34 static int sys_statvfs642(void)
36 const char path[] = "/";
37 struct statvfs64 stats;
39 GO(SYS_statvfs64, "4s 0m");
40 SY(SYS_statvfs64, x0 + path, x0 + &stats); SUCC;
42 size_t basetype_len = strlen(stats.f_basetype);
43 size_t fstr_len = strlen(stats.f_fstr);
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;
52 int main(void)
54 /* Uninitialised, but we know px[0] is 0x0. */
55 long *px = malloc(sizeof(long));
56 x0 = px[0];
58 /* SYS_fstatat64 67 */
59 GO(SYS_fstatat64, "4s 2m");
60 SY(SYS_fstatat64, x0 - 1, x0 + 1, x0, x0); FAILx(EBADF);
62 /* SYS_openat64 69 */
63 sys_openat64();
64 sys_openat642();
66 /* SYS_llseek 175 */
67 GO(SYS_llseek, "3s 0m");
68 SY(SYS_llseek, x0 - 1, x0, x0); FAILx(EBADF);
70 /* SYS_getdents64 213 */
71 GO(SYS_getdents64, "3s 1m");
72 SY(SYS_getdents64, x0, x0, x0 + 1); FAIL;
74 /* SYS_mmap64 214 */
75 GO(SYS_mmap64, "7s 0m");
76 SY(SYS_mmap64, x0, x0, x0, x0, x0, x0, x0); FAILx(EINVAL);
78 /* SYS_stat64 215 */
79 /* Tested in x86-solaris/scalar_obsolete.c. */
81 /* SYS_lstat64 216 */
82 /* Tested in x86-solaris/scalar_obsolete.c. */
84 /* SYS_fstat64 217 */
85 /* Tested in x86-solaris/scalar_obsolete.c. */
87 /* SYS_statvfs64 218 */
88 sys_statvfs64();
89 sys_statvfs642();
91 /* SYS_fstatvfs64 219 */
92 GO(SYS_fstatvfs64, "2s 1m");
93 SY(SYS_fstatvfs64, x0 - 1, x0 + 1); FAILx(EBADF);
95 /* SYS_setrlimit64 220 */
96 GO(SYS_setrlimit64, "2s 1m");
97 SY(SYS_setrlimit64, x0, x0); FAIL;
99 /* SYS_getrlimit64 221 */
100 GO(SYS_getrlimit64, "2s 1m");
101 SY(SYS_getrlimit64, x0, x0); FAIL;
103 /* SYS_pread64 222 */
104 GO(SYS_pread64, "5s 1m");
105 SY(SYS_pread64, x0 - 1, x0, x0 + 1, x0, x0); FAILx(EBADF);
107 /* SYS_pwrite64 223 */
108 GO(SYS_pwrite64, "5s 1m");
109 SY(SYS_pwrite64, x0 - 1, x0, x0 + 1, x0, x0); FAILx(EBADF);
111 /* SYS_open64 225 */
112 /* Tested in x86-solaris/scalar_obsolete.c. */
114 return 0;