Fixed some incorrect flags, added tests & impl for `io::Seek` in `ManagedFd` & `MemoryFile`. XXX: `MFD_HUGETLB` w/ `MAP_HUGETLB` support seems to be failing for unknown reasons...
assert_eq!(super::DEFAULT_FLAGS,cfg!(feature="default-cloexec").then(||super::MFD_CLOEXEC).unwrap_or_default(),"Compile-time default creation flags are not in accordance with provided global crate configuration");
}
//TODO: Test if `NamedMemoryFile.get_path()` works properly.
fnmem_seek()
{
// Test `SEEK_SET`.
letmutfile=super::MemoryFile::new_named("test-mem-seek").expect("Failed to create new file 'memfd:test-mem-seek'");
file.write_all(b"hello world").expect("Failed to write to memfd");
file.seek(io::SeekFrom::Start(6)).expect("Failed to seek to 6..");
letmutbuf=Vec::new();
letsz=file.read_to_end(&mutbuf).expect("Failed to read from memfd");
assert_eq!(sz,5,"Invalid number of bytes read");
assert_eq!(&buf,b"world","Invalid string data read");
file.seek_relative(-(szasi64)).expect("Failed to seek -5");
buf.clear();
assert_eq!(file.read_to_end(&mutbuf).expect("Failed to read from memfd (2nd pass)"),sz,"Invalid number of bytes re-read from file");
assert_eq!(&buf,b"world","Invalid string data read in 2nd pass");