FreeBSD regtest: remove test for version 13+ syscalls
[valgrind.git] / memcheck / tests / freebsd / aiov.c
blob2a21e205bfd9562c4983429730f6d4d7fe27a8e4
1 #include <assert.h>
2 #include <aio.h>
3 #include <sys/uio.h>
4 #include <fcntl.h>
5 #include <stdio.h>
6 #include <string.h>
7 #include <unistd.h>
8 #include <sys/stat.h>
9 int x;
11 int main(void)
13 #define LEN 10
14 char buf1[LEN];
15 char buf2[LEN];
16 char buf3[LEN];
17 struct iovec vec_array[] = {{buf1, LEN}, {buf2, LEN}, {buf3, LEN}};
18 //struct iovec bad_array[] = {{NULL, LEN}, {buf2, LEN}, {buf3, LEN}};
20 struct aiocb a;
22 memset(&a, 0, sizeof(struct aiocb));
24 a.aio_fildes = -1;
25 a.aio_offset = 0;
26 a.aio_iov = NULL;
27 a.aio_iovcnt = 3;
28 a.aio_reqprio = 0;
29 a.aio_lio_opcode = 0; // ignored
31 //------------------------------------------------------------------------
32 // The cases where aiocbp itself points to bogus memory is handled in
33 // memcheck/tests/darwin/scalar.c, so we don't check that here.
35 //------------------------------------------------------------------------
36 // XXX: This causes an unexpected undef value error later, at the XXX mark.
37 // Not sure why, it shouldn't.
38 // assert( aio_return(&a) < 0); // (iocb hasn't been inited)
40 //------------------------------------------------------------------------
41 assert( aio_readv(&a) < 0); // invalid fd
43 //------------------------------------------------------------------------
44 a.aio_fildes = open("aio.c", O_RDONLY);
45 assert(a.aio_fildes >= 0);
47 // unaddressable aio_iov
48 assert( aio_readv(&a) < 0);
50 //------------------------------------------------------------------------
51 //a.aio_iov = bad_array;
52 // unaddressable first element in aio_iov
53 // but it doesn't fail!
54 //assert( aio_readv(&a) < 0 );
56 a.aio_iov = vec_array;
57 assert( aio_readv(&a) == 0 );
59 // undefined -- aio_return() not called yet
60 if (((char*)(vec_array[0].iov_base))[0] == ((char*)(vec_array[0].iov_base))[9]) x++;
62 // also failed on macOS
63 // (don't crash on the repeated &a)
64 //assert( aio_readv(&a) == 0 );
66 while (0 != aio_error(&a)) { }
68 assert( aio_return(&a) > 0 ); // XXX: (undefined value error here)
70 if (((char*)(vec_array[0].iov_base))[0] == ((char*)(vec_array[0].iov_base))[9]) x++;
72 assert( aio_return(&a) < 0 ); // (repeated aio_return(); fails because
73 // Valgrind can't find &a in the table)
75 //------------------------------------------------------------------------
76 a.aio_iov = 0;
77 a.aio_fildes = creat("mytmpfile", S_IRUSR|S_IWUSR);
78 assert(a.aio_fildes >= 0);
80 // unaddressable aio_buf
81 assert( aio_writev(&a) < 0);
83 //------------------------------------------------------------------------
84 a.aio_iov = vec_array;
86 assert( aio_writev(&a) == 0 );
88 // (don't crash on the repeated &a)
89 // this failed on macOS
90 //assert( aio_writev(&a) < 0 );
92 while (0 != aio_error(&a)) { };
94 assert( aio_return(&a) > 0 );
96 assert( aio_return(&a) < 0 ); // (repeated aio_return(); fails because
97 // Valgrind can't find &a in the table)
99 unlink("mytmpfile");
101 return x;