Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
local_tee_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
14using namespace sysio;
15using namespace sysio::vm;
16extern wasm_allocator wa;
17
18BACKEND_TEST_CASE( "Testing wasm <local_tee_0_wasm>", "[local_tee_0_wasm_tests]" ) {
20 auto code = read_wasm( std::string(wasm_directory) + "local_tee.0.wasm");
21 backend_t bkend( code, &wa );
22
23 CHECK(bkend.call_with_return("env", "type-local-i32")->to_ui32() == UINT32_C(0));
24 CHECK(bkend.call_with_return("env", "type-local-i64")->to_ui64() == UINT32_C(0));
25 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "type-local-f32")->to_f32()) == UINT32_C(0));
26 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "type-local-f64")->to_f64()) == UINT64_C(0));
27 CHECK(bkend.call_with_return("env", "type-param-i32", UINT32_C(2))->to_ui32() == UINT32_C(10));
28 CHECK(bkend.call_with_return("env", "type-param-i64", UINT64_C(3))->to_ui64() == UINT32_C(11));
29 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "type-param-f32", bit_cast<float>(UINT32_C(1082969293)))->to_f32()) == UINT32_C(1093769626));
30 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "type-param-f64", bit_cast<double>(UINT64_C(4617878467915022336)))->to_f64()) == UINT64_C(4623057607486498406));
31 CHECK(bkend.call_with_return("env", "as-block-first", UINT32_C(0))->to_ui32() == UINT32_C(1));
32 CHECK(bkend.call_with_return("env", "as-block-mid", UINT32_C(0))->to_ui32() == UINT32_C(1));
33 CHECK(bkend.call_with_return("env", "as-block-last", UINT32_C(0))->to_ui32() == UINT32_C(1));
34 CHECK(bkend.call_with_return("env", "as-loop-first", UINT32_C(0))->to_ui32() == UINT32_C(3));
35 CHECK(bkend.call_with_return("env", "as-loop-mid", UINT32_C(0))->to_ui32() == UINT32_C(4));
36 CHECK(bkend.call_with_return("env", "as-loop-last", UINT32_C(0))->to_ui32() == UINT32_C(5));
37 CHECK(bkend.call_with_return("env", "as-br-value", UINT32_C(0))->to_ui32() == UINT32_C(9));
38 CHECK(!bkend.call_with_return("env", "as-br_if-cond", UINT32_C(0)));
39 CHECK(bkend.call_with_return("env", "as-br_if-value", UINT32_C(0))->to_ui32() == UINT32_C(8));
40 CHECK(bkend.call_with_return("env", "as-br_if-value-cond", UINT32_C(0))->to_ui32() == UINT32_C(6));
41 CHECK(!bkend.call_with_return("env", "as-br_table-index", UINT32_C(0)));
42 CHECK(bkend.call_with_return("env", "as-br_table-value", UINT32_C(0))->to_ui32() == UINT32_C(10));
43 CHECK(bkend.call_with_return("env", "as-br_table-value-index", UINT32_C(0))->to_ui32() == UINT32_C(6));
44 CHECK(bkend.call_with_return("env", "as-return-value", UINT32_C(0))->to_ui32() == UINT32_C(7));
45 CHECK(bkend.call_with_return("env", "as-if-cond", UINT32_C(0))->to_ui32() == UINT32_C(0));
46 CHECK(bkend.call_with_return("env", "as-if-then", UINT32_C(1))->to_ui32() == UINT32_C(3));
47 CHECK(bkend.call_with_return("env", "as-if-else", UINT32_C(0))->to_ui32() == UINT32_C(4));
48 CHECK(bkend.call_with_return("env", "as-select-first", UINT32_C(0), UINT32_C(1))->to_ui32() == UINT32_C(5));
49 CHECK(bkend.call_with_return("env", "as-select-second", UINT32_C(0), UINT32_C(0))->to_ui32() == UINT32_C(6));
50 CHECK(bkend.call_with_return("env", "as-select-cond", UINT32_C(0))->to_ui32() == UINT32_C(0));
51 CHECK(bkend.call_with_return("env", "as-call-first", UINT32_C(0))->to_ui32() == UINT32_C(4294967295));
52 CHECK(bkend.call_with_return("env", "as-call-mid", UINT32_C(0))->to_ui32() == UINT32_C(4294967295));
53 CHECK(bkend.call_with_return("env", "as-call-last", UINT32_C(0))->to_ui32() == UINT32_C(4294967295));
54 CHECK(bkend.call_with_return("env", "as-call_indirect-first", UINT32_C(0))->to_ui32() == UINT32_C(4294967295));
55 CHECK(bkend.call_with_return("env", "as-call_indirect-mid", UINT32_C(0))->to_ui32() == UINT32_C(4294967295));
56 CHECK(bkend.call_with_return("env", "as-call_indirect-last", UINT32_C(0))->to_ui32() == UINT32_C(4294967295));
57 CHECK(bkend.call_with_return("env", "as-call_indirect-index", UINT32_C(0))->to_ui32() == UINT32_C(4294967295));
58 CHECK(!bkend.call_with_return("env", "as-local.set-value"));
59 CHECK(bkend.call_with_return("env", "as-local.tee-value", UINT32_C(0))->to_ui32() == UINT32_C(1));
60 CHECK(!bkend.call_with_return("env", "as-global.set-value"));
61 CHECK(bkend.call_with_return("env", "as-load-address", UINT32_C(0))->to_ui32() == UINT32_C(0));
62 CHECK(bkend.call_with_return("env", "as-loadN-address", UINT32_C(0))->to_ui32() == UINT32_C(0));
63 CHECK(!bkend.call_with_return("env", "as-store-address", UINT32_C(0)));
64 CHECK(!bkend.call_with_return("env", "as-store-value", UINT32_C(0)));
65 CHECK(!bkend.call_with_return("env", "as-storeN-address", UINT32_C(0)));
66 CHECK(!bkend.call_with_return("env", "as-storeN-value", UINT32_C(0)));
67 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "as-unary-operand", bit_cast<float>(UINT32_C(0)))->to_f32()) == UINT32_C(4286640610));
68 CHECK(bkend.call_with_return("env", "as-binary-left", UINT32_C(0))->to_ui32() == UINT32_C(13));
69 CHECK(bkend.call_with_return("env", "as-binary-right", UINT32_C(0))->to_ui32() == UINT32_C(6));
70 CHECK(bkend.call_with_return("env", "as-test-operand", UINT32_C(0))->to_ui32() == UINT32_C(1));
71 CHECK(bkend.call_with_return("env", "as-compare-left", UINT32_C(0))->to_ui32() == UINT32_C(0));
72 CHECK(bkend.call_with_return("env", "as-compare-right", UINT32_C(0))->to_ui32() == UINT32_C(1));
73 CHECK(bkend.call_with_return("env", "as-convert-operand", UINT64_C(0))->to_ui32() == UINT32_C(41));
74 CHECK(bkend.call_with_return("env", "as-memory.grow-size", UINT32_C(0))->to_ui32() == UINT32_C(1));
75 CHECK(!bkend.call_with_return("env", "type-mixed", UINT64_C(1), bit_cast<float>(UINT32_C(1074580685)), bit_cast<double>(UINT64_C(4614613358185178726)), UINT32_C(4), UINT32_C(5)));
76 CHECK(bkend.call_with_return("env", "write", UINT64_C(1), bit_cast<float>(UINT32_C(1073741824)), bit_cast<double>(UINT64_C(4614613358185178726)), UINT32_C(4), UINT32_C(5))->to_ui64() == UINT32_C(56));
77 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "result", UINT64_C(18446744073709551615), bit_cast<float>(UINT32_C(3221225472)), bit_cast<double>(UINT64_C(13837985395039954534)), UINT32_C(4294967292), UINT32_C(4294967291))->to_f64()) == UINT64_C(4630094481904264806));
78}
79
80BACKEND_TEST_CASE( "Testing wasm <local_tee_1_wasm>", "[local_tee_1_wasm_tests]" ) {
82 auto code = read_wasm( std::string(wasm_directory) + "local_tee.1.wasm");
83 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
84}
85
86BACKEND_TEST_CASE( "Testing wasm <local_tee_10_wasm>", "[local_tee_10_wasm_tests]" ) {
88 auto code = read_wasm( std::string(wasm_directory) + "local_tee.10.wasm");
89 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
90}
91
92BACKEND_TEST_CASE( "Testing wasm <local_tee_11_wasm>", "[local_tee_11_wasm_tests]" ) {
94 auto code = read_wasm( std::string(wasm_directory) + "local_tee.11.wasm");
95 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
96}
97
98BACKEND_TEST_CASE( "Testing wasm <local_tee_12_wasm>", "[local_tee_12_wasm_tests]" ) {
100 auto code = read_wasm( std::string(wasm_directory) + "local_tee.12.wasm");
101 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
102}
103
104BACKEND_TEST_CASE( "Testing wasm <local_tee_13_wasm>", "[local_tee_13_wasm_tests]" ) {
106 auto code = read_wasm( std::string(wasm_directory) + "local_tee.13.wasm");
107 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
108}
109
110BACKEND_TEST_CASE( "Testing wasm <local_tee_14_wasm>", "[local_tee_14_wasm_tests]" ) {
112 auto code = read_wasm( std::string(wasm_directory) + "local_tee.14.wasm");
113 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
114}
115
116BACKEND_TEST_CASE( "Testing wasm <local_tee_15_wasm>", "[local_tee_15_wasm_tests]" ) {
118 auto code = read_wasm( std::string(wasm_directory) + "local_tee.15.wasm");
119 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
120}
121
122BACKEND_TEST_CASE( "Testing wasm <local_tee_16_wasm>", "[local_tee_16_wasm_tests]" ) {
124 auto code = read_wasm( std::string(wasm_directory) + "local_tee.16.wasm");
125 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
126}
127
128BACKEND_TEST_CASE( "Testing wasm <local_tee_17_wasm>", "[local_tee_17_wasm_tests]" ) {
130 auto code = read_wasm( std::string(wasm_directory) + "local_tee.17.wasm");
131 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
132}
133
134BACKEND_TEST_CASE( "Testing wasm <local_tee_18_wasm>", "[local_tee_18_wasm_tests]" ) {
136 auto code = read_wasm( std::string(wasm_directory) + "local_tee.18.wasm");
137 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
138}
139
140BACKEND_TEST_CASE( "Testing wasm <local_tee_19_wasm>", "[local_tee_19_wasm_tests]" ) {
142 auto code = read_wasm( std::string(wasm_directory) + "local_tee.19.wasm");
143 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
144}
145
146BACKEND_TEST_CASE( "Testing wasm <local_tee_2_wasm>", "[local_tee_2_wasm_tests]" ) {
148 auto code = read_wasm( std::string(wasm_directory) + "local_tee.2.wasm");
149 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
150}
151
152BACKEND_TEST_CASE( "Testing wasm <local_tee_20_wasm>", "[local_tee_20_wasm_tests]" ) {
154 auto code = read_wasm( std::string(wasm_directory) + "local_tee.20.wasm");
155 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
156}
157
158BACKEND_TEST_CASE( "Testing wasm <local_tee_21_wasm>", "[local_tee_21_wasm_tests]" ) {
160 auto code = read_wasm( std::string(wasm_directory) + "local_tee.21.wasm");
161 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
162}
163
164BACKEND_TEST_CASE( "Testing wasm <local_tee_22_wasm>", "[local_tee_22_wasm_tests]" ) {
166 auto code = read_wasm( std::string(wasm_directory) + "local_tee.22.wasm");
167 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
168}
169
170BACKEND_TEST_CASE( "Testing wasm <local_tee_23_wasm>", "[local_tee_23_wasm_tests]" ) {
172 auto code = read_wasm( std::string(wasm_directory) + "local_tee.23.wasm");
173 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
174}
175
176BACKEND_TEST_CASE( "Testing wasm <local_tee_24_wasm>", "[local_tee_24_wasm_tests]" ) {
178 auto code = read_wasm( std::string(wasm_directory) + "local_tee.24.wasm");
179 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
180}
181
182BACKEND_TEST_CASE( "Testing wasm <local_tee_25_wasm>", "[local_tee_25_wasm_tests]" ) {
184 auto code = read_wasm( std::string(wasm_directory) + "local_tee.25.wasm");
185 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
186}
187
188BACKEND_TEST_CASE( "Testing wasm <local_tee_26_wasm>", "[local_tee_26_wasm_tests]" ) {
190 auto code = read_wasm( std::string(wasm_directory) + "local_tee.26.wasm");
191 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
192}
193
194BACKEND_TEST_CASE( "Testing wasm <local_tee_27_wasm>", "[local_tee_27_wasm_tests]" ) {
196 auto code = read_wasm( std::string(wasm_directory) + "local_tee.27.wasm");
197 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
198}
199
200BACKEND_TEST_CASE( "Testing wasm <local_tee_28_wasm>", "[local_tee_28_wasm_tests]" ) {
202 auto code = read_wasm( std::string(wasm_directory) + "local_tee.28.wasm");
203 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
204}
205
206BACKEND_TEST_CASE( "Testing wasm <local_tee_29_wasm>", "[local_tee_29_wasm_tests]" ) {
208 auto code = read_wasm( std::string(wasm_directory) + "local_tee.29.wasm");
209 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
210}
211
212BACKEND_TEST_CASE( "Testing wasm <local_tee_3_wasm>", "[local_tee_3_wasm_tests]" ) {
214 auto code = read_wasm( std::string(wasm_directory) + "local_tee.3.wasm");
215 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
216}
217
218BACKEND_TEST_CASE( "Testing wasm <local_tee_30_wasm>", "[local_tee_30_wasm_tests]" ) {
220 auto code = read_wasm( std::string(wasm_directory) + "local_tee.30.wasm");
221 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
222}
223
224BACKEND_TEST_CASE( "Testing wasm <local_tee_31_wasm>", "[local_tee_31_wasm_tests]" ) {
226 auto code = read_wasm( std::string(wasm_directory) + "local_tee.31.wasm");
227 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
228}
229
230BACKEND_TEST_CASE( "Testing wasm <local_tee_32_wasm>", "[local_tee_32_wasm_tests]" ) {
232 auto code = read_wasm( std::string(wasm_directory) + "local_tee.32.wasm");
233 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
234}
235
236BACKEND_TEST_CASE( "Testing wasm <local_tee_33_wasm>", "[local_tee_33_wasm_tests]" ) {
238 auto code = read_wasm( std::string(wasm_directory) + "local_tee.33.wasm");
239 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
240}
241
242BACKEND_TEST_CASE( "Testing wasm <local_tee_34_wasm>", "[local_tee_34_wasm_tests]" ) {
244 auto code = read_wasm( std::string(wasm_directory) + "local_tee.34.wasm");
245 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
246}
247
248BACKEND_TEST_CASE( "Testing wasm <local_tee_35_wasm>", "[local_tee_35_wasm_tests]" ) {
250 auto code = read_wasm( std::string(wasm_directory) + "local_tee.35.wasm");
251 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
252}
253
254BACKEND_TEST_CASE( "Testing wasm <local_tee_36_wasm>", "[local_tee_36_wasm_tests]" ) {
256 auto code = read_wasm( std::string(wasm_directory) + "local_tee.36.wasm");
257 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
258}
259
260BACKEND_TEST_CASE( "Testing wasm <local_tee_37_wasm>", "[local_tee_37_wasm_tests]" ) {
262 auto code = read_wasm( std::string(wasm_directory) + "local_tee.37.wasm");
263 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
264}
265
266BACKEND_TEST_CASE( "Testing wasm <local_tee_38_wasm>", "[local_tee_38_wasm_tests]" ) {
268 auto code = read_wasm( std::string(wasm_directory) + "local_tee.38.wasm");
269 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
270}
271
272BACKEND_TEST_CASE( "Testing wasm <local_tee_39_wasm>", "[local_tee_39_wasm_tests]" ) {
274 auto code = read_wasm( std::string(wasm_directory) + "local_tee.39.wasm");
275 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
276}
277
278BACKEND_TEST_CASE( "Testing wasm <local_tee_4_wasm>", "[local_tee_4_wasm_tests]" ) {
280 auto code = read_wasm( std::string(wasm_directory) + "local_tee.4.wasm");
281 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
282}
283
284BACKEND_TEST_CASE( "Testing wasm <local_tee_40_wasm>", "[local_tee_40_wasm_tests]" ) {
286 auto code = read_wasm( std::string(wasm_directory) + "local_tee.40.wasm");
287 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
288}
289
290BACKEND_TEST_CASE( "Testing wasm <local_tee_41_wasm>", "[local_tee_41_wasm_tests]" ) {
292 auto code = read_wasm( std::string(wasm_directory) + "local_tee.41.wasm");
293 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
294}
295
296BACKEND_TEST_CASE( "Testing wasm <local_tee_5_wasm>", "[local_tee_5_wasm_tests]" ) {
298 auto code = read_wasm( std::string(wasm_directory) + "local_tee.5.wasm");
299 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
300}
301
302BACKEND_TEST_CASE( "Testing wasm <local_tee_6_wasm>", "[local_tee_6_wasm_tests]" ) {
304 auto code = read_wasm( std::string(wasm_directory) + "local_tee.6.wasm");
305 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
306}
307
308BACKEND_TEST_CASE( "Testing wasm <local_tee_7_wasm>", "[local_tee_7_wasm_tests]" ) {
310 auto code = read_wasm( std::string(wasm_directory) + "local_tee.7.wasm");
311 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
312}
313
314BACKEND_TEST_CASE( "Testing wasm <local_tee_8_wasm>", "[local_tee_8_wasm_tests]" ) {
316 auto code = read_wasm( std::string(wasm_directory) + "local_tee.8.wasm");
317 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
318}
319
320BACKEND_TEST_CASE( "Testing wasm <local_tee_9_wasm>", "[local_tee_9_wasm_tests]" ) {
322 auto code = read_wasm( std::string(wasm_directory) + "local_tee.9.wasm");
323 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
324}
325
auto call_with_return(host_t &host, const std::string_view &mod, const std::string_view &func, Args... args)
Definition backend.hpp:178
#define CHECK(cond)
Definition util.h:80
backend_t bkend(hello_wasm, ehm, &wa)
sysio::vm::backend< rhf_t > backend_t
#define CHECK_THROWS_AS(expr, exceptionType)
Definition catch.hpp:203
wasm_allocator wa
Definition main.cpp:10
std::vector< uint8_t > read_wasm(const std::string &fname)
Definition utils.hpp:30
#define UINT32_C(val)
Definition stdint.h:283
#define UINT64_C(val)
Definition stdint.h:284
#define BACKEND_TEST_CASE(name, tags)
Definition utils.hpp:59
T bit_cast(const U &u)
Definition utils.hpp:35