wasmer/lib/runtime/tests/spectests/traps.rs

750 lines
22 KiB
Rust
Raw Normal View History

2019-01-09 06:06:24 +00:00
// Rust test file autogenerated with cargo build (build/spectests.rs).
// Please do NOT modify it by hand, as it will be reset on next build.
// Test based on spectests/traps.wast
#![allow(
warnings,
dead_code
)]
use wabt::wat2wasm;
use std::{f32, f64};
use wasmer_runtime::types::Value;
use wasmer_runtime::{Instance, module::Module};
2019-01-09 06:06:24 +00:00
use wasmer_clif_backend::CraneliftCompiler;
use crate::spectests::_common::{
spectest_importobject,
NaNCheck,
};
// Line 5
fn create_module_1() -> Box<Instance> {
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");
let module = wasmer_runtime::compile(&wasm_binary[..], &CraneliftCompiler::new()).expect("WASM can't be compiled");
module.instantiate(&spectest_importobject()).expect("WASM can't be instantiated")
}
fn start_module_1(instance: &mut Instance) {
// TODO Review is explicit start needed? Start now called in runtime::Instance::new()
//instance.start();
}
// Line 16
fn c1_l16_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c1_l16_action_invoke");
let result = instance.call("no_dce.i32.div_s", &[Value::I32(1 as i32), Value::I32(0 as i32)]);
result.map(|_| ())
}
#[test]
fn c1_l16_assert_trap() {
let mut instance = create_module_1();
let result = c1_l16_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 17
fn c2_l17_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c2_l17_action_invoke");
let result = instance.call("no_dce.i32.div_u", &[Value::I32(1 as i32), Value::I32(0 as i32)]);
result.map(|_| ())
}
#[test]
fn c2_l17_assert_trap() {
let mut instance = create_module_1();
let result = c2_l17_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 18
fn c3_l18_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c3_l18_action_invoke");
let result = instance.call("no_dce.i64.div_s", &[Value::I64(1 as i64), Value::I64(0 as i64)]);
result.map(|_| ())
}
#[test]
fn c3_l18_assert_trap() {
let mut instance = create_module_1();
let result = c3_l18_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 19
fn c4_l19_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c4_l19_action_invoke");
let result = instance.call("no_dce.i64.div_u", &[Value::I64(1 as i64), Value::I64(0 as i64)]);
result.map(|_| ())
}
#[test]
fn c4_l19_assert_trap() {
let mut instance = create_module_1();
let result = c4_l19_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 20
fn c5_l20_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c5_l20_action_invoke");
let result = instance.call("no_dce.i32.div_s", &[Value::I32(-2147483648 as i32), Value::I32(-1 as i32)]);
result.map(|_| ())
}
#[test]
fn c5_l20_assert_trap() {
let mut instance = create_module_1();
let result = c5_l20_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 21
fn c6_l21_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c6_l21_action_invoke");
let result = instance.call("no_dce.i64.div_s", &[Value::I64(-9223372036854775808 as i64), Value::I64(-1 as i64)]);
result.map(|_| ())
}
#[test]
fn c6_l21_assert_trap() {
let mut instance = create_module_1();
let result = c6_l21_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 23
#[test]
fn test_module_1() {
let mut instance = create_module_1();
// We group the calls together
start_module_1(&mut instance);
}
fn create_module_2() -> Box<Instance> {
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");
let module = wasmer_runtime::compile(&wasm_binary[..], &CraneliftCompiler::new()).expect("WASM can't be compiled");
module.instantiate(&spectest_importobject()).expect("WASM can't be instantiated")
}
fn start_module_2(instance: &mut Instance) {
// TODO Review is explicit start needed? Start now called in runtime::Instance::new()
//instance.start();
}
// Line 34
fn c8_l34_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c8_l34_action_invoke");
let result = instance.call("no_dce.i32.rem_s", &[Value::I32(1 as i32), Value::I32(0 as i32)]);
result.map(|_| ())
}
#[test]
fn c8_l34_assert_trap() {
let mut instance = create_module_2();
let result = c8_l34_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 35
fn c9_l35_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c9_l35_action_invoke");
let result = instance.call("no_dce.i32.rem_u", &[Value::I32(1 as i32), Value::I32(0 as i32)]);
result.map(|_| ())
}
#[test]
fn c9_l35_assert_trap() {
let mut instance = create_module_2();
let result = c9_l35_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 36
fn c10_l36_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c10_l36_action_invoke");
let result = instance.call("no_dce.i64.rem_s", &[Value::I64(1 as i64), Value::I64(0 as i64)]);
result.map(|_| ())
}
#[test]
fn c10_l36_assert_trap() {
let mut instance = create_module_2();
let result = c10_l36_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 37
fn c11_l37_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c11_l37_action_invoke");
let result = instance.call("no_dce.i64.rem_u", &[Value::I64(1 as i64), Value::I64(0 as i64)]);
result.map(|_| ())
}
#[test]
fn c11_l37_assert_trap() {
let mut instance = create_module_2();
let result = c11_l37_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 39
#[test]
fn test_module_2() {
let mut instance = create_module_2();
// We group the calls together
start_module_2(&mut instance);
}
fn create_module_3() -> Box<Instance> {
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");
let module = wasmer_runtime::compile(&wasm_binary[..], &CraneliftCompiler::new()).expect("WASM can't be compiled");
module.instantiate(&spectest_importobject()).expect("WASM can't be instantiated")
}
fn start_module_3(instance: &mut Instance) {
// TODO Review is explicit start needed? Start now called in runtime::Instance::new()
//instance.start();
}
// Line 50
fn c13_l50_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c13_l50_action_invoke");
2019-01-10 01:32:02 +00:00
let result = instance.call("no_dce.i32.trunc_s_f32", &[Value::F32(f32::from_bits(2143289344))]);
2019-01-09 06:06:24 +00:00
result.map(|_| ())
}
#[test]
fn c13_l50_assert_trap() {
let mut instance = create_module_3();
let result = c13_l50_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 51
fn c14_l51_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c14_l51_action_invoke");
2019-01-10 01:32:02 +00:00
let result = instance.call("no_dce.i32.trunc_u_f32", &[Value::F32(f32::from_bits(2143289344))]);
2019-01-09 06:06:24 +00:00
result.map(|_| ())
}
#[test]
fn c14_l51_assert_trap() {
let mut instance = create_module_3();
let result = c14_l51_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 52
fn c15_l52_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c15_l52_action_invoke");
2019-01-10 01:32:02 +00:00
let result = instance.call("no_dce.i32.trunc_s_f64", &[Value::F64(f64::from_bits(9221120237041090560))]);
2019-01-09 06:06:24 +00:00
result.map(|_| ())
}
#[test]
fn c15_l52_assert_trap() {
let mut instance = create_module_3();
let result = c15_l52_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 53
fn c16_l53_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c16_l53_action_invoke");
2019-01-10 01:32:02 +00:00
let result = instance.call("no_dce.i32.trunc_u_f64", &[Value::F64(f64::from_bits(9221120237041090560))]);
2019-01-09 06:06:24 +00:00
result.map(|_| ())
}
#[test]
fn c16_l53_assert_trap() {
let mut instance = create_module_3();
let result = c16_l53_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 54
fn c17_l54_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c17_l54_action_invoke");
2019-01-10 01:32:02 +00:00
let result = instance.call("no_dce.i64.trunc_s_f32", &[Value::F32(f32::from_bits(2143289344))]);
2019-01-09 06:06:24 +00:00
result.map(|_| ())
}
#[test]
fn c17_l54_assert_trap() {
let mut instance = create_module_3();
let result = c17_l54_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 55
fn c18_l55_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c18_l55_action_invoke");
2019-01-10 01:32:02 +00:00
let result = instance.call("no_dce.i64.trunc_u_f32", &[Value::F32(f32::from_bits(2143289344))]);
2019-01-09 06:06:24 +00:00
result.map(|_| ())
}
#[test]
fn c18_l55_assert_trap() {
let mut instance = create_module_3();
let result = c18_l55_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 56
fn c19_l56_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c19_l56_action_invoke");
2019-01-10 01:32:02 +00:00
let result = instance.call("no_dce.i64.trunc_s_f64", &[Value::F64(f64::from_bits(9221120237041090560))]);
2019-01-09 06:06:24 +00:00
result.map(|_| ())
}
#[test]
fn c19_l56_assert_trap() {
let mut instance = create_module_3();
let result = c19_l56_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 57
fn c20_l57_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c20_l57_action_invoke");
2019-01-10 01:32:02 +00:00
let result = instance.call("no_dce.i64.trunc_u_f64", &[Value::F64(f64::from_bits(9221120237041090560))]);
2019-01-09 06:06:24 +00:00
result.map(|_| ())
}
#[test]
fn c20_l57_assert_trap() {
let mut instance = create_module_3();
let result = c20_l57_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 59
#[test]
fn test_module_3() {
let mut instance = create_module_3();
// We group the calls together
start_module_3(&mut instance);
}
fn create_module_4() -> Box<Instance> {
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");
let module = wasmer_runtime::compile(&wasm_binary[..], &CraneliftCompiler::new()).expect("WASM can't be compiled");
module.instantiate(&spectest_importobject()).expect("WASM can't be instantiated")
}
fn start_module_4(instance: &mut Instance) {
// TODO Review is explicit start needed? Start now called in runtime::Instance::new()
//instance.start();
}
// Line 78
fn c22_l78_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c22_l78_action_invoke");
let result = instance.call("no_dce.i32.load", &[Value::I32(65536 as i32)]);
result.map(|_| ())
}
#[test]
fn c22_l78_assert_trap() {
let mut instance = create_module_4();
let result = c22_l78_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 79
fn c23_l79_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c23_l79_action_invoke");
let result = instance.call("no_dce.i32.load16_s", &[Value::I32(65536 as i32)]);
result.map(|_| ())
}
#[test]
fn c23_l79_assert_trap() {
let mut instance = create_module_4();
let result = c23_l79_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 80
fn c24_l80_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c24_l80_action_invoke");
let result = instance.call("no_dce.i32.load16_u", &[Value::I32(65536 as i32)]);
result.map(|_| ())
}
#[test]
fn c24_l80_assert_trap() {
let mut instance = create_module_4();
let result = c24_l80_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 81
fn c25_l81_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c25_l81_action_invoke");
let result = instance.call("no_dce.i32.load8_s", &[Value::I32(65536 as i32)]);
result.map(|_| ())
}
#[test]
fn c25_l81_assert_trap() {
let mut instance = create_module_4();
let result = c25_l81_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 82
fn c26_l82_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c26_l82_action_invoke");
let result = instance.call("no_dce.i32.load8_u", &[Value::I32(65536 as i32)]);
result.map(|_| ())
}
#[test]
fn c26_l82_assert_trap() {
let mut instance = create_module_4();
let result = c26_l82_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 83
fn c27_l83_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c27_l83_action_invoke");
let result = instance.call("no_dce.i64.load", &[Value::I32(65536 as i32)]);
result.map(|_| ())
}
#[test]
fn c27_l83_assert_trap() {
let mut instance = create_module_4();
let result = c27_l83_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 84
fn c28_l84_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c28_l84_action_invoke");
let result = instance.call("no_dce.i64.load32_s", &[Value::I32(65536 as i32)]);
result.map(|_| ())
}
#[test]
fn c28_l84_assert_trap() {
let mut instance = create_module_4();
let result = c28_l84_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 85
fn c29_l85_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c29_l85_action_invoke");
let result = instance.call("no_dce.i64.load32_u", &[Value::I32(65536 as i32)]);
result.map(|_| ())
}
#[test]
fn c29_l85_assert_trap() {
let mut instance = create_module_4();
let result = c29_l85_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 86
fn c30_l86_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c30_l86_action_invoke");
let result = instance.call("no_dce.i64.load16_s", &[Value::I32(65536 as i32)]);
result.map(|_| ())
}
#[test]
fn c30_l86_assert_trap() {
let mut instance = create_module_4();
let result = c30_l86_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 87
fn c31_l87_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c31_l87_action_invoke");
let result = instance.call("no_dce.i64.load16_u", &[Value::I32(65536 as i32)]);
result.map(|_| ())
}
#[test]
fn c31_l87_assert_trap() {
let mut instance = create_module_4();
let result = c31_l87_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 88
fn c32_l88_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c32_l88_action_invoke");
let result = instance.call("no_dce.i64.load8_s", &[Value::I32(65536 as i32)]);
result.map(|_| ())
}
#[test]
fn c32_l88_assert_trap() {
let mut instance = create_module_4();
let result = c32_l88_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 89
fn c33_l89_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c33_l89_action_invoke");
let result = instance.call("no_dce.i64.load8_u", &[Value::I32(65536 as i32)]);
result.map(|_| ())
}
#[test]
fn c33_l89_assert_trap() {
let mut instance = create_module_4();
let result = c33_l89_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 90
fn c34_l90_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c34_l90_action_invoke");
let result = instance.call("no_dce.f32.load", &[Value::I32(65536 as i32)]);
result.map(|_| ())
}
#[test]
fn c34_l90_assert_trap() {
let mut instance = create_module_4();
let result = c34_l90_action_invoke(&mut*instance);
assert!(result.is_err());
}
// Line 91
fn c35_l91_action_invoke(instance: &mut Instance) -> Result<(), String> {
println!("Executing function {}", "c35_l91_action_invoke");
let result = instance.call("no_dce.f64.load", &[Value::I32(65536 as i32)]);
result.map(|_| ())
}
#[test]
fn c35_l91_assert_trap() {
let mut instance = create_module_4();
let result = c35_l91_action_invoke(&mut*instance);
assert!(result.is_err());
}
#[test]
fn test_module_4() {
let mut instance = create_module_4();
// We group the calls together
start_module_4(&mut instance);
}