Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
memory_redundancy_tests.cpp
Go to the documentation of this file.
1// Generated by spec_test_generator. DO NOT MODIFY THIS FILE.
2
3#include <algorithm>
4#include <vector>
5#include <iostream>
6#include <iterator>
7#include <cmath>
8#include <cstdlib>
9#include <catch2/catch.hpp>
10#include <utils.hpp>
11#include <wasm_config.hpp>
12#include <sysio/vm/backend.hpp>
13
14using namespace sysio;
15using namespace sysio::vm;
16extern wasm_allocator wa;
17
18BACKEND_TEST_CASE( "Testing wasm <memory_redundancy_0_wasm>", "[memory_redundancy_0_wasm_tests]" ) {
20 auto code = read_wasm( std::string(wasm_directory) + "memory_redundancy.0.wasm");
21 backend_t bkend( code, &wa );
22
23 CHECK(bkend.call_with_return("env", "test_store_to_load")->to_ui32() == UINT32_C(128));
24bkend("env", "zero_everything");
25 CHECK(bkend.call_with_return("env", "test_redundant_load")->to_ui32() == UINT32_C(128));
26bkend("env", "zero_everything");
27 CHECK(bit_cast<uint32_t>(bkend.call_with_return("env", "test_dead_store")->to_f32()) == UINT32_C(35));
28bkend("env", "zero_everything");
29 CHECK(bkend.call_with_return("env", "malloc_aliasing")->to_ui32() == UINT32_C(43));
30}
31
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
backend_t bkend(hello_wasm, ehm, &wa)
wasm_allocator wa
Definition main.cpp:10
std::vector< uint8_t > read_wasm(const std::string &fname)
Definition utils.hpp:30
#define UINT32_C(val)
Definition stdint.h:283
#define BACKEND_TEST_CASE(name, tags)
Definition utils.hpp:59
T bit_cast(const U &u)
Definition utils.hpp:35