(root)/
strace-6.5/
tests-mx32/
mmsg-silent.c
       1  /*
       2   * Check silent decoding of sendmmsg and recvmmsg syscalls.
       3   *
       4   * Copyright (c) 2016-2021 Dmitry V. Levin <ldv@strace.io>
       5   * Copyright (c) 2016-2023 The strace developers.
       6   * All rights reserved.
       7   *
       8   * SPDX-License-Identifier: GPL-2.0-or-later
       9   */
      10  
      11  #include "tests.h"
      12  #include <stdio.h>
      13  
      14  #include "msghdr.h"
      15  
      16  int
      17  main(void)
      18  {
      19  	int fds[2];
      20  	if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds))
      21  		perror_msg_and_skip("socketpair");
      22  
      23  	char buf = 'A';
      24  	struct iovec iov = { .iov_base = &buf, .iov_len = sizeof(buf) };
      25  	struct mmsghdr mh = {
      26  		.msg_hdr = {
      27  			.msg_iov = &iov,
      28  			.msg_iovlen = 1
      29  		}
      30  	};
      31  
      32  	int rc = send_mmsg(fds[1], &mh, 1, MSG_DONTWAIT);
      33  	if (rc < 0)
      34  		perror_msg_and_skip("sendmmsg");
      35  	printf("sendmmsg(%d, %p, 1, MSG_DONTWAIT) = %d\n", fds[1], &mh, rc);
      36  
      37  	kernel_old_timespec_t t = { .tv_sec = 0, .tv_nsec = 12345678 };
      38  	rc = recv_mmsg(fds[0], &mh, 1, MSG_DONTWAIT, &t);
      39  	printf("recvmmsg(%d, %p, 1, MSG_DONTWAIT, %p) = %d\n",
      40  	       fds[0], &mh, &t, rc);
      41  
      42  	puts("+++ exited with 0 +++");
      43  	return 0;
      44  }