Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
backend_tests.cpp
Go to the documentation of this file.
1#include <sysio/vm/backend.hpp>
2#include <catch2/catch.hpp>
3#include "utils.hpp"
4
5using namespace sysio::vm;
6
7extern wasm_allocator wa;
8
9BACKEND_TEST_CASE("Tests that the arguments of top level calls are validated",
10 "[call_typecheck]") {
11 /*
12 * (module
13 * (func (export "f0"))
14 * (func (export "f1") (param i32))
15 * )
16 */
17 std::vector<uint8_t> code = { 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x02, 0x60,
18 0x00, 0x00, 0x60, 0x01, 0x7f, 0x00, 0x03, 0x03, 0x02, 0x00, 0x01, 0x07,
19 0x0b, 0x02, 0x02, 0x66, 0x30, 0x00, 0x00, 0x02, 0x66, 0x31, 0x00, 0x01,
20 0x0a, 0x07, 0x02, 0x02, 0x00, 0x0b, 0x02, 0x00, 0x0b
21 };
22
24 backend_t bkend(code, &wa);
25
26 CHECK_THROWS_AS(bkend.call("env", "f0", 0), std::exception); // too many arguments
27 CHECK_THROWS_AS(bkend.call("env", "f1"), std::exception); // too few arguments
28 CHECK_THROWS_AS(bkend.call("env", "f1", UINT64_C(0)), std::exception); // wrong type of argument
29 CHECK_THROWS_AS(bkend.call("env", "f1", UINT32_C(0), UINT32_C(0)), std::exception); // too many arguments
30}
wasm_allocator wa
Definition main.cpp:10
bool call(host_t *host, uint32_t func_index, Args... args)
Definition backend.hpp:148
backend_t bkend(hello_wasm, ehm, &wa)
#define CHECK_THROWS_AS(expr, exceptionType)
Definition catch.hpp:203
#define UINT32_C(val)
Definition stdint.h:283
#define UINT64_C(val)
Definition stdint.h:284
#define BACKEND_TEST_CASE(name, tags)
Definition utils.hpp:59