1#include <sysio/vm/backend.hpp>
18std::vector<uint8_t> types_2_wasm = {
19 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x02, 0x60,
20 0x00, 0x00, 0x60, 0x00, 0x01, 0x7f
29std::vector<uint8_t> imports_2_wasm = {
30 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x04, 0x01, 0x60,
31 0x00, 0x00, 0x02, 0x13, 0x02, 0x03, 0x65, 0x6e, 0x76, 0x02, 0x66, 0x30,
32 0x00, 0x00, 0x03, 0x65, 0x6e, 0x76, 0x02, 0x66, 0x31, 0x00, 0x00
41std::vector<uint8_t> functions_2_wasm = {
42 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x04, 0x01, 0x60,
43 0x00, 0x00, 0x03, 0x03, 0x02, 0x00, 0x00, 0x0a, 0x07, 0x02, 0x02, 0x00,
44 0x0b, 0x02, 0x00, 0x0b
53std::vector<uint8_t> globals_2_wasm = {
54 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x06, 0x0b, 0x02, 0x7f,
55 0x00, 0x41, 0x00, 0x0b, 0x7f, 0x00, 0x41, 0x00, 0x0b
64std::vector<uint8_t> exports_2_wasm = {
65 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x04, 0x01, 0x60,
66 0x00, 0x00, 0x03, 0x03, 0x02, 0x00, 0x00, 0x07, 0x0b, 0x02, 0x02, 0x66,
67 0x31, 0x00, 0x00, 0x02, 0x66, 0x32, 0x00, 0x01, 0x0a, 0x07, 0x02, 0x02,
68 0x00, 0x0b, 0x02, 0x00, 0x0b
78std::vector<uint8_t> elems_2_wasm = {
79 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x04, 0x04, 0x01, 0x70,
80 0x00, 0x01, 0x09, 0x0b, 0x02, 0x00, 0x41, 0x00, 0x0b, 0x00, 0x00, 0x41,
91std::vector<uint8_t> data_2_wasm = {
92 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x05, 0x03, 0x01, 0x00,
93 0x01, 0x0b, 0x0b, 0x02, 0x00, 0x41, 0x00, 0x0b, 0x00, 0x00, 0x41, 0x00,
97struct empty_options {};
98struct dynamic_options {
99 std::uint32_t max_section_elements;
101struct static_options_1 {
102 static constexpr std::uint32_t max_section_elements = 1;
104struct static_options_2 {
105 static constexpr std::uint32_t max_section_elements = 2;
109#define SECTION_TEST_CASE_DEFS(name) \
111struct name ## _dynamic_options { \
112 std::uint32_t max_ ## name ## _section_elements; \
114struct name ## _static_options_1 { \
115 static constexpr std::uint32_t max_ ## name ## _section_elements = 1; \
117struct name ## _static_options_2 { \
118 static constexpr std::uint32_t max_ ## name ## _section_elements = 2; \
122#define SECTION_TEST_CASE_IMPL(name, wasm) \
123BACKEND_TEST_CASE("Test max_" #name "_section_elements", "[max_section_elements_test]") { \
124 backend<std::nullptr_t, TestType> backend_default(wasm, &wa); \
125 backend<std::nullptr_t, TestType, empty_options> backend_empty(wasm, &wa); \
126 CHECK_THROWS_AS((backend<std::nullptr_t, TestType, static_options_1>(wasm, &wa)), wasm_parse_exception); \
127 backend<std::nullptr_t, TestType, static_options_2> backend_static_fallback(wasm, &wa); \
128 CHECK_THROWS_AS((backend<std::nullptr_t, TestType, dynamic_options>(wasm, nullptr, {1})), wasm_parse_exception); \
129 backend<std::nullptr_t, TestType, dynamic_options> backend_dynamic_fallback(wasm, nullptr, {2}); \
131 CHECK_THROWS_AS((backend<std::nullptr_t, TestType, name ## _static_options_1>(wasm, &wa)), wasm_parse_exception); \
132 backend<std::nullptr_t, TestType, name ## _static_options_2> backend_static(wasm, &wa); \
133 CHECK_THROWS_AS((backend<std::nullptr_t, TestType, name ## _dynamic_options>(wasm, nullptr, {1})), wasm_parse_exception); \
134 backend<std::nullptr_t, TestType, name ## _dynamic_options> backend_dynamic(wasm, nullptr, {2}); \
137#define SECTION_TEST_CASE(name, wasm) \
138 SECTION_TEST_CASE_DEFS(name) \
139 SECTION_TEST_CASE_IMPL(name, wasm)
#define SECTION_TEST_CASE(name, wasm)