Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
float_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 <float_memory_0_wasm>", "[float_memory_0_wasm_tests]" ) {
20 auto code = read_wasm( std::string(wasm_directory) + "float_memory.0.wasm");
21 backend_t bkend( code, &wa );
22
23 CHECK(bkend.call_with_return("env", "i32.load")->to_ui32() == UINT32_C(2141192192));
24 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "f32.load")->to_f32()) == UINT32_C(2141192192));
25bkend("env", "reset");
26 CHECK(bkend.call_with_return("env", "i32.load")->to_ui32() == UINT32_C(0));
27 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "f32.load")->to_f32()) == UINT32_C(0));
28bkend("env", "f32.store");
29 CHECK(bkend.call_with_return("env", "i32.load")->to_ui32() == UINT32_C(2141192192));
30 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "f32.load")->to_f32()) == UINT32_C(2141192192));
31bkend("env", "reset");
32 CHECK(bkend.call_with_return("env", "i32.load")->to_ui32() == UINT32_C(0));
33 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "f32.load")->to_f32()) == UINT32_C(0));
34bkend("env", "i32.store");
35 CHECK(bkend.call_with_return("env", "i32.load")->to_ui32() == UINT32_C(2141192192));
36 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "f32.load")->to_f32()) == UINT32_C(2141192192));
37}
38
39BACKEND_TEST_CASE( "Testing wasm <float_memory_1_wasm>", "[float_memory_1_wasm_tests]" ) {
41 auto code = read_wasm( std::string(wasm_directory) + "float_memory.1.wasm");
42 backend_t bkend( code, &wa );
43
44 CHECK(bkend.call_with_return("env", "i64.load")->to_ui64() == UINT32_C(9219994337134247936));
45 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "f64.load")->to_f64()) == UINT64_C(9219994337134247936));
46bkend("env", "reset");
47 CHECK(bkend.call_with_return("env", "i64.load")->to_ui64() == UINT32_C(0));
48 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "f64.load")->to_f64()) == UINT64_C(0));
49bkend("env", "f64.store");
50 CHECK(bkend.call_with_return("env", "i64.load")->to_ui64() == UINT32_C(9219994337134247936));
51 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "f64.load")->to_f64()) == UINT64_C(9219994337134247936));
52bkend("env", "reset");
53 CHECK(bkend.call_with_return("env", "i64.load")->to_ui64() == UINT32_C(0));
54 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "f64.load")->to_f64()) == UINT64_C(0));
55bkend("env", "i64.store");
56 CHECK(bkend.call_with_return("env", "i64.load")->to_ui64() == UINT32_C(9219994337134247936));
57 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "f64.load")->to_f64()) == UINT64_C(9219994337134247936));
58}
59
60BACKEND_TEST_CASE( "Testing wasm <float_memory_2_wasm>", "[float_memory_2_wasm_tests]" ) {
62 auto code = read_wasm( std::string(wasm_directory) + "float_memory.2.wasm");
63 backend_t bkend( code, &wa );
64
65 CHECK(bkend.call_with_return("env", "i32.load")->to_ui32() == UINT32_C(2141192192));
66 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "f32.load")->to_f32()) == UINT32_C(2141192192));
67bkend("env", "reset");
68 CHECK(bkend.call_with_return("env", "i32.load")->to_ui32() == UINT32_C(0));
69 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "f32.load")->to_f32()) == UINT32_C(0));
70bkend("env", "f32.store");
71 CHECK(bkend.call_with_return("env", "i32.load")->to_ui32() == UINT32_C(2141192192));
72 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "f32.load")->to_f32()) == UINT32_C(2141192192));
73bkend("env", "reset");
74 CHECK(bkend.call_with_return("env", "i32.load")->to_ui32() == UINT32_C(0));
75 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "f32.load")->to_f32()) == UINT32_C(0));
76bkend("env", "i32.store");
77 CHECK(bkend.call_with_return("env", "i32.load")->to_ui32() == UINT32_C(2141192192));
78 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "f32.load")->to_f32()) == UINT32_C(2141192192));
79}
80
81BACKEND_TEST_CASE( "Testing wasm <float_memory_3_wasm>", "[float_memory_3_wasm_tests]" ) {
83 auto code = read_wasm( std::string(wasm_directory) + "float_memory.3.wasm");
84 backend_t bkend( code, &wa );
85
86 CHECK(bkend.call_with_return("env", "i64.load")->to_ui64() == UINT32_C(9219994337134247936));
87 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "f64.load")->to_f64()) == UINT64_C(9219994337134247936));
88bkend("env", "reset");
89 CHECK(bkend.call_with_return("env", "i64.load")->to_ui64() == UINT32_C(0));
90 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "f64.load")->to_f64()) == UINT64_C(0));
91bkend("env", "f64.store");
92 CHECK(bkend.call_with_return("env", "i64.load")->to_ui64() == UINT32_C(9219994337134247936));
93 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "f64.load")->to_f64()) == UINT64_C(9219994337134247936));
94bkend("env", "reset");
95 CHECK(bkend.call_with_return("env", "i64.load")->to_ui64() == UINT32_C(0));
96 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "f64.load")->to_f64()) == UINT64_C(0));
97bkend("env", "i64.store");
98 CHECK(bkend.call_with_return("env", "i64.load")->to_ui64() == UINT32_C(9219994337134247936));
99 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "f64.load")->to_f64()) == UINT64_C(9219994337134247936));
100}
101
102BACKEND_TEST_CASE( "Testing wasm <float_memory_4_wasm>", "[float_memory_4_wasm_tests]" ) {
104 auto code = read_wasm( std::string(wasm_directory) + "float_memory.4.wasm");
105 backend_t bkend( code, &wa );
106
107 CHECK(bkend.call_with_return("env", "i32.load")->to_ui32() == UINT32_C(2144337921));
108 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "f32.load")->to_f32()) == UINT32_C(2144337921));
109bkend("env", "reset");
110 CHECK(bkend.call_with_return("env", "i32.load")->to_ui32() == UINT32_C(0));
111 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "f32.load")->to_f32()) == UINT32_C(0));
112bkend("env", "f32.store");
113 CHECK(bkend.call_with_return("env", "i32.load")->to_ui32() == UINT32_C(2144337921));
114 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "f32.load")->to_f32()) == UINT32_C(2144337921));
115bkend("env", "reset");
116 CHECK(bkend.call_with_return("env", "i32.load")->to_ui32() == UINT32_C(0));
117 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "f32.load")->to_f32()) == UINT32_C(0));
118bkend("env", "i32.store");
119 CHECK(bkend.call_with_return("env", "i32.load")->to_ui32() == UINT32_C(2144337921));
120 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "f32.load")->to_f32()) == UINT32_C(2144337921));
121}
122
123BACKEND_TEST_CASE( "Testing wasm <float_memory_5_wasm>", "[float_memory_5_wasm_tests]" ) {
125 auto code = read_wasm( std::string(wasm_directory) + "float_memory.5.wasm");
126 backend_t bkend( code, &wa );
127
128 CHECK(bkend.call_with_return("env", "i64.load")->to_ui64() == UINT32_C(9222246136947933185));
129 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "f64.load")->to_f64()) == UINT64_C(9222246136947933185));
130bkend("env", "reset");
131 CHECK(bkend.call_with_return("env", "i64.load")->to_ui64() == UINT32_C(0));
132 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "f64.load")->to_f64()) == UINT64_C(0));
133bkend("env", "f64.store");
134 CHECK(bkend.call_with_return("env", "i64.load")->to_ui64() == UINT32_C(9222246136947933185));
135 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "f64.load")->to_f64()) == UINT64_C(9222246136947933185));
136bkend("env", "reset");
137 CHECK(bkend.call_with_return("env", "i64.load")->to_ui64() == UINT32_C(0));
138 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "f64.load")->to_f64()) == UINT64_C(0));
139bkend("env", "i64.store");
140 CHECK(bkend.call_with_return("env", "i64.load")->to_ui64() == UINT32_C(9222246136947933185));
141 CHECK(bit_cast<uint64_t>(bkend.call_with_return("env", "f64.load")->to_f64()) == UINT64_C(9222246136947933185));
142}
143
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)
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