tools/testing/selftests/nolibc/nolibc-test.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/nolibc/nolibc-test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/nolibc/nolibc-test.c- Extension
.c- Size
- 72967 bytes
- Lines
- 2453
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
stdio.hstdlib.hstring.hsys/auxv.hsys/ioctl.hsys/mman.hsys/mount.hsys/prctl.hsys/ptrace.hsys/random.hsys/reboot.hsys/resource.hsys/stat.hsys/syscall.hsys/sysmacros.hsys/time.hsys/timerfd.hsys/uio.hsys/utsname.hsys/wait.hdirent.herrno.hfcntl.hpoll.hsched.hsignal.hstdarg.hstddef.hstdint.htime.hunistd.hlimits.h
Detected Declarations
struct testenum RESULTenum strtox_funcenum fork_typefunction resultfunction __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function constructor1function constructor2function test_program_invocation_namefunction run_startupfunction test_getdents64function test_direntfunction test_getrandomfunction test_getpagesizefunction test_file_streamfunction test_file_stream_wsrfunction test_forkfunction test_ftruncatefunction test_stat_timestampsfunction test_timerfunction test_timerfdfunction test_uname
Annotated Snippet
struct test {
const char *name; /* test name */
int (*func)(int min, int max); /* handler */
};
#ifndef _NOLIBC_STDLIB_H
char *itoa(int i)
{
static char buf[12];
int ret;
ret = snprintf(buf, sizeof(buf), "%d", i);
return (ret >= 0 && ret < sizeof(buf)) ? buf : "#err";
}
#endif
#define CASE_ERR(err) \
case err: return #err
/* returns the error name (e.g. "ENOENT") for common errors, "SUCCESS" for 0,
* or the decimal value for less common ones.
*/
static const char *errorname(int err)
{
switch (err) {
case 0: return "SUCCESS";
CASE_ERR(EPERM);
CASE_ERR(ENOENT);
CASE_ERR(ESRCH);
CASE_ERR(EINTR);
CASE_ERR(EIO);
CASE_ERR(ENXIO);
CASE_ERR(E2BIG);
CASE_ERR(ENOEXEC);
CASE_ERR(EBADF);
CASE_ERR(ECHILD);
CASE_ERR(EAGAIN);
CASE_ERR(ENOMEM);
CASE_ERR(EACCES);
CASE_ERR(EFAULT);
CASE_ERR(ENOTBLK);
CASE_ERR(EBUSY);
CASE_ERR(EEXIST);
CASE_ERR(EXDEV);
CASE_ERR(ENODEV);
CASE_ERR(ENOTDIR);
CASE_ERR(EISDIR);
CASE_ERR(EINVAL);
CASE_ERR(ENFILE);
CASE_ERR(EMFILE);
CASE_ERR(ENOTTY);
CASE_ERR(ETXTBSY);
CASE_ERR(EFBIG);
CASE_ERR(ENOSPC);
CASE_ERR(ESPIPE);
CASE_ERR(EROFS);
CASE_ERR(EMLINK);
CASE_ERR(EPIPE);
CASE_ERR(EDOM);
CASE_ERR(ERANGE);
CASE_ERR(ENOSYS);
CASE_ERR(EOVERFLOW);
default:
return itoa(err);
}
}
enum RESULT {
OK,
FAIL,
SKIPPED,
};
static void result(int llen, enum RESULT r)
{
const char *msg;
if (r == OK)
msg = " [OK]";
else if (r == SKIPPED)
msg = "[SKIPPED]";
else
msg = " [FAIL]";
llen = 64 - llen;
if (llen < 0)
llen = 0;
printf("%*s%s\n", llen, "", msg);
}
Annotation
- Immediate include surface: `stdio.h`, `stdlib.h`, `string.h`, `sys/auxv.h`, `sys/ioctl.h`, `sys/mman.h`, `sys/mount.h`, `sys/prctl.h`.
- Detected declarations: `struct test`, `enum RESULT`, `enum strtox_func`, `enum fork_type`, `function result`, `function __attribute__`, `function __attribute__`, `function __attribute__`, `function __attribute__`, `function __attribute__`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.