Reenabled longjmp 🎉

This commit is contained in:
Syrus
2019-04-09 18:33:29 -07:00
parent b2446b567e
commit 02ed9f0e5f
13 changed files with 171 additions and 241 deletions

View File

@ -67,36 +67,36 @@ macro_rules! assert_emscripten_output {
}};
}
pub fn assert_emscripten_output(wasm_bytes: &[u8], raw_expected_str: &str) {
use wasmer_clif_backend::CraneliftCompiler;
use wasmer_emscripten::{generate_emscripten_env, stdio::StdioCapturer, EmscriptenGlobals};
// pub fn assert_emscripten_output(wasm_bytes: &[u8], raw_expected_str: &str) {
// use wasmer_clif_backend::CraneliftCompiler;
// use wasmer_emscripten::{generate_emscripten_env, stdio::StdioCapturer, EmscriptenGlobals};
let module = wasmer_runtime_core::compile_with(&wasm_bytes[..], &CraneliftCompiler::new())
.expect("WASM can't be compiled");
// let module = wasmer_runtime_core::compile_with(&wasm_bytes[..], &CraneliftCompiler::new())
// .expect("WASM can't be compiled");
let mut emscripten_globals = EmscriptenGlobals::new(&module);
let import_object = generate_emscripten_env(&mut emscripten_globals);
let mut instance = module
.instantiate(&import_object)
.map_err(|err| format!("Can't instantiate the WebAssembly module: {:?}", err))
.unwrap();
// let mut emscripten_globals = EmscriptenGlobals::new(&module);
// let import_object = generate_emscripten_env(&mut emscripten_globals);
// let mut instance = module
// .instantiate(&import_object)
// .map_err(|err| format!("Can't instantiate the WebAssembly module: {:?}", err))
// .unwrap();
let capturer = StdioCapturer::new();
// let capturer = StdioCapturer::new();
wasmer_emscripten::run_emscripten_instance(&module, &mut instance, "test", vec![])
.expect("run_emscripten_instance finishes");
// wasmer_emscripten::run_emscripten_instance(&module, &mut instance, "test", vec![])
// .expect("run_emscripten_instance finishes");
let raw_output_string = capturer.end().unwrap().0;
// let raw_output_string = capturer.end().unwrap().0;
// trim the strings to avoid cross-platform line ending and white space issues
let output = raw_output_string.trim();
let expected_output = raw_expected_str.trim();
// // trim the strings to avoid cross-platform line ending and white space issues
// let output = raw_output_string.trim();
// let expected_output = raw_expected_str.trim();
let contains_output = output.contains(expected_output);
// let contains_output = output.contains(expected_output);
assert!(
contains_output,
"Output: `{}` does not contain expected output: `{}`",
output, expected_output
);
}
// assert!(
// contains_output,
// "Output: `{}` does not contain expected output: `{}`",
// output, expected_output
// );
// }

View File

@ -1,5 +1,4 @@
#[test]
#[ignore]
fn test_test_longjmp2() {
assert_emscripten_output!(
"../../emtests/test_longjmp2.wasm",

View File

@ -1,5 +1,4 @@
#[test]
#[ignore]
fn test_test_longjmp4() {
assert_emscripten_output!(
"../../emtests/test_longjmp4.wasm",

View File

@ -1,5 +1,4 @@
#[test]
#[ignore]
fn test_test_longjmp_funcptr() {
assert_emscripten_output!(
"../../emtests/test_longjmp_funcptr.wasm",

View File

@ -1,5 +1,4 @@
#[test]
#[ignore]
fn test_test_longjmp_repeat() {
assert_emscripten_output!(
"../../emtests/test_longjmp_repeat.wasm",

View File

@ -1,5 +1,4 @@
#[test]
#[ignore]
fn test_test_longjmp_stacked() {
assert_emscripten_output!(
"../../emtests/test_longjmp_stacked.wasm",

View File

@ -1,5 +1,4 @@
#[test]
#[ignore]
fn test_test_longjmp_throw() {
assert_emscripten_output!(
"../../emtests/test_longjmp_throw.wasm",

View File

@ -1,5 +1,4 @@
#[test]
#[ignore]
fn test_test_longjmp_unwind() {
assert_emscripten_output!(
"../../emtests/test_longjmp_unwind.wasm",