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
14
using namespace
sysio
;
15
using namespace
sysio::vm
;
16
extern
wasm_allocator
wa
;
17
18
BACKEND_TEST_CASE
(
"Testing wasm <float_memory_0_wasm>"
,
"[float_memory_0_wasm_tests]"
) {
19
using
backend_t
=
backend<standalone_function_t, TestType>
;
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));
25
bkend
(
"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));
28
bkend
(
"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));
31
bkend
(
"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));
34
bkend
(
"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
39
BACKEND_TEST_CASE
(
"Testing wasm <float_memory_1_wasm>"
,
"[float_memory_1_wasm_tests]"
) {
40
using
backend_t
=
backend<standalone_function_t, TestType>
;
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));
46
bkend
(
"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));
49
bkend
(
"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));
52
bkend
(
"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));
55
bkend
(
"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
60
BACKEND_TEST_CASE
(
"Testing wasm <float_memory_2_wasm>"
,
"[float_memory_2_wasm_tests]"
) {
61
using
backend_t
=
backend<standalone_function_t, TestType>
;
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));
67
bkend
(
"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));
70
bkend
(
"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));
73
bkend
(
"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));
76
bkend
(
"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
81
BACKEND_TEST_CASE
(
"Testing wasm <float_memory_3_wasm>"
,
"[float_memory_3_wasm_tests]"
) {
82
using
backend_t
=
backend<standalone_function_t, TestType>
;
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));
88
bkend
(
"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));
91
bkend
(
"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));
94
bkend
(
"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));
97
bkend
(
"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
102
BACKEND_TEST_CASE
(
"Testing wasm <float_memory_4_wasm>"
,
"[float_memory_4_wasm_tests]"
) {
103
using
backend_t
=
backend<standalone_function_t, TestType>
;
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));
109
bkend
(
"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));
112
bkend
(
"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));
115
bkend
(
"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));
118
bkend
(
"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
123
BACKEND_TEST_CASE
(
"Testing wasm <float_memory_5_wasm>"
,
"[float_memory_5_wasm_tests]"
) {
124
using
backend_t
=
backend<standalone_function_t, TestType>
;
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));
130
bkend
(
"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));
133
bkend
(
"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));
136
bkend
(
"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));
139
bkend
(
"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
sysio::vm::backend
Definition
backend.hpp:62
sysio::vm::backend::call_with_return
auto call_with_return(host_t &host, const std::string_view &mod, const std::string_view &func, Args... args)
Definition
backend.hpp:178
sysio::vm::wasm_allocator
Definition
allocator.hpp:409
CHECK
#define CHECK(cond)
Definition
util.h:80
wa
wasm_allocator wa
Definition
main.cpp:10
bkend
backend_t bkend(hello_wasm, ehm, &wa)
sysio::vm
Definition
controller.hpp:23
sysio::vm::read_wasm
std::vector< uint8_t > read_wasm(const std::string &fname)
Definition
utils.hpp:30
sysio
Definition
abi_serializer.cpp:8
catch.hpp
UINT32_C
#define UINT32_C(val)
Definition
stdint.h:283
UINT64_C
#define UINT64_C(val)
Definition
stdint.h:284
BACKEND_TEST_CASE
#define BACKEND_TEST_CASE(name, tags)
Definition
utils.hpp:59
bit_cast
T bit_cast(const U &u)
Definition
utils.hpp:35
wasm_config.hpp
libraries
sys-vm
tests
spec
float_memory_tests.cpp
Generated by
1.12.0