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
14using namespace sysio;
15using namespace sysio::vm;
16extern wasm_allocator wa;
17
18BACKEND_TEST_CASE( "Testing wasm <memory_0_wasm>", "[memory_0_wasm_tests]" ) {
20 auto code = read_wasm( std::string(wasm_directory) + "memory.0.wasm");
21 backend_t bkend( code, &wa );
22
23}
24
25BACKEND_TEST_CASE( "Testing wasm <memory_1_wasm>", "[memory_1_wasm_tests]" ) {
27 auto code = read_wasm( std::string(wasm_directory) + "memory.1.wasm");
28 backend_t bkend( code, &wa );
29
30}
31
32BACKEND_TEST_CASE( "Testing wasm <memory_10_wasm>", "[memory_10_wasm_tests]" ) {
34 auto code = read_wasm( std::string(wasm_directory) + "memory.10.wasm");
35 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
36}
37
38BACKEND_TEST_CASE( "Testing wasm <memory_11_wasm>", "[memory_11_wasm_tests]" ) {
40 auto code = read_wasm( std::string(wasm_directory) + "memory.11.wasm");
41 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
42}
43
44BACKEND_TEST_CASE( "Testing wasm <memory_12_wasm>", "[memory_12_wasm_tests]" ) {
46 auto code = read_wasm( std::string(wasm_directory) + "memory.12.wasm");
47 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
48}
49
50BACKEND_TEST_CASE( "Testing wasm <memory_13_wasm>", "[memory_13_wasm_tests]" ) {
52 auto code = read_wasm( std::string(wasm_directory) + "memory.13.wasm");
53 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
54}
55
56BACKEND_TEST_CASE( "Testing wasm <memory_14_wasm>", "[memory_14_wasm_tests]" ) {
58 auto code = read_wasm( std::string(wasm_directory) + "memory.14.wasm");
59 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
60}
61
62BACKEND_TEST_CASE( "Testing wasm <memory_15_wasm>", "[memory_15_wasm_tests]" ) {
64 auto code = read_wasm( std::string(wasm_directory) + "memory.15.wasm");
65 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
66}
67
68BACKEND_TEST_CASE( "Testing wasm <memory_16_wasm>", "[memory_16_wasm_tests]" ) {
70 auto code = read_wasm( std::string(wasm_directory) + "memory.16.wasm");
71 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
72}
73
74BACKEND_TEST_CASE( "Testing wasm <memory_17_wasm>", "[memory_17_wasm_tests]" ) {
76 auto code = read_wasm( std::string(wasm_directory) + "memory.17.wasm");
77 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
78}
79
80BACKEND_TEST_CASE( "Testing wasm <memory_18_wasm>", "[memory_18_wasm_tests]" ) {
82 auto code = read_wasm( std::string(wasm_directory) + "memory.18.wasm");
83 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
84}
85
86BACKEND_TEST_CASE( "Testing wasm <memory_19_wasm>", "[memory_19_wasm_tests]" ) {
88 auto code = read_wasm( std::string(wasm_directory) + "memory.19.wasm");
89 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
90}
91
92BACKEND_TEST_CASE( "Testing wasm <memory_2_wasm>", "[memory_2_wasm_tests]" ) {
94 auto code = read_wasm( std::string(wasm_directory) + "memory.2.wasm");
95 backend_t bkend( code, &wa );
96
97}
98
99BACKEND_TEST_CASE( "Testing wasm <memory_20_wasm>", "[memory_20_wasm_tests]" ) {
101 auto code = read_wasm( std::string(wasm_directory) + "memory.20.wasm");
102 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
103}
104
105BACKEND_TEST_CASE( "Testing wasm <memory_21_wasm>", "[memory_21_wasm_tests]" ) {
107 auto code = read_wasm( std::string(wasm_directory) + "memory.21.wasm");
108 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
109}
110
111BACKEND_TEST_CASE( "Testing wasm <memory_22_wasm>", "[memory_22_wasm_tests]" ) {
113 auto code = read_wasm( std::string(wasm_directory) + "memory.22.wasm");
114 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
115}
116
117BACKEND_TEST_CASE( "Testing wasm <memory_23_wasm>", "[memory_23_wasm_tests]" ) {
119 auto code = read_wasm( std::string(wasm_directory) + "memory.23.wasm");
120 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
121}
122
123BACKEND_TEST_CASE( "Testing wasm <memory_24_wasm>", "[memory_24_wasm_tests]" ) {
125 auto code = read_wasm( std::string(wasm_directory) + "memory.24.wasm");
126 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
127}
128
129BACKEND_TEST_CASE( "Testing wasm <memory_25_wasm>", "[memory_25_wasm_tests]" ) {
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
178BACKEND_TEST_CASE( "Testing wasm <memory_3_wasm>", "[memory_3_wasm_tests]" ) {
180 auto code = read_wasm( std::string(wasm_directory) + "memory.3.wasm");
181 backend_t bkend( code, &wa );
182
183}
184
185BACKEND_TEST_CASE( "Testing wasm <memory_4_wasm>", "[memory_4_wasm_tests]" ) {
187 auto code = read_wasm( std::string(wasm_directory) + "memory.4.wasm");
188 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
189}
190
191BACKEND_TEST_CASE( "Testing wasm <memory_5_wasm>", "[memory_5_wasm_tests]" ) {
193 auto code = read_wasm( std::string(wasm_directory) + "memory.5.wasm");
194 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
195}
196
197BACKEND_TEST_CASE( "Testing wasm <memory_6_wasm>", "[memory_6_wasm_tests]" ) {
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
205BACKEND_TEST_CASE( "Testing wasm <memory_7_wasm>", "[memory_7_wasm_tests]" ) {
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
213BACKEND_TEST_CASE( "Testing wasm <memory_8_wasm>", "[memory_8_wasm_tests]" ) {
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
221BACKEND_TEST_CASE( "Testing wasm <memory_9_wasm>", "[memory_9_wasm_tests]" ) {
223 auto code = read_wasm( std::string(wasm_directory) + "memory.9.wasm");
224 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
225}
226
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