Update wasi-tests to wasi 0.11. (#5488)
This updates the tests to version 0.11 of the wasi bindings. There aren't any fundamental changes here; this just syncs up with the latest version so that it's consistent with other users of the wasi APIs.
This commit is contained in:
4
crates/test-programs/wasi-tests/Cargo.lock
generated
4
crates/test-programs/wasi-tests/Cargo.lock
generated
@@ -16,9 +16,9 @@ checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasi"
|
name = "wasi"
|
||||||
version = "0.10.2+wasi-snapshot-preview1"
|
version = "0.11.0+wasi-snapshot-preview1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
|
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasi-tests"
|
name = "wasi-tests"
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ publish = false
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
libc = "0.2.65"
|
libc = "0.2.65"
|
||||||
wasi = "0.10.2"
|
wasi = "0.11.0"
|
||||||
once_cell = "1.12"
|
once_cell = "1.12"
|
||||||
|
|
||||||
# This crate is built with the wasm32-wasi target, so it's separate
|
# This crate is built with the wasm32-wasi target, so it's separate
|
||||||
|
|||||||
@@ -8,17 +8,14 @@ unsafe fn test_close_preopen(dir_fd: wasi::Fd) {
|
|||||||
|
|
||||||
// Try to close a preopened directory handle.
|
// Try to close a preopened directory handle.
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::fd_close(pre_fd)
|
wasi::fd_close(pre_fd).expect_err("closing a preopened file descriptor"),
|
||||||
.expect_err("closing a preopened file descriptor")
|
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_NOTSUP
|
wasi::ERRNO_NOTSUP
|
||||||
);
|
);
|
||||||
|
|
||||||
// Try to renumber over a preopened directory handle.
|
// Try to renumber over a preopened directory handle.
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::fd_renumber(dir_fd, pre_fd)
|
wasi::fd_renumber(dir_fd, pre_fd)
|
||||||
.expect_err("renumbering over a preopened file descriptor")
|
.expect_err("renumbering over a preopened file descriptor"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_NOTSUP
|
wasi::ERRNO_NOTSUP
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -33,8 +30,7 @@ unsafe fn test_close_preopen(dir_fd: wasi::Fd) {
|
|||||||
// Try to renumber a preopened directory handle.
|
// Try to renumber a preopened directory handle.
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::fd_renumber(pre_fd, dir_fd)
|
wasi::fd_renumber(pre_fd, dir_fd)
|
||||||
.expect_err("renumbering over a preopened file descriptor")
|
.expect_err("renumbering over a preopened file descriptor"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_NOTSUP
|
wasi::ERRNO_NOTSUP
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,7 @@ unsafe fn test_dangling_symlink(dir_fd: wasi::Fd) {
|
|||||||
// Try to open it as a directory with O_NOFOLLOW.
|
// Try to open it as a directory with O_NOFOLLOW.
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_open(dir_fd, 0, "symlink", wasi::OFLAGS_DIRECTORY, 0, 0, 0)
|
wasi::path_open(dir_fd, 0, "symlink", wasi::OFLAGS_DIRECTORY, 0, 0, 0)
|
||||||
.expect_err("opening a dangling symlink as a directory")
|
.expect_err("opening a dangling symlink as a directory"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_NOTDIR,
|
wasi::ERRNO_NOTDIR,
|
||||||
wasi::ERRNO_LOOP
|
wasi::ERRNO_LOOP
|
||||||
);
|
);
|
||||||
@@ -18,8 +17,7 @@ unsafe fn test_dangling_symlink(dir_fd: wasi::Fd) {
|
|||||||
// Try to open it as a file with O_NOFOLLOW.
|
// Try to open it as a file with O_NOFOLLOW.
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_open(dir_fd, 0, "symlink", 0, 0, 0, 0)
|
wasi::path_open(dir_fd, 0, "symlink", 0, 0, 0, 0)
|
||||||
.expect_err("opening a dangling symlink as a file")
|
.expect_err("opening a dangling symlink as a file"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_LOOP
|
wasi::ERRNO_LOOP
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -23,9 +23,7 @@ unsafe fn test_directory_seek(dir_fd: wasi::Fd) {
|
|||||||
|
|
||||||
// Attempt to seek.
|
// Attempt to seek.
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::fd_seek(fd, 0, wasi::WHENCE_CUR)
|
wasi::fd_seek(fd, 0, wasi::WHENCE_CUR).expect_err("seek on a directory"),
|
||||||
.expect_err("seek on a directory")
|
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_BADF
|
wasi::ERRNO_BADF
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
unsafe fn test_fd_filestat_get() {
|
unsafe fn test_fd_filestat_get() {
|
||||||
|
|
||||||
let stat = wasi::fd_filestat_get(libc::STDIN_FILENO as u32).expect("failed filestat 0");
|
let stat = wasi::fd_filestat_get(libc::STDIN_FILENO as u32).expect("failed filestat 0");
|
||||||
assert_eq!(stat.size, 0, "stdio size should be 0");
|
assert_eq!(stat.size, 0, "stdio size should be 0");
|
||||||
assert_eq!(stat.atim, 0, "stdio atim should be 0");
|
assert_eq!(stat.atim, 0, "stdio atim should be 0");
|
||||||
|
|||||||
@@ -57,8 +57,7 @@ unsafe fn test_file_seek_tell(dir_fd: wasi::Fd) {
|
|||||||
// Seek before byte 0 is an error though
|
// Seek before byte 0 is an error though
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::fd_seek(file_fd, -2000, wasi::WHENCE_CUR)
|
wasi::fd_seek(file_fd, -2000, wasi::WHENCE_CUR)
|
||||||
.expect_err("seeking before byte 0 should be an error")
|
.expect_err("seeking before byte 0 should be an error"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_INVAL
|
wasi::ERRNO_INVAL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,7 @@ unsafe fn test_interesting_paths(dir_fd: wasi::Fd, arg: &str) {
|
|||||||
// Now open it with an absolute path.
|
// Now open it with an absolute path.
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_open(dir_fd, 0, "/dir/nested/file", 0, 0, 0, 0)
|
wasi::path_open(dir_fd, 0, "/dir/nested/file", 0, 0, 0, 0)
|
||||||
.expect_err("opening a file with an absolute path")
|
.expect_err("opening a file with an absolute path"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_PERM
|
wasi::ERRNO_PERM
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -39,8 +38,7 @@ unsafe fn test_interesting_paths(dir_fd: wasi::Fd, arg: &str) {
|
|||||||
// Now open it with a trailing NUL.
|
// Now open it with a trailing NUL.
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_open(dir_fd, 0, "dir/nested/file\0", 0, 0, 0, 0)
|
wasi::path_open(dir_fd, 0, "dir/nested/file\0", 0, 0, 0, 0)
|
||||||
.expect_err("opening a file with a trailing NUL")
|
.expect_err("opening a file with a trailing NUL"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_INVAL,
|
wasi::ERRNO_INVAL,
|
||||||
wasi::ERRNO_ILSEQ
|
wasi::ERRNO_ILSEQ
|
||||||
);
|
);
|
||||||
@@ -48,8 +46,7 @@ unsafe fn test_interesting_paths(dir_fd: wasi::Fd, arg: &str) {
|
|||||||
// Now open it with a trailing slash.
|
// Now open it with a trailing slash.
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_open(dir_fd, 0, "dir/nested/file/", 0, 0, 0, 0)
|
wasi::path_open(dir_fd, 0, "dir/nested/file/", 0, 0, 0, 0)
|
||||||
.expect_err("opening a file with a trailing slash should fail")
|
.expect_err("opening a file with a trailing slash should fail"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_NOTDIR,
|
wasi::ERRNO_NOTDIR,
|
||||||
wasi::ERRNO_NOENT
|
wasi::ERRNO_NOENT
|
||||||
);
|
);
|
||||||
@@ -57,8 +54,7 @@ unsafe fn test_interesting_paths(dir_fd: wasi::Fd, arg: &str) {
|
|||||||
// Now open it with trailing slashes.
|
// Now open it with trailing slashes.
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_open(dir_fd, 0, "dir/nested/file///", 0, 0, 0, 0)
|
wasi::path_open(dir_fd, 0, "dir/nested/file///", 0, 0, 0, 0)
|
||||||
.expect_err("opening a file with trailing slashes should fail")
|
.expect_err("opening a file with trailing slashes should fail"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_NOTDIR,
|
wasi::ERRNO_NOTDIR,
|
||||||
wasi::ERRNO_NOENT
|
wasi::ERRNO_NOENT
|
||||||
);
|
);
|
||||||
@@ -85,8 +81,7 @@ unsafe fn test_interesting_paths(dir_fd: wasi::Fd, arg: &str) {
|
|||||||
let bad_path = format!("dir/nested/../../../{}/dir/nested/file", arg);
|
let bad_path = format!("dir/nested/../../../{}/dir/nested/file", arg);
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_open(dir_fd, 0, &bad_path, 0, 0, 0, 0)
|
wasi::path_open(dir_fd, 0, &bad_path, 0, 0, 0, 0)
|
||||||
.expect_err("opening a file with too many \"..\"s in the path should fail")
|
.expect_err("opening a file with too many \"..\"s in the path should fail"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_PERM
|
wasi::ERRNO_PERM
|
||||||
);
|
);
|
||||||
wasi::path_unlink_file(dir_fd, "dir/nested/file")
|
wasi::path_unlink_file(dir_fd, "dir/nested/file")
|
||||||
|
|||||||
@@ -11,8 +11,7 @@ unsafe fn test_nofollow_errors(dir_fd: wasi::Fd) {
|
|||||||
// Try to open it as a directory with O_NOFOLLOW again.
|
// Try to open it as a directory with O_NOFOLLOW again.
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_open(dir_fd, 0, "symlink", wasi::OFLAGS_DIRECTORY, 0, 0, 0)
|
wasi::path_open(dir_fd, 0, "symlink", wasi::OFLAGS_DIRECTORY, 0, 0, 0)
|
||||||
.expect_err("opening a directory symlink as a directory should fail")
|
.expect_err("opening a directory symlink as a directory should fail"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_LOOP,
|
wasi::ERRNO_LOOP,
|
||||||
wasi::ERRNO_NOTDIR
|
wasi::ERRNO_NOTDIR
|
||||||
);
|
);
|
||||||
@@ -20,8 +19,7 @@ unsafe fn test_nofollow_errors(dir_fd: wasi::Fd) {
|
|||||||
// Try to open it with just O_NOFOLLOW.
|
// Try to open it with just O_NOFOLLOW.
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_open(dir_fd, 0, "symlink", 0, 0, 0, 0)
|
wasi::path_open(dir_fd, 0, "symlink", 0, 0, 0, 0)
|
||||||
.expect_err("opening a symlink with O_NOFOLLOW should fail")
|
.expect_err("opening a symlink with O_NOFOLLOW should fail"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_LOOP,
|
wasi::ERRNO_LOOP,
|
||||||
wasi::ERRNO_ACCES
|
wasi::ERRNO_ACCES
|
||||||
);
|
);
|
||||||
@@ -56,8 +54,7 @@ unsafe fn test_nofollow_errors(dir_fd: wasi::Fd) {
|
|||||||
// Try to open it as a directory with O_NOFOLLOW again.
|
// Try to open it as a directory with O_NOFOLLOW again.
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_open(dir_fd, 0, "symlink", wasi::OFLAGS_DIRECTORY, 0, 0, 0)
|
wasi::path_open(dir_fd, 0, "symlink", wasi::OFLAGS_DIRECTORY, 0, 0, 0)
|
||||||
.expect_err("opening a directory symlink as a directory should fail")
|
.expect_err("opening a directory symlink as a directory should fail"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_LOOP,
|
wasi::ERRNO_LOOP,
|
||||||
wasi::ERRNO_NOTDIR
|
wasi::ERRNO_NOTDIR
|
||||||
);
|
);
|
||||||
@@ -65,8 +62,7 @@ unsafe fn test_nofollow_errors(dir_fd: wasi::Fd) {
|
|||||||
// Try to open it with just O_NOFOLLOW.
|
// Try to open it with just O_NOFOLLOW.
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_open(dir_fd, 0, "symlink", 0, 0, 0, 0)
|
wasi::path_open(dir_fd, 0, "symlink", 0, 0, 0, 0)
|
||||||
.expect_err("opening a symlink with NOFOLLOW should fail")
|
.expect_err("opening a symlink with NOFOLLOW should fail"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_LOOP
|
wasi::ERRNO_LOOP
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -81,8 +77,7 @@ unsafe fn test_nofollow_errors(dir_fd: wasi::Fd) {
|
|||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
)
|
)
|
||||||
.expect_err("opening a symlink to a file as a directory")
|
.expect_err("opening a symlink to a file as a directory"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_NOTDIR
|
wasi::ERRNO_NOTDIR
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -67,8 +67,7 @@ unsafe fn test_path_filestat(dir_fd: wasi::Fd) {
|
|||||||
0,
|
0,
|
||||||
wasi::FDFLAGS_SYNC,
|
wasi::FDFLAGS_SYNC,
|
||||||
)
|
)
|
||||||
.expect_err("FDFLAGS_SYNC not supported by platform")
|
.expect_err("FDFLAGS_SYNC not supported by platform"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_NOTSUP
|
wasi::ERRNO_NOTSUP
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -95,8 +94,7 @@ unsafe fn test_path_filestat(dir_fd: wasi::Fd) {
|
|||||||
new_mtim,
|
new_mtim,
|
||||||
wasi::FSTFLAGS_MTIM | wasi::FSTFLAGS_MTIM_NOW,
|
wasi::FSTFLAGS_MTIM | wasi::FSTFLAGS_MTIM_NOW,
|
||||||
)
|
)
|
||||||
.expect_err("MTIM and MTIM_NOW can't both be set")
|
.expect_err("MTIM and MTIM_NOW can't both be set"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_INVAL
|
wasi::ERRNO_INVAL
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -118,8 +116,7 @@ unsafe fn test_path_filestat(dir_fd: wasi::Fd) {
|
|||||||
0,
|
0,
|
||||||
wasi::FSTFLAGS_ATIM | wasi::FSTFLAGS_ATIM_NOW,
|
wasi::FSTFLAGS_ATIM | wasi::FSTFLAGS_ATIM_NOW,
|
||||||
)
|
)
|
||||||
.expect_err("ATIM & ATIM_NOW can't both be set")
|
.expect_err("ATIM & ATIM_NOW can't both be set"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_INVAL
|
wasi::ERRNO_INVAL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -101,8 +101,7 @@ unsafe fn test_path_link(dir_fd: wasi::Fd) {
|
|||||||
|
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_link(dir_fd, 0, "file", dir_fd, "link")
|
wasi::path_link(dir_fd, 0, "file", dir_fd, "link")
|
||||||
.expect_err("creating a link to existing path should fail")
|
.expect_err("creating a link to existing path should fail"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_EXIST
|
wasi::ERRNO_EXIST
|
||||||
);
|
);
|
||||||
wasi::path_unlink_file(dir_fd, "link").expect("removing a file");
|
wasi::path_unlink_file(dir_fd, "link").expect("removing a file");
|
||||||
@@ -110,8 +109,7 @@ unsafe fn test_path_link(dir_fd: wasi::Fd) {
|
|||||||
// Create a link to itself
|
// Create a link to itself
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_link(dir_fd, 0, "file", dir_fd, "file")
|
wasi::path_link(dir_fd, 0, "file", dir_fd, "file")
|
||||||
.expect_err("creating a link to itself should fail")
|
.expect_err("creating a link to itself should fail"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_EXIST
|
wasi::ERRNO_EXIST
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -120,8 +118,7 @@ unsafe fn test_path_link(dir_fd: wasi::Fd) {
|
|||||||
|
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_link(dir_fd, 0, "file", dir_fd, "link")
|
wasi::path_link(dir_fd, 0, "file", dir_fd, "link")
|
||||||
.expect_err("creating a link where target is a directory should fail")
|
.expect_err("creating a link where target is a directory should fail"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_EXIST
|
wasi::ERRNO_EXIST
|
||||||
);
|
);
|
||||||
wasi::path_remove_directory(dir_fd, "link").expect("removing a dir");
|
wasi::path_remove_directory(dir_fd, "link").expect("removing a dir");
|
||||||
@@ -132,8 +129,7 @@ unsafe fn test_path_link(dir_fd: wasi::Fd) {
|
|||||||
|
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_link(dir_fd, 0, "subdir", dir_fd, "link")
|
wasi::path_link(dir_fd, 0, "subdir", dir_fd, "link")
|
||||||
.expect_err("creating a link to a directory should fail")
|
.expect_err("creating a link to a directory should fail"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_PERM,
|
wasi::ERRNO_PERM,
|
||||||
wasi::ERRNO_ACCES
|
wasi::ERRNO_ACCES
|
||||||
);
|
);
|
||||||
@@ -143,8 +139,7 @@ unsafe fn test_path_link(dir_fd: wasi::Fd) {
|
|||||||
// Create a link to a file with trailing slash
|
// Create a link to a file with trailing slash
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_link(dir_fd, 0, "file", dir_fd, "link/")
|
wasi::path_link(dir_fd, 0, "file", dir_fd, "link/")
|
||||||
.expect_err("creating a link to a file with trailing slash should fail")
|
.expect_err("creating a link to a file with trailing slash should fail"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_NOENT
|
wasi::ERRNO_NOENT
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -171,8 +166,7 @@ unsafe fn test_path_link(dir_fd: wasi::Fd) {
|
|||||||
|
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_link(dir_fd, 0, "file", dir_fd, "symlink")
|
wasi::path_link(dir_fd, 0, "file", dir_fd, "symlink")
|
||||||
.expect_err("creating a link where target is a dangling symlink")
|
.expect_err("creating a link where target is a dangling symlink"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_EXIST
|
wasi::ERRNO_EXIST
|
||||||
);
|
);
|
||||||
wasi::path_unlink_file(dir_fd, "symlink").expect("removing a symlink");
|
wasi::path_unlink_file(dir_fd, "symlink").expect("removing a symlink");
|
||||||
@@ -189,8 +183,7 @@ unsafe fn test_path_link(dir_fd: wasi::Fd) {
|
|||||||
dir_fd,
|
dir_fd,
|
||||||
"link",
|
"link",
|
||||||
)
|
)
|
||||||
.expect_err("calling path_link with LOOKUPFLAGS_SYMLINK_FOLLOW should fail")
|
.expect_err("calling path_link with LOOKUPFLAGS_SYMLINK_FOLLOW should fail"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_INVAL
|
wasi::ERRNO_INVAL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,7 @@ unsafe fn test_path_open_create_existing(dir_fd: wasi::Fd) {
|
|||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
)
|
)
|
||||||
.expect_err("trying to create a file that already exists")
|
.expect_err("trying to create a file that already exists"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_EXIST
|
wasi::ERRNO_EXIST
|
||||||
);
|
);
|
||||||
wasi::path_unlink_file(dir_fd, "file").expect("removing a file");
|
wasi::path_unlink_file(dir_fd, "file").expect("removing a file");
|
||||||
|
|||||||
@@ -8,8 +8,7 @@ unsafe fn test_dirfd_not_dir(dir_fd: wasi::Fd) {
|
|||||||
// Now try to open a file underneath it as if it were a directory.
|
// Now try to open a file underneath it as if it were a directory.
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_open(file_fd, 0, "foo", wasi::OFLAGS_CREAT, 0, 0, 0)
|
wasi::path_open(file_fd, 0, "foo", wasi::OFLAGS_CREAT, 0, 0, 0)
|
||||||
.expect_err("non-directory base fd should get ERRNO_NOTDIR")
|
.expect_err("non-directory base fd should get ERRNO_NOTDIR"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_NOTDIR
|
wasi::ERRNO_NOTDIR
|
||||||
);
|
);
|
||||||
wasi::fd_close(file_fd).expect("closing a file");
|
wasi::fd_close(file_fd).expect("closing a file");
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ unsafe fn test_path_open_missing(dir_fd: wasi::Fd) {
|
|||||||
dir_fd, 0, "file", 0, // not passing O_CREAT here
|
dir_fd, 0, "file", 0, // not passing O_CREAT here
|
||||||
0, 0, 0,
|
0, 0, 0,
|
||||||
)
|
)
|
||||||
.expect_err("trying to open a file that doesn't exist")
|
.expect_err("trying to open a file that doesn't exist"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_NOENT
|
wasi::ERRNO_NOENT
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,9 +27,7 @@ unsafe fn try_read_file(dir_fd: wasi::Fd) {
|
|||||||
// Since we no longer have the right to fd_read, trying to read a file
|
// Since we no longer have the right to fd_read, trying to read a file
|
||||||
// should be an error.
|
// should be an error.
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::fd_read(fd, &[iovec])
|
wasi::fd_read(fd, &[iovec]).expect_err("reading bytes from file should fail"),
|
||||||
.expect_err("reading bytes from file should fail")
|
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_BADF
|
wasi::ERRNO_BADF
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ unsafe fn test_path_rename(dir_fd: wasi::Fd) {
|
|||||||
// Check that source directory doesn't exist anymore
|
// Check that source directory doesn't exist anymore
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_open(dir_fd, 0, "source", wasi::OFLAGS_DIRECTORY, 0, 0, 0)
|
wasi::path_open(dir_fd, 0, "source", wasi::OFLAGS_DIRECTORY, 0, 0, 0)
|
||||||
.expect_err("opening a nonexistent path as a directory should fail")
|
.expect_err("opening a nonexistent path as a directory should fail"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_NOENT
|
wasi::ERRNO_NOENT
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -41,8 +40,7 @@ unsafe fn test_path_rename(dir_fd: wasi::Fd) {
|
|||||||
// Check that source directory doesn't exist anymore
|
// Check that source directory doesn't exist anymore
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_open(dir_fd, 0, "source", wasi::OFLAGS_DIRECTORY, 0, 0, 0)
|
wasi::path_open(dir_fd, 0, "source", wasi::OFLAGS_DIRECTORY, 0, 0, 0)
|
||||||
.expect_err("opening a nonexistent path as a directory")
|
.expect_err("opening a nonexistent path as a directory"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_NOENT
|
wasi::ERRNO_NOENT
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -72,8 +70,7 @@ unsafe fn test_path_rename(dir_fd: wasi::Fd) {
|
|||||||
|
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_rename(dir_fd, "source", dir_fd, "target")
|
wasi::path_rename(dir_fd, "source", dir_fd, "target")
|
||||||
.expect_err("renaming directory to a nonempty directory")
|
.expect_err("renaming directory to a nonempty directory"),
|
||||||
.raw_error(),
|
|
||||||
windows => wasi::ERRNO_ACCES,
|
windows => wasi::ERRNO_ACCES,
|
||||||
unix => wasi::ERRNO_NOTEMPTY
|
unix => wasi::ERRNO_NOTEMPTY
|
||||||
);
|
);
|
||||||
@@ -85,8 +82,7 @@ unsafe fn test_path_rename(dir_fd: wasi::Fd) {
|
|||||||
// Try renaming dir to a file
|
// Try renaming dir to a file
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_rename(dir_fd, "source", dir_fd, "target/file")
|
wasi::path_rename(dir_fd, "source", dir_fd, "target/file")
|
||||||
.expect_err("renaming a directory to a file")
|
.expect_err("renaming a directory to a file"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_NOTDIR
|
wasi::ERRNO_NOTDIR
|
||||||
);
|
);
|
||||||
wasi::path_unlink_file(dir_fd, "target/file").expect("removing a file");
|
wasi::path_unlink_file(dir_fd, "target/file").expect("removing a file");
|
||||||
@@ -107,8 +103,7 @@ unsafe fn test_path_rename(dir_fd: wasi::Fd) {
|
|||||||
// Check that source file doesn't exist anymore
|
// Check that source file doesn't exist anymore
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_open(dir_fd, 0, "source", 0, 0, 0, 0)
|
wasi::path_open(dir_fd, 0, "source", 0, 0, 0, 0)
|
||||||
.expect_err("opening a nonexistent path should fail")
|
.expect_err("opening a nonexistent path should fail"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_NOENT
|
wasi::ERRNO_NOENT
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -131,9 +126,7 @@ unsafe fn test_path_rename(dir_fd: wasi::Fd) {
|
|||||||
|
|
||||||
// Check that source file doesn't exist anymore
|
// Check that source file doesn't exist anymore
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_open(dir_fd, 0, "source", 0, 0, 0, 0)
|
wasi::path_open(dir_fd, 0, "source", 0, 0, 0, 0).expect_err("opening a nonexistent path"),
|
||||||
.expect_err("opening a nonexistent path")
|
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_NOENT
|
wasi::ERRNO_NOENT
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -153,8 +146,7 @@ unsafe fn test_path_rename(dir_fd: wasi::Fd) {
|
|||||||
|
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_rename(dir_fd, "source", dir_fd, "target")
|
wasi::path_rename(dir_fd, "source", dir_fd, "target")
|
||||||
.expect_err("renaming a file to existing directory should fail")
|
.expect_err("renaming a file to existing directory should fail"),
|
||||||
.raw_error(),
|
|
||||||
windows => wasi::ERRNO_ACCES,
|
windows => wasi::ERRNO_ACCES,
|
||||||
unix => wasi::ERRNO_ISDIR
|
unix => wasi::ERRNO_ISDIR
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -11,20 +11,19 @@ unsafe fn test_path_rename_trailing_slashes(dir_fd: wasi::Fd) {
|
|||||||
|
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_rename(dir_fd, "source/", dir_fd, "target")
|
wasi::path_rename(dir_fd, "source/", dir_fd, "target")
|
||||||
.expect_err("renaming a file with a trailing slash in the source name should fail")
|
.expect_err("renaming a file with a trailing slash in the source name should fail"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_NOTDIR
|
wasi::ERRNO_NOTDIR
|
||||||
);
|
);
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_rename(dir_fd, "source", dir_fd, "target/")
|
wasi::path_rename(dir_fd, "source", dir_fd, "target/").expect_err(
|
||||||
.expect_err("renaming a file with a trailing slash in the destination name should fail")
|
"renaming a file with a trailing slash in the destination name should fail"
|
||||||
.raw_error(),
|
),
|
||||||
wasi::ERRNO_NOTDIR
|
wasi::ERRNO_NOTDIR
|
||||||
);
|
);
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_rename(dir_fd, "source/", dir_fd, "target/")
|
wasi::path_rename(dir_fd, "source/", dir_fd, "target/").expect_err(
|
||||||
.expect_err("renaming a file with a trailing slash in the source and destination names should fail")
|
"renaming a file with a trailing slash in the source and destination names should fail"
|
||||||
.raw_error(),
|
),
|
||||||
wasi::ERRNO_NOTDIR
|
wasi::ERRNO_NOTDIR
|
||||||
);
|
);
|
||||||
wasi::path_unlink_file(dir_fd, "source").expect("removing a file");
|
wasi::path_unlink_file(dir_fd, "source").expect("removing a file");
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ unsafe fn test_path_symlink_trailing_slashes(dir_fd: wasi::Fd) {
|
|||||||
// 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/")
|
||||||
.expect_err("link destination ending with a slash should fail")
|
.expect_err("link destination ending with a slash should fail"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_NOENT
|
wasi::ERRNO_NOENT
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -21,8 +20,7 @@ unsafe fn test_path_symlink_trailing_slashes(dir_fd: wasi::Fd) {
|
|||||||
wasi::path_create_directory(dir_fd, "target").expect("creating a directory");
|
wasi::path_create_directory(dir_fd, "target").expect("creating a directory");
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_symlink("source", dir_fd, "target/")
|
wasi::path_symlink("source", dir_fd, "target/")
|
||||||
.expect_err("link destination already exists")
|
.expect_err("link destination already exists"),
|
||||||
.raw_error(),
|
|
||||||
unix => wasi::ERRNO_EXIST,
|
unix => wasi::ERRNO_EXIST,
|
||||||
windows => wasi::ERRNO_NOENT
|
windows => wasi::ERRNO_NOENT
|
||||||
);
|
);
|
||||||
@@ -32,8 +30,7 @@ unsafe fn test_path_symlink_trailing_slashes(dir_fd: wasi::Fd) {
|
|||||||
wasi::path_create_directory(dir_fd, "target").expect("creating a directory");
|
wasi::path_create_directory(dir_fd, "target").expect("creating a directory");
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_symlink("source", dir_fd, "target")
|
wasi::path_symlink("source", dir_fd, "target")
|
||||||
.expect_err("link destination already exists")
|
.expect_err("link destination already exists"),
|
||||||
.raw_error(),
|
|
||||||
unix => wasi::ERRNO_EXIST,
|
unix => wasi::ERRNO_EXIST,
|
||||||
windows => wasi::ERRNO_NOENT
|
windows => wasi::ERRNO_NOENT
|
||||||
);
|
);
|
||||||
@@ -44,8 +41,7 @@ unsafe fn test_path_symlink_trailing_slashes(dir_fd: wasi::Fd) {
|
|||||||
|
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_symlink("source", dir_fd, "target/")
|
wasi::path_symlink("source", dir_fd, "target/")
|
||||||
.expect_err("link destination already exists")
|
.expect_err("link destination already exists"),
|
||||||
.raw_error(),
|
|
||||||
unix => wasi::ERRNO_NOTDIR,
|
unix => wasi::ERRNO_NOTDIR,
|
||||||
windows => wasi::ERRNO_NOENT
|
windows => wasi::ERRNO_NOENT
|
||||||
);
|
);
|
||||||
@@ -56,8 +52,7 @@ unsafe fn test_path_symlink_trailing_slashes(dir_fd: wasi::Fd) {
|
|||||||
|
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_symlink("source", dir_fd, "target")
|
wasi::path_symlink("source", dir_fd, "target")
|
||||||
.expect_err("link destination already exists")
|
.expect_err("link destination already exists"),
|
||||||
.raw_error(),
|
|
||||||
unix => wasi::ERRNO_EXIST,
|
unix => wasi::ERRNO_EXIST,
|
||||||
windows => wasi::ERRNO_NOENT
|
windows => wasi::ERRNO_NOENT
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use wasi_tests::{assert_errno, open_scratch_directory};
|
|||||||
|
|
||||||
const CLOCK_ID: wasi::Userdata = 0x0123_45678;
|
const CLOCK_ID: wasi::Userdata = 0x0123_45678;
|
||||||
|
|
||||||
unsafe fn poll_oneoff_impl(r#in: &[wasi::Subscription]) -> Result<Vec<wasi::Event>, wasi::Error> {
|
unsafe fn poll_oneoff_impl(r#in: &[wasi::Subscription]) -> Result<Vec<wasi::Event>, wasi::Errno> {
|
||||||
let mut out: Vec<wasi::Event> = Vec::new();
|
let mut out: Vec<wasi::Event> = Vec::new();
|
||||||
out.resize_with(r#in.len(), || {
|
out.resize_with(r#in.len(), || {
|
||||||
MaybeUninit::<wasi::Event>::zeroed().assume_init()
|
MaybeUninit::<wasi::Event>::zeroed().assume_init()
|
||||||
@@ -17,7 +17,7 @@ unsafe fn poll_oneoff_impl(r#in: &[wasi::Subscription]) -> Result<Vec<wasi::Even
|
|||||||
/// seen their events occur.
|
/// seen their events occur.
|
||||||
unsafe fn poll_oneoff_with_retry(
|
unsafe fn poll_oneoff_with_retry(
|
||||||
r#in: &[wasi::Subscription],
|
r#in: &[wasi::Subscription],
|
||||||
) -> Result<Vec<wasi::Event>, wasi::Error> {
|
) -> Result<Vec<wasi::Event>, wasi::Errno> {
|
||||||
let mut subscriptions = r#in.to_vec();
|
let mut subscriptions = r#in.to_vec();
|
||||||
let mut events = Vec::new();
|
let mut events = Vec::new();
|
||||||
while !subscriptions.is_empty() {
|
while !subscriptions.is_empty() {
|
||||||
@@ -47,8 +47,7 @@ unsafe fn test_empty_poll() {
|
|||||||
let mut out: Vec<wasi::Event> = Vec::new();
|
let mut out: Vec<wasi::Event> = Vec::new();
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::poll_oneoff(r#in.as_ptr(), out.as_mut_ptr(), r#in.len())
|
wasi::poll_oneoff(r#in.as_ptr(), out.as_mut_ptr(), r#in.len())
|
||||||
.expect_err("empty poll_oneoff should fail")
|
.expect_err("empty poll_oneoff should fail"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_INVAL
|
wasi::ERRNO_INVAL
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -64,7 +63,7 @@ unsafe fn test_timeout() {
|
|||||||
let r#in = [wasi::Subscription {
|
let r#in = [wasi::Subscription {
|
||||||
userdata: CLOCK_ID,
|
userdata: CLOCK_ID,
|
||||||
u: wasi::SubscriptionU {
|
u: wasi::SubscriptionU {
|
||||||
tag: wasi::EVENTTYPE_CLOCK,
|
tag: wasi::EVENTTYPE_CLOCK.raw(),
|
||||||
u: wasi::SubscriptionUU { clock },
|
u: wasi::SubscriptionUU { clock },
|
||||||
},
|
},
|
||||||
}];
|
}];
|
||||||
@@ -75,7 +74,7 @@ unsafe fn test_timeout() {
|
|||||||
let event = &out[0];
|
let event = &out[0];
|
||||||
assert_errno!(event.error, wasi::ERRNO_SUCCESS);
|
assert_errno!(event.error, wasi::ERRNO_SUCCESS);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
event.r#type,
|
event.type_,
|
||||||
wasi::EVENTTYPE_CLOCK,
|
wasi::EVENTTYPE_CLOCK,
|
||||||
"the event.type should equal clock"
|
"the event.type should equal clock"
|
||||||
);
|
);
|
||||||
@@ -102,7 +101,7 @@ unsafe fn test_sleep() {
|
|||||||
let r#in = [wasi::Subscription {
|
let r#in = [wasi::Subscription {
|
||||||
userdata: CLOCK_ID,
|
userdata: CLOCK_ID,
|
||||||
u: wasi::SubscriptionU {
|
u: wasi::SubscriptionU {
|
||||||
tag: wasi::EVENTTYPE_CLOCK,
|
tag: wasi::EVENTTYPE_CLOCK.raw(),
|
||||||
u: wasi::SubscriptionUU { clock },
|
u: wasi::SubscriptionUU { clock },
|
||||||
},
|
},
|
||||||
}];
|
}];
|
||||||
@@ -113,7 +112,7 @@ unsafe fn test_sleep() {
|
|||||||
let event = &out[0];
|
let event = &out[0];
|
||||||
assert_errno!(event.error, wasi::ERRNO_SUCCESS);
|
assert_errno!(event.error, wasi::ERRNO_SUCCESS);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
event.r#type,
|
event.type_,
|
||||||
wasi::EVENTTYPE_CLOCK,
|
wasi::EVENTTYPE_CLOCK,
|
||||||
"the event.type should equal clock"
|
"the event.type should equal clock"
|
||||||
);
|
);
|
||||||
@@ -132,7 +131,7 @@ unsafe fn test_fd_readwrite(readable_fd: wasi::Fd, writable_fd: wasi::Fd, error_
|
|||||||
wasi::Subscription {
|
wasi::Subscription {
|
||||||
userdata: 1,
|
userdata: 1,
|
||||||
u: wasi::SubscriptionU {
|
u: wasi::SubscriptionU {
|
||||||
tag: wasi::EVENTTYPE_FD_READ,
|
tag: wasi::EVENTTYPE_FD_READ.raw(),
|
||||||
u: wasi::SubscriptionUU {
|
u: wasi::SubscriptionUU {
|
||||||
fd_read: wasi::SubscriptionFdReadwrite {
|
fd_read: wasi::SubscriptionFdReadwrite {
|
||||||
file_descriptor: readable_fd,
|
file_descriptor: readable_fd,
|
||||||
@@ -143,7 +142,7 @@ unsafe fn test_fd_readwrite(readable_fd: wasi::Fd, writable_fd: wasi::Fd, error_
|
|||||||
wasi::Subscription {
|
wasi::Subscription {
|
||||||
userdata: 2,
|
userdata: 2,
|
||||||
u: wasi::SubscriptionU {
|
u: wasi::SubscriptionU {
|
||||||
tag: wasi::EVENTTYPE_FD_WRITE,
|
tag: wasi::EVENTTYPE_FD_WRITE.raw(),
|
||||||
u: wasi::SubscriptionUU {
|
u: wasi::SubscriptionUU {
|
||||||
fd_write: wasi::SubscriptionFdReadwrite {
|
fd_write: wasi::SubscriptionFdReadwrite {
|
||||||
file_descriptor: writable_fd,
|
file_descriptor: writable_fd,
|
||||||
@@ -160,7 +159,7 @@ unsafe fn test_fd_readwrite(readable_fd: wasi::Fd, writable_fd: wasi::Fd, error_
|
|||||||
);
|
);
|
||||||
assert_errno!(out[0].error, error_code);
|
assert_errno!(out[0].error, error_code);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
out[0].r#type,
|
out[0].type_,
|
||||||
wasi::EVENTTYPE_FD_READ,
|
wasi::EVENTTYPE_FD_READ,
|
||||||
"the event.type_ should equal FD_READ"
|
"the event.type_ should equal FD_READ"
|
||||||
);
|
);
|
||||||
@@ -170,7 +169,7 @@ unsafe fn test_fd_readwrite(readable_fd: wasi::Fd, writable_fd: wasi::Fd, error_
|
|||||||
);
|
);
|
||||||
assert_errno!(out[1].error, error_code);
|
assert_errno!(out[1].error, error_code);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
out[1].r#type,
|
out[1].type_,
|
||||||
wasi::EVENTTYPE_FD_WRITE,
|
wasi::EVENTTYPE_FD_WRITE,
|
||||||
"the event.type_ should equal FD_WRITE"
|
"the event.type_ should equal FD_WRITE"
|
||||||
);
|
);
|
||||||
@@ -244,7 +243,7 @@ unsafe fn test_fd_readwrite_invalid_fd() {
|
|||||||
wasi::Subscription {
|
wasi::Subscription {
|
||||||
userdata: 1,
|
userdata: 1,
|
||||||
u: wasi::SubscriptionU {
|
u: wasi::SubscriptionU {
|
||||||
tag: wasi::EVENTTYPE_FD_READ,
|
tag: wasi::EVENTTYPE_FD_READ.raw(),
|
||||||
u: wasi::SubscriptionUU {
|
u: wasi::SubscriptionUU {
|
||||||
fd_read: fd_readwrite,
|
fd_read: fd_readwrite,
|
||||||
},
|
},
|
||||||
@@ -253,7 +252,7 @@ unsafe fn test_fd_readwrite_invalid_fd() {
|
|||||||
wasi::Subscription {
|
wasi::Subscription {
|
||||||
userdata: 2,
|
userdata: 2,
|
||||||
u: wasi::SubscriptionU {
|
u: wasi::SubscriptionU {
|
||||||
tag: wasi::EVENTTYPE_FD_WRITE,
|
tag: wasi::EVENTTYPE_FD_WRITE.raw(),
|
||||||
u: wasi::SubscriptionUU {
|
u: wasi::SubscriptionUU {
|
||||||
fd_write: fd_readwrite,
|
fd_write: fd_readwrite,
|
||||||
},
|
},
|
||||||
@@ -261,7 +260,7 @@ unsafe fn test_fd_readwrite_invalid_fd() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
let err = poll_oneoff_impl(&r#in).unwrap_err();
|
let err = poll_oneoff_impl(&r#in).unwrap_err();
|
||||||
assert_eq!(err.raw_error(), wasi::ERRNO_BADF)
|
assert_eq!(err, wasi::ERRNO_BADF)
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn test_poll_oneoff(dir_fd: wasi::Fd) {
|
unsafe fn test_poll_oneoff(dir_fd: wasi::Fd) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ const TIMEOUT: u64 = 200_000_000u64; // 200 milliseconds, required to satisfy sl
|
|||||||
const CLOCK_ID: wasi::Userdata = 0x0123_45678;
|
const CLOCK_ID: wasi::Userdata = 0x0123_45678;
|
||||||
const STDIN_ID: wasi::Userdata = 0x8765_43210;
|
const STDIN_ID: wasi::Userdata = 0x8765_43210;
|
||||||
|
|
||||||
unsafe fn poll_oneoff_impl(r#in: &[wasi::Subscription]) -> Result<Vec<wasi::Event>, wasi::Error> {
|
unsafe fn poll_oneoff_impl(r#in: &[wasi::Subscription]) -> Result<Vec<wasi::Event>, wasi::Errno> {
|
||||||
let mut out: Vec<wasi::Event> = Vec::new();
|
let mut out: Vec<wasi::Event> = Vec::new();
|
||||||
out.resize_with(r#in.len(), || {
|
out.resize_with(r#in.len(), || {
|
||||||
MaybeUninit::<wasi::Event>::zeroed().assume_init()
|
MaybeUninit::<wasi::Event>::zeroed().assume_init()
|
||||||
@@ -31,14 +31,14 @@ unsafe fn test_stdin_read() {
|
|||||||
wasi::Subscription {
|
wasi::Subscription {
|
||||||
userdata: CLOCK_ID,
|
userdata: CLOCK_ID,
|
||||||
u: wasi::SubscriptionU {
|
u: wasi::SubscriptionU {
|
||||||
tag: wasi::EVENTTYPE_CLOCK,
|
tag: wasi::EVENTTYPE_CLOCK.raw(),
|
||||||
u: wasi::SubscriptionUU { clock },
|
u: wasi::SubscriptionUU { clock },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
wasi::Subscription {
|
wasi::Subscription {
|
||||||
userdata: STDIN_ID,
|
userdata: STDIN_ID,
|
||||||
u: wasi::SubscriptionU {
|
u: wasi::SubscriptionU {
|
||||||
tag: wasi::EVENTTYPE_FD_READ,
|
tag: wasi::EVENTTYPE_FD_READ.raw(),
|
||||||
u: wasi::SubscriptionUU {
|
u: wasi::SubscriptionUU {
|
||||||
fd_read: fd_readwrite,
|
fd_read: fd_readwrite,
|
||||||
},
|
},
|
||||||
@@ -50,20 +50,20 @@ unsafe fn test_stdin_read() {
|
|||||||
// Both are valid behaviors that depend on the test environment.
|
// Both are valid behaviors that depend on the test environment.
|
||||||
assert!(out.len() >= 1, "stdin read should return at least 1 event");
|
assert!(out.len() >= 1, "stdin read should return at least 1 event");
|
||||||
for event in out {
|
for event in out {
|
||||||
if event.r#type == wasi::EVENTTYPE_CLOCK {
|
if event.type_ == wasi::EVENTTYPE_CLOCK {
|
||||||
assert_errno!(event.error, wasi::ERRNO_SUCCESS);
|
assert_errno!(event.error, wasi::ERRNO_SUCCESS);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
event.userdata, CLOCK_ID,
|
event.userdata, CLOCK_ID,
|
||||||
"the event.userdata should contain CLOCK_ID",
|
"the event.userdata should contain CLOCK_ID",
|
||||||
);
|
);
|
||||||
} else if event.r#type == wasi::EVENTTYPE_FD_READ {
|
} else if event.type_ == wasi::EVENTTYPE_FD_READ {
|
||||||
assert_errno!(event.error, wasi::ERRNO_SUCCESS);
|
assert_errno!(event.error, wasi::ERRNO_SUCCESS);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
event.userdata, STDIN_ID,
|
event.userdata, STDIN_ID,
|
||||||
"the event.userdata should contain STDIN_ID",
|
"the event.userdata should contain STDIN_ID",
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
panic!("unexpected event type {}", event.r#type);
|
panic!("unexpected event type {}", event.type_.raw());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,7 +74,7 @@ fn writable_subs(h: &HashMap<u64, wasi::Fd>) -> Vec<wasi::Subscription> {
|
|||||||
.map(|(ud, fd)| wasi::Subscription {
|
.map(|(ud, fd)| wasi::Subscription {
|
||||||
userdata: *ud,
|
userdata: *ud,
|
||||||
u: wasi::SubscriptionU {
|
u: wasi::SubscriptionU {
|
||||||
tag: wasi::EVENTTYPE_FD_WRITE,
|
tag: wasi::EVENTTYPE_FD_WRITE.raw(),
|
||||||
u: wasi::SubscriptionUU {
|
u: wasi::SubscriptionUU {
|
||||||
fd_write: wasi::SubscriptionFdReadwrite {
|
fd_write: wasi::SubscriptionFdReadwrite {
|
||||||
file_descriptor: *fd,
|
file_descriptor: *fd,
|
||||||
@@ -92,7 +92,7 @@ unsafe fn test_stdout_stderr_write() {
|
|||||||
let clock = wasi::Subscription {
|
let clock = wasi::Subscription {
|
||||||
userdata: CLOCK_ID,
|
userdata: CLOCK_ID,
|
||||||
u: wasi::SubscriptionU {
|
u: wasi::SubscriptionU {
|
||||||
tag: wasi::EVENTTYPE_CLOCK,
|
tag: wasi::EVENTTYPE_CLOCK.raw(),
|
||||||
u: wasi::SubscriptionUU {
|
u: wasi::SubscriptionUU {
|
||||||
clock: wasi::SubscriptionClock {
|
clock: wasi::SubscriptionClock {
|
||||||
id: wasi::CLOCKID_MONOTONIC,
|
id: wasi::CLOCKID_MONOTONIC,
|
||||||
@@ -114,7 +114,7 @@ unsafe fn test_stdout_stderr_write() {
|
|||||||
}
|
}
|
||||||
ud => {
|
ud => {
|
||||||
if let Some(_) = writable.remove(&ud) {
|
if let Some(_) = writable.remove(&ud) {
|
||||||
assert_eq!(event.r#type, wasi::EVENTTYPE_FD_WRITE);
|
assert_eq!(event.type_, wasi::EVENTTYPE_FD_WRITE);
|
||||||
assert_errno!(event.error, wasi::ERRNO_SUCCESS);
|
assert_errno!(event.error, wasi::ERRNO_SUCCESS);
|
||||||
} else {
|
} else {
|
||||||
panic!("Unknown userdata {}, pending sub: {:?}", ud, writable)
|
panic!("Unknown userdata {}, pending sub: {:?}", ud, writable)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ unsafe fn test_readlink(dir_fd: wasi::Fd) {
|
|||||||
let err = wasi::path_readlink(dir_fd, "symlink", buf.as_mut_ptr(), buf.len())
|
let err = wasi::path_readlink(dir_fd, "symlink", buf.as_mut_ptr(), buf.len())
|
||||||
.err()
|
.err()
|
||||||
.expect("readlink with too-small buffer should fail");
|
.expect("readlink with too-small buffer should fail");
|
||||||
assert_errno!(err.raw_error(), wasi::ERRNO_RANGE);
|
assert_errno!(err, wasi::ERRNO_RANGE);
|
||||||
|
|
||||||
// Clean up.
|
// Clean up.
|
||||||
wasi::path_unlink_file(dir_fd, "target").expect("removing a file");
|
wasi::path_unlink_file(dir_fd, "target").expect("removing a file");
|
||||||
|
|||||||
@@ -21,16 +21,14 @@ unsafe fn test_remove_directory_trailing_slashes(dir_fd: wasi::Fd) {
|
|||||||
// Test that removing it with no trailing slash fails.
|
// Test that removing it with no trailing slash fails.
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_remove_directory(dir_fd, "file")
|
wasi::path_remove_directory(dir_fd, "file")
|
||||||
.expect_err("remove_directory without a trailing slash on a file should fail")
|
.expect_err("remove_directory without a trailing slash on a file should fail"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_NOTDIR
|
wasi::ERRNO_NOTDIR
|
||||||
);
|
);
|
||||||
|
|
||||||
// Test that removing it with a trailing slash fails.
|
// Test that removing it with a trailing slash fails.
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_remove_directory(dir_fd, "file/")
|
wasi::path_remove_directory(dir_fd, "file/")
|
||||||
.expect_err("remove_directory with a trailing slash on a file should fail")
|
.expect_err("remove_directory with a trailing slash on a file should fail"),
|
||||||
.raw_error(),
|
|
||||||
unix => wasi::ERRNO_NOTDIR,
|
unix => wasi::ERRNO_NOTDIR,
|
||||||
windows => wasi::ERRNO_NOENT
|
windows => wasi::ERRNO_NOENT
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -11,8 +11,7 @@ unsafe fn test_remove_nonempty_directory(dir_fd: wasi::Fd) {
|
|||||||
// Test that attempting to unlink the first directory returns the expected error code.
|
// Test that attempting to unlink the first directory returns the expected error code.
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_remove_directory(dir_fd, "dir")
|
wasi::path_remove_directory(dir_fd, "dir")
|
||||||
.expect_err("remove_directory on a directory should return ENOTEMPTY")
|
.expect_err("remove_directory on a directory should return ENOTEMPTY"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_NOTEMPTY
|
wasi::ERRNO_NOTEMPTY
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -47,9 +47,7 @@ unsafe fn test_renumber(dir_fd: wasi::Fd) {
|
|||||||
|
|
||||||
// Ensure that fd_from is closed
|
// Ensure that fd_from is closed
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::fd_close(fd_from)
|
wasi::fd_close(fd_from).expect_err("closing already closed file descriptor"),
|
||||||
.expect_err("closing already closed file descriptor")
|
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_BADF
|
wasi::ERRNO_BADF
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,7 @@ unsafe fn test_symlink_loop(dir_fd: wasi::Fd) {
|
|||||||
// Try to open it.
|
// Try to open it.
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_open(dir_fd, 0, "symlink", 0, 0, 0, 0)
|
wasi::path_open(dir_fd, 0, "symlink", 0, 0, 0, 0)
|
||||||
.expect_err("opening a self-referencing symlink")
|
.expect_err("opening a self-referencing symlink"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_LOOP
|
wasi::ERRNO_LOOP
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -66,8 +66,7 @@ unsafe fn test_truncation_rights(dir_fd: wasi::Fd) {
|
|||||||
// wasi_unstable::RIGHT_PATH_FILESTAT_SET_SIZE right.
|
// wasi_unstable::RIGHT_PATH_FILESTAT_SET_SIZE right.
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_open(dir_fd, 0, "file", wasi::OFLAGS_TRUNC, 0, 0, 0)
|
wasi::path_open(dir_fd, 0, "file", wasi::OFLAGS_TRUNC, 0, 0, 0)
|
||||||
.expect_err("truncating a file without path_filestat_set_size right")
|
.expect_err("truncating a file without path_filestat_set_size right"),
|
||||||
.raw_error(),
|
|
||||||
wasi::ERRNO_PERM
|
wasi::ERRNO_PERM
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,7 @@ unsafe fn test_unlink_file_trailing_slashes(dir_fd: wasi::Fd) {
|
|||||||
// Test that unlinking it fails.
|
// Test that unlinking it fails.
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_unlink_file(dir_fd, "dir")
|
wasi::path_unlink_file(dir_fd, "dir")
|
||||||
.expect_err("unlink_file on a directory should fail")
|
.expect_err("unlink_file on a directory should fail"),
|
||||||
.raw_error(),
|
|
||||||
macos => wasi::ERRNO_PERM,
|
macos => wasi::ERRNO_PERM,
|
||||||
unix => wasi::ERRNO_ISDIR,
|
unix => wasi::ERRNO_ISDIR,
|
||||||
windows => wasi::ERRNO_ACCES
|
windows => wasi::ERRNO_ACCES
|
||||||
@@ -18,8 +17,7 @@ unsafe fn test_unlink_file_trailing_slashes(dir_fd: wasi::Fd) {
|
|||||||
// Test that unlinking it with a trailing flash fails.
|
// Test that unlinking it with a trailing flash fails.
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_unlink_file(dir_fd, "dir/")
|
wasi::path_unlink_file(dir_fd, "dir/")
|
||||||
.expect_err("unlink_file on a directory should fail")
|
.expect_err("unlink_file on a directory should fail"),
|
||||||
.raw_error(),
|
|
||||||
macos => wasi::ERRNO_PERM,
|
macos => wasi::ERRNO_PERM,
|
||||||
unix => wasi::ERRNO_ISDIR,
|
unix => wasi::ERRNO_ISDIR,
|
||||||
windows => wasi::ERRNO_ACCES
|
windows => wasi::ERRNO_ACCES
|
||||||
@@ -34,8 +32,7 @@ unsafe fn test_unlink_file_trailing_slashes(dir_fd: wasi::Fd) {
|
|||||||
// Test that unlinking it with a trailing flash fails.
|
// Test that unlinking it with a trailing flash fails.
|
||||||
assert_errno!(
|
assert_errno!(
|
||||||
wasi::path_unlink_file(dir_fd, "file/")
|
wasi::path_unlink_file(dir_fd, "file/")
|
||||||
.expect_err("unlink_file with a trailing slash should fail")
|
.expect_err("unlink_file with a trailing slash should fail"),
|
||||||
.raw_error(),
|
|
||||||
unix => wasi::ERRNO_NOTDIR,
|
unix => wasi::ERRNO_NOTDIR,
|
||||||
windows => wasi::ERRNO_NOENT
|
windows => wasi::ERRNO_NOENT
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ pub fn open_scratch_directory(path: &str) -> Result<wasi::Fd, String> {
|
|||||||
Ok(s) => s,
|
Ok(s) => s,
|
||||||
Err(_) => break,
|
Err(_) => break,
|
||||||
};
|
};
|
||||||
if stat.tag != wasi::PREOPENTYPE_DIR {
|
if stat.tag != wasi::PREOPENTYPE_DIR.raw() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let mut dst = Vec::with_capacity(stat.u.dir.pr_name_len);
|
let mut dst = Vec::with_capacity(stat.u.dir.pr_name_len);
|
||||||
@@ -122,8 +122,8 @@ macro_rules! assert_errno {
|
|||||||
}
|
}
|
||||||
assert!( $( e == $i || )+ false,
|
assert!( $( e == $i || )+ false,
|
||||||
"expected errno {}; got {}",
|
"expected errno {}; got {}",
|
||||||
Alt(&[ $( wasi::errno_name($i) ),+ ]),
|
Alt(&[ $( $i.name() ),+ ]),
|
||||||
wasi::errno_name(e),
|
e.name()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user