2 * Check decoding of getpeername syscall.
4 * Copyright (c) 2016-2018 Dmitry V. Levin <ldv@altlinux.org>
7 * SPDX-License-Identifier: GPL-2.0-or-later
10 #define TEST_SYSCALL_NAME getpeername
16 int lfd = socket(AF_UNIX, SOCK_STREAM, 0);
17 int cfd = socket(AF_UNIX, SOCK_STREAM, 0);
18 if (lfd < 0 || cfd < 0)
19 perror_msg_and_skip("socket");
21 (void) unlink(TEST_SOCKET);
23 const struct sockaddr_un un = {
24 .sun_family = AF_UNIX,
25 .sun_path = TEST_SOCKET
28 if (bind(lfd, (const void *) &un, sizeof(un)))
29 perror_msg_and_skip("bind");
31 perror_msg_and_skip("listen");
32 if (connect(cfd, (const void *) &un, sizeof(un)))
33 perror_msg_and_skip("connect");
34 if (accept(lfd, 0, 0) < 0)
35 perror_msg_and_skip("accept");
37 test_sockname_syscall(cfd);
39 (void) unlink(TEST_SOCKET);
41 puts("+++ exited with 0 +++");