From 7a35763d629fa10f27b5428005c3873f4c2fa8bc Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Wed, 3 Feb 2021 14:54:42 -0800 Subject: [PATCH] collapse two test flags into dangling_filesystem --- .../tests/wasm_tests/runtime/cap_std_sync.rs | 3 +- .../wasi-tests/src/bin/dangling_fd.rs | 28 +++++++++---------- .../wasi-tests/src/bin/dangling_symlink.rs | 2 +- .../wasi-tests/src/bin/path_link.rs | 2 +- .../src/bin/path_symlink_trailing_slashes.rs | 2 +- .../wasi-tests/src/bin/symlink_loop.rs | 2 +- crates/test-programs/wasi-tests/src/config.rs | 16 ++++------- 7 files changed, 24 insertions(+), 31 deletions(-) diff --git a/crates/test-programs/tests/wasm_tests/runtime/cap_std_sync.rs b/crates/test-programs/tests/wasm_tests/runtime/cap_std_sync.rs index 63984b4236..089d393ea3 100644 --- a/crates/test-programs/tests/wasm_tests/runtime/cap_std_sync.rs +++ b/crates/test-programs/tests/wasm_tests/runtime/cap_std_sync.rs @@ -32,10 +32,9 @@ pub fn instantiate(data: &[u8], bin_name: &str, workspace: Option<&Path>) -> any { builder = builder .env("ERRNO_MODE_WINDOWS", "1")? - .env("NO_DANGLING_SYMLINKS", "1")? + .env("NO_DANGLING_FILESYSTEM", "1")? .env("NO_FD_ALLOCATE", "1")? .env("NO_RENAME_DIR_TO_EMPTY_DIR", "1")? - .env("NO_DANGLING_DIRECTORY", "1")?; } #[cfg(all(unix, not(target_os = "macos")))] { diff --git a/crates/test-programs/wasi-tests/src/bin/dangling_fd.rs b/crates/test-programs/wasi-tests/src/bin/dangling_fd.rs index c97e2dcc16..85b8646e10 100644 --- a/crates/test-programs/wasi-tests/src/bin/dangling_fd.rs +++ b/crates/test-programs/wasi-tests/src/bin/dangling_fd.rs @@ -3,21 +3,21 @@ use std::{env, process}; 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, - // and then try creating it again - let fd = wasi::path_open(dir_fd, 0, "file", wasi::OFLAGS_CREAT, 0, 0, 0).unwrap(); - wasi::fd_close(fd).unwrap(); - let file_fd = wasi::path_open(dir_fd, 0, "file", 0, 0, 0, 0).expect("failed to open"); - assert_gt!( - file_fd, - libc::STDERR_FILENO as wasi::Fd, - "file descriptor range check", - ); - wasi::path_unlink_file(dir_fd, "file").expect("failed to unlink"); - let fd = wasi::path_open(dir_fd, 0, "file", wasi::OFLAGS_CREAT, 0, 0, 0).unwrap(); - wasi::fd_close(fd).unwrap(); + if TESTCONFIG.support_dangling_filesystem() { + // Create a file, open it, delete it without closing the handle, + // and then try creating it again + let fd = wasi::path_open(dir_fd, 0, "file", wasi::OFLAGS_CREAT, 0, 0, 0).unwrap(); + wasi::fd_close(fd).unwrap(); + let file_fd = wasi::path_open(dir_fd, 0, "file", 0, 0, 0, 0).expect("failed to open"); + assert_gt!( + file_fd, + libc::STDERR_FILENO as wasi::Fd, + "file descriptor range check", + ); + wasi::path_unlink_file(dir_fd, "file").expect("failed to unlink"); + let fd = wasi::path_open(dir_fd, 0, "file", wasi::OFLAGS_CREAT, 0, 0, 0).unwrap(); + wasi::fd_close(fd).unwrap(); - 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) diff --git a/crates/test-programs/wasi-tests/src/bin/dangling_symlink.rs b/crates/test-programs/wasi-tests/src/bin/dangling_symlink.rs index 596a9b766f..bfc9095d38 100644 --- a/crates/test-programs/wasi-tests/src/bin/dangling_symlink.rs +++ b/crates/test-programs/wasi-tests/src/bin/dangling_symlink.rs @@ -2,7 +2,7 @@ use std::{env, process}; use wasi_tests::{assert_errno, open_scratch_directory, TESTCONFIG}; unsafe fn test_dangling_symlink(dir_fd: wasi::Fd) { - if TESTCONFIG.support_dangling_symlinks() { + if TESTCONFIG.support_dangling_filesystem() { // First create a dangling symlink. wasi::path_symlink("target", dir_fd, "symlink").expect("creating a symlink"); diff --git a/crates/test-programs/wasi-tests/src/bin/path_link.rs b/crates/test-programs/wasi-tests/src/bin/path_link.rs index 7345ff64ee..44bfc26152 100644 --- a/crates/test-programs/wasi-tests/src/bin/path_link.rs +++ b/crates/test-programs/wasi-tests/src/bin/path_link.rs @@ -151,7 +151,7 @@ unsafe fn test_path_link(dir_fd: wasi::Fd) { wasi::ERRNO_NOENT ); - if TESTCONFIG.support_dangling_symlinks() { + if TESTCONFIG.support_dangling_filesystem() { // Create a link to a dangling symlink wasi::path_symlink("target", dir_fd, "symlink").expect("creating a dangling symlink"); diff --git a/crates/test-programs/wasi-tests/src/bin/path_symlink_trailing_slashes.rs b/crates/test-programs/wasi-tests/src/bin/path_symlink_trailing_slashes.rs index db4440c56a..f814303d75 100644 --- a/crates/test-programs/wasi-tests/src/bin/path_symlink_trailing_slashes.rs +++ b/crates/test-programs/wasi-tests/src/bin/path_symlink_trailing_slashes.rs @@ -2,7 +2,7 @@ use std::{env, process}; use wasi_tests::{assert_errno, create_file, open_scratch_directory, TESTCONFIG}; unsafe fn test_path_symlink_trailing_slashes(dir_fd: wasi::Fd) { - if TESTCONFIG.support_dangling_symlinks() { + if TESTCONFIG.support_dangling_filesystem() { // Dangling symlink: Link destination shouldn't end with a slash. assert_errno!( wasi::path_symlink("source", dir_fd, "target/") diff --git a/crates/test-programs/wasi-tests/src/bin/symlink_loop.rs b/crates/test-programs/wasi-tests/src/bin/symlink_loop.rs index e18fa28b28..c14356f897 100644 --- a/crates/test-programs/wasi-tests/src/bin/symlink_loop.rs +++ b/crates/test-programs/wasi-tests/src/bin/symlink_loop.rs @@ -2,7 +2,7 @@ use std::{env, process}; use wasi_tests::{assert_errno, open_scratch_directory, TESTCONFIG}; unsafe fn test_symlink_loop(dir_fd: wasi::Fd) { - if TESTCONFIG.support_dangling_symlinks() { + if TESTCONFIG.support_dangling_filesystem() { // Create a self-referencing symlink. wasi::path_symlink("symlink", dir_fd, "symlink").expect("creating a symlink"); diff --git a/crates/test-programs/wasi-tests/src/config.rs b/crates/test-programs/wasi-tests/src/config.rs index eb8a7e52fd..b2d095c5c2 100644 --- a/crates/test-programs/wasi-tests/src/config.rs +++ b/crates/test-programs/wasi-tests/src/config.rs @@ -1,9 +1,8 @@ pub struct TestConfig { errno_mode: ErrnoMode, - no_dangling_symlinks: bool, + no_dangling_filesystem: bool, no_fd_allocate: bool, no_rename_dir_to_empty_dir: bool, - no_dangling_directory: bool, no_fdflags_sync_support: bool, } @@ -25,17 +24,15 @@ impl TestConfig { } else { ErrnoMode::Permissive }; - let no_dangling_symlinks = std::env::var("NO_DANGLING_SYMLINKS").is_ok(); + let no_dangling_filesystem = std::env::var("NO_DANGLING_FILESYSTEM").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(); let no_fdflags_sync_support = std::env::var("NO_FDFLAGS_SYNC_SUPPORT").is_ok(); TestConfig { errno_mode, - no_dangling_symlinks, + no_dangling_filesystem, no_fd_allocate, no_rename_dir_to_empty_dir, - no_dangling_directory, no_fdflags_sync_support, } } @@ -57,8 +54,8 @@ impl TestConfig { _ => false, } } - pub fn support_dangling_symlinks(&self) -> bool { - !self.no_dangling_symlinks + pub fn support_dangling_filesystem(&self) -> bool { + !self.no_dangling_filesystem } pub fn support_fd_allocate(&self) -> bool { !self.no_fd_allocate @@ -66,9 +63,6 @@ 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 - } pub fn support_fdflags_sync(&self) -> bool { !self.no_fdflags_sync_support }