mirror of https://github.com/status-im/evmc.git
tools: Use VM::get_raw_pointer()
This commit is contained in:
parent
347c65ae63
commit
05e3519526
|
@ -7,15 +7,8 @@
|
|||
#include <evmc/loader.h>
|
||||
#include <iostream>
|
||||
|
||||
evmc_vm* evmc_vm_test::vm;
|
||||
evmc::VM evmc_vm_test::owned_vm;
|
||||
|
||||
void evmc_vm_test::init_vm(evmc_vm* _owned_vm) noexcept
|
||||
{
|
||||
vm = _owned_vm;
|
||||
owned_vm = evmc::VM{_owned_vm};
|
||||
}
|
||||
|
||||
class cli_parser
|
||||
{
|
||||
public:
|
||||
|
@ -127,7 +120,7 @@ int main(int argc, char* argv[])
|
|||
std::cout << "Testing " << evmc_module << "\n";
|
||||
|
||||
evmc_loader_error_code ec;
|
||||
auto vm_instance = evmc_load_and_configure(evmc_module.c_str(), &ec);
|
||||
auto vm = evmc::VM{evmc_load_and_configure(evmc_module.c_str(), &ec)};
|
||||
if (ec != EVMC_LOADER_SUCCESS)
|
||||
{
|
||||
const auto error = evmc_last_error_msg();
|
||||
|
@ -138,7 +131,7 @@ int main(int argc, char* argv[])
|
|||
return static_cast<int>(ec);
|
||||
}
|
||||
|
||||
evmc_vm_test::init_vm(vm_instance);
|
||||
evmc_vm_test::set_vm(std::move(vm));
|
||||
|
||||
std::cout << std::endl;
|
||||
return RUN_ALL_TESTS();
|
||||
|
|
|
@ -9,15 +9,17 @@
|
|||
class evmc_vm_test : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
static void init_vm(evmc_vm* owned_vm) noexcept;
|
||||
static void set_vm(evmc::VM _owned_vm) noexcept { owned_vm = std::move(_owned_vm); }
|
||||
|
||||
protected:
|
||||
/// The raw pointer to the loaded VM instance.
|
||||
/// The C API is used to allow more sophisticated unit tests.
|
||||
static evmc_vm* vm;
|
||||
evmc_vm* vm = nullptr;
|
||||
|
||||
/// The C++ RAII wrapper of the loaded VM instance.
|
||||
static evmc::VM owned_vm;
|
||||
|
||||
evmc_vm_test() : vm{owned_vm.get_raw_pointer()} {}
|
||||
|
||||
void SetUp() override { ASSERT_TRUE(vm != nullptr) << "VM instance not loaded"; }
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue