()
| 2374 | } |
| 2375 | |
| 2376 | // The shell binds the producer's stdout to a temp file the filter reads back, so |
| 2377 | // the payload only reaches the console if it travelled through the pipe. |
| 2378 | #[test] |
| 2379 | fn kernel_pipe_two_stage() { |
| 2380 | let shell = compile_hosted_program("shell"); |
| 2381 | let producer = compile_hosted( |
| 2382 | r#" |
| 2383 | external console_writeln: (str: u8*) |
| 2384 | external sys_exit: (code: i64) |
| 2385 | main: () -> i32 { |
| 2386 | console_writeln("PIPE_PAYLOAD".ptr) |
| 2387 | sys_exit(0) |
| 2388 | return 0 |
| 2389 | } |
| 2390 | "#, |
| 2391 | ); |
| 2392 | // Copy stdin to stdout until EOF (-1): a transparent filter. |
| 2393 | let filter = compile_hosted( |
| 2394 | r#" |
| 2395 | external sys_readchar: () -> i64 |
| 2396 | external console_putchar: (c: i32) |
| 2397 | external sys_exit: (code: i64) |
| 2398 | main: () -> i32 { |
| 2399 | while 1 == 1 { |
| 2400 | c: i64 = sys_readchar() |
| 2401 | if c < 0 { |
| 2402 | break |
| 2403 | } |
| 2404 | console_putchar(c as i32) |
| 2405 | } |
| 2406 | sys_exit(0) |
| 2407 | return 0 |
| 2408 | } |
| 2409 | "#, |
nothing calls this directly
no test coverage detected