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

Function test_basic_pipes

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

Source from the content-addressed store, hash-verified

1#[test]
2fn test_basic_pipes() {
3 use rustix::io::{read, write};
4 use rustix::pipe::pipe;
5
6 let message = b"Hello, tee!";
7
8 #[cfg(not(any(
9 solarish,
10 windows,
11 target_os = "espidf",
12 target_os = "haiku",
13 target_os = "redox",
14 target_os = "wasi",
15 )))]
16 assert!(message.len() <= rustix::pipe::PIPE_BUF);
17
18 let (reader, writer) = pipe().unwrap();
19
20 let n = write(&writer, message).unwrap();
21 assert_eq!(n, message.len());
22
23 let mut buf = vec![0_u8; 256];
24 let n = read(&reader, &mut buf).unwrap();
25 assert_eq!(n, message.len());
26 assert_eq!(&buf[..n], message);
27}
28
29#[cfg(not(any(apple, target_os = "aix", target_os = "espidf", target_os = "haiku")))]
30#[test]

Callers

nothing calls this directly

Calls 3

pipeFunction · 0.50
writeFunction · 0.50
readFunction · 0.50

Tested by

no test coverage detected