Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix various tests to pass CI again #785

Merged
merged 4 commits into from
Jan 9, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ rayon = "1.2.1"
wasm-webidl-bindings = "0.6"

[dev-dependencies]
wasmtime-runtime = { path = "crates/runtime" }
more-asserts = "0.2.1"
# This feature requires the wasm32-wasi target be installed. It enables
# wasm32-wasi integration tests. To enable, run
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{env, process};
use wasi_tests::open_scratch_directory;
use wasi_tests::{drop_rights, fd_get_rights, create_file};
use wasi_tests::{create_file, drop_rights, fd_get_rights};

const TEST_FILENAME: &'static str = "file";

Expand All @@ -27,8 +27,13 @@ unsafe fn try_read_file(dir_fd: wasi::Fd) {
};
// Since we no longer have the right to fd_read, trying to read a file
// should be an error.
let err = wasi::fd_read(fd, &[iovec]).expect_err("reading bytes from file should fail");
assert_eq!(err, wasi::ERRNO_NOTCAPABLE, "the errno should be ENOTCAPABLE");
assert_eq!(
wasi::fd_read(fd, &[iovec])
.expect_err("reading bytes from file should fail")
.raw_error(),
wasi::ERRNO_NOTCAPABLE,
"the errno should be ENOTCAPABLE"
);
}

unsafe fn test_read_rights(dir_fd: wasi::Fd) {
Expand Down
21 changes: 10 additions & 11 deletions tests/custom_signal_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ mod tests {

#[test]
fn test_custom_signal_handler_single_instance() {
let engine = HostRef::new(Engine::new(&Config::default()));
let store = HostRef::new(Store::new(&engine));
let engine = Engine::new(&Config::default());
let store = Store::new(&engine);
let data =
std::fs::read("tests/custom_signal_handler.wasm").expect("failed to read wasm file");
let module = HostRef::new(Module::new(&store, &data).expect("failed to create module"));
let module = Module::new(&store, &data).expect("failed to create module");
let instance = HostRef::new(
Instance::new(&store, &module, &[]).expect("failed to instantiate module"),
);
Expand Down Expand Up @@ -128,19 +128,18 @@ mod tests {
println!("calling read_out_of_bounds...");
let trap = read_out_of_bounds_func.borrow().call(&[]).unwrap_err();
assert!(trap
.borrow()
.message()
.starts_with("wasm trap: out of bounds memory access"));
}
}

#[test]
fn test_custom_signal_handler_multiple_instances() {
let engine = HostRef::new(Engine::new(&Config::default()));
let store = HostRef::new(Store::new(&engine));
let engine = Engine::new(&Config::default());
let store = Store::new(&engine);
let data =
std::fs::read("tests/custom_signal_handler.wasm").expect("failed to read wasm file");
let module = HostRef::new(Module::new(&store, &data).expect("failed to create module"));
let module = Module::new(&store, &data).expect("failed to create module");

// Set up multiple instances

Expand Down Expand Up @@ -237,13 +236,13 @@ mod tests {

#[test]
fn test_custom_signal_handler_instance_calling_another_instance() {
let engine = HostRef::new(Engine::new(&Config::default()));
let store = HostRef::new(Store::new(&engine));
let engine = Engine::new(&Config::default());
let store = Store::new(&engine);

// instance1 which defines 'read'
let data1 =
std::fs::read("tests/custom_signal_handler.wasm").expect("failed to read wasm file");
let module1 = HostRef::new(Module::new(&store, &data1).expect("failed to create module"));
let module1 = Module::new(&store, &data1).expect("failed to create module");
let instance1: HostRef<Instance> = HostRef::new(
Instance::new(&store, &module1, &[]).expect("failed to instantiate module"),
);
Expand All @@ -262,7 +261,7 @@ mod tests {
// instance2 wich calls 'instance1.read'
let data2 =
std::fs::read("tests/custom_signal_handler_2.wasm").expect("failed to read wasm file");
let module2 = HostRef::new(Module::new(&store, &data2).expect("failed to create module"));
let module2 = Module::new(&store, &data2).expect("failed to create module");
let instance2 = HostRef::new(
Instance::new(&store, &module2, &[instance1_read])
.expect("failed to instantiate module"),
Expand Down