Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
func_ptrs_tests.cpp File Reference
#include <algorithm>
#include <vector>
#include <iostream>
#include <iterator>
#include <cmath>
#include <cstdlib>
#include <catch2/catch.hpp>
#include <utils.hpp>
#include <wasm_config.hpp>
#include <sysio/vm/backend.hpp>
Include dependency graph for func_ptrs_tests.cpp:

Go to the source code of this file.

Functions

 BACKEND_TEST_CASE ("Testing wasm <func_ptrs_1_wasm>", "[func_ptrs_1_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <func_ptrs_2_wasm>", "[func_ptrs_2_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <func_ptrs_3_wasm>", "[func_ptrs_3_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <func_ptrs_4_wasm>", "[func_ptrs_4_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <func_ptrs_5_wasm>", "[func_ptrs_5_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <func_ptrs_6_wasm>", "[func_ptrs_6_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <func_ptrs_7_wasm>", "[func_ptrs_7_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <func_ptrs_8_wasm>", "[func_ptrs_8_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <func_ptrs_9_wasm>", "[func_ptrs_9_wasm_tests]")
 

Variables

wasm_allocator wa
 

Function Documentation

◆ BACKEND_TEST_CASE() [1/9]

BACKEND_TEST_CASE ( "Testing wasm <func_ptrs_1_wasm>" ,
"" [func_ptrs_1_wasm_tests] )

Definition at line 18 of file func_ptrs_tests.cpp.

18 {
20 auto code = read_wasm( std::string(wasm_directory) + "func_ptrs.1.wasm");
21 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
22}
sysio::vm::backend< rhf_t > backend_t
#define CHECK_THROWS_AS(expr, exceptionType)
Definition catch.hpp:203
std::vector< uint8_t > read_wasm(const std::string &fname)
Definition utils.hpp:30
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [2/9]

BACKEND_TEST_CASE ( "Testing wasm <func_ptrs_2_wasm>" ,
"" [func_ptrs_2_wasm_tests] )

Definition at line 24 of file func_ptrs_tests.cpp.

24 {
26 auto code = read_wasm( std::string(wasm_directory) + "func_ptrs.2.wasm");
27 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
28}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [3/9]

BACKEND_TEST_CASE ( "Testing wasm <func_ptrs_3_wasm>" ,
"" [func_ptrs_3_wasm_tests] )

Definition at line 30 of file func_ptrs_tests.cpp.

30 {
32 auto code = read_wasm( std::string(wasm_directory) + "func_ptrs.3.wasm");
33 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
34}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [4/9]

BACKEND_TEST_CASE ( "Testing wasm <func_ptrs_4_wasm>" ,
"" [func_ptrs_4_wasm_tests] )

Definition at line 36 of file func_ptrs_tests.cpp.

36 {
38 auto code = read_wasm( std::string(wasm_directory) + "func_ptrs.4.wasm");
39 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
40}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [5/9]

BACKEND_TEST_CASE ( "Testing wasm <func_ptrs_5_wasm>" ,
"" [func_ptrs_5_wasm_tests] )

Definition at line 42 of file func_ptrs_tests.cpp.

42 {
44 auto code = read_wasm( std::string(wasm_directory) + "func_ptrs.5.wasm");
45 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
46}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [6/9]

BACKEND_TEST_CASE ( "Testing wasm <func_ptrs_6_wasm>" ,
"" [func_ptrs_6_wasm_tests] )

Definition at line 48 of file func_ptrs_tests.cpp.

48 {
50 auto code = read_wasm( std::string(wasm_directory) + "func_ptrs.6.wasm");
51 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
52}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [7/9]

BACKEND_TEST_CASE ( "Testing wasm <func_ptrs_7_wasm>" ,
"" [func_ptrs_7_wasm_tests] )

Definition at line 54 of file func_ptrs_tests.cpp.

54 {
56 auto code = read_wasm( std::string(wasm_directory) + "func_ptrs.7.wasm");
57 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
58}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [8/9]

BACKEND_TEST_CASE ( "Testing wasm <func_ptrs_8_wasm>" ,
"" [func_ptrs_8_wasm_tests] )

Definition at line 60 of file func_ptrs_tests.cpp.

60 {
62 auto code = read_wasm( std::string(wasm_directory) + "func_ptrs.8.wasm");
63 backend_t bkend( code, &wa );
64
65 CHECK(bkend.call_with_return("env", "callt", UINT32_C(0))->to_ui32() == UINT32_C(1));
66 CHECK(bkend.call_with_return("env", "callt", UINT32_C(1))->to_ui32() == UINT32_C(2));
67 CHECK(bkend.call_with_return("env", "callt", UINT32_C(2))->to_ui32() == UINT32_C(3));
68 CHECK(bkend.call_with_return("env", "callt", UINT32_C(3))->to_ui32() == UINT32_C(4));
69 CHECK(bkend.call_with_return("env", "callt", UINT32_C(4))->to_ui32() == UINT32_C(5));
70 CHECK(bkend.call_with_return("env", "callt", UINT32_C(5))->to_ui32() == UINT32_C(1));
71 CHECK(bkend.call_with_return("env", "callt", UINT32_C(6))->to_ui32() == UINT32_C(3));
72 CHECK_THROWS_AS(bkend("env", "callt", UINT32_C(7)), std::exception);
73 CHECK_THROWS_AS(bkend("env", "callt", UINT32_C(100)), std::exception);
74 CHECK_THROWS_AS(bkend("env", "callt", UINT32_C(4294967295)), std::exception);
75 CHECK(bkend.call_with_return("env", "callu", UINT32_C(0))->to_ui32() == UINT32_C(1));
76 CHECK(bkend.call_with_return("env", "callu", UINT32_C(1))->to_ui32() == UINT32_C(2));
77 CHECK(bkend.call_with_return("env", "callu", UINT32_C(2))->to_ui32() == UINT32_C(3));
78 CHECK(bkend.call_with_return("env", "callu", UINT32_C(3))->to_ui32() == UINT32_C(4));
79 CHECK(bkend.call_with_return("env", "callu", UINT32_C(4))->to_ui32() == UINT32_C(5));
80 CHECK(bkend.call_with_return("env", "callu", UINT32_C(5))->to_ui32() == UINT32_C(1));
81 CHECK(bkend.call_with_return("env", "callu", UINT32_C(6))->to_ui32() == UINT32_C(3));
82 CHECK_THROWS_AS(bkend("env", "callu", UINT32_C(7)), std::exception);
83 CHECK_THROWS_AS(bkend("env", "callu", UINT32_C(100)), std::exception);
84 CHECK_THROWS_AS(bkend("env", "callu", UINT32_C(4294967295)), std::exception);
85}
auto call_with_return(host_t &host, const std::string_view &mod, const std::string_view &func, Args... args)
Definition backend.hpp:178
#define CHECK(cond)
Definition util.h:80
wasm_allocator wa
Definition main.cpp:10
backend_t bkend(hello_wasm, ehm, &wa)
#define UINT32_C(val)
Definition stdint.h:283
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [9/9]

BACKEND_TEST_CASE ( "Testing wasm <func_ptrs_9_wasm>" ,
"" [func_ptrs_9_wasm_tests] )

Definition at line 87 of file func_ptrs_tests.cpp.

87 {
89 auto code = read_wasm( std::string(wasm_directory) + "func_ptrs.9.wasm");
90 backend_t bkend( code, &wa );
91
92 CHECK(bkend.call_with_return("env", "callt", UINT32_C(0))->to_ui32() == UINT32_C(1));
93 CHECK(bkend.call_with_return("env", "callt", UINT32_C(1))->to_ui32() == UINT32_C(2));
94}
Here is the call graph for this function:

Variable Documentation

◆ wa

wasm_allocator wa
extern

Definition at line 10 of file main.cpp.