From 789eec382768d49c994a0d9c65a3e66d3bb2bac8 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Wed, 16 Dec 2020 15:16:14 -0800 Subject: [PATCH] dangling_fd test: open with either READ or CREAT|WRITE neither READ nor WRITE is an error --- .../wasi-tests/src/bin/dangling_fd.rs | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/crates/test-programs/wasi-tests/src/bin/dangling_fd.rs b/crates/test-programs/wasi-tests/src/bin/dangling_fd.rs index e63ecbc8d7..b2ee63c4e8 100644 --- a/crates/test-programs/wasi-tests/src/bin/dangling_fd.rs +++ b/crates/test-programs/wasi-tests/src/bin/dangling_fd.rs @@ -5,16 +5,35 @@ use wasi_tests::open_scratch_directory; 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(); + let fd = wasi::path_open( + dir_fd, + 0, + "file", + wasi::OFLAGS_CREAT, + wasi::RIGHTS_FD_WRITE, + 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"); + let file_fd = + wasi::path_open(dir_fd, 0, "file", 0, wasi::RIGHTS_FD_READ, 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(); + let fd = wasi::path_open( + dir_fd, + 0, + "file", + wasi::OFLAGS_CREAT, + wasi::RIGHTS_FD_WRITE, + 0, + 0, + ) + .unwrap(); wasi::fd_close(fd).unwrap(); // Now, repeat the same process but for a directory