| 29 | #[cfg(not(any(apple, target_os = "aix", target_os = "espidf", target_os = "haiku")))] |
| 30 | #[test] |
| 31 | fn test_basic_pipes_with() { |
| 32 | use rustix::io::{read, write}; |
| 33 | use rustix::pipe::{pipe_with, PipeFlags}; |
| 34 | |
| 35 | let message = b"Hello, tee!"; |
| 36 | |
| 37 | #[cfg(not(any( |
| 38 | solarish, |
| 39 | windows, |
| 40 | target_os = "espidf", |
| 41 | target_os = "haiku", |
| 42 | target_os = "redox", |
| 43 | target_os = "wasi", |
| 44 | )))] |
| 45 | assert!(message.len() <= rustix::pipe::PIPE_BUF); |
| 46 | |
| 47 | let (reader, writer) = pipe_with(PipeFlags::CLOEXEC).unwrap(); |
| 48 | |
| 49 | let n = write(&writer, message).unwrap(); |
| 50 | assert_eq!(n, message.len()); |
| 51 | |
| 52 | let mut buf = vec![0_u8; 256]; |
| 53 | let n = read(&reader, &mut buf).unwrap(); |
| 54 | assert_eq!(n, message.len()); |
| 55 | assert_eq!(&buf[..n], message); |
| 56 | } |