cap-std-sync: test opening a tempdir as ambient and then WasiDir
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use crate::file::{filetype_from, to_sysif_fdflags, File};
|
||||
use crate::file::{filetype_from, File};
|
||||
use cap_fs_ext::{DirExt, MetadataExt, SystemTimeSpec};
|
||||
use std::any::Any;
|
||||
use std::convert::TryInto;
|
||||
@@ -256,3 +256,20 @@ fn convert_systimespec(t: Option<wasi_common::SystemTimeSpec>) -> Option<SystemT
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::Dir;
|
||||
#[test]
|
||||
fn scratch_dir() {
|
||||
let tempdir = tempfile::Builder::new()
|
||||
.prefix("cap-std-sync")
|
||||
.tempdir()
|
||||
.expect("create temporary dir");
|
||||
let preopen_dir = unsafe { cap_std::fs::Dir::open_ambient_dir(tempdir.path()) }
|
||||
.expect("open ambient temporary dir");
|
||||
let preopen_dir = Dir::from_cap_std(preopen_dir);
|
||||
wasi_common::WasiDir::open_dir(&preopen_dir, false, ".")
|
||||
.expect("open the same directory via WasiDir abstraction");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user