Wire Sysio
Wire Sysion 1.0.0
Loading...
Searching...
No Matches
memory_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 <memory_0_wasm>"
,
"[memory_0_wasm_tests]"
) {
19
using
backend_t
=
backend<standalone_function_t, TestType>
;
20
auto
code =
read_wasm
( std::string(wasm_directory) +
"memory.0.wasm"
);
21
backend_t
bkend
( code, &
wa
);
22
23
}
24
25
BACKEND_TEST_CASE
(
"Testing wasm <memory_1_wasm>"
,
"[memory_1_wasm_tests]"
) {
26
using
backend_t
=
backend<standalone_function_t, TestType>
;
27
auto
code =
read_wasm
( std::string(wasm_directory) +
"memory.1.wasm"
);
28
backend_t
bkend
( code, &
wa
);
29
30
}
31
32
BACKEND_TEST_CASE
(
"Testing wasm <memory_10_wasm>"
,
"[memory_10_wasm_tests]"
) {
33
using
backend_t
=
backend<standalone_function_t, TestType>
;
34
auto
code =
read_wasm
( std::string(wasm_directory) +
"memory.10.wasm"
);
35
CHECK_THROWS_AS
(
backend_t
(code,
nullptr
), std::exception);
36
}
37
38
BACKEND_TEST_CASE
(
"Testing wasm <memory_11_wasm>"
,
"[memory_11_wasm_tests]"
) {
39
using
backend_t
=
backend<standalone_function_t, TestType>
;
40
auto
code =
read_wasm
( std::string(wasm_directory) +
"memory.11.wasm"
);
41
CHECK_THROWS_AS
(
backend_t
(code,
nullptr
), std::exception);
42
}
43
44
BACKEND_TEST_CASE
(
"Testing wasm <memory_12_wasm>"
,
"[memory_12_wasm_tests]"
) {
45
using
backend_t
=
backend<standalone_function_t, TestType>
;
46
auto
code =
read_wasm
( std::string(wasm_directory) +
"memory.12.wasm"
);
47
CHECK_THROWS_AS
(
backend_t
(code,
nullptr
), std::exception);
48
}
49
50
BACKEND_TEST_CASE
(
"Testing wasm <memory_13_wasm>"
,
"[memory_13_wasm_tests]"
) {
51
using
backend_t
=
backend<standalone_function_t, TestType>
;
52
auto
code =
read_wasm
( std::string(wasm_directory) +
"memory.13.wasm"
);
53
CHECK_THROWS_AS
(
backend_t
(code,
nullptr
), std::exception);
54
}
55
56
BACKEND_TEST_CASE
(
"Testing wasm <memory_14_wasm>"
,
"[memory_14_wasm_tests]"
) {
57
using
backend_t
=
backend<standalone_function_t, TestType>
;
58
auto
code =
read_wasm
( std::string(wasm_directory) +
"memory.14.wasm"
);
59
CHECK_THROWS_AS
(
backend_t
(code,
nullptr
), std::exception);
60
}
61
62
BACKEND_TEST_CASE
(
"Testing wasm <memory_15_wasm>"
,
"[memory_15_wasm_tests]"
) {
63
using
backend_t
=
backend<standalone_function_t, TestType>
;
64
auto
code =
read_wasm
( std::string(wasm_directory) +
"memory.15.wasm"
);
65
CHECK_THROWS_AS
(
backend_t
(code,
nullptr
), std::exception);
66
}
67
68
BACKEND_TEST_CASE
(
"Testing wasm <memory_16_wasm>"
,
"[memory_16_wasm_tests]"
) {
69
using
backend_t
=
backend<standalone_function_t, TestType>
;
70
auto
code =
read_wasm
( std::string(wasm_directory) +
"memory.16.wasm"
);
71
CHECK_THROWS_AS
(
backend_t
(code,
nullptr
), std::exception);
72
}
73
74
BACKEND_TEST_CASE
(
"Testing wasm <memory_17_wasm>"
,
"[memory_17_wasm_tests]"
) {
75
using
backend_t
=
backend<standalone_function_t, TestType>
;
76
auto
code =
read_wasm
( std::string(wasm_directory) +
"memory.17.wasm"
);
77
CHECK_THROWS_AS
(
backend_t
(code,
nullptr
), std::exception);
78
}
79
80
BACKEND_TEST_CASE
(
"Testing wasm <memory_18_wasm>"
,
"[memory_18_wasm_tests]"
) {
81
using
backend_t
=
backend<standalone_function_t, TestType>
;
82
auto
code =
read_wasm
( std::string(wasm_directory) +
"memory.18.wasm"
);
83
CHECK_THROWS_AS
(
backend_t
(code,
nullptr
), std::exception);
84
}
85
86
BACKEND_TEST_CASE
(
"Testing wasm <memory_19_wasm>"
,
"[memory_19_wasm_tests]"
) {
87
using
backend_t
=
backend<standalone_function_t, TestType>
;
88
auto
code =
read_wasm
( std::string(wasm_directory) +
"memory.19.wasm"
);
89
CHECK_THROWS_AS
(
backend_t
(code,
nullptr
), std::exception);
90
}
91
92
BACKEND_TEST_CASE
(
"Testing wasm <memory_2_wasm>"
,
"[memory_2_wasm_tests]"
) {
93
using
backend_t
=
backend<standalone_function_t, TestType>
;
94
auto
code =
read_wasm
( std::string(wasm_directory) +
"memory.2.wasm"
);
95
backend_t
bkend
( code, &
wa
);
96
97
}
98
99
BACKEND_TEST_CASE
(
"Testing wasm <memory_20_wasm>"
,
"[memory_20_wasm_tests]"
) {
100
using
backend_t
=
backend<standalone_function_t, TestType>
;
101
auto
code =
read_wasm
( std::string(wasm_directory) +
"memory.20.wasm"
);
102
CHECK_THROWS_AS
(
backend_t
(code,
nullptr
), std::exception);
103
}
104
105
BACKEND_TEST_CASE
(
"Testing wasm <memory_21_wasm>"
,
"[memory_21_wasm_tests]"
) {
106
using
backend_t
=
backend<standalone_function_t, TestType>
;
107
auto
code =
read_wasm
( std::string(wasm_directory) +
"memory.21.wasm"
);
108
CHECK_THROWS_AS
(
backend_t
(code,
nullptr
), std::exception);
109
}
110
111
BACKEND_TEST_CASE
(
"Testing wasm <memory_22_wasm>"
,
"[memory_22_wasm_tests]"
) {
112
using
backend_t
=
backend<standalone_function_t, TestType>
;
113
auto
code =
read_wasm
( std::string(wasm_directory) +
"memory.22.wasm"
);
114
CHECK_THROWS_AS
(
backend_t
(code,
nullptr
), std::exception);
115
}
116
117
BACKEND_TEST_CASE
(
"Testing wasm <memory_23_wasm>"
,
"[memory_23_wasm_tests]"
) {
118
using
backend_t
=
backend<standalone_function_t, TestType>
;
119
auto
code =
read_wasm
( std::string(wasm_directory) +
"memory.23.wasm"
);
120
CHECK_THROWS_AS
(
backend_t
(code,
nullptr
), std::exception);
121
}
122
123
BACKEND_TEST_CASE
(
"Testing wasm <memory_24_wasm>"
,
"[memory_24_wasm_tests]"
) {
124
using
backend_t
=
backend<standalone_function_t, TestType>
;
125
auto
code =
read_wasm
( std::string(wasm_directory) +
"memory.24.wasm"
);
126
CHECK_THROWS_AS
(
backend_t
(code,
nullptr
), std::exception);
127
}
128
129
BACKEND_TEST_CASE
(
"Testing wasm <memory_25_wasm>"
,
"[memory_25_wasm_tests]"
) {
130
using
backend_t
=
backend<standalone_function_t, TestType>
;
131
auto
code =
read_wasm
( std::string(wasm_directory) +
"memory.25.wasm"
);
132
backend_t
bkend
( code, &
wa
);
133
134
CHECK
(
bkend
.
call_with_return
(
"env"
,
"data"
)->to_ui32() ==
UINT32_C
(1));
135
CHECK
(
bit_cast<uint64_t>
(
bkend
.
call_with_return
(
"env"
,
"cast"
)->to_f64()) ==
UINT64_C
(4631107791820423168));
136
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i32_load8_s"
,
UINT32_C
(4294967295))->to_ui32() ==
UINT32_C
(4294967295));
137
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i32_load8_u"
,
UINT32_C
(4294967295))->to_ui32() ==
UINT32_C
(255));
138
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i32_load16_s"
,
UINT32_C
(4294967295))->to_ui32() ==
UINT32_C
(4294967295));
139
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i32_load16_u"
,
UINT32_C
(4294967295))->to_ui32() ==
UINT32_C
(65535));
140
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i32_load8_s"
,
UINT32_C
(100))->to_ui32() ==
UINT32_C
(100));
141
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i32_load8_u"
,
UINT32_C
(200))->to_ui32() ==
UINT32_C
(200));
142
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i32_load16_s"
,
UINT32_C
(20000))->to_ui32() ==
UINT32_C
(20000));
143
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i32_load16_u"
,
UINT32_C
(40000))->to_ui32() ==
UINT32_C
(40000));
144
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i32_load8_s"
,
UINT32_C
(4275856707))->to_ui32() ==
UINT32_C
(67));
145
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i32_load8_s"
,
UINT32_C
(878104047))->to_ui32() ==
UINT32_C
(4294967279));
146
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i32_load8_u"
,
UINT32_C
(4275856707))->to_ui32() ==
UINT32_C
(67));
147
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i32_load8_u"
,
UINT32_C
(878104047))->to_ui32() ==
UINT32_C
(239));
148
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i32_load16_s"
,
UINT32_C
(4275856707))->to_ui32() ==
UINT32_C
(25923));
149
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i32_load16_s"
,
UINT32_C
(878104047))->to_ui32() ==
UINT32_C
(4294954479));
150
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i32_load16_u"
,
UINT32_C
(4275856707))->to_ui32() ==
UINT32_C
(25923));
151
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i32_load16_u"
,
UINT32_C
(878104047))->to_ui32() ==
UINT32_C
(52719));
152
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i64_load8_s"
,
UINT64_C
(18446744073709551615))->to_ui64() ==
UINT32_C
(18446744073709551615));
153
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i64_load8_u"
,
UINT64_C
(18446744073709551615))->to_ui64() ==
UINT32_C
(255));
154
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i64_load16_s"
,
UINT64_C
(18446744073709551615))->to_ui64() ==
UINT32_C
(18446744073709551615));
155
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i64_load16_u"
,
UINT64_C
(18446744073709551615))->to_ui64() ==
UINT32_C
(65535));
156
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i64_load32_s"
,
UINT64_C
(18446744073709551615))->to_ui64() ==
UINT32_C
(18446744073709551615));
157
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i64_load32_u"
,
UINT64_C
(18446744073709551615))->to_ui64() ==
UINT32_C
(4294967295));
158
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i64_load8_s"
,
UINT64_C
(100))->to_ui64() ==
UINT32_C
(100));
159
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i64_load8_u"
,
UINT64_C
(200))->to_ui64() ==
UINT32_C
(200));
160
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i64_load16_s"
,
UINT64_C
(20000))->to_ui64() ==
UINT32_C
(20000));
161
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i64_load16_u"
,
UINT64_C
(40000))->to_ui64() ==
UINT32_C
(40000));
162
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i64_load32_s"
,
UINT64_C
(20000))->to_ui64() ==
UINT32_C
(20000));
163
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i64_load32_u"
,
UINT64_C
(40000))->to_ui64() ==
UINT32_C
(40000));
164
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i64_load8_s"
,
UINT64_C
(18364758543954109763))->to_ui64() ==
UINT32_C
(67));
165
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i64_load8_s"
,
UINT64_C
(3771275841602506223))->to_ui64() ==
UINT32_C
(18446744073709551599));
166
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i64_load8_u"
,
UINT64_C
(18364758543954109763))->to_ui64() ==
UINT32_C
(67));
167
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i64_load8_u"
,
UINT64_C
(3771275841602506223))->to_ui64() ==
UINT32_C
(239));
168
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i64_load16_s"
,
UINT64_C
(18364758543954109763))->to_ui64() ==
UINT32_C
(25923));
169
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i64_load16_s"
,
UINT64_C
(3771275841602506223))->to_ui64() ==
UINT32_C
(18446744073709538799));
170
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i64_load16_u"
,
UINT64_C
(18364758543954109763))->to_ui64() ==
UINT32_C
(25923));
171
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i64_load16_u"
,
UINT64_C
(3771275841602506223))->to_ui64() ==
UINT32_C
(52719));
172
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i64_load32_s"
,
UINT64_C
(18364758543954109763))->to_ui64() ==
UINT32_C
(1446274371));
173
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i64_load32_s"
,
UINT64_C
(3771275841602506223))->to_ui64() ==
UINT32_C
(18446744071976963567));
174
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i64_load32_u"
,
UINT64_C
(18364758543954109763))->to_ui64() ==
UINT32_C
(1446274371));
175
CHECK
(
bkend
.
call_with_return
(
"env"
,
"i64_load32_u"
,
UINT64_C
(3771275841602506223))->to_ui64() ==
UINT32_C
(2562379247));
176
}
177
178
BACKEND_TEST_CASE
(
"Testing wasm <memory_3_wasm>"
,
"[memory_3_wasm_tests]"
) {
179
using
backend_t
=
backend<standalone_function_t, TestType>
;
180
auto
code =
read_wasm
( std::string(wasm_directory) +
"memory.3.wasm"
);
181
backend_t
bkend
( code, &
wa
);
182
183
}
184
185
BACKEND_TEST_CASE
(
"Testing wasm <memory_4_wasm>"
,
"[memory_4_wasm_tests]"
) {
186
using
backend_t
=
backend<standalone_function_t, TestType>
;
187
auto
code =
read_wasm
( std::string(wasm_directory) +
"memory.4.wasm"
);
188
CHECK_THROWS_AS
(
backend_t
(code,
nullptr
), std::exception);
189
}
190
191
BACKEND_TEST_CASE
(
"Testing wasm <memory_5_wasm>"
,
"[memory_5_wasm_tests]"
) {
192
using
backend_t
=
backend<standalone_function_t, TestType>
;
193
auto
code =
read_wasm
( std::string(wasm_directory) +
"memory.5.wasm"
);
194
CHECK_THROWS_AS
(
backend_t
(code,
nullptr
), std::exception);
195
}
196
197
BACKEND_TEST_CASE
(
"Testing wasm <memory_6_wasm>"
,
"[memory_6_wasm_tests]"
) {
198
using
backend_t
=
backend<standalone_function_t, TestType>
;
199
auto
code =
read_wasm
( std::string(wasm_directory) +
"memory.6.wasm"
);
200
backend_t
bkend
( code, &
wa
);
201
202
CHECK
(
bkend
.
call_with_return
(
"env"
,
"memsize"
)->to_ui32() ==
UINT32_C
(0));
203
}
204
205
BACKEND_TEST_CASE
(
"Testing wasm <memory_7_wasm>"
,
"[memory_7_wasm_tests]"
) {
206
using
backend_t
=
backend<standalone_function_t, TestType>
;
207
auto
code =
read_wasm
( std::string(wasm_directory) +
"memory.7.wasm"
);
208
backend_t
bkend
( code, &
wa
);
209
210
CHECK
(
bkend
.
call_with_return
(
"env"
,
"memsize"
)->to_ui32() ==
UINT32_C
(0));
211
}
212
213
BACKEND_TEST_CASE
(
"Testing wasm <memory_8_wasm>"
,
"[memory_8_wasm_tests]"
) {
214
using
backend_t
=
backend<standalone_function_t, TestType>
;
215
auto
code =
read_wasm
( std::string(wasm_directory) +
"memory.8.wasm"
);
216
backend_t
bkend
( code, &
wa
);
217
218
CHECK
(
bkend
.
call_with_return
(
"env"
,
"memsize"
)->to_ui32() ==
UINT32_C
(1));
219
}
220
221
BACKEND_TEST_CASE
(
"Testing wasm <memory_9_wasm>"
,
"[memory_9_wasm_tests]"
) {
222
using
backend_t
=
backend<standalone_function_t, TestType>
;
223
auto
code =
read_wasm
( std::string(wasm_directory) +
"memory.9.wasm"
);
224
CHECK_THROWS_AS
(
backend_t
(code,
nullptr
), std::exception);
225
}
226
sysio::vm::backend
Definition
backend.hpp:62
sysio::vm::backend::call_with_return
auto call_with_return(host_t &host, const std::string_view &mod, const std::string_view &func, Args... args)
Definition
backend.hpp:178
sysio::vm::wasm_allocator
Definition
allocator.hpp:409
CHECK
#define CHECK(cond)
Definition
util.h:80
bkend
backend_t bkend(hello_wasm, ehm, &wa)
backend_t
sysio::vm::backend< rhf_t > backend_t
Definition
hello_driver.cpp:61
CHECK_THROWS_AS
#define CHECK_THROWS_AS(expr, exceptionType)
Definition
catch.hpp:203
wa
wasm_allocator wa
Definition
main.cpp:10
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
wasm_config.hpp
libraries
sys-vm
tests
spec
memory_tests.cpp
Generated by
1.12.0