diff --git a/test/integration/CMakeLists.txt b/test/integration/CMakeLists.txt index d6169e8cac..a8c282ad80 100644 --- a/test/integration/CMakeLists.txt +++ b/test/integration/CMakeLists.txt @@ -31,7 +31,10 @@ DUP1,4 {\"error\":null,\"gas\":999985,\"gasUsed\":15,\"output\":\"\"} ") - - get_property(ALL_TESTS DIRECTORY PROPERTY TESTS) - set_tests_properties(${ALL_TESTS} PROPERTIES ENVIRONMENT LLVM_PROFILE_FILE=${CMAKE_BINARY_DIR}/integration-%p.profraw) endif() + +add_subdirectory(statetest) + +get_property(ALL_TESTS DIRECTORY PROPERTY TESTS) +set_tests_properties(${ALL_TESTS} PROPERTIES ENVIRONMENT LLVM_PROFILE_FILE=${CMAKE_BINARY_DIR}/integration-%p.profraw) + diff --git a/test/integration/statetest/CMakeLists.txt b/test/integration/statetest/CMakeLists.txt new file mode 100644 index 0000000000..1fa57159a3 --- /dev/null +++ b/test/integration/statetest/CMakeLists.txt @@ -0,0 +1,32 @@ +# evmone: Fast Ethereum Virtual Machine implementation +# Copyright 2022 The evmone Authors. +# SPDX-License-Identifier: Apache-2.0 + +# Integration tests for evmone-statetest. + +set(PREFIX ${PREFIX}/statetest) +set(TESTS1 ${CMAKE_CURRENT_SOURCE_DIR}/tests1) + +add_test( + NAME ${PREFIX}/missing_arg + COMMAND evmone-statetest +) +set_tests_properties( + ${PREFIX}/missing_arg PROPERTIES + PASS_REGULAR_EXPRESSION "Missing argument with the path to the tests directory" +) + +add_test( + NAME ${PREFIX}/tests1_list + COMMAND evmone-statetest ${TESTS1} --gtest_list_tests +) +set_tests_properties( + ${PREFIX}/tests1_list PROPERTIES + PASS_REGULAR_EXPRESSION [[ +B\. + T +SuiteA\. + test1 + test2 +]] +) diff --git a/test/integration/statetest/tests1/B/T.json b/test/integration/statetest/tests1/B/T.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/integration/statetest/tests1/SuiteA/test1.json b/test/integration/statetest/tests1/SuiteA/test1.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/integration/statetest/tests1/SuiteA/test2.json b/test/integration/statetest/tests1/SuiteA/test2.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/statetest/statetest.cpp b/test/statetest/statetest.cpp index 9ef65537f0..f3c7c56b36 100644 --- a/test/statetest/statetest.cpp +++ b/test/statetest/statetest.cpp @@ -19,32 +19,34 @@ class StateTest : public testing::Test void TestBody() final { evmone::test::load_state_test(m_json_test_file); } }; -} // namespace -int main(int argc, char* argv[]) +void register_test_files(const fs::path& root_dir) { - testing::InitGoogleTest(&argc, argv); // Process GoogleTest flags. - - if (argc != 2) - { - std::cerr << "Missing argument with the path to the tests directory\n"; - return -1; - } - std::vector test_files; - const fs::path root_test_dir{argv[1]}; - std::copy_if(fs::recursive_directory_iterator{root_test_dir}, - fs::recursive_directory_iterator{}, std::back_inserter(test_files), - [](const fs::directory_entry& entry) { + std::copy_if(fs::recursive_directory_iterator{root_dir}, fs::recursive_directory_iterator{}, + std::back_inserter(test_files), [](const fs::directory_entry& entry) { return entry.is_regular_file() && entry.path().extension() == ".json"; }); std::sort(test_files.begin(), test_files.end()); for (const auto& p : test_files) { - const auto d = fs::relative(p, root_test_dir); + const auto d = fs::relative(p, root_dir); testing::RegisterTest(d.parent_path().string().c_str(), d.stem().string().c_str(), nullptr, nullptr, p.string().c_str(), 0, [p]() -> testing::Test* { return new StateTest(p); }); } +} +} // namespace + +int main(int argc, char* argv[]) +{ + testing::InitGoogleTest(&argc, argv); // Process GoogleTest flags. + + if (argc != 2) + { + std::cerr << "Missing argument with the path to the tests directory\n"; + return -1; + } + register_test_files(argv[1]); return RUN_ALL_TESTS(); }