()
| 1230 | "expected error to mention 'kmain', got: {}", |
| 1231 | err.message |
| 1232 | ); |
| 1233 | } |
| 1234 | |
| 1235 | #[test] |
| 1236 | fn kernel_boot_kmalloc_works() { |
| 1237 | let (uart, exit) = run_kernel_hll( |
| 1238 | r#" |
| 1239 | heap := import("kernel/mm/kernel_heap.hll") |
| 1240 | system := import("kernel/arch/riscv64/system.hll") |
| 1241 | external klog_ok: (msg: u8*) |
| 1242 | |
| 1243 | kmain: () { |
| 1244 | buf: u8* = heap.alloc_bytes(16) |
| 1245 | buf[0] = 72 |
| 1246 | buf[1] = 105 |
| 1247 | buf[2] = 33 |
| 1248 | buf[3] = 0 |
| 1249 | klog_ok(buf) |
| 1250 | system.shutdown(0) |
| 1251 | } |
| 1252 | "#, |
| 1253 | ); |
| 1254 | assert_eq!(uart, "[ OK ] Hi!\n"); |
| 1255 | assert_eq!(exit, Some(0)); |
| 1256 | } |
| 1257 | |
| 1258 | // --- Cross-module linking tests --- |
| 1259 | |
| 1260 | /// Compile and link two simple modules (plus stdlib): one provides a function, |
| 1261 | /// the other calls it. Verifies CallPlt relocations resolve correctly. |
| 1262 | #[test] |
| 1263 | fn cross_module_call_works() { |
| 1264 | let mut pipeline = CompilationPipeline::new(); |
| 1265 | pipeline.set_write_artifacts(false); |
| 1266 | |
| 1267 | // Stdlib provides _start -> main -> exit. |
| 1268 | let stdlib_objs = |
| 1269 | CompilationPipeline::compile_stdlib_objects(TargetMode::Hosted).expect("stdlib compile"); |
| 1270 | |
| 1271 | let module_a = r#" |
| 1272 | export add_one: (x: i32) -> i32 { |
| 1273 | return x + 1 |
| 1274 | } |
| 1275 | "#; |
| 1276 |
nothing calls this directly
no test coverage detected