Skip to content

Commit

Permalink
Merge pull request #3758 from wasmerio/more-tests
Browse files Browse the repository at this point in the history
More and better snapshot tests
  • Loading branch information
john-sharratt authored Apr 9, 2023
2 parents f5ed2be + f454334 commit 46568be
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 2 deletions.
12 changes: 12 additions & 0 deletions tests/integration/cli/tests/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ impl TestBuilder {
}

pub fn run_wasm(self, code: &[u8]) -> TestSnapshot {
#[allow(unused_mut)]
let mut snapshot = build_snapshot(self.spec, code);
// TODO: figure out why snapshot exit code is 79 on macos
#[cfg(target_os = "macos")]
Expand Down Expand Up @@ -734,6 +735,17 @@ fn test_snapshot_multithreading() {
assert_json_snapshot!(snapshot);
}

// multithreading with shared memory access
#[cfg_attr(any(target_env = "musl", target_os = "windows"), ignore)]
#[test]
fn test_snapshot_threaded_memory() {
let snapshot = TestBuilder::new()
.with_name(function!())
.debug_output(true)
.run_wasm(include_bytes!("./wasm/threaded-memory.wasm"));
assert_json_snapshot!(snapshot);
}

// full multi-threading with shared memory and shared compiled modules
#[cfg_attr(any(target_env = "musl", target_os = "windows"), ignore)]
#[test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: tests/integration/cli/tests/snapshot.rs
assertion_line: 466
assertion_line: 500
expression: snapshot
---
{
Expand All @@ -17,7 +17,7 @@ expression: snapshot
"Success": {
"stdout": "EFD_NONBLOCK:4\nsuccess write to efd, write 8 bytes(4)\nsuccess read from efd, read 8 bytes(4)\nsuccess write to efd, write 8 bytes(4)\nsuccess read from efd, read 8 bytes(4)\nsuccess write to efd, write 8 bytes(4)\nsuccess read from efd, read 8 bytes(4)\nsuccess write to efd, write 8 bytes(4)\nsuccess read from efd, read 8 bytes(4)\nsuccess write to efd, write 8 bytes(4)\nsuccess read from efd, read 8 bytes(4)\n",
"stderr": "",
"exit_code": 8
"exit_code": 0
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
source: tests/integration/cli/tests/snapshot.rs
assertion_line: 745
expression: snapshot
---
{
"spec": {
"name": "snapshot::test_snapshot_threaded_memory",
"use_packages": [],
"include_webcs": [],
"cli_args": [],
"debug_output": true,
"enable_threads": true,
"enable_network": false
},
"result": {
"Success": {
"stdout": "thread 1 started\nincrementing counter (val=0)\nthread 2 started\nincrementing counter (val=1)\nthread 3 started\nincrementing counter (val=2)\nthread 4 started\nincrementing counter (val=3)\nthread 5 started\nincrementing counter (val=4)\nthread 6 started\nincrementing counter (val=5)\nthread 7 started\nincrementing counter (val=6)\nthread 8 started\nincrementing counter (val=7)\nthread 9 started\nincrementing counter (val=8)\nwaiting for threads\nthread 1 finished\nthread 2 finished\nthread 3 finished\nthread 4 finished\nthread 5 finished\nthread 6 finished\nthread 7 finished\nthread 8 finished\nthread 9 finished\nall done\n",
"stderr": "",
"exit_code": 0
}
}
}
Binary file modified tests/integration/cli/tests/wasm/example-epoll.wasm
Binary file not shown.
Binary file not shown.

0 comments on commit 46568be

Please sign in to comment.