Update WASI tests to use wasi crate v0.9.0 (#743)

This commit updates _all_ WASI test programs to use the latest
version of the `wasi` crate (`v0.9.0`). While at it, it also
unifies asserting error conditions across all test programs.
This commit is contained in:
Jakub Konka
2019-12-24 22:04:15 +01:00
committed by Dan Gohman
parent 907e7aac01
commit 51f3ac0c45
37 changed files with 862 additions and 1860 deletions

View File

@@ -1,29 +1,26 @@
use std::{env, process};
use wasi_old::wasi_unstable;
use wasi_tests::open_scratch_directory;
use wasi_tests::utils::{cleanup_dir, create_dir};
use wasi_tests::wasi_wrappers::wasi_path_remove_directory;
unsafe fn test_remove_nonempty_directory(dir_fd: wasi_unstable::Fd) {
unsafe fn test_remove_nonempty_directory(dir_fd: wasi::Fd) {
// Create a directory in the scratch directory.
create_dir(dir_fd, "dir");
wasi::path_create_directory(dir_fd, "dir").expect("creating a directory");
// Create a directory in the directory we just created.
create_dir(dir_fd, "dir/nested");
wasi::path_create_directory(dir_fd, "dir/nested").expect("creating a subdirectory");
// Test that attempting to unlink the first directory returns the expected error code.
assert_eq!(
wasi_path_remove_directory(dir_fd, "dir"),
Err(wasi_unstable::ENOTEMPTY),
"remove_directory on a directory should return ENOTEMPTY",
wasi::path_remove_directory(dir_fd, "dir")
.expect_err("remove_directory on a directory should return ENOTEMPTY")
.raw_error(),
wasi::ERRNO_NOTEMPTY,
"errno should be ERRNO_NOTEMPTY",
);
// Removing the directories.
assert!(
wasi_path_remove_directory(dir_fd, "dir/nested").is_ok(),
"remove_directory on a nested directory should succeed",
);
cleanup_dir(dir_fd, "dir");
wasi::path_remove_directory(dir_fd, "dir/nested")
.expect("remove_directory on a nested directory should succeed");
wasi::path_remove_directory(dir_fd, "dir").expect("removing a directory");
}
fn main() {