()
| 2650 | #[test] |
| 2651 | fn kernel_cat_stdin_redirect() { |
| 2652 | let shell = compile_hosted_program("shell"); |
| 2653 | let image = build_fs_image(&[FsEntry::File { |
| 2654 | path: "/in.txt", |
| 2655 | data: b"FROM_STDIN\n", |
| 2656 | }]); |
| 2657 | |
| 2658 | let session = "cat < /in.txt\nexit\n"; |
| 2659 | let (_, outcome, uart) = boot_kernel( |
| 2660 | cached_kernel(), |
| 2661 | Some(&shell), |
| 2662 | Some(&image), |
| 2663 | session, |
| 2664 | 120_000_000, |
| 2665 | ); |
| 2666 | |
| 2667 | assert!(!uart.contains("PANIC!"), "kernel panicked; uart={uart:?}"); |
| 2668 | // "FROM_STDIN" is only in the file, never in the typed command, so any sighting |
| 2669 | // is cat printing the redirected input. |
| 2670 | assert!( |
| 2671 | uart.contains("FROM_STDIN"), |
| 2672 | "cat did not read redirected stdin; uart={uart:?}" |
| 2673 | ); |
| 2674 | assert!( |
| 2675 | matches!(outcome, RunOutcome::Halted(0)), |
| 2676 | "shell did not exit cleanly; outcome={outcome:?} uart={uart:?}" |
| 2677 | ); |
| 2678 | } |
| 2679 | |
| 2680 | // Input is injected mid-run, the way the GUI does it, so the shell really sleeps |
| 2681 | // in readchar and an incoming byte must raise the RX interrupt to wake it. |
| 2682 | #[test] |
| 2683 | fn kernel_shell_interrupt_wake_lists_running_background_job() { |
| 2684 | let shell = compile_hosted_program("shell"); |
| 2685 | // A background job that runs forever and never reads input, so it stays the |
| 2686 | // sole runnable process while the shell is blocked waiting for a keystroke. |
| 2687 | let spinner = compile_hosted( |
| 2688 | r#" |
| 2689 | external sys_exit: (code: i64) |
nothing calls this directly
no test coverage detected