tools/testing/selftests/user_events/ftrace_test.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/user_events/ftrace_test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/user_events/ftrace_test.c- Extension
.c- Size
- 14614 bytes
- Lines
- 598
- 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
errno.hlinux/user_events.hstdio.hstdlib.hfcntl.hsys/ioctl.hsys/stat.hsys/uio.hunistd.hkselftest_harness.huser_events_selftests.h
Detected Declarations
function trace_bytesfunction skip_until_empty_linefunction get_print_fmtfunction wait_for_deletefunction clearfunction check_print_fmtfunction main
Annotated Snippet
if (errno == EBUSY) {
if (!wait_for_delete())
goto fail;
} else if (errno != ENOENT)
goto fail;
}
close(fd);
return 0;
fail:
close(fd);
return -1;
}
static int check_print_fmt(const char *event, const char *expected, int *check)
{
struct user_reg reg = {0};
char print_fmt[256];
int ret;
int fd;
/* Ensure cleared */
ret = clear(check);
if (ret != 0)
return ret;
fd = open(data_file, O_RDWR);
if (fd == -1)
return fd;
reg.size = sizeof(reg);
reg.name_args = (__u64)event;
reg.enable_bit = 31;
reg.enable_addr = (__u64)check;
reg.enable_size = sizeof(*check);
/* Register should work */
ret = ioctl(fd, DIAG_IOCSREG, ®);
if (ret != 0) {
close(fd);
printf("Reg failed in fmt\n");
return ret;
}
/* Ensure correct print_fmt */
ret = get_print_fmt(print_fmt, sizeof(print_fmt));
close(fd);
if (ret != 0)
return ret;
return strcmp(print_fmt, expected);
}
FIXTURE(user) {
int status_fd;
int data_fd;
int enable_fd;
int check;
bool umount;
};
FIXTURE_SETUP(user) {
USER_EVENT_FIXTURE_SETUP(return, self->umount);
self->status_fd = open(status_file, O_RDONLY);
ASSERT_NE(-1, self->status_fd);
self->data_fd = open(data_file, O_RDWR);
ASSERT_NE(-1, self->data_fd);
self->enable_fd = -1;
}
FIXTURE_TEARDOWN(user) {
USER_EVENT_FIXTURE_TEARDOWN(self->umount);
close(self->status_fd);
close(self->data_fd);
if (self->enable_fd != -1) {
write(self->enable_fd, "0", sizeof("0"));
close(self->enable_fd);
}
Annotation
- Immediate include surface: `errno.h`, `linux/user_events.h`, `stdio.h`, `stdlib.h`, `fcntl.h`, `sys/ioctl.h`, `sys/stat.h`, `sys/uio.h`.
- Detected declarations: `function trace_bytes`, `function skip_until_empty_line`, `function get_print_fmt`, `function wait_for_delete`, `function clear`, `function check_print_fmt`, `function main`.
- 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.