Skip to content
This repository was archived by the owner on Apr 8, 2026. It is now read-only.

Commit e2bd548

Browse files
committed
cmake: Add helper for adding vmtester based VM test
1 parent 34be102 commit e2bd548

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

cmake/EVMC.cmake

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# EVMC: Ethereum Client-VM Connector API.
2+
# Copyright 2019 The EVMC Authors.
3+
# Licensed under the Apache License, Version 2.0.
4+
5+
6+
# Adds a CMake test to check the given EVMC VM implementation with the evmc-vmtester tool.
7+
#
8+
# evmc_add_vm_test(NAME <test_name> TARGET <vm>)
9+
# - NAME argument specifies the name of the added test,
10+
# - TARGET argument specifies the CMake target being a shared library with EVMC VM implementation.
11+
function(evmc_add_vm_test)
12+
if(NOT TARGET evmc::evmc-vmtester)
13+
message(FATAL_ERROR "The evmc-vmtester has not been installed with this EVMC package")
14+
endif()
15+
16+
cmake_parse_arguments("" "" NAME;TARGET "" ${ARGN})
17+
add_test(NAME ${_NAME} COMMAND $<TARGET_FILE:evmc::evmc-vmtester> $<TARGET_FILE:${_TARGET}>)
18+
endfunction()

test/vmtester/CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,22 @@
22
# Copyright 2018-2019 The EVMC Authors.
33
# Licensed under the Apache License, Version 2.0.
44

5+
include(EVMC)
56
include(GNUInstallDirs)
67

78
add_executable(evmc-vmtester vmtester.hpp vmtester.cpp tests.cpp)
89
set_target_properties(evmc-vmtester PROPERTIES RUNTIME_OUTPUT_DIRECTORY ..)
910
target_link_libraries(evmc-vmtester PRIVATE evmc loader evmc-example-host GTest::gtest)
1011
set_source_files_properties(vmtester.cpp PROPERTIES COMPILE_DEFINITIONS PROJECT_VERSION="${PROJECT_VERSION}")
12+
add_executable(evmc::evmc-vmtester ALIAS evmc-vmtester)
1113

1214

13-
install(TARGETS evmc-vmtester RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
15+
install(TARGETS evmc-vmtester EXPORT evmcTargets RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
1416

1517
set(prefix ${PROJECT_NAME}/vmtester)
1618

17-
add_test(NAME ${prefix}/examplevm COMMAND evmc-vmtester $<TARGET_FILE:evmc-example-vm>)
18-
add_test(NAME ${prefix}/example_precompiles_vm COMMAND evmc-vmtester $<TARGET_FILE:evmc-example-precompiles-vm>)
19+
evmc_add_vm_test(NAME ${prefix}/examplevm TARGET evmc-example-vm)
20+
evmc_add_vm_test(NAME ${prefix}/example_precompiles_vm TARGET evmc-example-precompiles-vm)
1921

2022
add_test(NAME ${prefix}/help COMMAND evmc-vmtester --version --help)
2123
set_tests_properties(${prefix}/help PROPERTIES PASS_REGULAR_EXPRESSION "Usage:")

0 commit comments

Comments
 (0)