Merge pull request #229 from ethereum/tests

Tests
This commit is contained in:
Paweł Bylica 2019-04-02 16:12:31 +02:00 committed by GitHub
commit 4408da2758
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 79 additions and 42 deletions

View File

@ -20,5 +20,4 @@ install:
- cmake --build . --config Release --target install - cmake --build . --config Release --target install
script: script:
- test/Release/evmc-test.exe - ctest -C Release -j4 --schedule-random --output-on-failure
- $HOME/bin/evmc-vmtester.exe $HOME/bin/evmc-example-vm.dll

View File

@ -54,7 +54,5 @@ build_script:
after_build: after_build:
- ps: >- - ps: >-
if ($env:GENERATOR) { if ($env:GENERATOR) {
cd C:\projects\evmc\build\test ctest -C $env:CONFIGURATION -j4 --schedule-random --output-on-failure
Release\evmc-test.exe
C:\install\bin\evmc-vmtester.exe C:\install\bin\evmc-example-vm.dll
} }

View File

@ -39,13 +39,9 @@ jobs:
- run: - run:
name: "Build" name: "Build"
command: cmake --build ~/build command: cmake --build ~/build
- run:
name: "Unit tests"
working_directory: ~/build/test
command: ./evmc-test
- run: - run:
name: "Test" name: "Test"
command: cmake --build ~/build --target test command: cmake --build ~/build --target test -- ARGS="-j4 --schedule-random --output-on-failure"
- run: - run:
name: "Install" name: "Install"
command: cmake --build ~/build --target install command: cmake --build ~/build --target install
@ -58,19 +54,6 @@ jobs:
- store_artifacts: - store_artifacts:
path: ~/package path: ~/package
destination: package destination: package
- run:
name: "Test CMake package config"
command: |
mkdir ~/build-example-evmc && cd ~/build-example-evmc
cmake ~/project/examples/use_evmc_in_cmake -DCMAKE_PREFIX_PATH=~/install
cmake --build .
mkdir ~/build-example-instructions && cd ~/build-example-instructions
cmake ~/project/examples/use_instructions_in_cmake -DCMAKE_PREFIX_PATH=~/install
cmake --build .
- run:
name: "Run evmc-vmtester libevmc-example-vm.so"
command: ~/install/bin/evmc-vmtester ~/install/lib/libevmc-example-vm.so
build-cxx17: build-cxx17:
<<: *build <<: *build

View File

@ -1,5 +1,6 @@
# EVMC: Ethereum Client-VM Connector API. # EVMC: Ethereum Client-VM Connector API.
# Copyright 2018 The EVMC Authors. # Copyright 2019 The EVMC Authors.
# Licensed under the Apache License, Version 2.0. See the LICENSE file. # Licensed under the Apache License, Version 2.0.
add_subdirectory(cmake_package)
add_subdirectory(compilation) add_subdirectory(compilation)

View File

@ -0,0 +1,50 @@
# EVMC: Ethereum Client-VM Connector API.
# Copyright 2019 The EVMC Authors.
# Licensed under the Apache License, Version 2.0.
set(install_dir ${CMAKE_CURRENT_BINARY_DIR}/install)
set(build_dir ${CMAKE_CURRENT_BINARY_DIR}/build)
set(use_evmc_build_dir ${CMAKE_CURRENT_BINARY_DIR}/use_evmc)
set(use_instructions_build_dir ${CMAKE_CURRENT_BINARY_DIR}/use_instructions)
file(MAKE_DIRECTORY ${build_dir} ${use_evmc_build_dir} ${use_instructions_build_dir})
add_test(
NAME cmake_package/configure
COMMAND ${CMAKE_COMMAND} ${PROJECT_SOURCE_DIR} -DCMAKE_INSTALL_PREFIX=${install_dir}
WORKING_DIRECTORY ${build_dir}
)
add_test(
NAME cmake_package/install
COMMAND ${CMAKE_COMMAND} --build ${build_dir} --target install
)
set_tests_properties(cmake_package/install PROPERTIES DEPENDS cmake_package/configure)
add_test(
NAME cmake_package/use_evmc/configure
COMMAND ${CMAKE_COMMAND} ${PROJECT_SOURCE_DIR}/examples/use_evmc_in_cmake -DCMAKE_PREFIX_PATH=${install_dir}
WORKING_DIRECTORY ${use_evmc_build_dir}
)
set_tests_properties(cmake_package/use_evmc/configure PROPERTIES DEPENDS cmake_package/install)
add_test(
NAME cmake_package/use_evmc/build
COMMAND ${CMAKE_COMMAND} --build ${use_evmc_build_dir}
)
set_tests_properties(cmake_package/use_evmc/build PROPERTIES DEPENDS cmake_package/use_evmc/configure)
add_test(
NAME cmake_package/use_instructions/configure
COMMAND ${CMAKE_COMMAND} ${PROJECT_SOURCE_DIR}/examples/use_instructions_in_cmake -DCMAKE_PREFIX_PATH=${install_dir}
WORKING_DIRECTORY ${use_instructions_build_dir}
)
set_tests_properties(cmake_package/use_instructions/configure PROPERTIES DEPENDS cmake_package/install)
add_test(
NAME cmake_package/use_instructions/build
COMMAND ${CMAKE_COMMAND} --build ${use_instructions_build_dir}
)
set_tests_properties(cmake_package/use_instructions/build PROPERTIES DEPENDS cmake_package/use_instructions/configure)

View File

@ -2,12 +2,14 @@
# Copyright 2019 The EVMC Authors. # Copyright 2019 The EVMC Authors.
# Licensed under the Apache License, Version 2.0. # Licensed under the Apache License, Version 2.0.
include(GoogleTest)
add_library(loader-mocked STATIC ${PROJECT_SOURCE_DIR}/lib/loader/loader.c) add_library(loader-mocked STATIC ${PROJECT_SOURCE_DIR}/lib/loader/loader.c)
target_link_libraries(loader-mocked PRIVATE evmc) target_link_libraries(loader-mocked PRIVATE evmc)
target_compile_definitions(loader-mocked PRIVATE EVMC_LOADER_MOCK=1) target_compile_definitions(loader-mocked PRIVATE EVMC_LOADER_MOCK=1)
add_executable( add_executable(
evmc-test evmc-unittests
loader_mock.h loader_mock.h
test_cpp.cpp test_cpp.cpp
test_helpers.cpp test_helpers.cpp
@ -15,5 +17,7 @@ add_executable(
test_loader.cpp test_loader.cpp
) )
target_link_libraries(evmc-test PRIVATE loader-mocked evmc-example-vm-static evmc-example-host instructions GTest::gtest GTest::main) target_link_libraries(evmc-unittests PRIVATE loader-mocked evmc-example-vm-static evmc-example-host instructions GTest::gtest GTest::main)
set_target_properties(evmc-test PROPERTIES RUNTIME_OUTPUT_DIRECTORY ..) set_target_properties(evmc-unittests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ..)
gtest_add_tests(TARGET evmc-unittests TEST_PREFIX unittests/)

View File

@ -12,23 +12,25 @@ set_source_files_properties(vmtester.cpp PROPERTIES COMPILE_DEFINITIONS PROJECT_
install(TARGETS evmc-vmtester RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) install(TARGETS evmc-vmtester RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
add_test(NAME vmtester-help COMMAND evmc-vmtester --version --help) add_test(NAME vmtester/examplevm COMMAND evmc-vmtester $<TARGET_FILE:evmc-example-vm>)
set_tests_properties(vmtester-help PROPERTIES PASS_REGULAR_EXPRESSION "Usage:")
add_test(NAME vmtester-nonexistingvm COMMAND evmc-vmtester nonexistingvm) add_test(NAME vmtester/help COMMAND evmc-vmtester --version --help)
set_tests_properties(vmtester-nonexistingvm PROPERTIES PASS_REGULAR_EXPRESSION "Cannot open") set_tests_properties(vmtester/help PROPERTIES PASS_REGULAR_EXPRESSION "Usage:")
add_test(NAME vmtester-noarg COMMAND evmc-vmtester) add_test(NAME vmtester/nonexistingvm COMMAND evmc-vmtester nonexistingvm)
set_tests_properties(vmtester-noarg PROPERTIES PASS_REGULAR_EXPRESSION "is required") set_tests_properties(vmtester/nonexistingvm PROPERTIES PASS_REGULAR_EXPRESSION "Cannot open")
add_test(NAME vmtester-too-many-args COMMAND evmc-vmtester a b) add_test(NAME vmtester/noarg COMMAND evmc-vmtester)
set_tests_properties(vmtester-too-many-args PROPERTIES PASS_REGULAR_EXPRESSION "Unexpected") set_tests_properties(vmtester/noarg PROPERTIES PASS_REGULAR_EXPRESSION "is required")
add_test(NAME vmtester-version COMMAND evmc-vmtester --version) add_test(NAME vmtester/too-many-args COMMAND evmc-vmtester a b)
set_tests_properties(vmtester-version PROPERTIES PASS_REGULAR_EXPRESSION ${PROJECT_VERSION}) set_tests_properties(vmtester/too-many-args PROPERTIES PASS_REGULAR_EXPRESSION "Unexpected")
add_test(NAME vmtester-unknown-option COMMAND evmc-vmtester --verbose) add_test(NAME vmtester/version COMMAND evmc-vmtester --version)
set_tests_properties(vmtester-unknown-option PROPERTIES PASS_REGULAR_EXPRESSION "Unknown") set_tests_properties(vmtester/version PROPERTIES PASS_REGULAR_EXPRESSION ${PROJECT_VERSION})
add_test(NAME vmtester-option-long-prefix COMMAND evmc-vmtester ---) add_test(NAME vmtester/unknown-option COMMAND evmc-vmtester --verbose)
set_tests_properties(vmtester-option-long-prefix PROPERTIES PASS_REGULAR_EXPRESSION "Unknown") set_tests_properties(vmtester/unknown-option PROPERTIES PASS_REGULAR_EXPRESSION "Unknown")
add_test(NAME vmtester/option-long-prefix COMMAND evmc-vmtester ---)
set_tests_properties(vmtester/option-long-prefix PROPERTIES PASS_REGULAR_EXPRESSION "Unknown")