collapse two test flags into dangling_filesystem

This commit is contained in:
Pat Hickey
2021-02-03 14:54:42 -08:00
parent a9639e52a4
commit 7a35763d62
7 changed files with 24 additions and 31 deletions

View File

@@ -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")))]
{

View File

@@ -3,6 +3,7 @@ use std::{env, process};
use wasi_tests::{open_scratch_directory, TESTCONFIG};
unsafe fn test_dangling_fd(dir_fd: wasi::Fd) {
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();
@@ -17,7 +18,6 @@ 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();
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)

View File

@@ -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");

View File

@@ -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");

View File

@@ -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/")

View File

@@ -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");

View File

@@ -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
}