diff --git a/test-programs/wasi-tests/src/bin/directory_seek.rs b/test-programs/wasi-tests/src/bin/directory_seek.rs index 85b96e6a..dc4fd52f 100644 --- a/test-programs/wasi-tests/src/bin/directory_seek.rs +++ b/test-programs/wasi-tests/src/bin/directory_seek.rs @@ -6,16 +6,8 @@ unsafe fn test_directory_seek(dir_fd: wasi::Fd) { wasi::path_create_directory(dir_fd, "dir").expect("failed to make directory"); // Open the directory and attempt to request rights for seeking. - let fd = wasi::path_open( - dir_fd, - 0, - "dir", - wasi::OFLAGS_DIRECTORY, - wasi::RIGHTS_FD_SEEK, - 0, - 0, - ) - .expect("failed to open file"); + let fd = wasi::path_open(dir_fd, 0, "dir", wasi::OFLAGS_DIRECTORY, 0, 0, 0) + .expect("failed to open file"); assert!( fd > libc::STDERR_FILENO as wasi::Fd, "file descriptor range check", @@ -27,19 +19,6 @@ unsafe fn test_directory_seek(dir_fd: wasi::Fd) { wasi::ERRNO_BADF ); - // Check if we obtained the right to seek. - let fdstat = wasi::fd_fdstat_get(fd).expect("failed to fdstat"); - assert_eq!( - fdstat.fs_filetype, - wasi::FILETYPE_DIRECTORY, - "expected the scratch directory to be a directory", - ); - assert_eq!( - (fdstat.fs_rights_base & wasi::RIGHTS_FD_SEEK), - 0, - "directory does NOT have the seek right", - ); - // Clean up. wasi::fd_close(fd).expect("failed to close fd"); wasi::path_remove_directory(dir_fd, "dir").expect("failed to remove dir"); diff --git a/test-programs/wasi-tests/src/bin/fd_advise.rs b/test-programs/wasi-tests/src/bin/fd_advise.rs index d6c37ae7..78a048db 100644 --- a/test-programs/wasi-tests/src/bin/fd_advise.rs +++ b/test-programs/wasi-tests/src/bin/fd_advise.rs @@ -8,12 +8,7 @@ unsafe fn test_fd_advise(dir_fd: wasi::Fd) { 0, "file", wasi::OFLAGS_CREAT, - wasi::RIGHTS_FD_READ - | wasi::RIGHTS_FD_WRITE - | wasi::RIGHTS_FD_ADVISE - | wasi::RIGHTS_FD_FILESTAT_GET - | wasi::RIGHTS_FD_FILESTAT_SET_SIZE - | wasi::RIGHTS_FD_ALLOCATE, + wasi::RIGHTS_FD_READ | wasi::RIGHTS_FD_WRITE, 0, 0, ) diff --git a/test-programs/wasi-tests/src/bin/fd_filestat_set.rs b/test-programs/wasi-tests/src/bin/fd_filestat_set.rs index 424831b3..de358dff 100644 --- a/test-programs/wasi-tests/src/bin/fd_filestat_set.rs +++ b/test-programs/wasi-tests/src/bin/fd_filestat_set.rs @@ -8,11 +8,7 @@ unsafe fn test_fd_filestat_set(dir_fd: wasi::Fd) { 0, "file", wasi::OFLAGS_CREAT, - wasi::RIGHTS_FD_READ - | wasi::RIGHTS_FD_WRITE - | wasi::RIGHTS_FD_FILESTAT_GET - | wasi::RIGHTS_FD_FILESTAT_SET_SIZE - | wasi::RIGHTS_FD_FILESTAT_SET_TIMES, + wasi::RIGHTS_FD_READ | wasi::RIGHTS_FD_WRITE, 0, 0, ) diff --git a/test-programs/wasi-tests/src/bin/fd_flags_set.rs b/test-programs/wasi-tests/src/bin/fd_flags_set.rs index cd55c3da..85864547 100644 --- a/test-programs/wasi-tests/src/bin/fd_flags_set.rs +++ b/test-programs/wasi-tests/src/bin/fd_flags_set.rs @@ -10,11 +10,7 @@ unsafe fn test_fd_fdstat_set_flags(dir_fd: wasi::Fd) { 0, FILE_NAME, wasi::OFLAGS_CREAT, - wasi::RIGHTS_FD_READ - | wasi::RIGHTS_FD_WRITE - | wasi::RIGHTS_FD_SEEK - | wasi::RIGHTS_FD_TELL - | wasi::RIGHTS_FD_FDSTAT_SET_FLAGS, + wasi::RIGHTS_FD_READ | wasi::RIGHTS_FD_WRITE, 0, wasi::FDFLAGS_APPEND, ) diff --git a/test-programs/wasi-tests/src/bin/fd_readdir.rs b/test-programs/wasi-tests/src/bin/fd_readdir.rs index 87aa112c..f7c5388f 100644 --- a/test-programs/wasi-tests/src/bin/fd_readdir.rs +++ b/test-programs/wasi-tests/src/bin/fd_readdir.rs @@ -98,10 +98,7 @@ unsafe fn test_fd_readdir(dir_fd: wasi::Fd) { 0, "file", wasi::OFLAGS_CREAT, - wasi::RIGHTS_FD_READ - | wasi::RIGHTS_FD_WRITE - | wasi::RIGHTS_FD_READDIR - | wasi::RIGHTS_FD_FILESTAT_GET, + wasi::RIGHTS_FD_READ | wasi::RIGHTS_FD_WRITE, 0, 0, ) @@ -155,10 +152,7 @@ unsafe fn test_fd_readdir_lots(dir_fd: wasi::Fd) { 0, &format!("file.{}", count), wasi::OFLAGS_CREAT, - wasi::RIGHTS_FD_READ - | wasi::RIGHTS_FD_WRITE - | wasi::RIGHTS_FD_READDIR - | wasi::RIGHTS_FD_FILESTAT_GET, + wasi::RIGHTS_FD_READ | wasi::RIGHTS_FD_WRITE, 0, 0, ) diff --git a/test-programs/wasi-tests/src/bin/file_allocate.rs b/test-programs/wasi-tests/src/bin/file_allocate.rs index 9008002e..d7a6dd57 100644 --- a/test-programs/wasi-tests/src/bin/file_allocate.rs +++ b/test-programs/wasi-tests/src/bin/file_allocate.rs @@ -8,10 +8,7 @@ unsafe fn test_file_allocate(dir_fd: wasi::Fd) { 0, "file", wasi::OFLAGS_CREAT, - wasi::RIGHTS_FD_READ - | wasi::RIGHTS_FD_WRITE - | wasi::RIGHTS_FD_ALLOCATE - | wasi::RIGHTS_FD_FILESTAT_GET, + wasi::RIGHTS_FD_READ | wasi::RIGHTS_FD_WRITE, 0, 0, ) diff --git a/test-programs/wasi-tests/src/bin/file_pread_pwrite.rs b/test-programs/wasi-tests/src/bin/file_pread_pwrite.rs index 9df32f3c..918fec84 100644 --- a/test-programs/wasi-tests/src/bin/file_pread_pwrite.rs +++ b/test-programs/wasi-tests/src/bin/file_pread_pwrite.rs @@ -9,7 +9,7 @@ unsafe fn test_file_pread_pwrite(dir_fd: wasi::Fd) { 0, "file", wasi::OFLAGS_CREAT, - wasi::RIGHTS_FD_READ | wasi::RIGHTS_FD_SEEK | wasi::RIGHTS_FD_WRITE, + wasi::RIGHTS_FD_READ | wasi::RIGHTS_FD_WRITE, 0, 0, ) diff --git a/test-programs/wasi-tests/src/bin/file_seek_tell.rs b/test-programs/wasi-tests/src/bin/file_seek_tell.rs index a3d3711b..a54fe14a 100644 --- a/test-programs/wasi-tests/src/bin/file_seek_tell.rs +++ b/test-programs/wasi-tests/src/bin/file_seek_tell.rs @@ -8,7 +8,7 @@ unsafe fn test_file_seek_tell(dir_fd: wasi::Fd) { 0, "file", wasi::OFLAGS_CREAT, - wasi::RIGHTS_FD_READ | wasi::RIGHTS_FD_WRITE | wasi::RIGHTS_FD_SEEK | wasi::RIGHTS_FD_TELL, + wasi::RIGHTS_FD_READ | wasi::RIGHTS_FD_WRITE, 0, 0, ) diff --git a/test-programs/wasi-tests/src/bin/overwrite_preopen.rs b/test-programs/wasi-tests/src/bin/overwrite_preopen.rs index 0721d18a..7b509c50 100644 --- a/test-programs/wasi-tests/src/bin/overwrite_preopen.rs +++ b/test-programs/wasi-tests/src/bin/overwrite_preopen.rs @@ -9,7 +9,8 @@ unsafe fn test_overwrite_preopen(dir_fd: wasi::Fd) { let old_dir_filestat = wasi::fd_filestat_get(dir_fd).expect("failed fd_filestat_get"); // Try to renumber over a preopened directory handle. - wasi::fd_renumber(dir_fd, pre_fd).expect("renumbering over a preopened file descriptor"); + wasi::fd_renumber(dir_fd, pre_fd) + .expect("renumbering over a preopened file descriptor"); // Ensure that pre_fd is still open. let new_dir_filestat = wasi::fd_filestat_get(pre_fd).expect("failed fd_filestat_get"); diff --git a/test-programs/wasi-tests/src/bin/path_filestat.rs b/test-programs/wasi-tests/src/bin/path_filestat.rs index 2b1629e4..2c4b63a9 100644 --- a/test-programs/wasi-tests/src/bin/path_filestat.rs +++ b/test-programs/wasi-tests/src/bin/path_filestat.rs @@ -2,13 +2,6 @@ use std::{env, process}; use wasi_tests::{assert_errno, open_scratch_directory, TESTCONFIG}; unsafe fn test_path_filestat(dir_fd: wasi::Fd) { - let mut fdstat = wasi::fd_fdstat_get(dir_fd).expect("fd_fdstat_get"); - assert_ne!( - fdstat.fs_rights_base & wasi::RIGHTS_PATH_FILESTAT_GET, - 0, - "the scratch directory should have RIGHT_PATH_FILESTAT_GET as base right", - ); - let fdflags = if TESTCONFIG.support_fdflags_sync() { wasi::FDFLAGS_APPEND | wasi::FDFLAGS_SYNC } else { @@ -21,7 +14,7 @@ unsafe fn test_path_filestat(dir_fd: wasi::Fd) { 0, "file", wasi::OFLAGS_CREAT, - wasi::RIGHTS_FD_READ | wasi::RIGHTS_FD_WRITE | wasi::RIGHTS_PATH_FILESTAT_GET, + wasi::RIGHTS_FD_READ | wasi::RIGHTS_FD_WRITE, 0, // Pass some flags for later retrieval fdflags, @@ -32,17 +25,7 @@ unsafe fn test_path_filestat(dir_fd: wasi::Fd) { "file descriptor range check", ); - fdstat = wasi::fd_fdstat_get(file_fd).expect("fd_fdstat_get"); - assert_eq!( - fdstat.fs_rights_base & wasi::RIGHTS_PATH_FILESTAT_GET, - 0, - "files shouldn't have rights for path_* syscalls even if manually given", - ); - assert_eq!( - fdstat.fs_rights_inheriting & wasi::RIGHTS_PATH_FILESTAT_GET, - 0, - "files shouldn't have rights for path_* syscalls even if manually given", - ); + let fdstat = wasi::fd_fdstat_get(file_fd).expect("fd_fdstat_get"); assert_eq!( fdstat.fs_flags & wasi::FDFLAGS_APPEND, wasi::FDFLAGS_APPEND, @@ -63,7 +46,7 @@ unsafe fn test_path_filestat(dir_fd: wasi::Fd) { 0, "file", 0, - wasi::RIGHTS_FD_READ | wasi::RIGHTS_FD_WRITE | wasi::RIGHTS_PATH_FILESTAT_GET, + wasi::RIGHTS_FD_READ | wasi::RIGHTS_FD_WRITE, 0, wasi::FDFLAGS_SYNC, ) diff --git a/test-programs/wasi-tests/src/bin/path_link.rs b/test-programs/wasi-tests/src/bin/path_link.rs index 1216c334..161d865d 100644 --- a/test-programs/wasi-tests/src/bin/path_link.rs +++ b/test-programs/wasi-tests/src/bin/path_link.rs @@ -1,15 +1,8 @@ use std::{env, process}; use wasi_tests::{assert_errno, create_file, open_scratch_directory, TESTCONFIG}; -const TEST_RIGHTS: wasi::Rights = wasi::RIGHTS_FD_READ - | wasi::RIGHTS_PATH_LINK_SOURCE - | wasi::RIGHTS_PATH_LINK_TARGET - | wasi::RIGHTS_FD_FILESTAT_GET - | wasi::RIGHTS_PATH_OPEN - | wasi::RIGHTS_PATH_UNLINK_FILE; - unsafe fn create_or_open(dir_fd: wasi::Fd, name: &str, flags: wasi::Oflags) -> wasi::Fd { - let file_fd = wasi::path_open(dir_fd, 0, name, flags, TEST_RIGHTS, TEST_RIGHTS, 0) + let file_fd = wasi::path_open(dir_fd, 0, name, flags, 0, 0, 0) .unwrap_or_else(|_| panic!("opening '{}'", name)); assert!( file_fd > libc::STDERR_FILENO as wasi::Fd, @@ -19,7 +12,7 @@ unsafe fn create_or_open(dir_fd: wasi::Fd, name: &str, flags: wasi::Oflags) -> w } unsafe fn open_link(dir_fd: wasi::Fd, name: &str) -> wasi::Fd { - let file_fd = wasi::path_open(dir_fd, 0, name, 0, TEST_RIGHTS, TEST_RIGHTS, 0) + let file_fd = wasi::path_open(dir_fd, 0, name, 0, 0, 0, 0) .unwrap_or_else(|_| panic!("opening a link '{}'", name)); assert!( file_fd > libc::STDERR_FILENO as wasi::Fd, @@ -91,9 +84,9 @@ unsafe fn test_path_link(dir_fd: wasi::Fd) { wasi::path_link(dir_fd, 0, "file", subdir_fd, "link").expect("creating a link in subdirectory"); let link_fd = open_link(subdir_fd, "link"); check_rights(file_fd, link_fd); + wasi::fd_close(link_fd).expect("Closing link_fd"); // needed for Windows wasi::path_unlink_file(subdir_fd, "link").expect("removing a link"); wasi::fd_close(subdir_fd).expect("Closing subdir_fd"); // needed for Windows - wasi::fd_close(link_fd).expect("Closing link_fd"); // needed for Windows wasi::path_remove_directory(dir_fd, "subdir").expect("removing a subdirectory"); // Create a link to a path that already exists diff --git a/test-programs/wasi-tests/src/bin/poll_oneoff_files.rs b/test-programs/wasi-tests/src/bin/poll_oneoff_files.rs index cbf98031..03539ea3 100644 --- a/test-programs/wasi-tests/src/bin/poll_oneoff_files.rs +++ b/test-programs/wasi-tests/src/bin/poll_oneoff_files.rs @@ -197,16 +197,8 @@ unsafe fn test_fd_readwrite_valid_fd(dir_fd: wasi::Fd) { wasi::fd_close(nonempty_file).expect("close"); // Now open the file for reading - let readable_fd = wasi::path_open( - dir_fd, - 0, - "readable_file", - 0, - wasi::RIGHTS_FD_READ | wasi::RIGHTS_POLL_FD_READWRITE, - 0, - 0, - ) - .expect("opening a readable file"); + let readable_fd = wasi::path_open(dir_fd, 0, "readable_file", 0, wasi::RIGHTS_FD_READ, 0, 0) + .expect("opening a readable file"); assert!( readable_fd > libc::STDERR_FILENO as wasi::Fd, @@ -218,7 +210,7 @@ unsafe fn test_fd_readwrite_valid_fd(dir_fd: wasi::Fd) { 0, "writable_file", wasi::OFLAGS_CREAT, - wasi::RIGHTS_FD_WRITE | wasi::RIGHTS_POLL_FD_READWRITE, + wasi::RIGHTS_FD_WRITE, 0, 0, ) @@ -231,6 +223,7 @@ unsafe fn test_fd_readwrite_valid_fd(dir_fd: wasi::Fd) { test_fd_readwrite(readable_fd, writable_fd, wasi::ERRNO_SUCCESS); wasi::fd_close(readable_fd).expect("closing readable_file"); + wasi::fd_close(writable_fd).expect("closing writable_file"); wasi::path_unlink_file(dir_fd, "readable_file").expect("removing readable_file"); wasi::path_unlink_file(dir_fd, "writable_file").expect("removing writable_file"); } diff --git a/test-programs/wasi-tests/src/bin/readlink.rs b/test-programs/wasi-tests/src/bin/readlink.rs index f085ef26..61564724 100644 --- a/test-programs/wasi-tests/src/bin/readlink.rs +++ b/test-programs/wasi-tests/src/bin/readlink.rs @@ -1,5 +1,5 @@ use std::{env, process}; -use wasi_tests::{create_file, open_scratch_directory}; +use wasi_tests::{assert_errno, create_file, open_scratch_directory}; unsafe fn test_readlink(dir_fd: wasi::Fd) { // Create a file in the scratch directory. @@ -21,8 +21,6 @@ unsafe fn test_readlink(dir_fd: wasi::Fd) { ); // Read link into smaller buffer than the actual link's length - // FIXME: the adapter will actually truncate in this case. we could instead - // return an error in the adapter? let buf = &mut [0u8; 4]; let bufused = wasi::path_readlink(dir_fd, "symlink", buf.as_mut_ptr(), buf.len()) .expect("readlink with too-small buffer should silently truncate"); diff --git a/test-programs/wasi-tests/src/bin/symlink_filestat.rs b/test-programs/wasi-tests/src/bin/symlink_filestat.rs index f588149b..cad9dcd6 100644 --- a/test-programs/wasi-tests/src/bin/symlink_filestat.rs +++ b/test-programs/wasi-tests/src/bin/symlink_filestat.rs @@ -2,20 +2,13 @@ use std::{env, process}; use wasi_tests::open_scratch_directory; unsafe fn test_path_filestat(dir_fd: wasi::Fd) { - let fdstat = wasi::fd_fdstat_get(dir_fd).expect("fd_fdstat_get"); - assert_ne!( - fdstat.fs_rights_base & wasi::RIGHTS_PATH_FILESTAT_GET, - 0, - "the scratch directory should have RIGHT_PATH_FILESTAT_GET as base right", - ); - // Create a file in the scratch directory. let file_fd = wasi::path_open( dir_fd, 0, "file", wasi::OFLAGS_CREAT, - wasi::RIGHTS_FD_READ | wasi::RIGHTS_FD_WRITE | wasi::RIGHTS_PATH_FILESTAT_GET, + wasi::RIGHTS_FD_READ | wasi::RIGHTS_FD_WRITE, 0, 0, )