Wire Sysio
Wire Sysion 1.0.0
Loading...
Searching...
No Matches
max_code_bytes_tests.cpp
Go to the documentation of this file.
1
#include <sysio/vm/backend.hpp>
2
3
#include "
utils.hpp
"
4
#include <
catch2/catch.hpp
>
5
6
using namespace
sysio::vm
;
7
8
extern
wasm_allocator
wa
;
9
10
namespace
{
11
12
/*
13
* (module
14
* (func (local i32))
15
* )
16
*/
17
std::vector<uint8_t> func_wasm = {
18
0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x04, 0x01, 0x60,
19
0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0x0a, 0x06, 0x01, 0x04, 0x01, 0x01,
20
0x7f, 0x0b
21
};
22
23
struct
empty_options {};
24
struct
static_options_3 {
25
static
constexpr
std::uint32_t max_code_bytes = 3;
26
};
27
struct
static_options_4 {
28
static
constexpr
std::uint32_t max_code_bytes = 4;
29
};
30
struct
dynamic_options {
31
std::uint32_t max_code_bytes;
32
};
33
34
}
35
36
BACKEND_TEST_CASE
(
"Test max_code_bytes default"
,
"[max_code_bytes_test]"
) {
37
using
backend_t
=
backend<std::nullptr_t, TestType>
;
38
backend_t
backend
(func_wasm, &
wa
);
39
}
40
41
BACKEND_TEST_CASE
(
"Test max_code_bytes unlimited"
,
"[max_code_bytes_test]"
) {
42
using
backend_t
=
backend<std::nullptr_t, TestType, empty_options>
;
43
backend_t
backend
(func_wasm, &
wa
);
44
}
45
46
BACKEND_TEST_CASE
(
"Test max_code_bytes static fail"
,
"[max_code_bytes_test]"
) {
47
using
backend_t
=
backend<std::nullptr_t, TestType, static_options_3>
;
48
CHECK_THROWS_AS
(
backend_t
(func_wasm, &
wa
), wasm_parse_exception);
49
}
50
51
BACKEND_TEST_CASE
(
"Test max_code_bytes static pass"
,
"[max_code_bytes_test]"
) {
52
using
backend_t
=
backend<std::nullptr_t, TestType, static_options_4>
;
53
backend_t
backend
(func_wasm, &
wa
);
54
}
55
56
BACKEND_TEST_CASE
(
"Test max_code_bytes dynamic fail"
,
"[max_code_bytes_test]"
) {
57
using
backend_t
=
backend<std::nullptr_t, TestType, dynamic_options>
;
58
CHECK_THROWS_AS
(
backend_t
(func_wasm,
nullptr
, dynamic_options{3}), wasm_parse_exception);
59
}
60
61
BACKEND_TEST_CASE
(
"Test max_code_bytes dynamic pass"
,
"[max_code_bytes_test]"
) {
62
using
backend_t
=
backend<std::nullptr_t, TestType, dynamic_options>
;
63
backend_t
backend
(func_wasm,
nullptr
, dynamic_options{4});
64
}
sysio::vm::backend
Definition
backend.hpp:62
sysio::vm::wasm_allocator
Definition
allocator.hpp:409
backend_t
sysio::vm::backend< rhf_t > backend_t
Definition
hello_driver.cpp:61
CHECK_THROWS_AS
#define CHECK_THROWS_AS(expr, exceptionType)
Definition
catch.hpp:203
wa
wasm_allocator wa
Definition
main.cpp:10
sysio::vm
Definition
controller.hpp:23
catch.hpp
utils.hpp
BACKEND_TEST_CASE
#define BACKEND_TEST_CASE(name, tags)
Definition
utils.hpp:59
libraries
sys-vm
tests
max_code_bytes_tests.cpp
Generated by
1.12.0