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

Function test_vmsplice_read

tests/pipe/splice.rs:109–127  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

107#[cfg(linux_kernel)]
108#[test]
109fn test_vmsplice_read() {
110 use rustix::io::write;
111 use rustix::pipe::{pipe, vmsplice, IoSliceRaw, SpliceFlags};
112
113 let (read_p, write_p) = pipe().unwrap();
114 let mut outputs = ([0; 5], [0; 1], [0; 5]);
115 let outputs_slices = [
116 IoSliceRaw::from_slice_mut(&mut outputs.0),
117 IoSliceRaw::from_slice_mut(&mut outputs.1),
118 IoSliceRaw::from_slice_mut(&mut outputs.2),
119 ];
120
121 write(&write_p, b"hello world").unwrap();
122 unsafe { vmsplice(&read_p, &outputs_slices, SpliceFlags::empty()).unwrap() };
123
124 assert_eq!(&outputs.0, b"hello");
125 assert_eq!(&outputs.1, b" ");
126 assert_eq!(&outputs.2, b"world");
127}

Callers

nothing calls this directly

Calls 3

pipeFunction · 0.50
writeFunction · 0.50
vmspliceFunction · 0.50

Tested by

no test coverage detected