diff --git a/spectests/README.md b/spectests/README.md index 8fd18699c..97bf4ca80 100644 --- a/spectests/README.md +++ b/spectests/README.md @@ -94,7 +94,7 @@ This spectests are currently covered: - switch.wast ✅ - tee_local.wast ✅ - token.wast -- traps.wast +- traps.wast ✅ - type.wast ✅ - typecheck.wast ✅ - unreachable.wast diff --git a/spectests/traps.wast b/spectests/traps.wast new file mode 100644 index 000000000..a9401408e --- /dev/null +++ b/spectests/traps.wast @@ -0,0 +1,91 @@ +;; Test that traps are preserved even in instructions which might otherwise +;; be dead-code-eliminated. These functions all perform an operation and +;; discard its return value. + +(module + (func (export "no_dce.i32.div_s") (param $x i32) (param $y i32) + (drop (i32.div_s (get_local $x) (get_local $y)))) + (func (export "no_dce.i32.div_u") (param $x i32) (param $y i32) + (drop (i32.div_u (get_local $x) (get_local $y)))) + (func (export "no_dce.i64.div_s") (param $x i64) (param $y i64) + (drop (i64.div_s (get_local $x) (get_local $y)))) + (func (export "no_dce.i64.div_u") (param $x i64) (param $y i64) + (drop (i64.div_u (get_local $x) (get_local $y)))) +) + +(assert_trap (invoke "no_dce.i32.div_s" (i32.const 1) (i32.const 0)) "integer divide by zero") +(assert_trap (invoke "no_dce.i32.div_u" (i32.const 1) (i32.const 0)) "integer divide by zero") +(assert_trap (invoke "no_dce.i64.div_s" (i64.const 1) (i64.const 0)) "integer divide by zero") +(assert_trap (invoke "no_dce.i64.div_u" (i64.const 1) (i64.const 0)) "integer divide by zero") +(assert_trap (invoke "no_dce.i32.div_s" (i32.const 0x80000000) (i32.const -1)) "integer overflow") +(assert_trap (invoke "no_dce.i64.div_s" (i64.const 0x8000000000000000) (i64.const -1)) "integer overflow") + +(module + (func (export "no_dce.i32.rem_s") (param $x i32) (param $y i32) + (drop (i32.rem_s (get_local $x) (get_local $y)))) + (func (export "no_dce.i32.rem_u") (param $x i32) (param $y i32) + (drop (i32.rem_u (get_local $x) (get_local $y)))) + (func (export "no_dce.i64.rem_s") (param $x i64) (param $y i64) + (drop (i64.rem_s (get_local $x) (get_local $y)))) + (func (export "no_dce.i64.rem_u") (param $x i64) (param $y i64) + (drop (i64.rem_u (get_local $x) (get_local $y)))) +) + +(assert_trap (invoke "no_dce.i32.rem_s" (i32.const 1) (i32.const 0)) "integer divide by zero") +(assert_trap (invoke "no_dce.i32.rem_u" (i32.const 1) (i32.const 0)) "integer divide by zero") +(assert_trap (invoke "no_dce.i64.rem_s" (i64.const 1) (i64.const 0)) "integer divide by zero") +(assert_trap (invoke "no_dce.i64.rem_u" (i64.const 1) (i64.const 0)) "integer divide by zero") + +(module + (func (export "no_dce.i32.trunc_s_f32") (param $x f32) (drop (i32.trunc_s/f32 (get_local $x)))) + (func (export "no_dce.i32.trunc_u_f32") (param $x f32) (drop (i32.trunc_u/f32 (get_local $x)))) + (func (export "no_dce.i32.trunc_s_f64") (param $x f64) (drop (i32.trunc_s/f64 (get_local $x)))) + (func (export "no_dce.i32.trunc_u_f64") (param $x f64) (drop (i32.trunc_u/f64 (get_local $x)))) + (func (export "no_dce.i64.trunc_s_f32") (param $x f32) (drop (i64.trunc_s/f32 (get_local $x)))) + (func (export "no_dce.i64.trunc_u_f32") (param $x f32) (drop (i64.trunc_u/f32 (get_local $x)))) + (func (export "no_dce.i64.trunc_s_f64") (param $x f64) (drop (i64.trunc_s/f64 (get_local $x)))) + (func (export "no_dce.i64.trunc_u_f64") (param $x f64) (drop (i64.trunc_u/f64 (get_local $x)))) +) + +(assert_trap (invoke "no_dce.i32.trunc_s_f32" (f32.const nan)) "invalid conversion to integer") +(assert_trap (invoke "no_dce.i32.trunc_u_f32" (f32.const nan)) "invalid conversion to integer") +(assert_trap (invoke "no_dce.i32.trunc_s_f64" (f64.const nan)) "invalid conversion to integer") +(assert_trap (invoke "no_dce.i32.trunc_u_f64" (f64.const nan)) "invalid conversion to integer") +(assert_trap (invoke "no_dce.i64.trunc_s_f32" (f32.const nan)) "invalid conversion to integer") +(assert_trap (invoke "no_dce.i64.trunc_u_f32" (f32.const nan)) "invalid conversion to integer") +(assert_trap (invoke "no_dce.i64.trunc_s_f64" (f64.const nan)) "invalid conversion to integer") +(assert_trap (invoke "no_dce.i64.trunc_u_f64" (f64.const nan)) "invalid conversion to integer") + +(module + (memory 1) + + (func (export "no_dce.i32.load") (param $i i32) (drop (i32.load (get_local $i)))) + (func (export "no_dce.i32.load16_s") (param $i i32) (drop (i32.load16_s (get_local $i)))) + (func (export "no_dce.i32.load16_u") (param $i i32) (drop (i32.load16_u (get_local $i)))) + (func (export "no_dce.i32.load8_s") (param $i i32) (drop (i32.load8_s (get_local $i)))) + (func (export "no_dce.i32.load8_u") (param $i i32) (drop (i32.load8_u (get_local $i)))) + (func (export "no_dce.i64.load") (param $i i32) (drop (i64.load (get_local $i)))) + (func (export "no_dce.i64.load32_s") (param $i i32) (drop (i64.load32_s (get_local $i)))) + (func (export "no_dce.i64.load32_u") (param $i i32) (drop (i64.load32_u (get_local $i)))) + (func (export "no_dce.i64.load16_s") (param $i i32) (drop (i64.load16_s (get_local $i)))) + (func (export "no_dce.i64.load16_u") (param $i i32) (drop (i64.load16_u (get_local $i)))) + (func (export "no_dce.i64.load8_s") (param $i i32) (drop (i64.load8_s (get_local $i)))) + (func (export "no_dce.i64.load8_u") (param $i i32) (drop (i64.load8_u (get_local $i)))) + (func (export "no_dce.f32.load") (param $i i32) (drop (f32.load (get_local $i)))) + (func (export "no_dce.f64.load") (param $i i32) (drop (f64.load (get_local $i)))) +) + +(assert_trap (invoke "no_dce.i32.load" (i32.const 65536)) "out of bounds memory access") +(assert_trap (invoke "no_dce.i32.load16_s" (i32.const 65536)) "out of bounds memory access") +(assert_trap (invoke "no_dce.i32.load16_u" (i32.const 65536)) "out of bounds memory access") +(assert_trap (invoke "no_dce.i32.load8_s" (i32.const 65536)) "out of bounds memory access") +(assert_trap (invoke "no_dce.i32.load8_u" (i32.const 65536)) "out of bounds memory access") +(assert_trap (invoke "no_dce.i64.load" (i32.const 65536)) "out of bounds memory access") +(assert_trap (invoke "no_dce.i64.load32_s" (i32.const 65536)) "out of bounds memory access") +(assert_trap (invoke "no_dce.i64.load32_u" (i32.const 65536)) "out of bounds memory access") +(assert_trap (invoke "no_dce.i64.load16_s" (i32.const 65536)) "out of bounds memory access") +(assert_trap (invoke "no_dce.i64.load16_u" (i32.const 65536)) "out of bounds memory access") +(assert_trap (invoke "no_dce.i64.load8_s" (i32.const 65536)) "out of bounds memory access") +(assert_trap (invoke "no_dce.i64.load8_u" (i32.const 65536)) "out of bounds memory access") +(assert_trap (invoke "no_dce.f32.load" (i32.const 65536)) "out of bounds memory access") +(assert_trap (invoke "no_dce.f64.load" (i32.const 65536)) "out of bounds memory access") diff --git a/src/build_spectests.rs b/src/build_spectests.rs index cb6b837cc..aaa9a23fc 100644 --- a/src/build_spectests.rs +++ b/src/build_spectests.rs @@ -67,6 +67,7 @@ const TESTS: [&str; 55] = [ "spectests/store_retval.wast", "spectests/switch.wast", "spectests/tee_local.wast", + "spectests/traps.wast", "spectests/typecheck.wast", "spectests/types.wast", ]; diff --git a/src/spectests/mod.rs b/src/spectests/mod.rs index e68af8f55..463226ee7 100644 --- a/src/spectests/mod.rs +++ b/src/spectests/mod.rs @@ -68,5 +68,6 @@ mod start; mod store_retval; mod switch; mod tee_local; +mod traps; mod typecheck; mod types; diff --git a/src/spectests/traps.rs b/src/spectests/traps.rs new file mode 100644 index 000000000..740a413bd --- /dev/null +++ b/src/spectests/traps.rs @@ -0,0 +1,930 @@ +// Rust test file autogenerated with cargo build (src/build_spectests.rs). +// Please do NOT modify it by hand, as it will be reseted on next build. +// Test based on spectests/traps.wast +#![allow( + warnings, + dead_code +)] +use std::panic; +use wabt::wat2wasm; + +use crate::webassembly::{instantiate, compile, ImportObject, ResultObject, Instance, Export}; +use super::_common::{ + spectest_importobject, + NaNCheck, +}; + + +// Line 5 +fn create_module_1() -> ResultObject { + let module_str = "(module + (type (;0;) (func (param i32 i32))) + (type (;1;) (func (param i64 i64))) + (func (;0;) (type 0) (param i32 i32) + get_local 0 + get_local 1 + i32.div_s + drop) + (func (;1;) (type 0) (param i32 i32) + get_local 0 + get_local 1 + i32.div_u + drop) + (func (;2;) (type 1) (param i64 i64) + get_local 0 + get_local 1 + i64.div_s + drop) + (func (;3;) (type 1) (param i64 i64) + get_local 0 + get_local 1 + i64.div_u + drop) + (export \"no_dce.i32.div_s\" (func 0)) + (export \"no_dce.i32.div_u\" (func 1)) + (export \"no_dce.i64.div_s\" (func 2)) + (export \"no_dce.i64.div_u\" (func 3))) + "; + let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); + instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") +} + +fn start_module_1(result_object: &ResultObject) { + result_object.instance.start(); +} + +// Line 16 +fn c1_l16_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c1_l16_action_invoke"); + let func_index = match result_object.module.info.exports.get("no_dce.i32.div_s") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, i32, &Instance) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(1 as i32, 0 as i32, &result_object.instance); + +} + +#[test] +fn c1_l16_assert_trap() { + let result_object = create_module_1(); + let result = panic::catch_unwind(|| { + c1_l16_action_invoke(&result_object); + }); + assert!(result.is_err()); +} + +// Line 17 +fn c2_l17_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c2_l17_action_invoke"); + let func_index = match result_object.module.info.exports.get("no_dce.i32.div_u") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, i32, &Instance) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(1 as i32, 0 as i32, &result_object.instance); + +} + +#[test] +fn c2_l17_assert_trap() { + let result_object = create_module_1(); + let result = panic::catch_unwind(|| { + c2_l17_action_invoke(&result_object); + }); + assert!(result.is_err()); +} + +// Line 18 +fn c3_l18_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c3_l18_action_invoke"); + let func_index = match result_object.module.info.exports.get("no_dce.i64.div_s") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, i64, &Instance) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(1 as i64, 0 as i64, &result_object.instance); + +} + +#[test] +fn c3_l18_assert_trap() { + let result_object = create_module_1(); + let result = panic::catch_unwind(|| { + c3_l18_action_invoke(&result_object); + }); + assert!(result.is_err()); +} + +// Line 19 +fn c4_l19_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c4_l19_action_invoke"); + let func_index = match result_object.module.info.exports.get("no_dce.i64.div_u") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, i64, &Instance) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(1 as i64, 0 as i64, &result_object.instance); + +} + +#[test] +fn c4_l19_assert_trap() { + let result_object = create_module_1(); + let result = panic::catch_unwind(|| { + c4_l19_action_invoke(&result_object); + }); + assert!(result.is_err()); +} + +// Line 20 +fn c5_l20_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c5_l20_action_invoke"); + let func_index = match result_object.module.info.exports.get("no_dce.i32.div_s") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, i32, &Instance) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-2147483648 as i32, -1 as i32, &result_object.instance); + +} + +#[test] +fn c5_l20_assert_trap() { + let result_object = create_module_1(); + let result = panic::catch_unwind(|| { + c5_l20_action_invoke(&result_object); + }); + assert!(result.is_err()); +} + +// Line 21 +fn c6_l21_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c6_l21_action_invoke"); + let func_index = match result_object.module.info.exports.get("no_dce.i64.div_s") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, i64, &Instance) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(-9223372036854775808 as i64, -1 as i64, &result_object.instance); + +} + +#[test] +fn c6_l21_assert_trap() { + let result_object = create_module_1(); + let result = panic::catch_unwind(|| { + c6_l21_action_invoke(&result_object); + }); + assert!(result.is_err()); +} + +// Line 23 + +#[test] +fn test_module_1() { + let result_object = create_module_1(); + // We group the calls together + start_module_1(&result_object); +} +fn create_module_2() -> ResultObject { + let module_str = "(module + (type (;0;) (func (param i32 i32))) + (type (;1;) (func (param i64 i64))) + (func (;0;) (type 0) (param i32 i32) + get_local 0 + get_local 1 + i32.rem_s + drop) + (func (;1;) (type 0) (param i32 i32) + get_local 0 + get_local 1 + i32.rem_u + drop) + (func (;2;) (type 1) (param i64 i64) + get_local 0 + get_local 1 + i64.rem_s + drop) + (func (;3;) (type 1) (param i64 i64) + get_local 0 + get_local 1 + i64.rem_u + drop) + (export \"no_dce.i32.rem_s\" (func 0)) + (export \"no_dce.i32.rem_u\" (func 1)) + (export \"no_dce.i64.rem_s\" (func 2)) + (export \"no_dce.i64.rem_u\" (func 3))) + "; + let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); + instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") +} + +fn start_module_2(result_object: &ResultObject) { + result_object.instance.start(); +} + +// Line 34 +fn c8_l34_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c8_l34_action_invoke"); + let func_index = match result_object.module.info.exports.get("no_dce.i32.rem_s") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, i32, &Instance) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(1 as i32, 0 as i32, &result_object.instance); + +} + +#[test] +fn c8_l34_assert_trap() { + let result_object = create_module_2(); + let result = panic::catch_unwind(|| { + c8_l34_action_invoke(&result_object); + }); + assert!(result.is_err()); +} + +// Line 35 +fn c9_l35_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c9_l35_action_invoke"); + let func_index = match result_object.module.info.exports.get("no_dce.i32.rem_u") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, i32, &Instance) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(1 as i32, 0 as i32, &result_object.instance); + +} + +#[test] +fn c9_l35_assert_trap() { + let result_object = create_module_2(); + let result = panic::catch_unwind(|| { + c9_l35_action_invoke(&result_object); + }); + assert!(result.is_err()); +} + +// Line 36 +fn c10_l36_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c10_l36_action_invoke"); + let func_index = match result_object.module.info.exports.get("no_dce.i64.rem_s") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, i64, &Instance) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(1 as i64, 0 as i64, &result_object.instance); + +} + +#[test] +fn c10_l36_assert_trap() { + let result_object = create_module_2(); + let result = panic::catch_unwind(|| { + c10_l36_action_invoke(&result_object); + }); + assert!(result.is_err()); +} + +// Line 37 +fn c11_l37_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c11_l37_action_invoke"); + let func_index = match result_object.module.info.exports.get("no_dce.i64.rem_u") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i64, i64, &Instance) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(1 as i64, 0 as i64, &result_object.instance); + +} + +#[test] +fn c11_l37_assert_trap() { + let result_object = create_module_2(); + let result = panic::catch_unwind(|| { + c11_l37_action_invoke(&result_object); + }); + assert!(result.is_err()); +} + +// Line 39 + +#[test] +fn test_module_2() { + let result_object = create_module_2(); + // We group the calls together + start_module_2(&result_object); +} +fn create_module_3() -> ResultObject { + let module_str = "(module + (type (;0;) (func (param f32))) + (type (;1;) (func (param f64))) + (func (;0;) (type 0) (param f32) + get_local 0 + i32.trunc_s/f32 + drop) + (func (;1;) (type 0) (param f32) + get_local 0 + i32.trunc_u/f32 + drop) + (func (;2;) (type 1) (param f64) + get_local 0 + i32.trunc_s/f64 + drop) + (func (;3;) (type 1) (param f64) + get_local 0 + i32.trunc_u/f64 + drop) + (func (;4;) (type 0) (param f32) + get_local 0 + i64.trunc_s/f32 + drop) + (func (;5;) (type 0) (param f32) + get_local 0 + i64.trunc_u/f32 + drop) + (func (;6;) (type 1) (param f64) + get_local 0 + i64.trunc_s/f64 + drop) + (func (;7;) (type 1) (param f64) + get_local 0 + i64.trunc_u/f64 + drop) + (export \"no_dce.i32.trunc_s_f32\" (func 0)) + (export \"no_dce.i32.trunc_u_f32\" (func 1)) + (export \"no_dce.i32.trunc_s_f64\" (func 2)) + (export \"no_dce.i32.trunc_u_f64\" (func 3)) + (export \"no_dce.i64.trunc_s_f32\" (func 4)) + (export \"no_dce.i64.trunc_u_f32\" (func 5)) + (export \"no_dce.i64.trunc_s_f64\" (func 6)) + (export \"no_dce.i64.trunc_u_f64\" (func 7))) + "; + let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); + instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") +} + +fn start_module_3(result_object: &ResultObject) { + result_object.instance.start(); +} + +// Line 50 +fn c13_l50_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c13_l50_action_invoke"); + let func_index = match result_object.module.info.exports.get("no_dce.i32.trunc_s_f32") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f32, &Instance) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(f32::from_bits(2143289344), &result_object.instance); + +} + +#[test] +fn c13_l50_assert_trap() { + let result_object = create_module_3(); + let result = panic::catch_unwind(|| { + c13_l50_action_invoke(&result_object); + }); + assert!(result.is_err()); +} + +// Line 51 +fn c14_l51_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c14_l51_action_invoke"); + let func_index = match result_object.module.info.exports.get("no_dce.i32.trunc_u_f32") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f32, &Instance) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(f32::from_bits(2143289344), &result_object.instance); + +} + +#[test] +fn c14_l51_assert_trap() { + let result_object = create_module_3(); + let result = panic::catch_unwind(|| { + c14_l51_action_invoke(&result_object); + }); + assert!(result.is_err()); +} + +// Line 52 +fn c15_l52_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c15_l52_action_invoke"); + let func_index = match result_object.module.info.exports.get("no_dce.i32.trunc_s_f64") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f64, &Instance) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(f64::from_bits(9221120237041090560), &result_object.instance); + +} + +#[test] +fn c15_l52_assert_trap() { + let result_object = create_module_3(); + let result = panic::catch_unwind(|| { + c15_l52_action_invoke(&result_object); + }); + assert!(result.is_err()); +} + +// Line 53 +fn c16_l53_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c16_l53_action_invoke"); + let func_index = match result_object.module.info.exports.get("no_dce.i32.trunc_u_f64") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f64, &Instance) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(f64::from_bits(9221120237041090560), &result_object.instance); + +} + +#[test] +fn c16_l53_assert_trap() { + let result_object = create_module_3(); + let result = panic::catch_unwind(|| { + c16_l53_action_invoke(&result_object); + }); + assert!(result.is_err()); +} + +// Line 54 +fn c17_l54_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c17_l54_action_invoke"); + let func_index = match result_object.module.info.exports.get("no_dce.i64.trunc_s_f32") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f32, &Instance) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(f32::from_bits(2143289344), &result_object.instance); + +} + +#[test] +fn c17_l54_assert_trap() { + let result_object = create_module_3(); + let result = panic::catch_unwind(|| { + c17_l54_action_invoke(&result_object); + }); + assert!(result.is_err()); +} + +// Line 55 +fn c18_l55_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c18_l55_action_invoke"); + let func_index = match result_object.module.info.exports.get("no_dce.i64.trunc_u_f32") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f32, &Instance) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(f32::from_bits(2143289344), &result_object.instance); + +} + +#[test] +fn c18_l55_assert_trap() { + let result_object = create_module_3(); + let result = panic::catch_unwind(|| { + c18_l55_action_invoke(&result_object); + }); + assert!(result.is_err()); +} + +// Line 56 +fn c19_l56_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c19_l56_action_invoke"); + let func_index = match result_object.module.info.exports.get("no_dce.i64.trunc_s_f64") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f64, &Instance) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(f64::from_bits(9221120237041090560), &result_object.instance); + +} + +#[test] +fn c19_l56_assert_trap() { + let result_object = create_module_3(); + let result = panic::catch_unwind(|| { + c19_l56_action_invoke(&result_object); + }); + assert!(result.is_err()); +} + +// Line 57 +fn c20_l57_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c20_l57_action_invoke"); + let func_index = match result_object.module.info.exports.get("no_dce.i64.trunc_u_f64") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(f64, &Instance) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(f64::from_bits(9221120237041090560), &result_object.instance); + +} + +#[test] +fn c20_l57_assert_trap() { + let result_object = create_module_3(); + let result = panic::catch_unwind(|| { + c20_l57_action_invoke(&result_object); + }); + assert!(result.is_err()); +} + +// Line 59 + +#[test] +fn test_module_3() { + let result_object = create_module_3(); + // We group the calls together + start_module_3(&result_object); +} +fn create_module_4() -> ResultObject { + let module_str = "(module + (type (;0;) (func (param i32))) + (func (;0;) (type 0) (param i32) + get_local 0 + i32.load + drop) + (func (;1;) (type 0) (param i32) + get_local 0 + i32.load16_s + drop) + (func (;2;) (type 0) (param i32) + get_local 0 + i32.load16_u + drop) + (func (;3;) (type 0) (param i32) + get_local 0 + i32.load8_s + drop) + (func (;4;) (type 0) (param i32) + get_local 0 + i32.load8_u + drop) + (func (;5;) (type 0) (param i32) + get_local 0 + i64.load + drop) + (func (;6;) (type 0) (param i32) + get_local 0 + i64.load32_s + drop) + (func (;7;) (type 0) (param i32) + get_local 0 + i64.load32_u + drop) + (func (;8;) (type 0) (param i32) + get_local 0 + i64.load16_s + drop) + (func (;9;) (type 0) (param i32) + get_local 0 + i64.load16_u + drop) + (func (;10;) (type 0) (param i32) + get_local 0 + i64.load8_s + drop) + (func (;11;) (type 0) (param i32) + get_local 0 + i64.load8_u + drop) + (func (;12;) (type 0) (param i32) + get_local 0 + f32.load + drop) + (func (;13;) (type 0) (param i32) + get_local 0 + f64.load + drop) + (memory (;0;) 1) + (export \"no_dce.i32.load\" (func 0)) + (export \"no_dce.i32.load16_s\" (func 1)) + (export \"no_dce.i32.load16_u\" (func 2)) + (export \"no_dce.i32.load8_s\" (func 3)) + (export \"no_dce.i32.load8_u\" (func 4)) + (export \"no_dce.i64.load\" (func 5)) + (export \"no_dce.i64.load32_s\" (func 6)) + (export \"no_dce.i64.load32_u\" (func 7)) + (export \"no_dce.i64.load16_s\" (func 8)) + (export \"no_dce.i64.load16_u\" (func 9)) + (export \"no_dce.i64.load8_s\" (func 10)) + (export \"no_dce.i64.load8_u\" (func 11)) + (export \"no_dce.f32.load\" (func 12)) + (export \"no_dce.f64.load\" (func 13))) + "; + let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed"); + instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated") +} + +fn start_module_4(result_object: &ResultObject) { + result_object.instance.start(); +} + +// Line 78 +fn c22_l78_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c22_l78_action_invoke"); + let func_index = match result_object.module.info.exports.get("no_dce.i32.load") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &Instance) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(65536 as i32, &result_object.instance); + +} + +#[test] +fn c22_l78_assert_trap() { + let result_object = create_module_4(); + let result = panic::catch_unwind(|| { + c22_l78_action_invoke(&result_object); + }); + assert!(result.is_err()); +} + +// Line 79 +fn c23_l79_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c23_l79_action_invoke"); + let func_index = match result_object.module.info.exports.get("no_dce.i32.load16_s") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &Instance) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(65536 as i32, &result_object.instance); + +} + +#[test] +fn c23_l79_assert_trap() { + let result_object = create_module_4(); + let result = panic::catch_unwind(|| { + c23_l79_action_invoke(&result_object); + }); + assert!(result.is_err()); +} + +// Line 80 +fn c24_l80_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c24_l80_action_invoke"); + let func_index = match result_object.module.info.exports.get("no_dce.i32.load16_u") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &Instance) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(65536 as i32, &result_object.instance); + +} + +#[test] +fn c24_l80_assert_trap() { + let result_object = create_module_4(); + let result = panic::catch_unwind(|| { + c24_l80_action_invoke(&result_object); + }); + assert!(result.is_err()); +} + +// Line 81 +fn c25_l81_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c25_l81_action_invoke"); + let func_index = match result_object.module.info.exports.get("no_dce.i32.load8_s") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &Instance) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(65536 as i32, &result_object.instance); + +} + +#[test] +fn c25_l81_assert_trap() { + let result_object = create_module_4(); + let result = panic::catch_unwind(|| { + c25_l81_action_invoke(&result_object); + }); + assert!(result.is_err()); +} + +// Line 82 +fn c26_l82_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c26_l82_action_invoke"); + let func_index = match result_object.module.info.exports.get("no_dce.i32.load8_u") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &Instance) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(65536 as i32, &result_object.instance); + +} + +#[test] +fn c26_l82_assert_trap() { + let result_object = create_module_4(); + let result = panic::catch_unwind(|| { + c26_l82_action_invoke(&result_object); + }); + assert!(result.is_err()); +} + +// Line 83 +fn c27_l83_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c27_l83_action_invoke"); + let func_index = match result_object.module.info.exports.get("no_dce.i64.load") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &Instance) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(65536 as i32, &result_object.instance); + +} + +#[test] +fn c27_l83_assert_trap() { + let result_object = create_module_4(); + let result = panic::catch_unwind(|| { + c27_l83_action_invoke(&result_object); + }); + assert!(result.is_err()); +} + +// Line 84 +fn c28_l84_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c28_l84_action_invoke"); + let func_index = match result_object.module.info.exports.get("no_dce.i64.load32_s") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &Instance) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(65536 as i32, &result_object.instance); + +} + +#[test] +fn c28_l84_assert_trap() { + let result_object = create_module_4(); + let result = panic::catch_unwind(|| { + c28_l84_action_invoke(&result_object); + }); + assert!(result.is_err()); +} + +// Line 85 +fn c29_l85_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c29_l85_action_invoke"); + let func_index = match result_object.module.info.exports.get("no_dce.i64.load32_u") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &Instance) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(65536 as i32, &result_object.instance); + +} + +#[test] +fn c29_l85_assert_trap() { + let result_object = create_module_4(); + let result = panic::catch_unwind(|| { + c29_l85_action_invoke(&result_object); + }); + assert!(result.is_err()); +} + +// Line 86 +fn c30_l86_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c30_l86_action_invoke"); + let func_index = match result_object.module.info.exports.get("no_dce.i64.load16_s") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &Instance) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(65536 as i32, &result_object.instance); + +} + +#[test] +fn c30_l86_assert_trap() { + let result_object = create_module_4(); + let result = panic::catch_unwind(|| { + c30_l86_action_invoke(&result_object); + }); + assert!(result.is_err()); +} + +// Line 87 +fn c31_l87_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c31_l87_action_invoke"); + let func_index = match result_object.module.info.exports.get("no_dce.i64.load16_u") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &Instance) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(65536 as i32, &result_object.instance); + +} + +#[test] +fn c31_l87_assert_trap() { + let result_object = create_module_4(); + let result = panic::catch_unwind(|| { + c31_l87_action_invoke(&result_object); + }); + assert!(result.is_err()); +} + +// Line 88 +fn c32_l88_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c32_l88_action_invoke"); + let func_index = match result_object.module.info.exports.get("no_dce.i64.load8_s") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &Instance) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(65536 as i32, &result_object.instance); + +} + +#[test] +fn c32_l88_assert_trap() { + let result_object = create_module_4(); + let result = panic::catch_unwind(|| { + c32_l88_action_invoke(&result_object); + }); + assert!(result.is_err()); +} + +// Line 89 +fn c33_l89_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c33_l89_action_invoke"); + let func_index = match result_object.module.info.exports.get("no_dce.i64.load8_u") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &Instance) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(65536 as i32, &result_object.instance); + +} + +#[test] +fn c33_l89_assert_trap() { + let result_object = create_module_4(); + let result = panic::catch_unwind(|| { + c33_l89_action_invoke(&result_object); + }); + assert!(result.is_err()); +} + +// Line 90 +fn c34_l90_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c34_l90_action_invoke"); + let func_index = match result_object.module.info.exports.get("no_dce.f32.load") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &Instance) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(65536 as i32, &result_object.instance); + +} + +#[test] +fn c34_l90_assert_trap() { + let result_object = create_module_4(); + let result = panic::catch_unwind(|| { + c34_l90_action_invoke(&result_object); + }); + assert!(result.is_err()); +} + +// Line 91 +fn c35_l91_action_invoke(result_object: &ResultObject) { + println!("Executing function {}", "c35_l91_action_invoke"); + let func_index = match result_object.module.info.exports.get("no_dce.f64.load") { + Some(&Export::Function(index)) => index, + _ => panic!("Function not found"), + }; + let invoke_fn: fn(i32, &Instance) = get_instance_function!(result_object.instance, func_index); + let result = invoke_fn(65536 as i32, &result_object.instance); + +} + +#[test] +fn c35_l91_assert_trap() { + let result_object = create_module_4(); + let result = panic::catch_unwind(|| { + c35_l91_action_invoke(&result_object); + }); + assert!(result.is_err()); +} + +#[test] +fn test_module_4() { + let result_object = create_module_4(); + // We group the calls together + start_module_4(&result_object); +}