()
| 2485 | FsEntry::File { |
| 2486 | path: "/producer.elf", |
| 2487 | data: &producer_exec, |
| 2488 | }, |
| 2489 | FsEntry::File { |
| 2490 | path: "/filter.elf", |
| 2491 | data: &filter_exec, |
| 2492 | }, |
| 2493 | ]); |
| 2494 | |
| 2495 | let session = "/producer.elf | /filter.elf > /piped.txt\ncat /piped.txt\nexit\n"; |
| 2496 | let (_, outcome, uart) = boot_kernel( |
| 2497 | cached_kernel(), |
| 2498 | Some(&shell), |
| 2499 | Some(&image), |
| 2500 | session, |
| 2501 | 200_000_000, |
| 2502 | ); |
| 2503 | |
| 2504 | assert!(!uart.contains("PANIC!"), "kernel panicked; uart={uart:?}"); |
| 2505 | let cat = uart.find("cat /piped.txt").expect("cat not echoed"); |
| 2506 | let before = &uart[..cat]; |
| 2507 | let after = &uart[cat..]; |
| 2508 | assert!( |
| 2509 | !before.contains("VIA_PIPE"), |
| 2510 | "pipeline output leaked to console instead of the file; uart={uart:?}" |
| 2511 | ); |
| 2512 | assert!( |
| 2513 | after.contains("VIA_PIPE"), |
| 2514 | "piped output was not captured into the file; uart={uart:?}" |
| 2515 | ); |
| 2516 | assert!( |
| 2517 | matches!(outcome, RunOutcome::Halted(0)), |
| 2518 | "shell did not exit cleanly; outcome={outcome:?} uart={uart:?}" |
| 2519 | ); |
| 2520 | } |
| 2521 | |
| 2522 | // A builtin producer: `cat` runs in the shell with its output bound to the pipe |
| 2523 | // temp file, exercising the builtin branch of sh_run_stage. |
| 2524 | #[test] |
| 2525 | fn kernel_pipe_builtin_source() { |
| 2526 | let shell = compile_hosted_program("shell"); |
| 2527 | let filter = compile_hosted( |
| 2528 | r#" |
| 2529 | external sys_readchar: () -> i64 |
| 2530 | external console_putchar: (c: i32) |
| 2531 | external sys_exit: (code: i64) |
| 2532 | main: () -> i32 { |
| 2533 | while 1 == 1 { |
| 2534 | c: i64 = sys_readchar() |
| 2535 | if c < 0 { |
| 2536 | break |
| 2537 | } |
| 2538 | console_putchar(c as i32) |
| 2539 | } |
| 2540 | sys_exit(0) |
| 2541 | return 0 |
| 2542 | } |
| 2543 | "#, |
| 2544 | ); |
nothing calls this directly
no test coverage detected