tools/testing/selftests/user_events/user_events_selftests.h
Source file repositories/reference/linux-study-clean/tools/testing/selftests/user_events/user_events_selftests.h
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/user_events/user_events_selftests.h- Extension
.h- Size
- 2191 bytes
- Lines
- 115
- 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
sys/stat.hsys/types.hsys/mount.hunistd.herrno.hkselftest.h
Detected Declarations
function tracefs_unmountfunction tracefs_enabledfunction user_events_enabled
Annotated Snippet
if (mount(NULL, "/sys/kernel/tracing", "tracefs", 0, NULL) != 0) {
*message = "Cannot mount tracefs";
*fail = true;
return false;
}
*umount = true;
ret = stat("/sys/kernel/tracing/README", &buf);
}
if (ret == -1) {
*message = "Cannot access tracefs";
*fail = true;
return false;
}
return true;
}
static inline bool user_events_enabled(char **message, bool *fail, bool *umount)
{
struct stat buf;
int ret;
*message = "";
*fail = false;
*umount = false;
if (getuid() != 0) {
*message = "Must be run as root";
*fail = true;
return false;
}
if (!tracefs_enabled(message, fail, umount))
return false;
/* Ensure user_events is installed */
ret = stat("/sys/kernel/tracing/user_events_data", &buf);
if (ret == -1) {
switch (errno) {
case ENOENT:
*message = "user_events is not installed";
return false;
default:
*message = "Cannot access user_events_data";
*fail = true;
return false;
}
}
return true;
}
#define USER_EVENT_FIXTURE_SETUP(statement, umount) do { \
char *message; \
bool fail; \
if (!user_events_enabled(&message, &fail, &(umount))) { \
if (fail) { \
TH_LOG("Setup failed due to: %s", message); \
ASSERT_FALSE(fail); \
} \
SKIP(statement, "Skipping due to: %s", message); \
} \
} while (0)
#define USER_EVENT_FIXTURE_TEARDOWN(umount) do { \
if ((umount)) \
tracefs_unmount(); \
} while (0)
#endif /* _USER_EVENTS_SELFTESTS_H */
Annotation
- Immediate include surface: `sys/stat.h`, `sys/types.h`, `sys/mount.h`, `unistd.h`, `errno.h`, `kselftest.h`.
- Detected declarations: `function tracefs_unmount`, `function tracefs_enabled`, `function user_events_enabled`.
- 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.