17 struct iovec vec_array
[] = {{buf1
, LEN
}, {buf2
, LEN
}, {buf3
, LEN
}};
18 //struct iovec bad_array[] = {{NULL, LEN}, {buf2, LEN}, {buf3, LEN}};
22 memset(&a
, 0, sizeof(struct aiocb
));
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 //------------------------------------------------------------------------
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)