fd_allocate: put meat of test behind a guard
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
use more_asserts::assert_gt;
|
use more_asserts::assert_gt;
|
||||||
use std::{env, process};
|
use std::{env, process};
|
||||||
use wasi_tests::open_scratch_directory;
|
use wasi_tests::{open_scratch_directory, TESTCONFIG};
|
||||||
|
|
||||||
unsafe fn test_file_allocate(dir_fd: wasi::Fd) {
|
unsafe fn test_file_allocate(dir_fd: wasi::Fd) {
|
||||||
// Create a file in the scratch directory.
|
// Create a file in the scratch directory.
|
||||||
@@ -27,6 +27,7 @@ unsafe fn test_file_allocate(dir_fd: wasi::Fd) {
|
|||||||
let mut stat = wasi::fd_filestat_get(file_fd).expect("reading file stats");
|
let mut stat = wasi::fd_filestat_get(file_fd).expect("reading file stats");
|
||||||
assert_eq!(stat.size, 0, "file size should be 0");
|
assert_eq!(stat.size, 0, "file size should be 0");
|
||||||
|
|
||||||
|
if TESTCONFIG.support_fd_allocate() {
|
||||||
// Allocate some size
|
// Allocate some size
|
||||||
wasi::fd_allocate(file_fd, 0, 100).expect("allocating size");
|
wasi::fd_allocate(file_fd, 0, 100).expect("allocating size");
|
||||||
stat = wasi::fd_filestat_get(file_fd).expect("reading file stats");
|
stat = wasi::fd_filestat_get(file_fd).expect("reading file stats");
|
||||||
@@ -41,7 +42,7 @@ unsafe fn test_file_allocate(dir_fd: wasi::Fd) {
|
|||||||
wasi::fd_allocate(file_fd, 90, 20).expect("allocating size larger than current size");
|
wasi::fd_allocate(file_fd, 90, 20).expect("allocating size larger than current size");
|
||||||
stat = wasi::fd_filestat_get(file_fd).expect("reading file stats");
|
stat = wasi::fd_filestat_get(file_fd).expect("reading file stats");
|
||||||
assert_eq!(stat.size, 110, "file size should increase from 100 to 110");
|
assert_eq!(stat.size, 110, "file size should increase from 100 to 110");
|
||||||
|
}
|
||||||
wasi::fd_close(file_fd).expect("closing a file");
|
wasi::fd_close(file_fd).expect("closing a file");
|
||||||
wasi::path_unlink_file(dir_fd, "file").expect("removing a file");
|
wasi::path_unlink_file(dir_fd, "file").expect("removing a file");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user