MCPcopy Create free account
hub / github.com/bytecodealliance/rustix / test_basic_pipes_with

Function test_basic_pipes_with

tests/pipe/basic.rs:31–56  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29#[cfg(not(any(apple, target_os = "aix", target_os = "espidf", target_os = "haiku")))]
30#[test]
31fn 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}

Callers

nothing calls this directly

Calls 3

pipe_withFunction · 0.50
writeFunction · 0.50
readFunction · 0.50

Tested by

no test coverage detected