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

Function test_readwrite_v

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

Source from the content-addressed store, hash-verified

99#[cfg(feature = "fs")]
100#[test]
101fn test_readwrite_v() {
102 use rustix::fs::{openat, seek, Mode, OFlags, SeekFrom, CWD};
103 use rustix::io::{readv, writev};
104
105 let tmp = tempfile::tempdir().unwrap();
106 let dir = openat(CWD, tmp.path(), OFlags::RDONLY, Mode::empty()).unwrap();
107 let file = openat(
108 &dir,
109 "file",
110 OFlags::RDWR | OFlags::CREATE | OFlags::TRUNC,
111 Mode::RUSR | Mode::WUSR,
112 )
113 .unwrap();
114
115 writev(&file, &[IoSlice::new(b"hello")]).unwrap();
116 writev(&file, &[IoSlice::new(b"world")]).unwrap();
117 seek(&file, SeekFrom::Start(0)).unwrap();
118 let mut buf = [0_u8; 5];
119 readv(&file, &mut [IoSliceMut::new(&mut buf)]).unwrap();
120 assert_eq!(&buf, b"hello");
121 readv(&file, &mut [IoSliceMut::new(&mut buf)]).unwrap();
122 assert_eq!(&buf, b"world");
123}
124
125#[cfg(feature = "fs")]
126#[test]

Callers

nothing calls this directly

Calls 5

openatFunction · 0.50
writevFunction · 0.50
seekFunction · 0.50
readvFunction · 0.50
pathMethod · 0.45

Tested by

no test coverage detected