Cross-architecture test suite

This commit is contained in:
2026-07-03 12:39:26 +01:00
parent 9cf135302d
commit c8e89e8115
10 changed files with 500 additions and 8 deletions
+11
View File
@@ -3,6 +3,8 @@ const danos = @import("danos");
const arch = @import("arch");
const console = @import("console.zig");
const pmm = @import("pmm.zig");
const tests = @import("tests.zig");
const build_options = @import("build_options");
const BootInfo = danos.BootInfo;
/// The calling convention used to enter the kernel. Pinned to SysV explicitly:
@@ -25,6 +27,8 @@ export fn _start(boot_info: *const BootInfo) callconv(kernel_abi) noreturn {
}
fn kmain(boot_info: *const BootInfo) noreturn {
arch.serialInit(); // machine-readable log; console mirrors to it
const fb = boot_info.framebuffer;
con = console.Console.init(fb);
con.clear();
@@ -87,6 +91,13 @@ fn kmain(boot_info: *const BootInfo) noreturn {
con.print("\ndanos: paging enabled\n", .{});
con.print(" page tables: CR3 = 0x{x:0>16}\n", .{arch.readCr3()});
// In a test build (`zig build -Dtest-case=<name>`), run that case and stop.
// Normal builds fall through to the idle halt.
if (build_options.test_case) |case| {
tests.run(case, boot_info);
arch.halt();
}
con.write("\nkernel initialised; nothing left to do, halting.\n");
arch.halt();