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

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

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