dangling directories are a windows thing
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use more_asserts::assert_gt;
|
||||
use std::{env, process};
|
||||
use wasi_tests::open_scratch_directory;
|
||||
use wasi_tests::{open_scratch_directory, TESTCONFIG};
|
||||
|
||||
unsafe fn test_dangling_fd(dir_fd: wasi::Fd) {
|
||||
// Create a file, open it, delete it without closing the handle,
|
||||
@@ -17,17 +17,19 @@ unsafe fn test_dangling_fd(dir_fd: wasi::Fd) {
|
||||
let fd = wasi::path_open(dir_fd, 0, "file", wasi::OFLAGS_CREAT, 0, 0, 0).unwrap();
|
||||
wasi::fd_close(fd).unwrap();
|
||||
|
||||
// Now, repeat the same process but for a directory
|
||||
wasi::path_create_directory(dir_fd, "subdir").expect("failed to create dir");
|
||||
let subdir_fd = wasi::path_open(dir_fd, 0, "subdir", wasi::OFLAGS_DIRECTORY, 0, 0, 0)
|
||||
.expect("failed to open dir");
|
||||
assert_gt!(
|
||||
subdir_fd,
|
||||
libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
wasi::path_remove_directory(dir_fd, "subdir").expect("failed to remove dir 2");
|
||||
wasi::path_create_directory(dir_fd, "subdir").expect("failed to create dir 2");
|
||||
if TESTCONFIG.support_dangling_directory() {
|
||||
// Now, repeat the same process but for a directory
|
||||
wasi::path_create_directory(dir_fd, "subdir").expect("failed to create dir");
|
||||
let subdir_fd = wasi::path_open(dir_fd, 0, "subdir", wasi::OFLAGS_DIRECTORY, 0, 0, 0)
|
||||
.expect("failed to open dir");
|
||||
assert_gt!(
|
||||
subdir_fd,
|
||||
libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
wasi::path_remove_directory(dir_fd, "subdir").expect("failed to remove dir 2");
|
||||
wasi::path_create_directory(dir_fd, "subdir").expect("failed to create dir 2");
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
||||
@@ -11,11 +11,9 @@ unsafe fn test_remove_directory_trailing_slashes(dir_fd: wasi::Fd) {
|
||||
|
||||
wasi::path_create_directory(dir_fd, "dir").expect("creating a directory");
|
||||
|
||||
/* XXX disabled: this fails presently on windows and linux
|
||||
// Test that removing it with a trailing slash succeeds.
|
||||
wasi::path_remove_directory(dir_fd, "dir/")
|
||||
.expect("remove_directory with a trailing slash on a directory should succeed");
|
||||
*/
|
||||
|
||||
// Create a temporary file.
|
||||
create_file(dir_fd, "file");
|
||||
|
||||
@@ -3,6 +3,7 @@ pub struct TestConfig {
|
||||
no_dangling_symlinks: bool,
|
||||
no_fd_allocate: bool,
|
||||
no_rename_dir_to_empty_dir: bool,
|
||||
no_dangling_directory: bool,
|
||||
}
|
||||
|
||||
enum ErrnoMode {
|
||||
@@ -23,11 +24,13 @@ impl TestConfig {
|
||||
let no_dangling_symlinks = std::env::var("NO_DANGLING_SYMLINKS").is_ok();
|
||||
let no_fd_allocate = std::env::var("NO_FD_ALLOCATE").is_ok();
|
||||
let no_rename_dir_to_empty_dir = std::env::var("NO_RENAME_DIR_TO_EMPTY_DIR").is_ok();
|
||||
let no_dangling_directory = std::env::var("NO_DANGLING_DIRECTORY").is_ok();
|
||||
TestConfig {
|
||||
errno_mode,
|
||||
no_dangling_symlinks,
|
||||
no_fd_allocate,
|
||||
no_rename_dir_to_empty_dir,
|
||||
no_dangling_directory,
|
||||
}
|
||||
}
|
||||
pub fn errno_expect_unix(&self) -> bool {
|
||||
@@ -51,4 +54,7 @@ impl TestConfig {
|
||||
pub fn support_rename_dir_to_empty_dir(&self) -> bool {
|
||||
!self.no_rename_dir_to_empty_dir
|
||||
}
|
||||
pub fn support_dangling_directory(&self) -> bool {
|
||||
!self.no_dangling_directory
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user