1#include <sysio/vm/backend.hpp>
26std::vector<uint8_t> code_after_end_wasm = {
27 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x07, 0x01, 0x60,
28 0x03, 0x7e, 0x7e, 0x7e, 0x00, 0x03, 0x02, 0x01, 0x00, 0x05, 0x03, 0x01,
29 0x00, 0x00, 0x06, 0x06, 0x01, 0x7f, 0x00, 0x41, 0x00, 0x0b, 0x07, 0x09,
30 0x01, 0x05, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x00, 0x00, 0x0a, 0x15, 0x01,
31 0x13, 0x00, 0x0b, 0x02, 0x40, 0x00, 0x0b, 0x03, 0x40, 0x00, 0x0b, 0x41,
32 0x00, 0x01, 0x20, 0x00, 0x23, 0x00, 0x3f, 0x00
45std::vector<uint8_t> make_wasm(std::initializer_list<uint8_t> il) {
46 std::vector<uint8_t> result = {
47 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x07, 0x01, 0x60,
48 0x03, 0x7e, 0x7e, 0x7e, 0x00, 0x03, 0x02, 0x01, 0x00, 0x04, 0x04, 0x01,
49 0x70, 0x00, 0x01, 0x05, 0x03, 0x01, 0x00, 0x00, 0x06, 0x06, 0x01, 0x7f,
50 0x01, 0x41, 0x00, 0x0b, 0x07, 0x09, 0x01, 0x05, 0x61, 0x70, 0x70, 0x6c,
51 0x79, 0x00, 0x00, 0x09, 0x07, 0x01, 0x00, 0x41, 0x00, 0x0b, 0x01, 0x00,
54 result.push_back(il.size() + 4);
56 result.push_back(il.size() + 2);
58 result.push_back(0x0b);
59 result.insert(result.end(), il);
63std::vector<std::vector<uint8_t>> fail_wasms = {
67 make_wasm({0x41, 0x00, 0x04, 0x40, 0x0b}),
69 make_wasm({0x0C, 0x00}),
70 make_wasm({0x41, 0x00, 0x0D, 0x00}),
71 make_wasm({0x41, 0x00, 0x0E, 0x00, 0x00}),
72 make_wasm({0x42, 0x00, 0x42, 0x00, 0x42, 0x00, 0x10, 0x00}),
73 make_wasm({0x42, 0x00, 0x42, 0x00, 0x42, 0x00, 0x41, 0x00, 0x11, 0x00, 0x00}),
74 make_wasm({0x41, 0x00, 0x1A}),
75 make_wasm({0x41, 0x00, 0x41, 0x00, 0x41, 0x00, 0x1B}),
76 make_wasm({0x42, 0x00, 0x21, 0x00}),
77 make_wasm({0x42, 0x00, 0x22, 0x00}),
78 make_wasm({0x41, 0x00, 0x24, 0x00}),
79 make_wasm({0x41, 0x00, 0x28, 0x00, 0x00}),
80 make_wasm({0x41, 0x00, 0x41, 0x41, 0x36, 0x00, 0x00}),
81 make_wasm({0x41, 0x00, 0x40, 0x00}),
82 make_wasm({0x41, 0x00, 0x67}),
83 make_wasm({0x41, 0x00, 0x41, 0x00, 0x6a}),
84 make_wasm({0x41, 0x00, 0xac}),
89struct empty_options {};
90struct static_options_false {
91 static constexpr bool allow_code_after_function_end =
false;
93struct static_options_true {
94 static constexpr bool allow_code_after_function_end =
true;
96struct dynamic_options {
97 bool allow_code_after_function_end;
102BACKEND_TEST_CASE(
"Test allow_code_after_function_end default",
"[allow_code_after_function_end_test]") {
107BACKEND_TEST_CASE(
"Test allow_code_after_function_end unlimited",
"[allow_code_after_function_end_test]") {
112BACKEND_TEST_CASE(
"Test allow_code_after_function_end static fail",
"[allow_code_after_function_end_test]") {
117BACKEND_TEST_CASE(
"Test allow_code_after_function_end static pass",
"[allow_code_after_function_end_test]") {
120 for(
auto wasm : fail_wasms) {
125BACKEND_TEST_CASE(
"Test allow_code_after_function_end dynamic fail",
"[allow_code_after_function_end_test]") {
130BACKEND_TEST_CASE(
"Test allow_code_after_function_end dynamic pass",
"[allow_code_after_function_end_test]") {
133 for(
auto wasm : fail_wasms) {
sysio::vm::backend< rhf_t > backend_t
#define CHECK_THROWS_AS(expr, exceptionType)
#define BACKEND_TEST_CASE(name, tags)