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

Function kernel_kill_background_job

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

Source from the content-addressed store, hash-verified

2047 );
2048 assert!(
2049 uart.contains("] done pid 2"),
2050 "killed job was not reaped from the table; uart={uart:?}"
2051 );
2052 assert!(
2053 uart.contains("no background jobs"),
2054 "job still listed after kill %1; uart={uart:?}"
2055 );
2056 assert!(
2057 matches!(outcome, StepOutcome::Halted(0)),
2058 "shell did not exit cleanly after kill; outcome={outcome:?} uart={uart:?}"
2059 );
2060}
2061
2062// `prog > file` binds the child's fd 1 to an FS file. Ordering is the proof: a
2063// failed redirect would print the marker to the UART before `cat` reads it back.
2064#[test]
2065fn kernel_redirect_stdout_to_file() {
2066 let shell = compile_hosted_program("shell");
2067 let printer = compile_hosted(
2068 r#"
2069external console_writeln: (str: u8*)
2070external sc_exit: (code: i64)
2071main: () -> i32 {
2072 console_writeln("REDIRECT_OK".ptr)
2073 sc_exit(0)
2074 return 0
2075}
2076"#,
2077 );
2078 let printer_exec = assembled_to_elf_file(&printer);
2079 let image = build_fs_image(&[FsEntry::File {
2080 path: "/printer.elf",
2081 data: &printer_exec,
2082 }]);
2083
2084 let session = "run /printer.elf > /out.txt\ncat /out.txt\nexit\n";
2085 let (_, outcome, uart) = boot_kernel(
2086 cached_kernel(),
2087 Some(&shell),
2088 Some(&image),
2089 session,
2090 120_000_000,
2091 );
2092
2093 assert!(!uart.contains("PANIC!"), "kernel panicked; uart={uart:?}");
2094 let mark = uart
2095 .find("REDIRECT_OK")
2096 .expect("marker never reached the UART");
2097 let cat = uart.find("cat /out.txt").expect("cat command not echoed");
2098 assert!(
2099 mark > cat,
2100 "marker appeared before `cat`, so stdout was NOT redirected; uart={uart:?}"

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