Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
address_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 <address_0_wasm>", "[address_0_wasm_tests]" ) {
20 auto code = read_wasm( std::string(wasm_directory) + "address.0.wasm");
21 backend_t bkend( code, &wa );
22
23 CHECK(bkend.call_with_return("env", "8u_good1", UINT32_C(0))->to_ui32() == UINT32_C(97));
24 CHECK(bkend.call_with_return("env", "8u_good2", UINT32_C(0))->to_ui32() == UINT32_C(97));
25 CHECK(bkend.call_with_return("env", "8u_good3", UINT32_C(0))->to_ui32() == UINT32_C(98));
26 CHECK(bkend.call_with_return("env", "8u_good4", UINT32_C(0))->to_ui32() == UINT32_C(99));
27 CHECK(bkend.call_with_return("env", "8u_good5", UINT32_C(0))->to_ui32() == UINT32_C(122));
28 CHECK(bkend.call_with_return("env", "8s_good1", UINT32_C(0))->to_ui32() == UINT32_C(97));
29 CHECK(bkend.call_with_return("env", "8s_good2", UINT32_C(0))->to_ui32() == UINT32_C(97));
30 CHECK(bkend.call_with_return("env", "8s_good3", UINT32_C(0))->to_ui32() == UINT32_C(98));
31 CHECK(bkend.call_with_return("env", "8s_good4", UINT32_C(0))->to_ui32() == UINT32_C(99));
32 CHECK(bkend.call_with_return("env", "8s_good5", UINT32_C(0))->to_ui32() == UINT32_C(122));
33 CHECK(bkend.call_with_return("env", "16u_good1", UINT32_C(0))->to_ui32() == UINT32_C(25185));
34 CHECK(bkend.call_with_return("env", "16u_good2", UINT32_C(0))->to_ui32() == UINT32_C(25185));
35 CHECK(bkend.call_with_return("env", "16u_good3", UINT32_C(0))->to_ui32() == UINT32_C(25442));
36 CHECK(bkend.call_with_return("env", "16u_good4", UINT32_C(0))->to_ui32() == UINT32_C(25699));
37 CHECK(bkend.call_with_return("env", "16u_good5", UINT32_C(0))->to_ui32() == UINT32_C(122));
38 CHECK(bkend.call_with_return("env", "16s_good1", UINT32_C(0))->to_ui32() == UINT32_C(25185));
39 CHECK(bkend.call_with_return("env", "16s_good2", UINT32_C(0))->to_ui32() == UINT32_C(25185));
40 CHECK(bkend.call_with_return("env", "16s_good3", UINT32_C(0))->to_ui32() == UINT32_C(25442));
41 CHECK(bkend.call_with_return("env", "16s_good4", UINT32_C(0))->to_ui32() == UINT32_C(25699));
42 CHECK(bkend.call_with_return("env", "16s_good5", UINT32_C(0))->to_ui32() == UINT32_C(122));
43 CHECK(bkend.call_with_return("env", "32_good1", UINT32_C(0))->to_ui32() == UINT32_C(1684234849));
44 CHECK(bkend.call_with_return("env", "32_good2", UINT32_C(0))->to_ui32() == UINT32_C(1684234849));
45 CHECK(bkend.call_with_return("env", "32_good3", UINT32_C(0))->to_ui32() == UINT32_C(1701077858));
46 CHECK(bkend.call_with_return("env", "32_good4", UINT32_C(0))->to_ui32() == UINT32_C(1717920867));
47 CHECK(bkend.call_with_return("env", "32_good5", UINT32_C(0))->to_ui32() == UINT32_C(122));
48 CHECK(bkend.call_with_return("env", "8u_good1", UINT32_C(65507))->to_ui32() == UINT32_C(0));
49 CHECK(bkend.call_with_return("env", "8u_good2", UINT32_C(65507))->to_ui32() == UINT32_C(0));
50 CHECK(bkend.call_with_return("env", "8u_good3", UINT32_C(65507))->to_ui32() == UINT32_C(0));
51 CHECK(bkend.call_with_return("env", "8u_good4", UINT32_C(65507))->to_ui32() == UINT32_C(0));
52 CHECK(bkend.call_with_return("env", "8u_good5", UINT32_C(65507))->to_ui32() == UINT32_C(0));
53 CHECK(bkend.call_with_return("env", "8s_good1", UINT32_C(65507))->to_ui32() == UINT32_C(0));
54 CHECK(bkend.call_with_return("env", "8s_good2", UINT32_C(65507))->to_ui32() == UINT32_C(0));
55 CHECK(bkend.call_with_return("env", "8s_good3", UINT32_C(65507))->to_ui32() == UINT32_C(0));
56 CHECK(bkend.call_with_return("env", "8s_good4", UINT32_C(65507))->to_ui32() == UINT32_C(0));
57 CHECK(bkend.call_with_return("env", "8s_good5", UINT32_C(65507))->to_ui32() == UINT32_C(0));
58 CHECK(bkend.call_with_return("env", "16u_good1", UINT32_C(65507))->to_ui32() == UINT32_C(0));
59 CHECK(bkend.call_with_return("env", "16u_good2", UINT32_C(65507))->to_ui32() == UINT32_C(0));
60 CHECK(bkend.call_with_return("env", "16u_good3", UINT32_C(65507))->to_ui32() == UINT32_C(0));
61 CHECK(bkend.call_with_return("env", "16u_good4", UINT32_C(65507))->to_ui32() == UINT32_C(0));
62 CHECK(bkend.call_with_return("env", "16u_good5", UINT32_C(65507))->to_ui32() == UINT32_C(0));
63 CHECK(bkend.call_with_return("env", "16s_good1", UINT32_C(65507))->to_ui32() == UINT32_C(0));
64 CHECK(bkend.call_with_return("env", "16s_good2", UINT32_C(65507))->to_ui32() == UINT32_C(0));
65 CHECK(bkend.call_with_return("env", "16s_good3", UINT32_C(65507))->to_ui32() == UINT32_C(0));
66 CHECK(bkend.call_with_return("env", "16s_good4", UINT32_C(65507))->to_ui32() == UINT32_C(0));
67 CHECK(bkend.call_with_return("env", "16s_good5", UINT32_C(65507))->to_ui32() == UINT32_C(0));
68 CHECK(bkend.call_with_return("env", "32_good1", UINT32_C(65507))->to_ui32() == UINT32_C(0));
69 CHECK(bkend.call_with_return("env", "32_good2", UINT32_C(65507))->to_ui32() == UINT32_C(0));
70 CHECK(bkend.call_with_return("env", "32_good3", UINT32_C(65507))->to_ui32() == UINT32_C(0));
71 CHECK(bkend.call_with_return("env", "32_good4", UINT32_C(65507))->to_ui32() == UINT32_C(0));
72 CHECK(bkend.call_with_return("env", "32_good5", UINT32_C(65507))->to_ui32() == UINT32_C(0));
73 CHECK(bkend.call_with_return("env", "8u_good1", UINT32_C(65508))->to_ui32() == UINT32_C(0));
74 CHECK(bkend.call_with_return("env", "8u_good2", UINT32_C(65508))->to_ui32() == UINT32_C(0));
75 CHECK(bkend.call_with_return("env", "8u_good3", UINT32_C(65508))->to_ui32() == UINT32_C(0));
76 CHECK(bkend.call_with_return("env", "8u_good4", UINT32_C(65508))->to_ui32() == UINT32_C(0));
77 CHECK(bkend.call_with_return("env", "8u_good5", UINT32_C(65508))->to_ui32() == UINT32_C(0));
78 CHECK(bkend.call_with_return("env", "8s_good1", UINT32_C(65508))->to_ui32() == UINT32_C(0));
79 CHECK(bkend.call_with_return("env", "8s_good2", UINT32_C(65508))->to_ui32() == UINT32_C(0));
80 CHECK(bkend.call_with_return("env", "8s_good3", UINT32_C(65508))->to_ui32() == UINT32_C(0));
81 CHECK(bkend.call_with_return("env", "8s_good4", UINT32_C(65508))->to_ui32() == UINT32_C(0));
82 CHECK(bkend.call_with_return("env", "8s_good5", UINT32_C(65508))->to_ui32() == UINT32_C(0));
83 CHECK(bkend.call_with_return("env", "16u_good1", UINT32_C(65508))->to_ui32() == UINT32_C(0));
84 CHECK(bkend.call_with_return("env", "16u_good2", UINT32_C(65508))->to_ui32() == UINT32_C(0));
85 CHECK(bkend.call_with_return("env", "16u_good3", UINT32_C(65508))->to_ui32() == UINT32_C(0));
86 CHECK(bkend.call_with_return("env", "16u_good4", UINT32_C(65508))->to_ui32() == UINT32_C(0));
87 CHECK(bkend.call_with_return("env", "16u_good5", UINT32_C(65508))->to_ui32() == UINT32_C(0));
88 CHECK(bkend.call_with_return("env", "16s_good1", UINT32_C(65508))->to_ui32() == UINT32_C(0));
89 CHECK(bkend.call_with_return("env", "16s_good2", UINT32_C(65508))->to_ui32() == UINT32_C(0));
90 CHECK(bkend.call_with_return("env", "16s_good3", UINT32_C(65508))->to_ui32() == UINT32_C(0));
91 CHECK(bkend.call_with_return("env", "16s_good4", UINT32_C(65508))->to_ui32() == UINT32_C(0));
92 CHECK(bkend.call_with_return("env", "16s_good5", UINT32_C(65508))->to_ui32() == UINT32_C(0));
93 CHECK(bkend.call_with_return("env", "32_good1", UINT32_C(65508))->to_ui32() == UINT32_C(0));
94 CHECK(bkend.call_with_return("env", "32_good2", UINT32_C(65508))->to_ui32() == UINT32_C(0));
95 CHECK(bkend.call_with_return("env", "32_good3", UINT32_C(65508))->to_ui32() == UINT32_C(0));
96 CHECK(bkend.call_with_return("env", "32_good4", UINT32_C(65508))->to_ui32() == UINT32_C(0));
97 CHECK_THROWS_AS(bkend("env", "32_good5", UINT32_C(65508)), std::exception);
98 CHECK_THROWS_AS(bkend("env", "8u_bad", UINT32_C(0)), std::exception);
99 CHECK_THROWS_AS(bkend("env", "8s_bad", UINT32_C(0)), std::exception);
100 CHECK_THROWS_AS(bkend("env", "16u_bad", UINT32_C(0)), std::exception);
101 CHECK_THROWS_AS(bkend("env", "16s_bad", UINT32_C(0)), std::exception);
102 CHECK_THROWS_AS(bkend("env", "32_bad", UINT32_C(0)), std::exception);
103 CHECK_THROWS_AS(bkend("env", "8u_bad", UINT32_C(1)), std::exception);
104 CHECK_THROWS_AS(bkend("env", "8s_bad", UINT32_C(1)), std::exception);
105 CHECK_THROWS_AS(bkend("env", "16u_bad", UINT32_C(1)), std::exception);
106 CHECK_THROWS_AS(bkend("env", "16s_bad", UINT32_C(1)), std::exception);
107 CHECK_THROWS_AS(bkend("env", "32_bad", UINT32_C(1)), std::exception);
108}
109
110BACKEND_TEST_CASE( "Testing wasm <address_2_wasm>", "[address_2_wasm_tests]" ) {
112 auto code = read_wasm( std::string(wasm_directory) + "address.2.wasm");
113 backend_t bkend( code, &wa );
114
115 CHECK(bkend.call_with_return("env", "8u_good1", UINT32_C(0))->to_ui64() == UINT32_C(97));
116 CHECK(bkend.call_with_return("env", "8u_good2", UINT32_C(0))->to_ui64() == UINT32_C(97));
117 CHECK(bkend.call_with_return("env", "8u_good3", UINT32_C(0))->to_ui64() == UINT32_C(98));
118 CHECK(bkend.call_with_return("env", "8u_good4", UINT32_C(0))->to_ui64() == UINT32_C(99));
119 CHECK(bkend.call_with_return("env", "8u_good5", UINT32_C(0))->to_ui64() == UINT32_C(122));
120 CHECK(bkend.call_with_return("env", "8s_good1", UINT32_C(0))->to_ui64() == UINT32_C(97));
121 CHECK(bkend.call_with_return("env", "8s_good2", UINT32_C(0))->to_ui64() == UINT32_C(97));
122 CHECK(bkend.call_with_return("env", "8s_good3", UINT32_C(0))->to_ui64() == UINT32_C(98));
123 CHECK(bkend.call_with_return("env", "8s_good4", UINT32_C(0))->to_ui64() == UINT32_C(99));
124 CHECK(bkend.call_with_return("env", "8s_good5", UINT32_C(0))->to_ui64() == UINT32_C(122));
125 CHECK(bkend.call_with_return("env", "16u_good1", UINT32_C(0))->to_ui64() == UINT32_C(25185));
126 CHECK(bkend.call_with_return("env", "16u_good2", UINT32_C(0))->to_ui64() == UINT32_C(25185));
127 CHECK(bkend.call_with_return("env", "16u_good3", UINT32_C(0))->to_ui64() == UINT32_C(25442));
128 CHECK(bkend.call_with_return("env", "16u_good4", UINT32_C(0))->to_ui64() == UINT32_C(25699));
129 CHECK(bkend.call_with_return("env", "16u_good5", UINT32_C(0))->to_ui64() == UINT32_C(122));
130 CHECK(bkend.call_with_return("env", "16s_good1", UINT32_C(0))->to_ui64() == UINT32_C(25185));
131 CHECK(bkend.call_with_return("env", "16s_good2", UINT32_C(0))->to_ui64() == UINT32_C(25185));
132 CHECK(bkend.call_with_return("env", "16s_good3", UINT32_C(0))->to_ui64() == UINT32_C(25442));
133 CHECK(bkend.call_with_return("env", "16s_good4", UINT32_C(0))->to_ui64() == UINT32_C(25699));
134 CHECK(bkend.call_with_return("env", "16s_good5", UINT32_C(0))->to_ui64() == UINT32_C(122));
135 CHECK(bkend.call_with_return("env", "32u_good1", UINT32_C(0))->to_ui64() == UINT32_C(1684234849));
136 CHECK(bkend.call_with_return("env", "32u_good2", UINT32_C(0))->to_ui64() == UINT32_C(1684234849));
137 CHECK(bkend.call_with_return("env", "32u_good3", UINT32_C(0))->to_ui64() == UINT32_C(1701077858));
138 CHECK(bkend.call_with_return("env", "32u_good4", UINT32_C(0))->to_ui64() == UINT32_C(1717920867));
139 CHECK(bkend.call_with_return("env", "32u_good5", UINT32_C(0))->to_ui64() == UINT32_C(122));
140 CHECK(bkend.call_with_return("env", "32s_good1", UINT32_C(0))->to_ui64() == UINT32_C(1684234849));
141 CHECK(bkend.call_with_return("env", "32s_good2", UINT32_C(0))->to_ui64() == UINT32_C(1684234849));
142 CHECK(bkend.call_with_return("env", "32s_good3", UINT32_C(0))->to_ui64() == UINT32_C(1701077858));
143 CHECK(bkend.call_with_return("env", "32s_good4", UINT32_C(0))->to_ui64() == UINT32_C(1717920867));
144 CHECK(bkend.call_with_return("env", "32s_good5", UINT32_C(0))->to_ui64() == UINT32_C(122));
145 CHECK(bkend.call_with_return("env", "64_good1", UINT32_C(0))->to_ui64() == UINT32_C(7523094288207667809));
146 CHECK(bkend.call_with_return("env", "64_good2", UINT32_C(0))->to_ui64() == UINT32_C(7523094288207667809));
147 CHECK(bkend.call_with_return("env", "64_good3", UINT32_C(0))->to_ui64() == UINT32_C(7595434461045744482));
148 CHECK(bkend.call_with_return("env", "64_good4", UINT32_C(0))->to_ui64() == UINT32_C(7667774633883821155));
149 CHECK(bkend.call_with_return("env", "64_good5", UINT32_C(0))->to_ui64() == UINT32_C(122));
150 CHECK(bkend.call_with_return("env", "8u_good1", UINT32_C(65503))->to_ui64() == UINT32_C(0));
151 CHECK(bkend.call_with_return("env", "8u_good2", UINT32_C(65503))->to_ui64() == UINT32_C(0));
152 CHECK(bkend.call_with_return("env", "8u_good3", UINT32_C(65503))->to_ui64() == UINT32_C(0));
153 CHECK(bkend.call_with_return("env", "8u_good4", UINT32_C(65503))->to_ui64() == UINT32_C(0));
154 CHECK(bkend.call_with_return("env", "8u_good5", UINT32_C(65503))->to_ui64() == UINT32_C(0));
155 CHECK(bkend.call_with_return("env", "8s_good1", UINT32_C(65503))->to_ui64() == UINT32_C(0));
156 CHECK(bkend.call_with_return("env", "8s_good2", UINT32_C(65503))->to_ui64() == UINT32_C(0));
157 CHECK(bkend.call_with_return("env", "8s_good3", UINT32_C(65503))->to_ui64() == UINT32_C(0));
158 CHECK(bkend.call_with_return("env", "8s_good4", UINT32_C(65503))->to_ui64() == UINT32_C(0));
159 CHECK(bkend.call_with_return("env", "8s_good5", UINT32_C(65503))->to_ui64() == UINT32_C(0));
160 CHECK(bkend.call_with_return("env", "16u_good1", UINT32_C(65503))->to_ui64() == UINT32_C(0));
161 CHECK(bkend.call_with_return("env", "16u_good2", UINT32_C(65503))->to_ui64() == UINT32_C(0));
162 CHECK(bkend.call_with_return("env", "16u_good3", UINT32_C(65503))->to_ui64() == UINT32_C(0));
163 CHECK(bkend.call_with_return("env", "16u_good4", UINT32_C(65503))->to_ui64() == UINT32_C(0));
164 CHECK(bkend.call_with_return("env", "16u_good5", UINT32_C(65503))->to_ui64() == UINT32_C(0));
165 CHECK(bkend.call_with_return("env", "16s_good1", UINT32_C(65503))->to_ui64() == UINT32_C(0));
166 CHECK(bkend.call_with_return("env", "16s_good2", UINT32_C(65503))->to_ui64() == UINT32_C(0));
167 CHECK(bkend.call_with_return("env", "16s_good3", UINT32_C(65503))->to_ui64() == UINT32_C(0));
168 CHECK(bkend.call_with_return("env", "16s_good4", UINT32_C(65503))->to_ui64() == UINT32_C(0));
169 CHECK(bkend.call_with_return("env", "16s_good5", UINT32_C(65503))->to_ui64() == UINT32_C(0));
170 CHECK(bkend.call_with_return("env", "32u_good1", UINT32_C(65503))->to_ui64() == UINT32_C(0));
171 CHECK(bkend.call_with_return("env", "32u_good2", UINT32_C(65503))->to_ui64() == UINT32_C(0));
172 CHECK(bkend.call_with_return("env", "32u_good3", UINT32_C(65503))->to_ui64() == UINT32_C(0));
173 CHECK(bkend.call_with_return("env", "32u_good4", UINT32_C(65503))->to_ui64() == UINT32_C(0));
174 CHECK(bkend.call_with_return("env", "32u_good5", UINT32_C(65503))->to_ui64() == UINT32_C(0));
175 CHECK(bkend.call_with_return("env", "32s_good1", UINT32_C(65503))->to_ui64() == UINT32_C(0));
176 CHECK(bkend.call_with_return("env", "32s_good2", UINT32_C(65503))->to_ui64() == UINT32_C(0));
177 CHECK(bkend.call_with_return("env", "32s_good3", UINT32_C(65503))->to_ui64() == UINT32_C(0));
178 CHECK(bkend.call_with_return("env", "32s_good4", UINT32_C(65503))->to_ui64() == UINT32_C(0));
179 CHECK(bkend.call_with_return("env", "32s_good5", UINT32_C(65503))->to_ui64() == UINT32_C(0));
180 CHECK(bkend.call_with_return("env", "64_good1", UINT32_C(65503))->to_ui64() == UINT32_C(0));
181 CHECK(bkend.call_with_return("env", "64_good2", UINT32_C(65503))->to_ui64() == UINT32_C(0));
182 CHECK(bkend.call_with_return("env", "64_good3", UINT32_C(65503))->to_ui64() == UINT32_C(0));
183 CHECK(bkend.call_with_return("env", "64_good4", UINT32_C(65503))->to_ui64() == UINT32_C(0));
184 CHECK(bkend.call_with_return("env", "64_good5", UINT32_C(65503))->to_ui64() == UINT32_C(0));
185 CHECK(bkend.call_with_return("env", "8u_good1", UINT32_C(65504))->to_ui64() == UINT32_C(0));
186 CHECK(bkend.call_with_return("env", "8u_good2", UINT32_C(65504))->to_ui64() == UINT32_C(0));
187 CHECK(bkend.call_with_return("env", "8u_good3", UINT32_C(65504))->to_ui64() == UINT32_C(0));
188 CHECK(bkend.call_with_return("env", "8u_good4", UINT32_C(65504))->to_ui64() == UINT32_C(0));
189 CHECK(bkend.call_with_return("env", "8u_good5", UINT32_C(65504))->to_ui64() == UINT32_C(0));
190 CHECK(bkend.call_with_return("env", "8s_good1", UINT32_C(65504))->to_ui64() == UINT32_C(0));
191 CHECK(bkend.call_with_return("env", "8s_good2", UINT32_C(65504))->to_ui64() == UINT32_C(0));
192 CHECK(bkend.call_with_return("env", "8s_good3", UINT32_C(65504))->to_ui64() == UINT32_C(0));
193 CHECK(bkend.call_with_return("env", "8s_good4", UINT32_C(65504))->to_ui64() == UINT32_C(0));
194 CHECK(bkend.call_with_return("env", "8s_good5", UINT32_C(65504))->to_ui64() == UINT32_C(0));
195 CHECK(bkend.call_with_return("env", "16u_good1", UINT32_C(65504))->to_ui64() == UINT32_C(0));
196 CHECK(bkend.call_with_return("env", "16u_good2", UINT32_C(65504))->to_ui64() == UINT32_C(0));
197 CHECK(bkend.call_with_return("env", "16u_good3", UINT32_C(65504))->to_ui64() == UINT32_C(0));
198 CHECK(bkend.call_with_return("env", "16u_good4", UINT32_C(65504))->to_ui64() == UINT32_C(0));
199 CHECK(bkend.call_with_return("env", "16u_good5", UINT32_C(65504))->to_ui64() == UINT32_C(0));
200 CHECK(bkend.call_with_return("env", "16s_good1", UINT32_C(65504))->to_ui64() == UINT32_C(0));
201 CHECK(bkend.call_with_return("env", "16s_good2", UINT32_C(65504))->to_ui64() == UINT32_C(0));
202 CHECK(bkend.call_with_return("env", "16s_good3", UINT32_C(65504))->to_ui64() == UINT32_C(0));
203 CHECK(bkend.call_with_return("env", "16s_good4", UINT32_C(65504))->to_ui64() == UINT32_C(0));
204 CHECK(bkend.call_with_return("env", "16s_good5", UINT32_C(65504))->to_ui64() == UINT32_C(0));
205 CHECK(bkend.call_with_return("env", "32u_good1", UINT32_C(65504))->to_ui64() == UINT32_C(0));
206 CHECK(bkend.call_with_return("env", "32u_good2", UINT32_C(65504))->to_ui64() == UINT32_C(0));
207 CHECK(bkend.call_with_return("env", "32u_good3", UINT32_C(65504))->to_ui64() == UINT32_C(0));
208 CHECK(bkend.call_with_return("env", "32u_good4", UINT32_C(65504))->to_ui64() == UINT32_C(0));
209 CHECK(bkend.call_with_return("env", "32u_good5", UINT32_C(65504))->to_ui64() == UINT32_C(0));
210 CHECK(bkend.call_with_return("env", "32s_good1", UINT32_C(65504))->to_ui64() == UINT32_C(0));
211 CHECK(bkend.call_with_return("env", "32s_good2", UINT32_C(65504))->to_ui64() == UINT32_C(0));
212 CHECK(bkend.call_with_return("env", "32s_good3", UINT32_C(65504))->to_ui64() == UINT32_C(0));
213 CHECK(bkend.call_with_return("env", "32s_good4", UINT32_C(65504))->to_ui64() == UINT32_C(0));
214 CHECK(bkend.call_with_return("env", "32s_good5", UINT32_C(65504))->to_ui64() == UINT32_C(0));
215 CHECK(bkend.call_with_return("env", "64_good1", UINT32_C(65504))->to_ui64() == UINT32_C(0));
216 CHECK(bkend.call_with_return("env", "64_good2", UINT32_C(65504))->to_ui64() == UINT32_C(0));
217 CHECK(bkend.call_with_return("env", "64_good3", UINT32_C(65504))->to_ui64() == UINT32_C(0));
218 CHECK(bkend.call_with_return("env", "64_good4", UINT32_C(65504))->to_ui64() == UINT32_C(0));
219 CHECK_THROWS_AS(bkend("env", "64_good5", UINT32_C(65504)), std::exception);
220 CHECK_THROWS_AS(bkend("env", "8u_bad", UINT32_C(0)), std::exception);
221 CHECK_THROWS_AS(bkend("env", "8s_bad", UINT32_C(0)), std::exception);
222 CHECK_THROWS_AS(bkend("env", "16u_bad", UINT32_C(0)), std::exception);
223 CHECK_THROWS_AS(bkend("env", "16s_bad", UINT32_C(0)), std::exception);
224 CHECK_THROWS_AS(bkend("env", "32u_bad", UINT32_C(0)), std::exception);
225 CHECK_THROWS_AS(bkend("env", "32s_bad", UINT32_C(0)), std::exception);
226 CHECK_THROWS_AS(bkend("env", "64_bad", UINT32_C(0)), std::exception);
227 CHECK_THROWS_AS(bkend("env", "8u_bad", UINT32_C(1)), std::exception);
228 CHECK_THROWS_AS(bkend("env", "8s_bad", UINT32_C(1)), std::exception);
229 CHECK_THROWS_AS(bkend("env", "16u_bad", UINT32_C(1)), std::exception);
230 CHECK_THROWS_AS(bkend("env", "16s_bad", UINT32_C(1)), std::exception);
231 CHECK_THROWS_AS(bkend("env", "32u_bad", UINT32_C(0)), std::exception);
232 CHECK_THROWS_AS(bkend("env", "32s_bad", UINT32_C(0)), std::exception);
233 CHECK_THROWS_AS(bkend("env", "64_bad", UINT32_C(1)), std::exception);
234}
235
236BACKEND_TEST_CASE( "Testing wasm <address_3_wasm>", "[address_3_wasm_tests]" ) {
238 auto code = read_wasm( std::string(wasm_directory) + "address.3.wasm");
239 backend_t bkend( code, &wa );
240
241 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "32_good1", UINT32_C(0))->to_f32()) == UINT32_C(0));
242 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "32_good2", UINT32_C(0))->to_f32()) == UINT32_C(0));
243 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "32_good3", UINT32_C(0))->to_f32()) == UINT32_C(0));
244 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "32_good4", UINT32_C(0))->to_f32()) == UINT32_C(0));
245 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "32_good5", UINT32_C(0))->to_f32()) == UINT32_C(2144337921));
246 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "32_good1", UINT32_C(65524))->to_f32()) == UINT32_C(0));
247 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "32_good2", UINT32_C(65524))->to_f32()) == UINT32_C(0));
248 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "32_good3", UINT32_C(65524))->to_f32()) == UINT32_C(0));
249 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "32_good4", UINT32_C(65524))->to_f32()) == UINT32_C(0));
250 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "32_good5", UINT32_C(65524))->to_f32()) == UINT32_C(0));
251 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "32_good1", UINT32_C(65525))->to_f32()) == UINT32_C(0));
252 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "32_good2", UINT32_C(65525))->to_f32()) == UINT32_C(0));
253 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "32_good3", UINT32_C(65525))->to_f32()) == UINT32_C(0));
254 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "32_good4", UINT32_C(65525))->to_f32()) == UINT32_C(0));
255 CHECK_THROWS_AS(bkend("env", "32_good5", UINT32_C(65525)), std::exception);
256 CHECK_THROWS_AS(bkend("env", "32_bad", UINT32_C(0)), std::exception);
257 CHECK_THROWS_AS(bkend("env", "32_bad", UINT32_C(1)), std::exception);
258}
259
260BACKEND_TEST_CASE( "Testing wasm <address_4_wasm>", "[address_4_wasm_tests]" ) {
262 auto code = read_wasm( std::string(wasm_directory) + "address.4.wasm");
263 backend_t bkend( code, &wa );
264
265 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "64_good1", UINT32_C(0))->to_f64()) == UINT64_C(0));
266 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "64_good2", UINT32_C(0))->to_f64()) == UINT64_C(0));
267 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "64_good3", UINT32_C(0))->to_f64()) == UINT64_C(0));
268 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "64_good4", UINT32_C(0))->to_f64()) == UINT64_C(0));
269 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "64_good5", UINT32_C(0))->to_f64()) == UINT64_C(9222246136947933185));
270 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "64_good1", UINT32_C(65510))->to_f64()) == UINT64_C(0));
271 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "64_good2", UINT32_C(65510))->to_f64()) == UINT64_C(0));
272 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "64_good3", UINT32_C(65510))->to_f64()) == UINT64_C(0));
273 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "64_good4", UINT32_C(65510))->to_f64()) == UINT64_C(0));
274 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "64_good5", UINT32_C(65510))->to_f64()) == UINT64_C(0));
275 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "64_good1", UINT32_C(65511))->to_f64()) == UINT64_C(0));
276 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "64_good2", UINT32_C(65511))->to_f64()) == UINT64_C(0));
277 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "64_good3", UINT32_C(65511))->to_f64()) == UINT64_C(0));
278 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "64_good4", UINT32_C(65511))->to_f64()) == UINT64_C(0));
279 CHECK_THROWS_AS(bkend("env", "64_good5", UINT32_C(65511)), std::exception);
280 CHECK_THROWS_AS(bkend("env", "64_bad", UINT32_C(0)), std::exception);
281 CHECK_THROWS_AS(bkend("env", "64_bad", UINT32_C(1)), std::exception);
282}
283
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)
#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