Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
br_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 <br_0_wasm>", "[br_0_wasm_tests]" ) {
20 auto code = read_wasm( std::string(wasm_directory) + "br.0.wasm");
21 backend_t bkend( code, &wa );
22
23 CHECK(!bkend.call_with_return("env", "type-i32"));
24 CHECK(!bkend.call_with_return("env", "type-i64"));
25 CHECK(!bkend.call_with_return("env", "type-f32"));
26 CHECK(!bkend.call_with_return("env", "type-f64"));
27 CHECK(bkend.call_with_return("env", "type-i32-value")->to_ui32() == UINT32_C(1));
28 CHECK(bkend.call_with_return("env", "type-i64-value")->to_ui64() == UINT32_C(2));
29 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "type-f32-value")->to_f32()) == UINT32_C(1077936128));
30 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "type-f64-value")->to_f64()) == UINT64_C(4616189618054758400));
31 CHECK(!bkend.call_with_return("env", "as-block-first"));
32 CHECK(!bkend.call_with_return("env", "as-block-mid"));
33 CHECK(!bkend.call_with_return("env", "as-block-last"));
34 CHECK(bkend.call_with_return("env", "as-block-value")->to_ui32() == UINT32_C(2));
35 CHECK(bkend.call_with_return("env", "as-loop-first")->to_ui32() == UINT32_C(3));
36 CHECK(bkend.call_with_return("env", "as-loop-mid")->to_ui32() == UINT32_C(4));
37 CHECK(bkend.call_with_return("env", "as-loop-last")->to_ui32() == UINT32_C(5));
38 CHECK(bkend.call_with_return("env", "as-br-value")->to_ui32() == UINT32_C(9));
39 CHECK(!bkend.call_with_return("env", "as-br_if-cond"));
40 CHECK(bkend.call_with_return("env", "as-br_if-value")->to_ui32() == UINT32_C(8));
41 CHECK(bkend.call_with_return("env", "as-br_if-value-cond")->to_ui32() == UINT32_C(9));
42 CHECK(!bkend.call_with_return("env", "as-br_table-index"));
43 CHECK(bkend.call_with_return("env", "as-br_table-value")->to_ui32() == UINT32_C(10));
44 CHECK(bkend.call_with_return("env", "as-br_table-value-index")->to_ui32() == UINT32_C(11));
45 CHECK(bkend.call_with_return("env", "as-return-value")->to_ui64() == UINT32_C(7));
46 CHECK(bkend.call_with_return("env", "as-if-cond")->to_ui32() == UINT32_C(2));
47 CHECK(bkend.call_with_return("env", "as-if-then", UINT32_C(1), UINT32_C(6))->to_ui32() == UINT32_C(3));
48 CHECK(bkend.call_with_return("env", "as-if-then", UINT32_C(0), UINT32_C(6))->to_ui32() == UINT32_C(6));
49 CHECK(bkend.call_with_return("env", "as-if-else", UINT32_C(0), UINT32_C(6))->to_ui32() == UINT32_C(4));
50 CHECK(bkend.call_with_return("env", "as-if-else", UINT32_C(1), UINT32_C(6))->to_ui32() == UINT32_C(6));
51 CHECK(bkend.call_with_return("env", "as-select-first", UINT32_C(0), UINT32_C(6))->to_ui32() == UINT32_C(5));
52 CHECK(bkend.call_with_return("env", "as-select-first", UINT32_C(1), UINT32_C(6))->to_ui32() == UINT32_C(5));
53 CHECK(bkend.call_with_return("env", "as-select-second", UINT32_C(0), UINT32_C(6))->to_ui32() == UINT32_C(6));
54 CHECK(bkend.call_with_return("env", "as-select-second", UINT32_C(1), UINT32_C(6))->to_ui32() == UINT32_C(6));
55 CHECK(bkend.call_with_return("env", "as-select-cond")->to_ui32() == UINT32_C(7));
56 CHECK(bkend.call_with_return("env", "as-call-first")->to_ui32() == UINT32_C(12));
57 CHECK(bkend.call_with_return("env", "as-call-mid")->to_ui32() == UINT32_C(13));
58 CHECK(bkend.call_with_return("env", "as-call-last")->to_ui32() == UINT32_C(14));
59 CHECK(bkend.call_with_return("env", "as-call_indirect-func")->to_ui32() == UINT32_C(20));
60 CHECK(bkend.call_with_return("env", "as-call_indirect-first")->to_ui32() == UINT32_C(21));
61 CHECK(bkend.call_with_return("env", "as-call_indirect-mid")->to_ui32() == UINT32_C(22));
62 CHECK(bkend.call_with_return("env", "as-call_indirect-last")->to_ui32() == UINT32_C(23));
63 CHECK(bkend.call_with_return("env", "as-local.set-value")->to_ui32() == UINT32_C(17));
64 CHECK(bkend.call_with_return("env", "as-local.tee-value")->to_ui32() == UINT32_C(1));
65 CHECK(bkend.call_with_return("env", "as-global.set-value")->to_ui32() == UINT32_C(1));
66 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "as-load-address")->to_f32()) == UINT32_C(1071225242));
67 CHECK(bkend.call_with_return("env", "as-loadN-address")->to_ui64() == UINT32_C(30));
68 CHECK(bkend.call_with_return("env", "as-store-address")->to_ui32() == UINT32_C(30));
69 CHECK(bkend.call_with_return("env", "as-store-value")->to_ui32() == UINT32_C(31));
70 CHECK(bkend.call_with_return("env", "as-storeN-address")->to_ui32() == UINT32_C(32));
71 CHECK(bkend.call_with_return("env", "as-storeN-value")->to_ui32() == UINT32_C(33));
72 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "as-unary-operand")->to_f32()) == UINT32_C(1079613850));
73 CHECK(bkend.call_with_return("env", "as-binary-left")->to_ui32() == UINT32_C(3));
74 CHECK(bkend.call_with_return("env", "as-binary-right")->to_ui64() == UINT32_C(45));
75 CHECK(bkend.call_with_return("env", "as-test-operand")->to_ui32() == UINT32_C(44));
76 CHECK(bkend.call_with_return("env", "as-compare-left")->to_ui32() == UINT32_C(43));
77 CHECK(bkend.call_with_return("env", "as-compare-right")->to_ui32() == UINT32_C(42));
78 CHECK(bkend.call_with_return("env", "as-convert-operand")->to_ui32() == UINT32_C(41));
79 CHECK(bkend.call_with_return("env", "as-memory.grow-size")->to_ui32() == UINT32_C(40));
80 CHECK(bkend.call_with_return("env", "nested-block-value")->to_ui32() == UINT32_C(9));
81 CHECK(bkend.call_with_return("env", "nested-br-value")->to_ui32() == UINT32_C(9));
82 CHECK(bkend.call_with_return("env", "nested-br_if-value")->to_ui32() == UINT32_C(9));
83 CHECK(bkend.call_with_return("env", "nested-br_if-value-cond")->to_ui32() == UINT32_C(9));
84 CHECK(bkend.call_with_return("env", "nested-br_table-value")->to_ui32() == UINT32_C(9));
85 CHECK(bkend.call_with_return("env", "nested-br_table-value-index")->to_ui32() == UINT32_C(9));
86}
87
88BACKEND_TEST_CASE( "Testing wasm <br_1_wasm>", "[br_1_wasm_tests]" ) {
90 auto code = read_wasm( std::string(wasm_directory) + "br.1.wasm");
91 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
92}
93
94BACKEND_TEST_CASE( "Testing wasm <br_10_wasm>", "[br_10_wasm_tests]" ) {
96 auto code = read_wasm( std::string(wasm_directory) + "br.10.wasm");
97 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
98}
99
100BACKEND_TEST_CASE( "Testing wasm <br_11_wasm>", "[br_11_wasm_tests]" ) {
102 auto code = read_wasm( std::string(wasm_directory) + "br.11.wasm");
103 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
104}
105
106BACKEND_TEST_CASE( "Testing wasm <br_12_wasm>", "[br_12_wasm_tests]" ) {
108 auto code = read_wasm( std::string(wasm_directory) + "br.12.wasm");
109 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
110}
111
112BACKEND_TEST_CASE( "Testing wasm <br_13_wasm>", "[br_13_wasm_tests]" ) {
114 auto code = read_wasm( std::string(wasm_directory) + "br.13.wasm");
115 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
116}
117
118BACKEND_TEST_CASE( "Testing wasm <br_14_wasm>", "[br_14_wasm_tests]" ) {
120 auto code = read_wasm( std::string(wasm_directory) + "br.14.wasm");
121 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
122}
123
124BACKEND_TEST_CASE( "Testing wasm <br_15_wasm>", "[br_15_wasm_tests]" ) {
126 auto code = read_wasm( std::string(wasm_directory) + "br.15.wasm");
127 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
128}
129
130BACKEND_TEST_CASE( "Testing wasm <br_16_wasm>", "[br_16_wasm_tests]" ) {
132 auto code = read_wasm( std::string(wasm_directory) + "br.16.wasm");
133 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
134}
135
136BACKEND_TEST_CASE( "Testing wasm <br_17_wasm>", "[br_17_wasm_tests]" ) {
138 auto code = read_wasm( std::string(wasm_directory) + "br.17.wasm");
139 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
140}
141
142BACKEND_TEST_CASE( "Testing wasm <br_18_wasm>", "[br_18_wasm_tests]" ) {
144 auto code = read_wasm( std::string(wasm_directory) + "br.18.wasm");
145 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
146}
147
148BACKEND_TEST_CASE( "Testing wasm <br_19_wasm>", "[br_19_wasm_tests]" ) {
150 auto code = read_wasm( std::string(wasm_directory) + "br.19.wasm");
151 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
152}
153
154BACKEND_TEST_CASE( "Testing wasm <br_2_wasm>", "[br_2_wasm_tests]" ) {
156 auto code = read_wasm( std::string(wasm_directory) + "br.2.wasm");
157 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
158}
159
160BACKEND_TEST_CASE( "Testing wasm <br_20_wasm>", "[br_20_wasm_tests]" ) {
162 auto code = read_wasm( std::string(wasm_directory) + "br.20.wasm");
163 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
164}
165
166BACKEND_TEST_CASE( "Testing wasm <br_3_wasm>", "[br_3_wasm_tests]" ) {
168 auto code = read_wasm( std::string(wasm_directory) + "br.3.wasm");
169 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
170}
171
172BACKEND_TEST_CASE( "Testing wasm <br_4_wasm>", "[br_4_wasm_tests]" ) {
174 auto code = read_wasm( std::string(wasm_directory) + "br.4.wasm");
175 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
176}
177
178BACKEND_TEST_CASE( "Testing wasm <br_5_wasm>", "[br_5_wasm_tests]" ) {
180 auto code = read_wasm( std::string(wasm_directory) + "br.5.wasm");
181 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
182}
183
184BACKEND_TEST_CASE( "Testing wasm <br_6_wasm>", "[br_6_wasm_tests]" ) {
186 auto code = read_wasm( std::string(wasm_directory) + "br.6.wasm");
187 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
188}
189
190BACKEND_TEST_CASE( "Testing wasm <br_7_wasm>", "[br_7_wasm_tests]" ) {
192 auto code = read_wasm( std::string(wasm_directory) + "br.7.wasm");
193 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
194}
195
196BACKEND_TEST_CASE( "Testing wasm <br_8_wasm>", "[br_8_wasm_tests]" ) {
198 auto code = read_wasm( std::string(wasm_directory) + "br.8.wasm");
199 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
200}
201
202BACKEND_TEST_CASE( "Testing wasm <br_9_wasm>", "[br_9_wasm_tests]" ) {
204 auto code = read_wasm( std::string(wasm_directory) + "br.9.wasm");
205 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
206}
207
wasm_allocator wa
Definition main.cpp:10
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
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