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

Function test_preadv2_nowait

tests/io/read_write.rs:262–300  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

260#[cfg(all(feature = "net", feature = "pipe"))]
261#[test]
262fn test_preadv2_nowait() {
263 use rustix::io::{preadv2, ReadWriteFlags};
264 use rustix::net::{socketpair, AddressFamily, SocketFlags, SocketType};
265 use rustix::pipe::pipe;
266
267 let mut buf = [0_u8; 5];
268
269 let (reader, _writer) = socketpair(
270 AddressFamily::UNIX,
271 SocketType::STREAM,
272 SocketFlags::CLOEXEC,
273 None,
274 )
275 .unwrap();
276 match preadv2(
277 &reader,
278 &mut [IoSliceMut::new(&mut buf)],
279 u64::MAX,
280 ReadWriteFlags::NOWAIT,
281 ) {
282 Err(rustix::io::Errno::OPNOTSUPP | rustix::io::Errno::NOSYS) => {}
283 Err(rustix::io::Errno::AGAIN) => {}
284 Ok(_) => panic!("preadv2 unexpectedly succeeded"),
285 Err(e) => panic!("preadv2 failed with an unexpected error: {:?}", e),
286 }
287
288 let (reader, _writer) = pipe().unwrap();
289 match preadv2(
290 &reader,
291 &mut [IoSliceMut::new(&mut buf)],
292 u64::MAX,
293 ReadWriteFlags::NOWAIT,
294 ) {
295 Err(rustix::io::Errno::OPNOTSUPP | rustix::io::Errno::NOSYS) => {}
296 Err(rustix::io::Errno::AGAIN) => {}
297 Ok(_) => panic!("preadv2 unexpectedly succeeded"),
298 Err(e) => panic!("preadv2 failed with an unexpected error: {:?}", e),
299 }
300}
301
302#[cfg(all(feature = "net", feature = "pipe"))]
303#[cfg(not(target_os = "espidf"))] // no preadv/pwritev

Callers

nothing calls this directly

Calls 3

socketpairFunction · 0.50
preadv2Function · 0.50
pipeFunction · 0.50

Tested by

no test coverage detected