Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
globals_tests.cpp File Reference
#include <algorithm>
#include <vector>
#include <iostream>
#include <iterator>
#include <cmath>
#include <cstdlib>
#include <catch2/catch.hpp>
#include <utils.hpp>
#include <wasm_config.hpp>
#include <sysio/vm/backend.hpp>
Include dependency graph for globals_tests.cpp:

Go to the source code of this file.

Functions

 BACKEND_TEST_CASE ("Testing wasm <globals_0_wasm>", "[globals_0_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <globals_1_wasm>", "[globals_1_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <globals_10_wasm>", "[globals_10_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <globals_11_wasm>", "[globals_11_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <globals_12_wasm>", "[globals_12_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <globals_13_wasm>", "[globals_13_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <globals_15_wasm>", "[globals_15_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <globals_16_wasm>", "[globals_16_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <globals_17_wasm>", "[globals_17_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <globals_18_wasm>", "[globals_18_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <globals_19_wasm>", "[globals_19_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <globals_2_wasm>", "[globals_2_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <globals_20_wasm>", "[globals_20_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <globals_21_wasm>", "[globals_21_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <globals_22_wasm>", "[globals_22_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <globals_23_wasm>", "[globals_23_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <globals_24_wasm>", "[globals_24_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <globals_25_wasm>", "[globals_25_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <globals_26_wasm>", "[globals_26_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <globals_27_wasm>", "[globals_27_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <globals_28_wasm>", "[globals_28_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <globals_29_wasm>", "[globals_29_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <globals_3_wasm>", "[globals_3_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <globals_30_wasm>", "[globals_30_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <globals_31_wasm>", "[globals_31_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <globals_4_wasm>", "[globals_4_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <globals_5_wasm>", "[globals_5_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <globals_6_wasm>", "[globals_6_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <globals_7_wasm>", "[globals_7_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <globals_8_wasm>", "[globals_8_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <globals_9_wasm>", "[globals_9_wasm_tests]")
 

Variables

wasm_allocator wa
 

Function Documentation

◆ BACKEND_TEST_CASE() [1/31]

BACKEND_TEST_CASE ( "Testing wasm <globals_0_wasm>" ,
"" [globals_0_wasm_tests] )

Definition at line 18 of file globals_tests.cpp.

18 {
20 auto code = read_wasm( std::string(wasm_directory) + "globals.0.wasm");
21 backend_t bkend( code, &wa );
22
23 CHECK(bkend.call_with_return("env", "get-a")->to_ui32() == UINT32_C(4294967294));
24 CHECK(bkend.call_with_return("env", "get-b")->to_ui64() == UINT32_C(18446744073709551611));
25 CHECK(bkend.call_with_return("env", "get-x")->to_ui32() == UINT32_C(4294967284));
26 CHECK(bkend.call_with_return("env", "get-y")->to_ui64() == UINT32_C(18446744073709551601));
27 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "get-1")->to_f32()) == UINT32_C(3225419776));
28 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "get-2")->to_f64()) == UINT64_C(13839561654909534208));
29 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "get-5")->to_f32()) == UINT32_C(3243245568));
30 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "get-6")->to_f64()) == UINT64_C(13847442954257432576));
31 CHECK(!bkend.call_with_return("env", "set-x", UINT32_C(6)));
32 CHECK(!bkend.call_with_return("env", "set-y", UINT64_C(7)));
33 CHECK(!bkend.call_with_return("env", "set-5", bit_cast<float>(UINT32_C(1090519040))));
34 CHECK(!bkend.call_with_return("env", "set-6", bit_cast<double>(UINT64_C(4621256167635550208))));
35 CHECK(bkend.call_with_return("env", "get-x")->to_ui32() == UINT32_C(6));
36 CHECK(bkend.call_with_return("env", "get-y")->to_ui64() == UINT32_C(7));
37 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "get-5")->to_f32()) == UINT32_C(1090519040));
38 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "get-6")->to_f64()) == UINT64_C(4621256167635550208));
39 CHECK(bkend.call_with_return("env", "as-select-first")->to_ui32() == UINT32_C(6));
40 CHECK(bkend.call_with_return("env", "as-select-mid")->to_ui32() == UINT32_C(2));
41 CHECK(bkend.call_with_return("env", "as-select-last")->to_ui32() == UINT32_C(2));
42 CHECK(bkend.call_with_return("env", "as-loop-first")->to_ui32() == UINT32_C(6));
43 CHECK(bkend.call_with_return("env", "as-loop-mid")->to_ui32() == UINT32_C(6));
44 CHECK(bkend.call_with_return("env", "as-loop-last")->to_ui32() == UINT32_C(6));
45 CHECK(bkend.call_with_return("env", "as-if-condition")->to_ui32() == UINT32_C(2));
46 CHECK(bkend.call_with_return("env", "as-if-then")->to_ui32() == UINT32_C(6));
47 CHECK(bkend.call_with_return("env", "as-if-else")->to_ui32() == UINT32_C(6));
48 CHECK(bkend.call_with_return("env", "as-br_if-first")->to_ui32() == UINT32_C(6));
49 CHECK(bkend.call_with_return("env", "as-br_if-last")->to_ui32() == UINT32_C(2));
50 CHECK(bkend.call_with_return("env", "as-br_table-first")->to_ui32() == UINT32_C(6));
51 CHECK(bkend.call_with_return("env", "as-br_table-last")->to_ui32() == UINT32_C(2));
52 CHECK(bkend.call_with_return("env", "as-call_indirect-first")->to_ui32() == UINT32_C(6));
53 CHECK(bkend.call_with_return("env", "as-call_indirect-mid")->to_ui32() == UINT32_C(2));
54 CHECK_THROWS_AS(bkend("env", "as-call_indirect-last"), std::exception);
55 CHECK(!bkend.call_with_return("env", "as-store-first"));
56 CHECK(!bkend.call_with_return("env", "as-store-last"));
57 CHECK(bkend.call_with_return("env", "as-load-operand")->to_ui32() == UINT32_C(1));
58 CHECK(bkend.call_with_return("env", "as-memory.grow-value")->to_ui32() == UINT32_C(1));
59 CHECK(bkend.call_with_return("env", "as-call-value")->to_ui32() == UINT32_C(6));
60 CHECK(bkend.call_with_return("env", "as-return-value")->to_ui32() == UINT32_C(6));
61 CHECK(!bkend.call_with_return("env", "as-drop-operand"));
62 CHECK(bkend.call_with_return("env", "as-br-value")->to_ui32() == UINT32_C(6));
63 CHECK(bkend.call_with_return("env", "as-local.set-value", UINT32_C(1))->to_ui32() == UINT32_C(6));
64 CHECK(bkend.call_with_return("env", "as-local.tee-value", UINT32_C(1))->to_ui32() == UINT32_C(6));
65 CHECK(bkend.call_with_return("env", "as-global.set-value")->to_ui32() == UINT32_C(6));
66 CHECK(bkend.call_with_return("env", "as-unary-operand")->to_ui32() == UINT32_C(0));
67 CHECK(bkend.call_with_return("env", "as-binary-operand")->to_ui32() == UINT32_C(36));
68 CHECK(bkend.call_with_return("env", "as-compare-operand")->to_ui32() == UINT32_C(1));
69}
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
wasm_allocator wa
Definition main.cpp:10
backend_t bkend(hello_wasm, ehm, &wa)
#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
T bit_cast(const U &u)
Definition utils.hpp:35
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [2/31]

BACKEND_TEST_CASE ( "Testing wasm <globals_10_wasm>" ,
"" [globals_10_wasm_tests] )

Definition at line 77 of file globals_tests.cpp.

77 {
79 auto code = read_wasm( std::string(wasm_directory) + "globals.10.wasm");
80 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
81}
sysio::vm::backend< rhf_t > backend_t
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [3/31]

BACKEND_TEST_CASE ( "Testing wasm <globals_11_wasm>" ,
"" [globals_11_wasm_tests] )

Definition at line 83 of file globals_tests.cpp.

83 {
85 auto code = read_wasm( std::string(wasm_directory) + "globals.11.wasm");
86 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
87}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [4/31]

BACKEND_TEST_CASE ( "Testing wasm <globals_12_wasm>" ,
"" [globals_12_wasm_tests] )

Definition at line 89 of file globals_tests.cpp.

89 {
91 auto code = read_wasm( std::string(wasm_directory) + "globals.12.wasm");
92 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
93}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [5/31]

BACKEND_TEST_CASE ( "Testing wasm <globals_13_wasm>" ,
"" [globals_13_wasm_tests] )

Definition at line 95 of file globals_tests.cpp.

95 {
97 auto code = read_wasm( std::string(wasm_directory) + "globals.13.wasm");
98 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
99}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [6/31]

BACKEND_TEST_CASE ( "Testing wasm <globals_15_wasm>" ,
"" [globals_15_wasm_tests] )

Definition at line 101 of file globals_tests.cpp.

101 {
103 auto code = read_wasm( std::string(wasm_directory) + "globals.15.wasm");
104 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
105}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [7/31]

BACKEND_TEST_CASE ( "Testing wasm <globals_16_wasm>" ,
"" [globals_16_wasm_tests] )

Definition at line 107 of file globals_tests.cpp.

107 {
109 auto code = read_wasm( std::string(wasm_directory) + "globals.16.wasm");
110 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
111}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [8/31]

BACKEND_TEST_CASE ( "Testing wasm <globals_17_wasm>" ,
"" [globals_17_wasm_tests] )

Definition at line 113 of file globals_tests.cpp.

113 {
115 auto code = read_wasm( std::string(wasm_directory) + "globals.17.wasm");
116 backend_t bkend( code, &wa );
117
118}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [9/31]

BACKEND_TEST_CASE ( "Testing wasm <globals_18_wasm>" ,
"" [globals_18_wasm_tests] )

Definition at line 120 of file globals_tests.cpp.

120 {
122 auto code = read_wasm( std::string(wasm_directory) + "globals.18.wasm");
123 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
124}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [10/31]

BACKEND_TEST_CASE ( "Testing wasm <globals_19_wasm>" ,
"" [globals_19_wasm_tests] )

Definition at line 126 of file globals_tests.cpp.

126 {
128 auto code = read_wasm( std::string(wasm_directory) + "globals.19.wasm");
129 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
130}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [11/31]

BACKEND_TEST_CASE ( "Testing wasm <globals_1_wasm>" ,
"" [globals_1_wasm_tests] )

Definition at line 71 of file globals_tests.cpp.

71 {
73 auto code = read_wasm( std::string(wasm_directory) + "globals.1.wasm");
74 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
75}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [12/31]

BACKEND_TEST_CASE ( "Testing wasm <globals_20_wasm>" ,
"" [globals_20_wasm_tests] )

Definition at line 139 of file globals_tests.cpp.

139 {
141 auto code = read_wasm( std::string(wasm_directory) + "globals.20.wasm");
142 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
143}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [13/31]

BACKEND_TEST_CASE ( "Testing wasm <globals_21_wasm>" ,
"" [globals_21_wasm_tests] )

Definition at line 145 of file globals_tests.cpp.

145 {
147 auto code = read_wasm( std::string(wasm_directory) + "globals.21.wasm");
148 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
149}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [14/31]

BACKEND_TEST_CASE ( "Testing wasm <globals_22_wasm>" ,
"" [globals_22_wasm_tests] )

Definition at line 151 of file globals_tests.cpp.

151 {
153 auto code = read_wasm( std::string(wasm_directory) + "globals.22.wasm");
154 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
155}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [15/31]

BACKEND_TEST_CASE ( "Testing wasm <globals_23_wasm>" ,
"" [globals_23_wasm_tests] )

Definition at line 157 of file globals_tests.cpp.

157 {
159 auto code = read_wasm( std::string(wasm_directory) + "globals.23.wasm");
160 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
161}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [16/31]

BACKEND_TEST_CASE ( "Testing wasm <globals_24_wasm>" ,
"" [globals_24_wasm_tests] )

Definition at line 163 of file globals_tests.cpp.

163 {
165 auto code = read_wasm( std::string(wasm_directory) + "globals.24.wasm");
166 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
167}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [17/31]

BACKEND_TEST_CASE ( "Testing wasm <globals_25_wasm>" ,
"" [globals_25_wasm_tests] )

Definition at line 169 of file globals_tests.cpp.

169 {
171 auto code = read_wasm( std::string(wasm_directory) + "globals.25.wasm");
172 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
173}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [18/31]

BACKEND_TEST_CASE ( "Testing wasm <globals_26_wasm>" ,
"" [globals_26_wasm_tests] )

Definition at line 175 of file globals_tests.cpp.

175 {
177 auto code = read_wasm( std::string(wasm_directory) + "globals.26.wasm");
178 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
179}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [19/31]

BACKEND_TEST_CASE ( "Testing wasm <globals_27_wasm>" ,
"" [globals_27_wasm_tests] )

Definition at line 181 of file globals_tests.cpp.

181 {
183 auto code = read_wasm( std::string(wasm_directory) + "globals.27.wasm");
184 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
185}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [20/31]

BACKEND_TEST_CASE ( "Testing wasm <globals_28_wasm>" ,
"" [globals_28_wasm_tests] )

Definition at line 187 of file globals_tests.cpp.

187 {
189 auto code = read_wasm( std::string(wasm_directory) + "globals.28.wasm");
190 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
191}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [21/31]

BACKEND_TEST_CASE ( "Testing wasm <globals_29_wasm>" ,
"" [globals_29_wasm_tests] )

Definition at line 193 of file globals_tests.cpp.

193 {
195 auto code = read_wasm( std::string(wasm_directory) + "globals.29.wasm");
196 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
197}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [22/31]

BACKEND_TEST_CASE ( "Testing wasm <globals_2_wasm>" ,
"" [globals_2_wasm_tests] )

Definition at line 132 of file globals_tests.cpp.

132 {
134 auto code = read_wasm( std::string(wasm_directory) + "globals.2.wasm");
135 backend_t bkend( code, &wa );
136
137}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [23/31]

BACKEND_TEST_CASE ( "Testing wasm <globals_30_wasm>" ,
"" [globals_30_wasm_tests] )

Definition at line 206 of file globals_tests.cpp.

206 {
208 auto code = read_wasm( std::string(wasm_directory) + "globals.30.wasm");
209 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
210}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [24/31]

BACKEND_TEST_CASE ( "Testing wasm <globals_31_wasm>" ,
"" [globals_31_wasm_tests] )

Definition at line 212 of file globals_tests.cpp.

212 {
214 auto code = read_wasm( std::string(wasm_directory) + "globals.31.wasm");
215 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
216}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [25/31]

BACKEND_TEST_CASE ( "Testing wasm <globals_3_wasm>" ,
"" [globals_3_wasm_tests] )

Definition at line 199 of file globals_tests.cpp.

199 {
201 auto code = read_wasm( std::string(wasm_directory) + "globals.3.wasm");
202 backend_t bkend( code, &wa );
203
204}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [26/31]

BACKEND_TEST_CASE ( "Testing wasm <globals_4_wasm>" ,
"" [globals_4_wasm_tests] )

Definition at line 218 of file globals_tests.cpp.

218 {
220 auto code = read_wasm( std::string(wasm_directory) + "globals.4.wasm");
221 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
222}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [27/31]

BACKEND_TEST_CASE ( "Testing wasm <globals_5_wasm>" ,
"" [globals_5_wasm_tests] )

Definition at line 224 of file globals_tests.cpp.

224 {
226 auto code = read_wasm( std::string(wasm_directory) + "globals.5.wasm");
227 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
228}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [28/31]

BACKEND_TEST_CASE ( "Testing wasm <globals_6_wasm>" ,
"" [globals_6_wasm_tests] )

Definition at line 230 of file globals_tests.cpp.

230 {
232 auto code = read_wasm( std::string(wasm_directory) + "globals.6.wasm");
233 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
234}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [29/31]

BACKEND_TEST_CASE ( "Testing wasm <globals_7_wasm>" ,
"" [globals_7_wasm_tests] )

Definition at line 236 of file globals_tests.cpp.

236 {
238 auto code = read_wasm( std::string(wasm_directory) + "globals.7.wasm");
239 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
240}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [30/31]

BACKEND_TEST_CASE ( "Testing wasm <globals_8_wasm>" ,
"" [globals_8_wasm_tests] )

Definition at line 242 of file globals_tests.cpp.

242 {
244 auto code = read_wasm( std::string(wasm_directory) + "globals.8.wasm");
245 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
246}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [31/31]

BACKEND_TEST_CASE ( "Testing wasm <globals_9_wasm>" ,
"" [globals_9_wasm_tests] )

Definition at line 248 of file globals_tests.cpp.

248 {
250 auto code = read_wasm( std::string(wasm_directory) + "globals.9.wasm");
251 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
252}
Here is the call graph for this function:

Variable Documentation

◆ wa

wasm_allocator wa
extern

Definition at line 10 of file main.cpp.