A hosted user program injected as pid 1 must spawn and exit with code 0.
(uart: &str, outcome: &StepOutcome, label: &str)
| 134 | uart.contains("[ PROC ] pid 1 ready"), |
| 135 | "{label}: user process was not spawned; uart={uart:?}" |
| 136 | ); |
| 137 | // A pid-1 program exiting cleanly calls kshutdown(0), halting the VM with 0. |
| 138 | assert!( |
| 139 | matches!(outcome, StepOutcome::Halted(0)), |
| 140 | "{label}: user process did not exit cleanly with code 0; got {outcome:?}, uart={uart:?}" |
| 141 | ); |
| 142 | } |
| 143 | |
| 144 | // Compile a hosted program and inject it as pid 1 (no FS image), then assert a |
| 145 | // clean spawn-and-exit. |
| 146 | fn run_example_in_kernel(user_src: &str, label: &str) { |
| 147 | let user = compile_hosted(user_src); |
| 148 | let (_, outcome, uart) = boot_kernel(cached_kernel(), Some(&user), None, "", 10_000_000); |
| 149 | assert_user_exit_ok(&uart, &outcome, label); |
| 150 | } |
| 151 | |
| 152 | fn run_example_manifest_in_kernel(name: &str) { |
| 153 | let manifest_path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) |
| 154 | .join("programs/example") |
| 155 | .join(name) |
| 156 | .join(format!("{name}.build")); |
| 157 | let manifest = BuildManifest::from_file(&manifest_path) |
no outgoing calls