()
| 2561 | Some(&image), |
| 2562 | session, |
| 2563 | 160_000_000, |
| 2564 | ); |
| 2565 | |
| 2566 | assert!(!uart.contains("PANIC!"), "kernel panicked; uart={uart:?}"); |
| 2567 | let cmd = uart.find("filter.elf").expect("pipeline not echoed"); |
| 2568 | let after = &uart[cmd..]; |
| 2569 | assert!( |
| 2570 | after.contains("CAT_PIPED"), |
| 2571 | "builtin cat output did not travel through the pipe; uart={uart:?}" |
| 2572 | ); |
| 2573 | assert!( |
| 2574 | matches!(outcome, RunOutcome::Halted(0)), |
| 2575 | "shell did not exit cleanly; outcome={outcome:?} uart={uart:?}" |
| 2576 | ); |
| 2577 | } |
| 2578 | |
| 2579 | // `cat` with no file argument copies its input source to the sink, so as a pipe |
| 2580 | // consumer it must print what the shell wired to its stdin. |
| 2581 | #[test] |
| 2582 | fn kernel_pipe_echo_into_cat() { |
| 2583 | let shell = compile_hosted_program("shell"); |
| 2584 | let image = build_fs_image(&[FsEntry::Dir { path: "/tmp" }]); |
| 2585 | |
| 2586 | let session = "echo CAT_STDIN | cat\nexit\n"; |
| 2587 | let (_, outcome, uart) = boot_kernel( |
| 2588 | cached_kernel(), |
| 2589 | Some(&shell), |
| 2590 | Some(&image), |
| 2591 | session, |
| 2592 | 120_000_000, |
| 2593 | ); |
| 2594 | |
| 2595 | assert!(!uart.contains("PANIC!"), "kernel panicked; uart={uart:?}"); |
| 2596 | // The command echo prints "CAT_STDIN" once (the typed line). If the pipe worked, |
| 2597 | // cat prints it a second time, so the count is >= 2. |
| 2598 | let n = uart.matches("CAT_STDIN").count(); |
| 2599 | assert!( |
| 2600 | n >= 2, |
| 2601 | "echo did not pipe into cat; saw CAT_STDIN {n} time(s); uart={uart:?}" |
| 2602 | ); |
| 2603 | assert!( |
| 2604 | matches!(outcome, RunOutcome::Halted(0)), |
| 2605 | "shell did not exit cleanly; outcome={outcome:?} uart={uart:?}" |
| 2606 | ); |
| 2607 | } |
| 2608 | |
| 2609 | // The shell's pipe temp file starts with a dot and `ls` hides dotfiles, so it |
| 2610 | // must not appear in the listing (regression for a leaked `.pipe0` entry). |
| 2611 | #[test] |
| 2612 | fn kernel_pipe_ls_hides_temp_file() { |
| 2613 | let shell = compile_hosted_program("shell"); |
| 2614 | let image = build_fs_image(&[ |
| 2615 | FsEntry::File { |
| 2616 | path: "/real.txt", |
| 2617 | data: b"x", |
| 2618 | }, |
nothing calls this directly
no test coverage detected