See also: Userspace Index, Kernel Syscall, Kernel Init
usr/selftest is a minimal freestanding userspace binary (pure assembly, no libc) used to validate context switching and syscall handling.
What It Tests
-
Syscall write to stdout — verifies the userspace-to-kernel trap path
-
Blocking read from stdin — verifies input handling and TTY integration
-
Open
/as a directory and iterate FAT directory entries — verifies file system syscalls -
FAT directory parsing — parses 8.3 filenames, handles end markers (0x00), deleted entries (0xE5), and long filename entries (attr 0x0F)
-
Syscall exit — verifies process termination and scheduler handoff
Implementation
-
221 lines of assembly (
selftest.S) -
Built with
-ffreestanding -nostdlib -nostartfiles -nodefaultlibs -static -Wl,-e,_start -no-pie -
Used by kernel init flow as the initial userspace process
-
Launched via
ELF_LoadProcess("/usr/bin/selftest")