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,44 +1,24 @@
use std::{env, process};
use wasi_old::wasi_unstable;
use wasi_tests::open_scratch_directory;
use wasi_tests::utils::{cleanup_file, close_fd};
use wasi_tests::wasi_wrappers::wasi_path_open;
use wasi_tests::{create_file, open_scratch_directory};
unsafe fn test_path_open_create_existing(dir_fd: wasi_unstable::Fd) {
let mut fd: wasi_unstable::Fd = wasi_unstable::Fd::max_value() - 1;
let mut status = wasi_path_open(
dir_fd,
0,
"file",
wasi_unstable::O_CREAT | wasi_unstable::O_EXCL,
0,
0,
0,
&mut fd,
);
unsafe fn test_path_open_create_existing(dir_fd: wasi::Fd) {
create_file(dir_fd, "file");
assert_eq!(
status,
wasi_unstable::raw::__WASI_ESUCCESS,
"creating a file"
wasi::path_open(
dir_fd,
0,
"file",
wasi::OFLAGS_CREAT | wasi::OFLAGS_EXCL,
0,
0,
0,
)
.expect_err("trying to create a file that already exists")
.raw_error(),
wasi::ERRNO_EXIST,
"errno should be ERRNO_EXIST"
);
close_fd(fd);
fd = wasi_unstable::Fd::max_value() - 1;
status = wasi_path_open(
dir_fd,
0,
"file",
wasi_unstable::O_CREAT | wasi_unstable::O_EXCL,
0,
0,
0,
&mut fd,
);
assert_eq!(
status,
wasi_unstable::raw::__WASI_EEXIST,
"trying to create a file that already exists"
);
cleanup_file(dir_fd, "file");
wasi::path_unlink_file(dir_fd, "file").expect("removing a file");
}
fn main() {