Remove dependency on more-asserts (#4408)
* Remove dependency on `more-asserts` In my recent adventures to do a bit of gardening on our dependencies I noticed that there's a new major version for the `more-asserts` crate. Instead of updating to this though I've opted to instead remove the dependency since I don't think we heavily lean on this crate and otherwise one-off prints are probably sufficient to avoid the need for pulling in a whole crate for this. * Remove exemption for `more-asserts`
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
use more_asserts::assert_le;
|
||||
|
||||
unsafe fn test_clock_time_get() {
|
||||
// Test that clock_time_get succeeds. Even in environments where it's not
|
||||
// desirable to expose high-precision timers, it should still succeed.
|
||||
@@ -10,7 +8,7 @@ unsafe fn test_clock_time_get() {
|
||||
wasi::clock_time_get(wasi::CLOCKID_MONOTONIC, 0).expect("precision 0 should work");
|
||||
|
||||
let time = wasi::clock_time_get(wasi::CLOCKID_MONOTONIC, 0).expect("re-fetch time should work");
|
||||
assert_le!(first_time, time, "CLOCK_MONOTONIC should be monotonic");
|
||||
assert!(first_time <= time, "CLOCK_MONOTONIC should be monotonic");
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
use more_asserts::assert_gt;
|
||||
use std::{env, process};
|
||||
use wasi_tests::{assert_errno, open_scratch_directory};
|
||||
|
||||
unsafe fn test_close_preopen(dir_fd: wasi::Fd) {
|
||||
let pre_fd: wasi::Fd = (libc::STDERR_FILENO + 1) as wasi::Fd;
|
||||
|
||||
assert_gt!(dir_fd, pre_fd, "dir_fd number");
|
||||
assert!(dir_fd > pre_fd, "dir_fd number");
|
||||
|
||||
// Try to close a preopened directory handle.
|
||||
assert_errno!(
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use more_asserts::assert_gt;
|
||||
use std::{env, process};
|
||||
use wasi_tests::{open_scratch_directory, TESTCONFIG};
|
||||
|
||||
@@ -9,9 +8,8 @@ unsafe fn test_dangling_fd(dir_fd: wasi::Fd) {
|
||||
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,
|
||||
assert!(
|
||||
file_fd > libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
wasi::path_unlink_file(dir_fd, "file").expect("failed to unlink");
|
||||
@@ -22,9 +20,8 @@ unsafe fn test_dangling_fd(dir_fd: wasi::Fd) {
|
||||
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)
|
||||
.expect("failed to open dir");
|
||||
assert_gt!(
|
||||
subdir_fd,
|
||||
libc::STDERR_FILENO as wasi::Fd,
|
||||
assert!(
|
||||
subdir_fd > libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
wasi::path_remove_directory(dir_fd, "subdir").expect("failed to remove dir 2");
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use more_asserts::assert_gt;
|
||||
use std::{env, process};
|
||||
use wasi_tests::{assert_errno, open_scratch_directory};
|
||||
|
||||
@@ -17,9 +16,8 @@ unsafe fn test_directory_seek(dir_fd: wasi::Fd) {
|
||||
0,
|
||||
)
|
||||
.expect("failed to open file");
|
||||
assert_gt!(
|
||||
fd,
|
||||
libc::STDERR_FILENO as wasi::Fd,
|
||||
assert!(
|
||||
fd > libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use more_asserts::assert_gt;
|
||||
use std::{env, process};
|
||||
use wasi_tests::{open_scratch_directory, TESTCONFIG};
|
||||
|
||||
@@ -19,9 +18,8 @@ unsafe fn test_fd_advise(dir_fd: wasi::Fd) {
|
||||
0,
|
||||
)
|
||||
.expect("failed to open file");
|
||||
assert_gt!(
|
||||
file_fd,
|
||||
libc::STDERR_FILENO as wasi::Fd,
|
||||
assert!(
|
||||
file_fd > libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use more_asserts::assert_gt;
|
||||
use std::{env, process};
|
||||
use wasi_tests::open_scratch_directory;
|
||||
|
||||
@@ -18,9 +17,8 @@ unsafe fn test_fd_filestat_set(dir_fd: wasi::Fd) {
|
||||
0,
|
||||
)
|
||||
.expect("failed to create file");
|
||||
assert_gt!(
|
||||
file_fd,
|
||||
libc::STDERR_FILENO as wasi::Fd,
|
||||
assert!(
|
||||
file_fd > libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use more_asserts::assert_gt;
|
||||
use std::{env, mem, process, slice, str};
|
||||
use wasi_tests::open_scratch_directory;
|
||||
|
||||
@@ -107,9 +106,8 @@ unsafe fn test_fd_readdir(dir_fd: wasi::Fd) {
|
||||
0,
|
||||
)
|
||||
.expect("failed to create file");
|
||||
assert_gt!(
|
||||
file_fd,
|
||||
libc::STDERR_FILENO as wasi::Fd,
|
||||
assert!(
|
||||
file_fd > libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
|
||||
@@ -165,9 +163,8 @@ unsafe fn test_fd_readdir_lots(dir_fd: wasi::Fd) {
|
||||
0,
|
||||
)
|
||||
.expect("failed to create file");
|
||||
assert_gt!(
|
||||
file_fd,
|
||||
libc::STDERR_FILENO as wasi::Fd,
|
||||
assert!(
|
||||
file_fd > libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
wasi::fd_close(file_fd).expect("closing a file");
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use more_asserts::assert_gt;
|
||||
use std::{env, process};
|
||||
use wasi_tests::{open_scratch_directory, TESTCONFIG};
|
||||
|
||||
@@ -17,9 +16,8 @@ unsafe fn test_file_allocate(dir_fd: wasi::Fd) {
|
||||
0,
|
||||
)
|
||||
.expect("opening a file");
|
||||
assert_gt!(
|
||||
file_fd,
|
||||
libc::STDERR_FILENO as wasi::Fd,
|
||||
assert!(
|
||||
file_fd > libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use more_asserts::assert_gt;
|
||||
use std::{env, process};
|
||||
use std::convert::TryInto;
|
||||
use std::{env, process};
|
||||
use wasi_tests::open_scratch_directory;
|
||||
|
||||
unsafe fn test_file_pread_pwrite(dir_fd: wasi::Fd) {
|
||||
@@ -15,9 +14,8 @@ unsafe fn test_file_pread_pwrite(dir_fd: wasi::Fd) {
|
||||
0,
|
||||
)
|
||||
.expect("opening a file");
|
||||
assert_gt!(
|
||||
file_fd,
|
||||
libc::STDERR_FILENO as wasi::Fd,
|
||||
assert!(
|
||||
file_fd > libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
|
||||
@@ -50,23 +48,19 @@ unsafe fn test_file_pread_pwrite(dir_fd: wasi::Fd) {
|
||||
let mut ciovecs: Vec<wasi::Ciovec> = Vec::new();
|
||||
let mut remaining = contents.len() - offset;
|
||||
if remaining > 2 {
|
||||
ciovecs.push(
|
||||
wasi::Ciovec {
|
||||
buf: contents[offset..].as_ptr() as *const _,
|
||||
buf_len: 2,
|
||||
},
|
||||
);
|
||||
ciovecs.push(wasi::Ciovec {
|
||||
buf: contents[offset..].as_ptr() as *const _,
|
||||
buf_len: 2,
|
||||
});
|
||||
remaining -= 2;
|
||||
}
|
||||
ciovecs.push(
|
||||
wasi::Ciovec {
|
||||
buf: contents[contents.len() - remaining..].as_ptr() as *const _,
|
||||
buf_len: remaining
|
||||
},
|
||||
);
|
||||
ciovecs.push(wasi::Ciovec {
|
||||
buf: contents[contents.len() - remaining..].as_ptr() as *const _,
|
||||
buf_len: remaining,
|
||||
});
|
||||
|
||||
nwritten =
|
||||
wasi::fd_pwrite(file_fd, ciovecs.as_slice(), offset.try_into().unwrap()).expect("writing bytes at offset 0");
|
||||
nwritten = wasi::fd_pwrite(file_fd, ciovecs.as_slice(), offset.try_into().unwrap())
|
||||
.expect("writing bytes at offset 0");
|
||||
|
||||
offset += nwritten;
|
||||
if offset == contents.len() {
|
||||
@@ -91,14 +85,14 @@ unsafe fn test_file_pread_pwrite(dir_fd: wasi::Fd) {
|
||||
},
|
||||
wasi::Iovec {
|
||||
buf: buffer[2..].as_mut_ptr() as *mut _,
|
||||
buf_len: 2
|
||||
buf_len: 2,
|
||||
},
|
||||
];
|
||||
nread = wasi::fd_pread(file_fd, iovecs, offset as _).expect("reading bytes at offset 0");
|
||||
if nread == 0 {
|
||||
break;
|
||||
}
|
||||
contents[offset..offset+nread].copy_from_slice(&buffer[0..nread]);
|
||||
contents[offset..offset + nread].copy_from_slice(&buffer[0..nread]);
|
||||
offset += nread;
|
||||
}
|
||||
assert_eq!(offset, 4, "nread bytes check");
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use more_asserts::assert_gt;
|
||||
use std::{env, process};
|
||||
use wasi_tests::{assert_errno, open_scratch_directory};
|
||||
|
||||
@@ -14,9 +13,8 @@ unsafe fn test_file_seek_tell(dir_fd: wasi::Fd) {
|
||||
0,
|
||||
)
|
||||
.expect("opening a file");
|
||||
assert_gt!(
|
||||
file_fd,
|
||||
libc::STDERR_FILENO as wasi::Fd,
|
||||
assert!(
|
||||
file_fd > libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use more_asserts::assert_gt;
|
||||
use std::{env, process};
|
||||
use wasi_tests::open_scratch_directory;
|
||||
|
||||
@@ -14,18 +13,16 @@ unsafe fn test_file_unbuffered_write(dir_fd: wasi::Fd) {
|
||||
0,
|
||||
)
|
||||
.expect("create and open file for reading");
|
||||
assert_gt!(
|
||||
fd_read,
|
||||
libc::STDERR_FILENO as wasi::Fd,
|
||||
assert!(
|
||||
fd_read > libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
|
||||
// Open the same file but for writing
|
||||
let fd_write = wasi::path_open(dir_fd, 0, "file", 0, wasi::RIGHTS_FD_WRITE, 0, 0)
|
||||
.expect("opening file for writing");
|
||||
assert_gt!(
|
||||
fd_write,
|
||||
libc::STDERR_FILENO as wasi::Fd,
|
||||
assert!(
|
||||
fd_write > libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use more_asserts::assert_gt;
|
||||
use std::{env, process};
|
||||
use wasi_tests::{assert_errno, create_file, open_scratch_directory};
|
||||
|
||||
@@ -31,9 +30,8 @@ unsafe fn test_interesting_paths(dir_fd: wasi::Fd, arg: &str) {
|
||||
0,
|
||||
)
|
||||
.expect("opening a file with \"..\" in the path");
|
||||
assert_gt!(
|
||||
file_fd,
|
||||
libc::STDERR_FILENO as wasi::Fd,
|
||||
assert!(
|
||||
file_fd > libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
wasi::fd_close(file_fd).expect("closing a file");
|
||||
@@ -68,9 +66,8 @@ unsafe fn test_interesting_paths(dir_fd: wasi::Fd, arg: &str) {
|
||||
// Now open the directory with a trailing slash.
|
||||
file_fd = wasi::path_open(dir_fd, 0, "dir/nested/", 0, 0, 0, 0)
|
||||
.expect("opening a directory with a trailing slash");
|
||||
assert_gt!(
|
||||
file_fd,
|
||||
libc::STDERR_FILENO as wasi::Fd,
|
||||
assert!(
|
||||
file_fd > libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
wasi::fd_close(file_fd).expect("closing a file");
|
||||
@@ -78,9 +75,8 @@ unsafe fn test_interesting_paths(dir_fd: wasi::Fd, arg: &str) {
|
||||
// Now open the directory with trailing slashes.
|
||||
file_fd = wasi::path_open(dir_fd, 0, "dir/nested///", 0, 0, 0, 0)
|
||||
.expect("opening a directory with trailing slashes");
|
||||
assert_gt!(
|
||||
file_fd,
|
||||
libc::STDERR_FILENO as wasi::Fd,
|
||||
assert!(
|
||||
file_fd > libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
wasi::fd_close(file_fd).expect("closing a file");
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use more_asserts::assert_gt;
|
||||
use std::{env, process};
|
||||
use wasi_tests::open_scratch_directory;
|
||||
|
||||
@@ -6,9 +5,8 @@ unsafe fn test_isatty(dir_fd: wasi::Fd) {
|
||||
// Create a file in the scratch directory and test if it's a tty.
|
||||
let file_fd =
|
||||
wasi::path_open(dir_fd, 0, "file", wasi::OFLAGS_CREAT, 0, 0, 0).expect("opening a file");
|
||||
assert_gt!(
|
||||
file_fd,
|
||||
libc::STDERR_FILENO as wasi::Fd,
|
||||
assert!(
|
||||
file_fd > libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
assert_eq!(
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use more_asserts::assert_gt;
|
||||
use std::{env, process};
|
||||
use wasi_tests::{assert_errno, open_scratch_directory};
|
||||
|
||||
@@ -38,9 +37,8 @@ unsafe fn test_nofollow_errors(dir_fd: wasi::Fd) {
|
||||
0,
|
||||
)
|
||||
.expect("opening a symlink as a directory");
|
||||
assert_gt!(
|
||||
file_fd,
|
||||
libc::STDERR_FILENO as wasi::Fd,
|
||||
assert!(
|
||||
file_fd > libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
wasi::fd_close(file_fd).expect("closing a file");
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use more_asserts::assert_gt;
|
||||
use std::{env, process};
|
||||
use wasi_tests::{assert_errno, open_scratch_directory, TESTCONFIG};
|
||||
|
||||
@@ -28,9 +27,8 @@ unsafe fn test_path_filestat(dir_fd: wasi::Fd) {
|
||||
fdflags,
|
||||
)
|
||||
.expect("opening a file");
|
||||
assert_gt!(
|
||||
file_fd,
|
||||
libc::STDERR_FILENO as wasi::Fd,
|
||||
assert!(
|
||||
file_fd > libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use more_asserts::assert_gt;
|
||||
use std::{env, process};
|
||||
use wasi_tests::{assert_errno, create_file, open_scratch_directory, TESTCONFIG};
|
||||
|
||||
@@ -12,9 +11,8 @@ const TEST_RIGHTS: wasi::Rights = wasi::RIGHTS_FD_READ
|
||||
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)
|
||||
.unwrap_or_else(|_| panic!("opening '{}'", name));
|
||||
assert_gt!(
|
||||
file_fd,
|
||||
libc::STDERR_FILENO as wasi::Fd,
|
||||
assert!(
|
||||
file_fd > libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
file_fd
|
||||
@@ -23,9 +21,8 @@ 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)
|
||||
.unwrap_or_else(|_| panic!("opening a link '{}'", name));
|
||||
assert_gt!(
|
||||
file_fd,
|
||||
libc::STDERR_FILENO as wasi::Fd,
|
||||
assert!(
|
||||
file_fd > libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
file_fd
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use more_asserts::assert_gt;
|
||||
use std::{env, process};
|
||||
use wasi_tests::{assert_errno, create_file, open_scratch_directory, TESTCONFIG};
|
||||
|
||||
@@ -21,9 +20,8 @@ unsafe fn test_path_rename(dir_fd: wasi::Fd) {
|
||||
// Check that target directory exists
|
||||
let mut fd = wasi::path_open(dir_fd, 0, "target", wasi::OFLAGS_DIRECTORY, 0, 0, 0)
|
||||
.expect("opening renamed path as a directory");
|
||||
assert_gt!(
|
||||
fd,
|
||||
libc::STDERR_FILENO as wasi::Fd,
|
||||
assert!(
|
||||
fd > libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
|
||||
@@ -51,9 +49,8 @@ unsafe fn test_path_rename(dir_fd: wasi::Fd) {
|
||||
// Check that target directory exists
|
||||
fd = wasi::path_open(dir_fd, 0, "target", wasi::OFLAGS_DIRECTORY, 0, 0, 0)
|
||||
.expect("opening renamed path as a directory");
|
||||
assert_gt!(
|
||||
fd,
|
||||
libc::STDERR_FILENO as wasi::Fd,
|
||||
assert!(
|
||||
fd > libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
|
||||
@@ -117,9 +114,8 @@ unsafe fn test_path_rename(dir_fd: wasi::Fd) {
|
||||
|
||||
// Check that target file exists
|
||||
fd = wasi::path_open(dir_fd, 0, "target", 0, 0, 0, 0).expect("opening renamed path");
|
||||
assert_gt!(
|
||||
fd,
|
||||
libc::STDERR_FILENO as wasi::Fd,
|
||||
assert!(
|
||||
fd > libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
|
||||
@@ -143,9 +139,8 @@ unsafe fn test_path_rename(dir_fd: wasi::Fd) {
|
||||
|
||||
// Check that target file exists
|
||||
fd = wasi::path_open(dir_fd, 0, "target", 0, 0, 0, 0).expect("opening renamed path");
|
||||
assert_gt!(
|
||||
fd,
|
||||
libc::STDERR_FILENO as wasi::Fd,
|
||||
assert!(
|
||||
fd > libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use more_asserts::assert_gt;
|
||||
use std::{env, mem::MaybeUninit, process};
|
||||
use wasi_tests::{assert_errno, open_scratch_directory};
|
||||
|
||||
@@ -16,7 +15,9 @@ unsafe fn poll_oneoff_impl(r#in: &[wasi::Subscription]) -> Result<Vec<wasi::Even
|
||||
|
||||
/// Repeatedly call `poll_oneoff` until all the subcriptions in `in` have
|
||||
/// seen their events occur.
|
||||
unsafe fn poll_oneoff_with_retry(r#in: &[wasi::Subscription]) -> Result<Vec<wasi::Event>, wasi::Error> {
|
||||
unsafe fn poll_oneoff_with_retry(
|
||||
r#in: &[wasi::Subscription],
|
||||
) -> Result<Vec<wasi::Event>, wasi::Error> {
|
||||
let mut subscriptions = r#in.to_vec();
|
||||
let mut events = Vec::new();
|
||||
while !subscriptions.is_empty() {
|
||||
@@ -24,7 +25,11 @@ unsafe fn poll_oneoff_with_retry(r#in: &[wasi::Subscription]) -> Result<Vec<wasi
|
||||
out.resize_with(subscriptions.len(), || {
|
||||
MaybeUninit::<wasi::Event>::zeroed().assume_init()
|
||||
});
|
||||
let size = wasi::poll_oneoff(subscriptions.as_ptr(), out.as_mut_ptr(), subscriptions.len())?;
|
||||
let size = wasi::poll_oneoff(
|
||||
subscriptions.as_ptr(),
|
||||
out.as_mut_ptr(),
|
||||
subscriptions.len(),
|
||||
)?;
|
||||
out.truncate(size);
|
||||
|
||||
// Append the events from this `poll` to the result.
|
||||
@@ -204,9 +209,8 @@ unsafe fn test_fd_readwrite_valid_fd(dir_fd: wasi::Fd) {
|
||||
)
|
||||
.expect("opening a readable file");
|
||||
|
||||
assert_gt!(
|
||||
readable_fd,
|
||||
libc::STDERR_FILENO as wasi::Fd,
|
||||
assert!(
|
||||
readable_fd > libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
// Create a file in the scratch directory.
|
||||
@@ -220,9 +224,8 @@ unsafe fn test_fd_readwrite_valid_fd(dir_fd: wasi::Fd) {
|
||||
0,
|
||||
)
|
||||
.expect("opening a writable file");
|
||||
assert_gt!(
|
||||
writable_fd,
|
||||
libc::STDERR_FILENO as wasi::Fd,
|
||||
assert!(
|
||||
writable_fd > libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
use more_asserts::assert_gt;
|
||||
use std::{env, process};
|
||||
use wasi_tests::{assert_errno, open_scratch_directory};
|
||||
|
||||
unsafe fn test_renumber(dir_fd: wasi::Fd) {
|
||||
let pre_fd: wasi::Fd = (libc::STDERR_FILENO + 1) as wasi::Fd;
|
||||
|
||||
assert_gt!(dir_fd, pre_fd, "dir_fd number");
|
||||
assert!(dir_fd > pre_fd, "dir_fd number");
|
||||
|
||||
// Create a file in the scratch directory.
|
||||
let fd_from = wasi::path_open(
|
||||
@@ -18,9 +17,8 @@ unsafe fn test_renumber(dir_fd: wasi::Fd) {
|
||||
0,
|
||||
)
|
||||
.expect("opening a file");
|
||||
assert_gt!(
|
||||
fd_from,
|
||||
libc::STDERR_FILENO as wasi::Fd,
|
||||
assert!(
|
||||
fd_from > libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
|
||||
@@ -39,9 +37,8 @@ unsafe fn test_renumber(dir_fd: wasi::Fd) {
|
||||
0,
|
||||
)
|
||||
.expect("opening a file");
|
||||
assert_gt!(
|
||||
fd_to,
|
||||
libc::STDERR_FILENO as wasi::Fd,
|
||||
assert!(
|
||||
fd_to > libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use more_asserts::assert_gt;
|
||||
use std::{env, process};
|
||||
use wasi_tests::open_scratch_directory;
|
||||
|
||||
@@ -22,9 +21,8 @@ unsafe fn create_symlink_to_file(dir_fd: wasi::Fd) {
|
||||
0,
|
||||
)
|
||||
.expect("opening a symlink as a directory");
|
||||
assert_gt!(
|
||||
target_file_via_symlink,
|
||||
libc::STDERR_FILENO as wasi::Fd,
|
||||
assert!(
|
||||
target_file_via_symlink > libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
wasi::fd_close(target_file_via_symlink).expect("close the symlink file");
|
||||
@@ -52,9 +50,8 @@ unsafe fn create_symlink_to_directory(dir_fd: wasi::Fd) {
|
||||
0,
|
||||
)
|
||||
.expect("opening a symlink as a directory");
|
||||
assert_gt!(
|
||||
target_dir_via_symlink,
|
||||
libc::STDERR_FILENO as wasi::Fd,
|
||||
assert!(
|
||||
target_dir_via_symlink > libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
wasi::fd_close(target_dir_via_symlink).expect("closing a file");
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use more_asserts::assert_gt;
|
||||
use std::{env, process};
|
||||
use wasi_tests::open_scratch_directory;
|
||||
|
||||
@@ -21,9 +20,8 @@ unsafe fn test_path_filestat(dir_fd: wasi::Fd) {
|
||||
0,
|
||||
)
|
||||
.expect("opening a file");
|
||||
assert_gt!(
|
||||
file_fd,
|
||||
libc::STDERR_FILENO as wasi::Fd,
|
||||
assert!(
|
||||
file_fd > libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use more_asserts::assert_gt;
|
||||
pub mod config;
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
@@ -43,9 +42,8 @@ pub fn open_scratch_directory(path: &str) -> Result<wasi::Fd, String> {
|
||||
pub unsafe fn create_file(dir_fd: wasi::Fd, filename: &str) {
|
||||
let file_fd =
|
||||
wasi::path_open(dir_fd, 0, filename, wasi::OFLAGS_CREAT, 0, 0, 0).expect("creating a file");
|
||||
assert_gt!(
|
||||
file_fd,
|
||||
libc::STDERR_FILENO as wasi::Fd,
|
||||
assert!(
|
||||
file_fd > libc::STDERR_FILENO as wasi::Fd,
|
||||
"file descriptor range check",
|
||||
);
|
||||
wasi::fd_close(file_fd).expect("closing a file");
|
||||
|
||||
Reference in New Issue
Block a user