Skip to content

[ISSUE] Add EL0 test_milo End-to-End Userspace Verification Command #220

Done

Description

@marcobuschini

Problem Statement & Context

Currently, running a full end-to-end test pass requires invoking individual kernel shell test * commands from the milo> monitor (kernel/shell/shell.cpp), or manually running individual EL0 binaries (/bin/hello, /bin/hello_musl, /bin/hello_dyn, /bin/fb_test) after entering sh or bash. Once inside milo-sh or milo-bash in EL0, there is no single test_milo command that exercises the userspace ABI, syscalls, memory management, filesystems (rootfs, tmpfs, ext2, devfs), pipes/FDs, signals/wait4, and /dev/fb0 framebuffer path in one cohesive run with clear pass/fail reporting and exit status.

Scope & Technical Touchpoints

In Scope

  • Add a self-contained EL0 C test utility user/test_milo.c compiled with $(MUSL_CC) and packaged at /bin/test_milo in Makefile (initrds/busybox.cpio and initrds/bash.cpio).
  • Exercise real EL0 syscall and subsystem behavior across:
    • Process & job control: getpid, getppid, setsid/setpgid/getpgid, clone (SIGCHLD), execve (/bin/hello and -ENOENT negative check), wait4 (WNOHANG and blocking exit status decoding).
    • Signals & timers: rt_sigaction, rt_sigprocmask, kill, clock_gettime, nanosleep (short/zero interval), times, getrusage, uname, sysinfo, getrandom.
    • Memory & address space: brk expand/shrink, anonymous mmap (MAP_PRIVATE | MAP_ANONYMOUS) + mprotect + munmap, and fork() (clone) memory isolation.
    • File descriptors, pipes & VFS: pipe2, dup/dup3, fcntl, ppoll/pselect6, getdents64, fstat/newfstatat/faccessat/readlinkat/getcwd/chdir, read-only check on /init.txt (-EROFS), read/write/truncate/unlink/rename on /tmp (tmpfs), and mount/geometry check on /mnt/disk (ext2 when available).
    • TTY & framebuffer: /dev/console and /dev/null behavior, and /dev/fb0 ioctl (FBIOGET_VSCREENINFO, FBIOGET_FSCREENINFO, FBIO_FLUSH) + MAP_SHARED mmap when /dev/fb0 is present.
  • Print structured [PASS] / [FAIL] lines and a final summary count, exiting with 0 when all checks pass and non-zero (1) if any check fails.

Technical Touchpoints

  • user/test_milo.c (new EL0 test binary)
  • Makefile (SRCS_C, TEST_MILO_BIN / build rule, $(BUSYBOX_CPIO), $(BASH_CPIO))
  • Existing UAPI & syscall contracts in kernel/uapi/ and kernel/syscalls/ (SyscallDispatcher.cpp, FileSyscalls.cpp, MemorySyscalls.cpp, ProcessSyscalls.cpp, SignalSyscalls.cpp, TimeSyscalls.cpp)
  • Existing rootfs, tmpfs, ext2, and devfs (kernel/fs/)

Out of Scope

  • Modifying kernel syscall ABI numbers or rewriting existing kernel unit tests in kernel/shell/tests/ or tests/host/.
  • Full network stack (virtio-net TCP/IP) or interactive GUI input (virtio-input) unless a deterministic loopback/device probe is supported without blocking stdin.

Proposed Subissues

  • [SUBISSUE #1]: Create user/test_milo.c core EL0 harness (process, signals, time/sysinfo, brk/mmap/munmap, pipe2/dup3/fcntl/ppoll) and wire /bin/test_milo into Makefile initrd targets. (No prerequisites)
  • [SUBISSUE #2]: Add VFS (rootfs, tmpfs, ext2), TTY (/dev/console, /dev/null), and /dev/fb0 (ioctl + MAP_SHARED + flush) checks to user/test_milo.c with graceful skip/assert handling when optional mounts or /dev/fb0 are absent. (Depends on #1)
  • [SUBISSUE #3]: Add optional flags/non-interactive summary output and verification notes in Makefile / docs for running test_milo inside QEMU shells and CI. (Depends on #1, #2)

Acceptance Criteria

  • /bin/test_milo builds cleanly with $(MUSL_CC) (-Wall -Wextra) and is included in initrds/busybox.cpio and initrds/bash.cpio when HAS_MUSL_CC is present.
  • Running test_milo inside milo-sh or milo-bash executes all checks non-interactively (never hanging on stdin read), prints clear [PASS]/[FAIL] results, and exits 0 on full pass.
  • Re-running test_milo multiple times in the same shell session leaves no zombie children, leaked FDs, or PFA frame leaks.
  • make -j$(nproc) all && make -j$(nproc) quality passes with zero warnings and ASan/UBSan green.

Edge Cases

  • Missing optional hardware/mounts: /mnt/disk may not be mounted if no ext2 block image is attached, and /dev/fb0 may be absent if no framebuffer/GPU device is present; test_milo must handle those cleanly without false failures or panics.
  • No stdin blocking: All reads/polls in test_milo must use pipes, /dev/null, /init.txt, or O_NONBLOCK / zero-timeout ppoll so automated runs never block waiting for interactive serial keystrokes.
  • Repeated invocations: Running test_milo back-to-back in a single shell session must reap all spawned child PIDs and clean up temporary /tmp test files so subsequent runs see clean state.

Linked Subissues (TODO)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions