Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
stack_restriction_tests.cpp
Go to the documentation of this file.
1#include <iostream>
2#include <vector>
3
4#include <sysio/vm/backend.hpp>
5#include <sysio/vm/watchdog.hpp>
6
7#include "utils.hpp"
8#include <catch2/catch.hpp>
9
10using namespace sysio;
11using namespace sysio::vm;
12
13extern wasm_allocator wa;
14
15BACKEND_TEST_CASE("Test that we can load and run a wasm that uses 8191 stack elements",
16 "[8k_minus_1_stack_elems_test]") {
17 // comes from the wasm
18 /*
19 (module
20 (type (;0;) (func))
21 (type (;1;) (func (param i32)))
22 (func (;0;) (type 1) (param i32)
23 (local i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64
24 i64 i64 i64 i64 i64) get_local 0 i32.const 249 i32.eq br_if 0 (;@0;) get_local 0 i32.const 1 i32.add call 0) (func
25 (;1;) (type 0) (local i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64
26 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64
27 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64
28 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64
29 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64
30 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64
31 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64) i32.const 0 call 0) (memory
32 (;0;) 0) (export "fun" (func 1)))
33 */
34 std::vector<uint8_t> _8k_stack_size_1_under_wasm = {
35 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x02, 0x60, 0x00, 0x00, 0x60, 0x01, 0x7f, 0x00,
36 0x03, 0x03, 0x02, 0x01, 0x00, 0x05, 0x03, 0x01, 0x00, 0x00, 0x07, 0x07, 0x01, 0x03, 0x66, 0x75, 0x6e, 0x00,
37 0x01, 0x0a, 0x1f, 0x02, 0x13, 0x01, 0x1f, 0x7e, 0x20, 0x00, 0x41, 0xf9, 0x01, 0x46, 0x0d, 0x00, 0x20, 0x00,
38 0x41, 0x01, 0x6a, 0x10, 0x00, 0x0b, 0x09, 0x01, 0xbe, 0x01, 0x7e, 0x41, 0x00, 0x10, 0x00, 0x0b
39 };
40
42 backend_t bkend(_8k_stack_size_1_under_wasm, &wa);
44}
45
46BACKEND_TEST_CASE("Test that we can load and run a wasm that uses 8192 stack elements", "[8k_stack_elems_test]") {
47 // comes from the wasm
48 /*
49 (module
50 (type (;0;) (func))
51 (type (;1;) (func (param i32)))
52 (func (;0;) (type 1) (param i32)
53 (local i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64
54 i64 i64 i64 i64 i64) get_local 0 i32.const 249 i32.eq br_if 0 (;@0;) get_local 0 i32.const 1 i32.add call 0) (func
55 (;1;) (type 0) (local i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64
56 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64
57 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64
58 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64
59 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64
60 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64
61 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64) i32.const 0 call 0) (memory
62 (;0;) 0) (export "fun" (func 1)))
63 */
64
65 std::vector<uint8_t> _8k_stack_size_wasm = { 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x02, 0x60,
66 0x00, 0x00, 0x60, 0x01, 0x7f, 0x00, 0x03, 0x03, 0x02, 0x01, 0x00, 0x05,
67 0x03, 0x01, 0x00, 0x00, 0x07, 0x07, 0x01, 0x03, 0x66, 0x75, 0x6e, 0x00,
68 0x01, 0x0a, 0x1f, 0x02, 0x13, 0x01, 0x9d, 0x03, 0x7e, 0x20, 0x00, 0x41,
69 0x14, 0x46, 0x0d, 0x00, 0x20, 0x00, 0x41, 0x01, 0x6a, 0x10, 0x00, 0x0b,
70 0x09, 0x01, 0xfe, 0x02, 0x7e, 0x41, 0x00, 0x10, 0x00, 0x0b };
71
73 backend_t bkend(_8k_stack_size_wasm, &wa);
75}
void execute_all(Watchdog &&wd, host_t &host)
Definition backend.hpp:219
backend_t bkend(hello_wasm, ehm, &wa)
wasm_allocator wa
Definition main.cpp:10
#define BACKEND_TEST_CASE(name, tags)
Definition utils.hpp:59