tools/testing/selftests/net/af_unix/msg_oob.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/net/af_unix/msg_oob.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/net/af_unix/msg_oob.c- Extension
.c- Size
- 17398 bytes
- Lines
- 892
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
fcntl.hstring.hunistd.hnetinet/in.hsys/epoll.hsys/ioctl.hsys/signalfd.hsys/socket.hkselftest_harness.h
Detected Declarations
function create_unix_socketpairfunction create_tcp_socketpairfunction setup_sigurgfunction setup_epollprifunction close_socketsfunction __epollpairfunction __sendpairfunction __recvpairfunction __setinlinepairfunction __siocatmarkpairfunction __resetpair
Annotated Snippet
if (flags & MSG_OOB) {
ASSERT_EQ(bytes, sizeof(siginfo));
ASSERT_EQ(siginfo.ssi_signo, SIGURG);
bytes = read(self->signal_fd, &siginfo, sizeof(siginfo));
}
ASSERT_EQ(bytes, -1);
}
ASSERT_EQ(ret[0], len);
ASSERT_EQ(ret[0], ret[1]);
}
static void __recvpair(struct __test_metadata *_metadata,
FIXTURE_DATA(msg_oob) *self,
const char *expected_buf, int expected_len,
int buf_len, int flags, bool is_sender)
{
int i, ret[2], recv_errno[2], expected_errno = 0;
char recv_buf[2][BUF_SZ] = {};
bool printed = false;
ASSERT_GE(BUF_SZ, buf_len);
errno = 0;
for (i = 0; i < 2; i++) {
int index = is_sender ? i * 2 : i * 2 + 1;
ret[i] = recv(self->fd[index], recv_buf[i], buf_len, flags);
recv_errno[i] = errno;
}
if (expected_len < 0) {
expected_errno = -expected_len;
expected_len = -1;
}
if (ret[0] != expected_len || recv_errno[0] != expected_errno) {
TH_LOG("AF_UNIX :%s", ret[0] < 0 ? strerror(recv_errno[0]) : recv_buf[0]);
TH_LOG("Expected:%s", expected_errno ? strerror(expected_errno) : expected_buf);
ASSERT_EQ(ret[0], expected_len);
ASSERT_EQ(recv_errno[0], expected_errno);
}
if (ret[0] != ret[1] || recv_errno[0] != recv_errno[1]) {
TH_LOG("AF_UNIX :%s", ret[0] < 0 ? strerror(recv_errno[0]) : recv_buf[0]);
TH_LOG("TCP :%s", ret[1] < 0 ? strerror(recv_errno[1]) : recv_buf[1]);
printed = true;
if (self->tcp_compliant) {
ASSERT_EQ(ret[0], ret[1]);
ASSERT_EQ(recv_errno[0], recv_errno[1]);
}
}
if (expected_len >= 0) {
int cmp;
cmp = strncmp(expected_buf, recv_buf[0], expected_len);
if (cmp) {
TH_LOG("AF_UNIX :%s", ret[0] < 0 ? strerror(recv_errno[0]) : recv_buf[0]);
TH_LOG("Expected:%s", expected_errno ? strerror(expected_errno) : expected_buf);
ASSERT_EQ(cmp, 0);
}
cmp = strncmp(recv_buf[0], recv_buf[1], expected_len);
if (cmp) {
if (!printed) {
TH_LOG("AF_UNIX :%s", ret[0] < 0 ? strerror(recv_errno[0]) : recv_buf[0]);
TH_LOG("TCP :%s", ret[1] < 0 ? strerror(recv_errno[1]) : recv_buf[1]);
}
if (self->tcp_compliant)
ASSERT_EQ(cmp, 0);
}
}
}
static void __setinlinepair(struct __test_metadata *_metadata,
FIXTURE_DATA(msg_oob) *self)
{
int i, oob_inline = 1;
for (i = 0; i < 2; i++) {
int ret;
Annotation
- Immediate include surface: `fcntl.h`, `string.h`, `unistd.h`, `netinet/in.h`, `sys/epoll.h`, `sys/ioctl.h`, `sys/signalfd.h`, `sys/socket.h`.
- Detected declarations: `function create_unix_socketpair`, `function create_tcp_socketpair`, `function setup_sigurg`, `function setup_epollpri`, `function close_sockets`, `function __epollpair`, `function __sendpair`, `function __recvpair`, `function __setinlinepair`, `function __siocatmarkpair`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.