diff --git a/.travis.yml b/.travis.yml index 04d8dc2..c4243b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,5 +20,4 @@ install: - cmake --build . --config Release --target install script: - - test/Release/evmc-test.exe - - $HOME/bin/evmc-vmtester.exe $HOME/bin/evmc-example-vm.dll + - ctest -C Release -j4 --schedule-random --output-on-failure diff --git a/appveyor.yml b/appveyor.yml index 6a35abf..05e9b43 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -54,7 +54,5 @@ build_script: after_build: - ps: >- if ($env:GENERATOR) { - cd C:\projects\evmc\build\test - Release\evmc-test.exe - C:\install\bin\evmc-vmtester.exe C:\install\bin\evmc-example-vm.dll + ctest -C $env:CONFIGURATION -j4 --schedule-random --output-on-failure } diff --git a/circle.yml b/circle.yml index 603db99..89474d4 100644 --- a/circle.yml +++ b/circle.yml @@ -39,13 +39,9 @@ jobs: - run: name: "Build" command: cmake --build ~/build - - run: - name: "Unit tests" - working_directory: ~/build/test - command: ./evmc-test - run: name: "Test" - command: cmake --build ~/build --target test + command: cmake --build ~/build --target test -- ARGS="-j4 --schedule-random --output-on-failure" - run: name: "Install" command: cmake --build ~/build --target install @@ -58,19 +54,6 @@ jobs: - store_artifacts: path: ~/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 diff --git a/test/integration/CMakeLists.txt b/test/integration/CMakeLists.txt index 0355a47..0d0790e 100644 --- a/test/integration/CMakeLists.txt +++ b/test/integration/CMakeLists.txt @@ -1,5 +1,6 @@ # EVMC: Ethereum Client-VM Connector API. -# Copyright 2018 The EVMC Authors. -# Licensed under the Apache License, Version 2.0. See the LICENSE file. +# Copyright 2019 The EVMC Authors. +# Licensed under the Apache License, Version 2.0. +add_subdirectory(cmake_package) add_subdirectory(compilation) diff --git a/test/integration/cmake_package/CMakeLists.txt b/test/integration/cmake_package/CMakeLists.txt new file mode 100644 index 0000000..b363330 --- /dev/null +++ b/test/integration/cmake_package/CMakeLists.txt @@ -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) diff --git a/test/unittests/CMakeLists.txt b/test/unittests/CMakeLists.txt index 94ccc97..919633c 100644 --- a/test/unittests/CMakeLists.txt +++ b/test/unittests/CMakeLists.txt @@ -2,12 +2,14 @@ # Copyright 2019 The EVMC Authors. # Licensed under the Apache License, Version 2.0. +include(GoogleTest) + 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) add_executable( - evmc-test + evmc-unittests loader_mock.h test_cpp.cpp test_helpers.cpp @@ -15,5 +17,7 @@ add_executable( test_loader.cpp ) -target_link_libraries(evmc-test PRIVATE loader-mocked evmc-example-vm-static evmc-example-host instructions GTest::gtest GTest::main) -set_target_properties(evmc-test PROPERTIES RUNTIME_OUTPUT_DIRECTORY ..) +target_link_libraries(evmc-unittests PRIVATE loader-mocked evmc-example-vm-static evmc-example-host instructions GTest::gtest GTest::main) +set_target_properties(evmc-unittests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ..) + +gtest_add_tests(TARGET evmc-unittests TEST_PREFIX unittests/) diff --git a/test/vmtester/CMakeLists.txt b/test/vmtester/CMakeLists.txt index cb0097c..33d5630 100644 --- a/test/vmtester/CMakeLists.txt +++ b/test/vmtester/CMakeLists.txt @@ -12,23 +12,25 @@ set_source_files_properties(vmtester.cpp PROPERTIES COMPILE_DEFINITIONS PROJECT_ install(TARGETS evmc-vmtester RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -add_test(NAME vmtester-help COMMAND evmc-vmtester --version --help) -set_tests_properties(vmtester-help PROPERTIES PASS_REGULAR_EXPRESSION "Usage:") +add_test(NAME vmtester/examplevm COMMAND evmc-vmtester $) -add_test(NAME vmtester-nonexistingvm COMMAND evmc-vmtester nonexistingvm) -set_tests_properties(vmtester-nonexistingvm PROPERTIES PASS_REGULAR_EXPRESSION "Cannot open") +add_test(NAME vmtester/help COMMAND evmc-vmtester --version --help) +set_tests_properties(vmtester/help PROPERTIES PASS_REGULAR_EXPRESSION "Usage:") -add_test(NAME vmtester-noarg COMMAND evmc-vmtester) -set_tests_properties(vmtester-noarg PROPERTIES PASS_REGULAR_EXPRESSION "is required") +add_test(NAME vmtester/nonexistingvm COMMAND evmc-vmtester nonexistingvm) +set_tests_properties(vmtester/nonexistingvm PROPERTIES PASS_REGULAR_EXPRESSION "Cannot open") -add_test(NAME vmtester-too-many-args COMMAND evmc-vmtester a b) -set_tests_properties(vmtester-too-many-args PROPERTIES PASS_REGULAR_EXPRESSION "Unexpected") +add_test(NAME vmtester/noarg COMMAND evmc-vmtester) +set_tests_properties(vmtester/noarg PROPERTIES PASS_REGULAR_EXPRESSION "is required") -add_test(NAME vmtester-version COMMAND evmc-vmtester --version) -set_tests_properties(vmtester-version PROPERTIES PASS_REGULAR_EXPRESSION ${PROJECT_VERSION}) +add_test(NAME vmtester/too-many-args COMMAND evmc-vmtester a b) +set_tests_properties(vmtester/too-many-args PROPERTIES PASS_REGULAR_EXPRESSION "Unexpected") -add_test(NAME vmtester-unknown-option COMMAND evmc-vmtester --verbose) -set_tests_properties(vmtester-unknown-option PROPERTIES PASS_REGULAR_EXPRESSION "Unknown") +add_test(NAME vmtester/version COMMAND evmc-vmtester --version) +set_tests_properties(vmtester/version PROPERTIES PASS_REGULAR_EXPRESSION ${PROJECT_VERSION}) -add_test(NAME vmtester-option-long-prefix COMMAND evmc-vmtester ---) -set_tests_properties(vmtester-option-long-prefix PROPERTIES PASS_REGULAR_EXPRESSION "Unknown") +add_test(NAME vmtester/unknown-option COMMAND evmc-vmtester --verbose) +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")