Wire Sysio
Wire Sysion 1.0.0
Loading...
Searching...
No Matches
forbid_export_mutable_globals_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
* (global (export "i") (mut i32) (i32.const 0))
15
* )
16
*/
17
std::vector<uint8_t> mut_global_wasm = {
18
0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x06, 0x06, 0x01, 0x7f,
19
0x01, 0x41, 0x00, 0x0b, 0x07, 0x05, 0x01, 0x01, 0x69, 0x03, 0x00
20
};
21
22
struct
empty_options {};
23
struct
static_options_false {
24
static
constexpr
bool
forbid_export_mutable_globals =
false
;
25
};
26
struct
static_options_true {
27
static
constexpr
bool
forbid_export_mutable_globals =
true
;
28
};
29
struct
dynamic_options {
30
bool
forbid_export_mutable_globals;
31
};
32
33
}
34
35
BACKEND_TEST_CASE
(
"Test forbid_export_mutable_globals default"
,
"[forbid_export_mutable_globals_test]"
) {
36
using
backend_t
=
backend<std::nullptr_t, TestType>
;
37
backend_t
backend
(mut_global_wasm, &
wa
);
38
}
39
40
BACKEND_TEST_CASE
(
"Test forbid_export_mutable_globals empty"
,
"[forbid_export_mutable_globals_test]"
) {
41
using
backend_t
=
backend<std::nullptr_t, TestType, empty_options>
;
42
backend_t
backend
(mut_global_wasm, &
wa
);
43
}
44
45
BACKEND_TEST_CASE
(
"Test forbid_export_mutable_globals static pass"
,
"[forbid_export_mutable_globals_test]"
) {
46
using
backend_t
=
backend<std::nullptr_t, TestType, static_options_false>
;
47
backend_t
backend
(mut_global_wasm, &
wa
);
48
}
49
50
BACKEND_TEST_CASE
(
"Test forbid_export_mutable_globals static fail"
,
"[forbid_export_mutable_globals_test]"
) {
51
using
backend_t
=
backend<std::nullptr_t, TestType, static_options_true>
;
52
CHECK_THROWS_AS
(
backend_t
(mut_global_wasm, &
wa
), wasm_parse_exception);
53
}
54
55
BACKEND_TEST_CASE
(
"Test forbid_export_mutable_globals dynamic pass"
,
"[forbid_export_mutable_globals_test]"
) {
56
using
backend_t
=
backend<std::nullptr_t, TestType, dynamic_options>
;
57
backend_t
backend
(mut_global_wasm,
nullptr
, dynamic_options{
false
});
58
}
59
60
BACKEND_TEST_CASE
(
"Test forbid_export_mutable_globals dynamic fail"
,
"[forbid_export_mutable_globals_test]"
) {
61
using
backend_t
=
backend<std::nullptr_t, TestType, dynamic_options>
;
62
CHECK_THROWS_AS
(
backend_t
(mut_global_wasm,
nullptr
, dynamic_options{
true
}), wasm_parse_exception);
63
}
sysio::vm::backend
Definition
backend.hpp:62
sysio::vm::wasm_allocator
Definition
allocator.hpp:409
wa
wasm_allocator wa
Definition
main.cpp:10
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
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
forbid_export_mutable_globals_tests.cpp
Generated by
1.12.0