Skip to content

Self Tests

Oguzhan KAYNAK edited this page Oct 20, 2026 · 5 revisions

Self Tests

kernel/tests/selftest.cpp holds 651 checks. A kernel built with ATLOS_SELFTEST=ON runs them instead of the keyboard demo and halts with the result. The test presets set ATLOS_DEBUG_EXIT_PORT, so the result is also written to an I/O port where the test scripts put QEMU's isa-debug-exit device; on real hardware the serial log is the result:

scripts/build.sh selftest      # or: ctest --preset selftest

Exit code 0 means every check passed, 1 a failed check, 2 a crash, panic or timeout. The serial log is in build/selftest/selftest.log. The selftest target also builds the test disk (scripts/make-disk-image.sh, no root) and attaches it; the tests read and write /disk0, then fsck.fat and mtools check on the host what the kernel wrote.

scripts/build.sh crashtest boots a kernel that reads an unmapped address on purpose and checks the fault report (CR2, decoded error code, a backtrace that scripts/symbolize.sh resolves to the right functions).

Most tests build their own objects instead of using the kernel's: a 64 block PhysicalMemoryManager, schedulers on a fake tick source, the PIT against a fake interrupt controller, the VGA console on a RAM buffer, a fake multiboot memory map. That keeps them deterministic and lets them reach edge cases (exhaustion, double frees, the exact wake-up tick) without disturbing the running kernel.

static void testSomething()
{
    group("Something");
    CHECK(value == expected);
}

More: docs/testing.md

scripts/build.sh shelltest boots the normal kernel and types commands into its shell over the serial port (Enter, Backspace, the Up arrow, Ctrl+C as a terminal sends them), checking each answer.

Clone this wiki locally