4 #include <sys/socket.h>
13 #if defined(HAVE_SENDMMSG) && defined(HAVE_STRUCT_MMSGHDR)
14 const int R = 0, W = 1;
19 char three[] = "three";
21 struct iovec iov[] = {
24 .iov_len = sizeof(one) - 1
27 .iov_len = sizeof(two) - 1
30 .iov_len = sizeof(three) - 1
34 struct mmsghdr mmh[] = {
47 #define n_mmh (sizeof(mmh)/sizeof(mmh[0]))
50 * Following open/dup2/close calls make the output of strace
51 * more predictable, so we can just compare the output and
52 * expected output (mmsg.expected) for testing purposes.
54 while ((fd = open("/dev/null", O_RDWR)) < 3)
58 assert(socketpair(AF_UNIX, SOCK_DGRAM, 0, sv) == 0);
60 assert(dup2(sv[W], W) == W);
61 assert(close(sv[W]) == 0);
62 assert(dup2(sv[R], R) == R);
63 assert(close(sv[R]) == 0);
65 int r = sendmmsg(W, mmh, n_mmh, 0);
66 if (r < 0 && errno == ENOSYS)
68 assert((size_t)r == n_mmh);
69 assert(close(W) == 0);
71 assert(recvmmsg(R, mmh, n_mmh, 0, NULL) == n_mmh);
72 assert(close(R) == 0);