Wire Sysio
Wire Sysion 1.0.0
Loading...
Searching...
No Matches
traps_tests.cpp
Go to the documentation of this file.
1
// Generated by spec_test_generator. DO NOT MODIFY THIS FILE.
2
3
#include <algorithm>
4
#include <vector>
5
#include <iostream>
6
#include <iterator>
7
#include <cmath>
8
#include <cstdlib>
9
#include <
catch2/catch.hpp
>
10
#include <utils.hpp>
11
#include <
wasm_config.hpp
>
12
#include <sysio/vm/backend.hpp>
13
14
using namespace
sysio
;
15
using namespace
sysio::vm
;
16
extern
wasm_allocator
wa
;
17
18
BACKEND_TEST_CASE
(
"Testing wasm <traps_0_wasm>"
,
"[traps_0_wasm_tests]"
) {
19
using
backend_t
=
backend<standalone_function_t, TestType>
;
20
auto
code =
read_wasm
( std::string(wasm_directory) +
"traps.0.wasm"
);
21
backend_t
bkend
( code, &
wa
);
22
23
CHECK_THROWS_AS
(
bkend
(
"env"
,
"no_dce.i32.div_s"
,
UINT32_C
(1),
UINT32_C
(0)), std::exception);
24
CHECK_THROWS_AS
(
bkend
(
"env"
,
"no_dce.i32.div_u"
,
UINT32_C
(1),
UINT32_C
(0)), std::exception);
25
CHECK_THROWS_AS
(
bkend
(
"env"
,
"no_dce.i64.div_s"
,
UINT64_C
(1),
UINT64_C
(0)), std::exception);
26
CHECK_THROWS_AS
(
bkend
(
"env"
,
"no_dce.i64.div_u"
,
UINT64_C
(1),
UINT64_C
(0)), std::exception);
27
CHECK_THROWS_AS
(
bkend
(
"env"
,
"no_dce.i32.div_s"
,
UINT32_C
(2147483648),
UINT32_C
(4294967295)), std::exception);
28
CHECK_THROWS_AS
(
bkend
(
"env"
,
"no_dce.i64.div_s"
,
UINT64_C
(9223372036854775808),
UINT64_C
(18446744073709551615)), std::exception);
29
}
30
31
BACKEND_TEST_CASE
(
"Testing wasm <traps_1_wasm>"
,
"[traps_1_wasm_tests]"
) {
32
using
backend_t
=
backend<standalone_function_t, TestType>
;
33
auto
code =
read_wasm
( std::string(wasm_directory) +
"traps.1.wasm"
);
34
backend_t
bkend
( code, &
wa
);
35
36
CHECK_THROWS_AS
(
bkend
(
"env"
,
"no_dce.i32.rem_s"
,
UINT32_C
(1),
UINT32_C
(0)), std::exception);
37
CHECK_THROWS_AS
(
bkend
(
"env"
,
"no_dce.i32.rem_u"
,
UINT32_C
(1),
UINT32_C
(0)), std::exception);
38
CHECK_THROWS_AS
(
bkend
(
"env"
,
"no_dce.i64.rem_s"
,
UINT64_C
(1),
UINT64_C
(0)), std::exception);
39
CHECK_THROWS_AS
(
bkend
(
"env"
,
"no_dce.i64.rem_u"
,
UINT64_C
(1),
UINT64_C
(0)), std::exception);
40
}
41
42
BACKEND_TEST_CASE
(
"Testing wasm <traps_2_wasm>"
,
"[traps_2_wasm_tests]"
) {
43
using
backend_t
=
backend<standalone_function_t, TestType>
;
44
auto
code =
read_wasm
( std::string(wasm_directory) +
"traps.2.wasm"
);
45
backend_t
bkend
( code, &
wa
);
46
47
CHECK_THROWS_AS
(
bkend
(
"env"
,
"no_dce.i32.trunc_f32_s"
,
bit_cast<float>
(
UINT32_C
(2143289344))), std::exception);
48
CHECK_THROWS_AS
(
bkend
(
"env"
,
"no_dce.i32.trunc_f32_u"
,
bit_cast<float>
(
UINT32_C
(2143289344))), std::exception);
49
CHECK_THROWS_AS
(
bkend
(
"env"
,
"no_dce.i32.trunc_f64_s"
,
bit_cast<double>
(
UINT64_C
(9221120237041090560))), std::exception);
50
CHECK_THROWS_AS
(
bkend
(
"env"
,
"no_dce.i32.trunc_f64_u"
,
bit_cast<double>
(
UINT64_C
(9221120237041090560))), std::exception);
51
CHECK_THROWS_AS
(
bkend
(
"env"
,
"no_dce.i64.trunc_f32_s"
,
bit_cast<float>
(
UINT32_C
(2143289344))), std::exception);
52
CHECK_THROWS_AS
(
bkend
(
"env"
,
"no_dce.i64.trunc_f32_u"
,
bit_cast<float>
(
UINT32_C
(2143289344))), std::exception);
53
CHECK_THROWS_AS
(
bkend
(
"env"
,
"no_dce.i64.trunc_f64_s"
,
bit_cast<double>
(
UINT64_C
(9221120237041090560))), std::exception);
54
CHECK_THROWS_AS
(
bkend
(
"env"
,
"no_dce.i64.trunc_f64_u"
,
bit_cast<double>
(
UINT64_C
(9221120237041090560))), std::exception);
55
}
56
57
BACKEND_TEST_CASE
(
"Testing wasm <traps_3_wasm>"
,
"[traps_3_wasm_tests]"
) {
58
using
backend_t
=
backend<standalone_function_t, TestType>
;
59
auto
code =
read_wasm
( std::string(wasm_directory) +
"traps.3.wasm"
);
60
backend_t
bkend
( code, &
wa
);
61
62
CHECK_THROWS_AS
(
bkend
(
"env"
,
"no_dce.i32.load"
,
UINT32_C
(65536)), std::exception);
63
CHECK_THROWS_AS
(
bkend
(
"env"
,
"no_dce.i32.load16_s"
,
UINT32_C
(65536)), std::exception);
64
CHECK_THROWS_AS
(
bkend
(
"env"
,
"no_dce.i32.load16_u"
,
UINT32_C
(65536)), std::exception);
65
CHECK_THROWS_AS
(
bkend
(
"env"
,
"no_dce.i32.load8_s"
,
UINT32_C
(65536)), std::exception);
66
CHECK_THROWS_AS
(
bkend
(
"env"
,
"no_dce.i32.load8_u"
,
UINT32_C
(65536)), std::exception);
67
CHECK_THROWS_AS
(
bkend
(
"env"
,
"no_dce.i64.load"
,
UINT32_C
(65536)), std::exception);
68
CHECK_THROWS_AS
(
bkend
(
"env"
,
"no_dce.i64.load32_s"
,
UINT32_C
(65536)), std::exception);
69
CHECK_THROWS_AS
(
bkend
(
"env"
,
"no_dce.i64.load32_u"
,
UINT32_C
(65536)), std::exception);
70
CHECK_THROWS_AS
(
bkend
(
"env"
,
"no_dce.i64.load16_s"
,
UINT32_C
(65536)), std::exception);
71
CHECK_THROWS_AS
(
bkend
(
"env"
,
"no_dce.i64.load16_u"
,
UINT32_C
(65536)), std::exception);
72
CHECK_THROWS_AS
(
bkend
(
"env"
,
"no_dce.i64.load8_s"
,
UINT32_C
(65536)), std::exception);
73
CHECK_THROWS_AS
(
bkend
(
"env"
,
"no_dce.i64.load8_u"
,
UINT32_C
(65536)), std::exception);
74
CHECK_THROWS_AS
(
bkend
(
"env"
,
"no_dce.f32.load"
,
UINT32_C
(65536)), std::exception);
75
CHECK_THROWS_AS
(
bkend
(
"env"
,
"no_dce.f64.load"
,
UINT32_C
(65536)), std::exception);
76
}
77
sysio::vm::backend
Definition
backend.hpp:62
sysio::vm::wasm_allocator
Definition
allocator.hpp:409
bkend
backend_t bkend(hello_wasm, ehm, &wa)
CHECK_THROWS_AS
#define CHECK_THROWS_AS(expr, exceptionType)
Definition
catch.hpp:203
sysio::vm
Definition
controller.hpp:23
sysio::vm::read_wasm
std::vector< uint8_t > read_wasm(const std::string &fname)
Definition
utils.hpp:30
sysio
Definition
abi_serializer.cpp:8
catch.hpp
UINT32_C
#define UINT32_C(val)
Definition
stdint.h:283
UINT64_C
#define UINT64_C(val)
Definition
stdint.h:284
BACKEND_TEST_CASE
#define BACKEND_TEST_CASE(name, tags)
Definition
utils.hpp:59
bit_cast
T bit_cast(const U &u)
Definition
utils.hpp:35
wa
wasm_allocator wa
Definition
main.cpp:10
wasm_config.hpp
libraries
sys-vm
tests
spec
traps_tests.cpp
Generated by
1.12.0