MCPcopy Create free account
hub / github.com/LPC4/Full-Stack / kernel_pipe_to_file

Function kernel_pipe_to_file

tests/integration/kernel_integration.rs:2487–2556  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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]
2525fn kernel_pipe_builtin_source() {
2526 let shell = compile_hosted_program("shell");
2527 let filter = compile_hosted(
2528 r#"
2529external sys_readchar: () -> i64
2530external console_putchar: (c: i32)
2531external sys_exit: (code: i64)
2532main: () -> 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 );

Callers

nothing calls this directly

Calls 6

compile_hosted_programFunction · 0.85
compile_hostedFunction · 0.85
assembled_to_elf_fileFunction · 0.85
build_fs_imageFunction · 0.85
boot_kernelFunction · 0.85
cached_kernelFunction · 0.85

Tested by

no test coverage detected