MCPcopy Create free account
hub / github.com/LPC4/Full-Stack / run_kernel

Function run_kernel

crates/virtual-machine/tests/vm_rom_boot.rs:23–47  ·  view source on GitHub ↗

Assemble a minimal kernel and run it via `VirtualMachine::new_kernel`. Returns (uart_output, exit_code).

(src: &str, max_steps: u64)

Source from the content-addressed store, hash-verified

21 .map(|l| {
22 if let Some(name) = l.strip_suffix(':') {
23 RvInstruction::Label(name.to_owned())
24 } else if l.starts_with('.') {
25 RvInstruction::Directive(l.to_owned())
26 } else {
27 RvInstruction::Directive(format!("\t{l}"))
28 }
29 })
30 .collect();
31
32 let output = Assembler::assemble(&tokens).expect("kernel assembly failed");
33 let mut vm = VirtualMachine::new_kernel(&output);
34 let result = vm.run(max_steps);
35 let code = match result.outcome {
36 StepOutcome::Halted(c) => c,
37 StepOutcome::Continue => i64::MIN,
38 };
39 (result.uart_output, code)
40}
41
42// --- ROM structure tests ---
43
44#[test]
45fn rom_assembles_without_error() {
46 let bytes = generate_rom_image();
47 assert!(!bytes.is_empty(), "ROM image must not be empty");
48}
49
50#[test]

Calls 3

DirectiveEnum · 0.85
collectMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected