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 builder = builder
.env("ERRNO_MODE_WINDOWS", "1")? .env("ERRNO_MODE_WINDOWS", "1")?
.env("NO_DANGLING_SYMLINKS", "1")? .env("NO_DANGLING_FILESYSTEM", "1")?
.env("NO_FD_ALLOCATE", "1")? .env("NO_FD_ALLOCATE", "1")?
.env("NO_RENAME_DIR_TO_EMPTY_DIR", "1")? .env("NO_RENAME_DIR_TO_EMPTY_DIR", "1")?
.env("NO_DANGLING_DIRECTORY", "1")?;
} }
#[cfg(all(unix, not(target_os = "macos")))] #[cfg(all(unix, not(target_os = "macos")))]
{ {

View File

@@ -3,21 +3,21 @@ use std::{env, process};
use wasi_tests::{open_scratch_directory, TESTCONFIG}; use wasi_tests::{open_scratch_directory, TESTCONFIG};
unsafe fn test_dangling_fd(dir_fd: wasi::Fd) { unsafe fn test_dangling_fd(dir_fd: wasi::Fd) {
// Create a file, open it, delete it without closing the handle, if TESTCONFIG.support_dangling_filesystem() {
// and then try creating it again // Create a file, open it, delete it without closing the handle,
let fd = wasi::path_open(dir_fd, 0, "file", wasi::OFLAGS_CREAT, 0, 0, 0).unwrap(); // and then try creating it again
wasi::fd_close(fd).unwrap(); let fd = wasi::path_open(dir_fd, 0, "file", wasi::OFLAGS_CREAT, 0, 0, 0).unwrap();
let file_fd = wasi::path_open(dir_fd, 0, "file", 0, 0, 0, 0).expect("failed to open"); wasi::fd_close(fd).unwrap();
assert_gt!( let file_fd = wasi::path_open(dir_fd, 0, "file", 0, 0, 0, 0).expect("failed to open");
file_fd, assert_gt!(
libc::STDERR_FILENO as wasi::Fd, file_fd,
"file descriptor range check", 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::path_unlink_file(dir_fd, "file").expect("failed to unlink");
wasi::fd_close(fd).unwrap(); 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 // Now, repeat the same process but for a directory
wasi::path_create_directory(dir_fd, "subdir").expect("failed to create dir"); 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) 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}; use wasi_tests::{assert_errno, open_scratch_directory, TESTCONFIG};
unsafe fn test_dangling_symlink(dir_fd: wasi::Fd) { unsafe fn test_dangling_symlink(dir_fd: wasi::Fd) {
if TESTCONFIG.support_dangling_symlinks() { if TESTCONFIG.support_dangling_filesystem() {
// First create a dangling symlink. // First create a dangling symlink.
wasi::path_symlink("target", dir_fd, "symlink").expect("creating a 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 wasi::ERRNO_NOENT
); );
if TESTCONFIG.support_dangling_symlinks() { if TESTCONFIG.support_dangling_filesystem() {
// Create a link to a dangling symlink // Create a link to a dangling symlink
wasi::path_symlink("target", dir_fd, "symlink").expect("creating 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}; use wasi_tests::{assert_errno, create_file, open_scratch_directory, TESTCONFIG};
unsafe fn test_path_symlink_trailing_slashes(dir_fd: wasi::Fd) { 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. // Dangling symlink: Link destination shouldn't end with a slash.
assert_errno!( assert_errno!(
wasi::path_symlink("source", dir_fd, "target/") 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}; use wasi_tests::{assert_errno, open_scratch_directory, TESTCONFIG};
unsafe fn test_symlink_loop(dir_fd: wasi::Fd) { unsafe fn test_symlink_loop(dir_fd: wasi::Fd) {
if TESTCONFIG.support_dangling_symlinks() { if TESTCONFIG.support_dangling_filesystem() {
// Create a self-referencing symlink. // Create a self-referencing symlink.
wasi::path_symlink("symlink", dir_fd, "symlink").expect("creating a symlink"); wasi::path_symlink("symlink", dir_fd, "symlink").expect("creating a symlink");

View File

@@ -1,9 +1,8 @@
pub struct TestConfig { pub struct TestConfig {
errno_mode: ErrnoMode, errno_mode: ErrnoMode,
no_dangling_symlinks: bool, no_dangling_filesystem: bool,
no_fd_allocate: bool, no_fd_allocate: bool,
no_rename_dir_to_empty_dir: bool, no_rename_dir_to_empty_dir: bool,
no_dangling_directory: bool,
no_fdflags_sync_support: bool, no_fdflags_sync_support: bool,
} }
@@ -25,17 +24,15 @@ impl TestConfig {
} else { } else {
ErrnoMode::Permissive 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_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_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(); let no_fdflags_sync_support = std::env::var("NO_FDFLAGS_SYNC_SUPPORT").is_ok();
TestConfig { TestConfig {
errno_mode, errno_mode,
no_dangling_symlinks, no_dangling_filesystem,
no_fd_allocate, no_fd_allocate,
no_rename_dir_to_empty_dir, no_rename_dir_to_empty_dir,
no_dangling_directory,
no_fdflags_sync_support, no_fdflags_sync_support,
} }
} }
@@ -57,8 +54,8 @@ impl TestConfig {
_ => false, _ => false,
} }
} }
pub fn support_dangling_symlinks(&self) -> bool { pub fn support_dangling_filesystem(&self) -> bool {
!self.no_dangling_symlinks !self.no_dangling_filesystem
} }
pub fn support_fd_allocate(&self) -> bool { pub fn support_fd_allocate(&self) -> bool {
!self.no_fd_allocate !self.no_fd_allocate
@@ -66,9 +63,6 @@ impl TestConfig {
pub fn support_rename_dir_to_empty_dir(&self) -> bool { pub fn support_rename_dir_to_empty_dir(&self) -> bool {
!self.no_rename_dir_to_empty_dir !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 { pub fn support_fdflags_sync(&self) -> bool {
!self.no_fdflags_sync_support !self.no_fdflags_sync_support
} }