cmake: Move vmtester from test/ to tools/

This commit is contained in:
Paweł Bylica 2019-11-27 12:34:28 +01:00
parent 36d9f14307
commit c2f77c9da2
No known key found for this signature in database
GPG Key ID: 7A0C037434FE77EF
10 changed files with 53 additions and 47 deletions

View File

@ -53,18 +53,19 @@ target_include_directories(evmc INTERFACE $<BUILD_INTERFACE:${include_dir}>$<INS
add_subdirectory(lib)
if(EVMC_TOOLS)
add_subdirectory(tools)
endif()
if(EVMC_EXAMPLES)
add_subdirectory(examples)
endif()
if(EVMC_TESTING)
enable_testing()
endif()
if(EVMC_TESTING OR EVMC_TOOLS)
add_subdirectory(test)
endif()
if(EVMC_TESTING OR EVMC_EXAMPLES)
add_subdirectory(examples)
endif()
write_basic_package_version_file(evmcConfigVersion.cmake COMPATIBILITY ExactVersion)
configure_package_config_file(

View File

@ -50,7 +50,7 @@ commands:
- persist_to_workspace:
root: ~/build
paths:
- test/evmc-vmtester
- bin/evmc-vmtester
- examples/evmc-example
jobs:
@ -204,7 +204,7 @@ jobs:
- run:
name: Test with evmc-vmtester
command: |
~/build/test/evmc-vmtester target/debug/libexamplerustvm.so
~/build/bin/evmc-vmtester target/debug/libexamplerustvm.so
- run:
name: Test with evmc-example
command: |
@ -235,7 +235,7 @@ jobs:
- run:
name: Test with evmc-vmtester
command: |
~/build/test/evmc-vmtester target/x86_64-unknown-linux-gnu/debug/libexamplerustvm.so
~/build/bin/evmc-vmtester target/x86_64-unknown-linux-gnu/debug/libexamplerustvm.so
- run:
name: Test with evmc-example
command: |

View File

@ -2,21 +2,6 @@
# Copyright 2018-2019 The EVMC Authors.
# Licensed under the Apache License, Version 2.0.
hunter_add_package(GTest)
find_package(GTest CONFIG REQUIRED)
# Disable support for std::tr1::tuple in GTest. This causes problems in Visual Studio 2015.
set_target_properties(GTest::gtest PROPERTIES INTERFACE_COMPILE_DEFINITIONS GTEST_HAS_TR1_TUPLE=0)
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_C_EXTENSIONS OFF)
endif()
if(EVMC_TESTING)
add_subdirectory(integration)
add_subdirectory(unittests)
endif()
add_subdirectory(integration)
add_subdirectory(unittests)
add_subdirectory(vmtester)

View File

@ -4,6 +4,12 @@
include(GoogleTest)
hunter_add_package(GTest)
find_package(GTest CONFIG REQUIRED)
# Disable support for std::tr1::tuple in GTest. This causes problems in Visual Studio 2015.
set_target_properties(GTest::gtest PROPERTIES INTERFACE_COMPILE_DEFINITIONS GTEST_HAS_TR1_TUPLE=0)
add_library(loader-mocked STATIC ${PROJECT_SOURCE_DIR}/lib/loader/loader.c)
target_link_libraries(loader-mocked PRIVATE evmc)
target_compile_definitions(loader-mocked PRIVATE EVMC_LOADER_MOCK=1)
@ -24,7 +30,7 @@ target_link_libraries(
evmc::example-vm-static
evmc::example-precompiles-vm-static
evmc-example-host
instructions
evmc::instructions
GTest::gtest_main
)
set_target_properties(evmc-unittests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ..)

View File

@ -3,41 +3,29 @@
# 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::mocked_host GTest::gtest)
set_source_files_properties(vmtester.cpp PROPERTIES COMPILE_DEFINITIONS PROJECT_VERSION="${PROJECT_VERSION}")
add_executable(evmc::evmc-vmtester ALIAS evmc-vmtester)
if(EVMC_INSTALL)
install(TARGETS evmc-vmtester EXPORT evmcTargets RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
set(prefix ${PROJECT_NAME}/vmtester)
evmc_add_vm_test(NAME ${prefix}/examplevm TARGET example-vm)
evmc_add_vm_test(NAME ${prefix}/example_precompiles_vm TARGET example-precompiles-vm)
add_test(NAME ${prefix}/help COMMAND evmc-vmtester --version --help)
add_test(NAME ${prefix}/help COMMAND evmc::evmc-vmtester --version --help)
set_tests_properties(${prefix}/help PROPERTIES PASS_REGULAR_EXPRESSION "Usage:")
add_test(NAME ${prefix}/nonexistingvm COMMAND evmc-vmtester nonexistingvm)
add_test(NAME ${prefix}/nonexistingvm COMMAND evmc::evmc-vmtester nonexistingvm)
set_tests_properties(${prefix}/nonexistingvm PROPERTIES PASS_REGULAR_EXPRESSION "[Cc]annot open")
add_test(NAME ${prefix}/noarg COMMAND evmc-vmtester)
add_test(NAME ${prefix}/noarg COMMAND evmc::evmc-vmtester)
set_tests_properties(${prefix}/noarg PROPERTIES PASS_REGULAR_EXPRESSION "is required")
add_test(NAME ${prefix}/too-many-args COMMAND evmc-vmtester a b)
add_test(NAME ${prefix}/too-many-args COMMAND evmc::evmc-vmtester a b)
set_tests_properties(${prefix}/too-many-args PROPERTIES PASS_REGULAR_EXPRESSION "Unexpected")
add_test(NAME ${prefix}/version COMMAND evmc-vmtester --version)
add_test(NAME ${prefix}/version COMMAND evmc::evmc-vmtester --version)
set_tests_properties(${prefix}/version PROPERTIES PASS_REGULAR_EXPRESSION ${PROJECT_VERSION})
add_test(NAME ${prefix}/unknown-option COMMAND evmc-vmtester --verbose)
add_test(NAME ${prefix}/unknown-option COMMAND evmc::evmc-vmtester --verbose)
set_tests_properties(${prefix}/unknown-option PROPERTIES PASS_REGULAR_EXPRESSION "Unknown")
add_test(NAME ${prefix}/option-long-prefix COMMAND evmc-vmtester ---)
add_test(NAME ${prefix}/option-long-prefix COMMAND evmc::evmc-vmtester ---)
set_tests_properties(${prefix}/option-long-prefix PROPERTIES PASS_REGULAR_EXPRESSION "Unknown")

5
tools/CMakeLists.txt Normal file
View File

@ -0,0 +1,5 @@
# EVMC: Ethereum Client-VM Connector API.
# Copyright 2019 The EVMC Authors.
# Licensed under the Apache License, Version 2.0.
add_subdirectory(vmtester)

View File

@ -0,0 +1,21 @@
# EVMC: Ethereum Client-VM Connector API.
# Copyright 2018-2019 The EVMC Authors.
# Licensed under the Apache License, Version 2.0.
include(GNUInstallDirs)
hunter_add_package(GTest)
find_package(GTest CONFIG REQUIRED)
# Disable support for std::tr1::tuple in GTest. This causes problems in Visual Studio 2015.
set_target_properties(GTest::gtest PROPERTIES INTERFACE_COMPILE_DEFINITIONS GTEST_HAS_TR1_TUPLE=0)
add_executable(evmc-vmtester vmtester.hpp vmtester.cpp tests.cpp)
set_target_properties(evmc-vmtester PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
target_link_libraries(evmc-vmtester PRIVATE evmc::loader evmc::mocked_host GTest::gtest)
set_source_files_properties(vmtester.cpp PROPERTIES COMPILE_DEFINITIONS PROJECT_VERSION="${PROJECT_VERSION}")
add_executable(evmc::evmc-vmtester ALIAS evmc-vmtester)
if(EVMC_INSTALL)
install(TARGETS evmc-vmtester EXPORT evmcTargets RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()