From fc6b80b7c4166da48d4a5a8e799dba25c51a3e6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Wed, 29 May 2019 14:13:31 +0200 Subject: [PATCH 1/3] cmake: Add helper for adding vmtester based VM test --- cmake/EVMC.cmake | 18 ++++++++++++++++++ test/vmtester/CMakeLists.txt | 8 +++++--- 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 cmake/EVMC.cmake diff --git a/cmake/EVMC.cmake b/cmake/EVMC.cmake new file mode 100644 index 000000000..6a735848e --- /dev/null +++ b/cmake/EVMC.cmake @@ -0,0 +1,18 @@ +# EVMC: Ethereum Client-VM Connector API. +# Copyright 2019 The EVMC Authors. +# Licensed under the Apache License, Version 2.0. + + +# Adds a CMake test to check the given EVMC VM implementation with the evmc-vmtester tool. +# +# evmc_add_vm_test(NAME TARGET ) +# - NAME argument specifies the name of the added test, +# - TARGET argument specifies the CMake target being a shared library with EVMC VM implementation. +function(evmc_add_vm_test) + if(NOT TARGET evmc::evmc-vmtester) + message(FATAL_ERROR "The evmc-vmtester has not been installed with this EVMC package") + endif() + + cmake_parse_arguments("" "" NAME;TARGET "" ${ARGN}) + add_test(NAME ${_NAME} COMMAND $ $) +endfunction() diff --git a/test/vmtester/CMakeLists.txt b/test/vmtester/CMakeLists.txt index 2f33200a4..b87dfb233 100644 --- a/test/vmtester/CMakeLists.txt +++ b/test/vmtester/CMakeLists.txt @@ -2,20 +2,22 @@ # Copyright 2018-2019 The EVMC Authors. # Licensed under the Apache License, Version 2.0. +include(EVMC) include(GNUInstallDirs) add_executable(evmc-vmtester vmtester.hpp vmtester.cpp tests.cpp) set_target_properties(evmc-vmtester PROPERTIES RUNTIME_OUTPUT_DIRECTORY ..) target_link_libraries(evmc-vmtester PRIVATE evmc loader evmc-example-host GTest::gtest) set_source_files_properties(vmtester.cpp PROPERTIES COMPILE_DEFINITIONS PROJECT_VERSION="${PROJECT_VERSION}") +add_executable(evmc::evmc-vmtester ALIAS evmc-vmtester) -install(TARGETS evmc-vmtester RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(TARGETS evmc-vmtester EXPORT evmcTargets RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) set(prefix ${PROJECT_NAME}/vmtester) -add_test(NAME ${prefix}/examplevm COMMAND evmc-vmtester $) -add_test(NAME ${prefix}/example_precompiles_vm COMMAND evmc-vmtester $) +evmc_add_vm_test(NAME ${prefix}/examplevm TARGET evmc-example-vm) +evmc_add_vm_test(NAME ${prefix}/example_precompiles_vm TARGET evmc-example-precompiles-vm) add_test(NAME ${prefix}/help COMMAND evmc-vmtester --version --help) set_tests_properties(${prefix}/help PROPERTIES PASS_REGULAR_EXPRESSION "Usage:") From fece3b066ca295710fec60d427cb5ee06f1156c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Wed, 29 May 2019 14:44:36 +0200 Subject: [PATCH 2/3] cmake: Include EVMC.cmake module in the package --- CMakeLists.txt | 1 + cmake/Config.cmake.in | 4 +++- examples/use_evmc_in_cmake/CMakeLists.txt | 7 +++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 027819c86..aa0472e98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,6 +79,7 @@ install( FILES ${CMAKE_CURRENT_BINARY_DIR}/evmcConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/evmcConfigVersion.cmake + cmake/EVMC.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/evmc ) diff --git a/cmake/Config.cmake.in b/cmake/Config.cmake.in index 13df106bb..84e2d806b 100644 --- a/cmake/Config.cmake.in +++ b/cmake/Config.cmake.in @@ -1,4 +1,6 @@ @PACKAGE_INIT@ -include("${CMAKE_CURRENT_LIST_DIR}/evmcTargets.cmake") +include(${CMAKE_CURRENT_LIST_DIR}/evmcTargets.cmake) check_required_components(evmc) + +include(${CMAKE_CURRENT_LIST_DIR}/EVMC.cmake) diff --git a/examples/use_evmc_in_cmake/CMakeLists.txt b/examples/use_evmc_in_cmake/CMakeLists.txt index 06da88786..0871fefab 100644 --- a/examples/use_evmc_in_cmake/CMakeLists.txt +++ b/examples/use_evmc_in_cmake/CMakeLists.txt @@ -12,3 +12,10 @@ find_package(evmc CONFIG REQUIRED) add_executable(use_evmc_in_cmake use_evmc_in_cmake.c) target_link_libraries(use_evmc_in_cmake PRIVATE evmc::evmc) + + + +# Only for integration tests. +if(NOT COMMAND evmc_add_vm_test) + message(FATAL_ERROR "Function evmc_add_vm_test() not in EVMC.cmake module") +endif() From 2a2a7328d9530e7584e7aab63e5c927a050810f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Wed, 17 Jul 2019 14:20:46 +0200 Subject: [PATCH 3/3] changelog: Add entry about evmc-vmtester's CMake helper --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 89a067727..b4b691a51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## [6.3.0] - unreleased +- Added: [[#303](https://github.com/ethereum/evmc/pull/303)] + A CMake helper for running evmc-vmtester. - Added: [[#313](https://github.com/ethereum/evmc/pull/313)] The loader module introduces standardized EVMC module configuration string which contains path to the module and additional options.