mirror of https://github.com/status-im/evmc.git
Add unit tests for "evmc_create()"
This commit is contained in:
parent
8006ef86c2
commit
391a300d08
|
@ -5,6 +5,10 @@
|
||||||
add_library(vm-mock SHARED vm_mock.c)
|
add_library(vm-mock SHARED vm_mock.c)
|
||||||
target_link_libraries(vm-mock PRIVATE evmc)
|
target_link_libraries(vm-mock PRIVATE evmc)
|
||||||
|
|
||||||
|
add_library(vm-mock-default SHARED vm_mock_default.c)
|
||||||
|
target_link_libraries(vm-mock-default PRIVATE evmc)
|
||||||
|
|
||||||
|
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
set(cmd create_symlink)
|
set(cmd create_symlink)
|
||||||
else()
|
else()
|
||||||
|
@ -13,6 +17,7 @@ endif()
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET vm-mock POST_BUILD
|
TARGET vm-mock POST_BUILD
|
||||||
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E ${cmd} $<TARGET_FILE:vm-mock> libaaa.so
|
COMMAND ${CMAKE_COMMAND} -E ${cmd} $<TARGET_FILE:vm-mock> libaaa.so
|
||||||
COMMAND ${CMAKE_COMMAND} -E ${cmd} $<TARGET_FILE:vm-mock> double_prefix_aaa.evm
|
COMMAND ${CMAKE_COMMAND} -E ${cmd} $<TARGET_FILE:vm-mock> double_prefix_aaa.evm
|
||||||
COMMAND ${CMAKE_COMMAND} -E ${cmd} $<TARGET_FILE:vm-mock> double-prefix-aaa.evm
|
COMMAND ${CMAKE_COMMAND} -E ${cmd} $<TARGET_FILE:vm-mock> double-prefix-aaa.evm
|
||||||
|
@ -26,6 +31,9 @@ add_custom_command(
|
||||||
COMMAND ${CMAKE_COMMAND} -E ${cmd} $<TARGET_FILE:vm-mock> ../aaa.evm
|
COMMAND ${CMAKE_COMMAND} -E ${cmd} $<TARGET_FILE:vm-mock> ../aaa.evm
|
||||||
COMMAND ${CMAKE_COMMAND} -E ${cmd} $<TARGET_FILE:vm-mock> failure.vm
|
COMMAND ${CMAKE_COMMAND} -E ${cmd} $<TARGET_FILE:vm-mock> failure.vm
|
||||||
COMMAND ${CMAKE_COMMAND} -E ${cmd} $<TARGET_FILE:vm-mock> abi42.vm
|
COMMAND ${CMAKE_COMMAND} -E ${cmd} $<TARGET_FILE:vm-mock> abi42.vm
|
||||||
|
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E ${cmd} $<TARGET_FILE:vm-mock-default> default.evmc
|
||||||
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E touch empty.file
|
COMMAND ${CMAKE_COMMAND} -E touch empty.file
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -245,6 +245,19 @@ TEST(loader, lib_)
|
||||||
EXPECT_EQ(x, nullptr);
|
EXPECT_EQ(x, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(loader, load_default)
|
||||||
|
{
|
||||||
|
auto path = "unittests/default.evmc";
|
||||||
|
|
||||||
|
evmc_loader_error_code ec;
|
||||||
|
auto fn = evmc_load(path, &ec);
|
||||||
|
EXPECT_EQ(ec, EVMC_LOADER_SUCCESS);
|
||||||
|
EXPECT_EQ((uintptr_t)fn(), 0xdeaf);
|
||||||
|
|
||||||
|
fn = evmc_load(path, nullptr);
|
||||||
|
EXPECT_EQ((uintptr_t)fn(), 0xdeaf);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(loader, load_and_create_failure)
|
TEST(loader, load_and_create_failure)
|
||||||
{
|
{
|
||||||
evmc_loader_error_code ec;
|
evmc_loader_error_code ec;
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
/* EVMC: Ethereum Client-VM Connector API.
|
||||||
|
* Copyright 2018 The EVMC Authors.
|
||||||
|
* Licensed under the Apache License, Version 2.0. See the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <evmc/utils.h>
|
||||||
|
|
||||||
|
EVMC_EXPORT void* evmc_create()
|
||||||
|
{
|
||||||
|
return (void*)0xdeaf;
|
||||||
|
}
|
Loading…
Reference in New Issue