Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,10 @@ commands:
fixtures_suffix:
type: string
default: ""
filter:
ignore:
description: "--ignore flags for the paths not to collect"
type: string
default: "*"
default: ""
steps:
- download_execution_spec_tests:
repo: <<parameters.repo>>
Expand All @@ -176,14 +177,14 @@ commands:
working_directory: ~/build
command: >
LLVM_PROFILE_FILE=state_tests.profraw
bin/evmone-statetest --gtest_filter='<<parameters.filter>>' ~/spec-tests/fixtures/state_tests
bin/evmone-statetest <<parameters.ignore>> ~/spec-tests/fixtures/state_tests
- run:
name: "Execution spec tests (<<parameters.release>>, blockchain_tests)"
# Tests for in-development EVM revision currently passing.
working_directory: ~/build
command: >
LLVM_PROFILE_FILE=blockchain_tests.profraw
bin/evmone-blockchaintest --gtest_filter='<<parameters.filter>>' ~/spec-tests/fixtures/blockchain_tests
bin/evmone-blockchaintest <<parameters.ignore>> ~/spec-tests/fixtures/blockchain_tests

configure:
description: "Configure"
Expand Down Expand Up @@ -467,7 +468,7 @@ jobs:
- run_execution_spec_tests:
release: tests-glamsterdam-devnet@v8.1.2
fixtures_suffix: _glamsterdam-devnet
filter: "-for_amsterdam/*:for_bpo2toamsterdamattime15k/*"
ignore: "--ignore for_amsterdam --ignore for_bpo2toamsterdamattime15k"
- collect_coverage_clang:
flags: eest-develop
ignore_filename_regex: lib/evmone/(advanced|cpu_check|eof|lru_cache|tracing|vm)|test/(experimental|unittests)
Expand Down Expand Up @@ -517,7 +518,9 @@ jobs:
command: >
LLVM_PROFILE_FILE=blockchain_tests_invalid.profraw
bin/evmone-blockchaintest
--gtest_filter='-bc4895-withdrawals.shanghaiWithoutWithdrawalsRLP:bcInvalidHeaderTest.*:bcUncleHeaderValidity.gasLimitTooLowExactBound'
--ignore bc4895-withdrawals/shanghaiWithoutWithdrawalsRLP.json
--ignore bcInvalidHeaderTest
--ignore bcUncleHeaderValidity/gasLimitTooLowExactBound.json
~/tests/BlockchainTests/InvalidBlocks
~/tests/LegacyTests/Cancun/BlockchainTests/InvalidBlocks
- collect_coverage_clang:
Expand Down
38 changes: 32 additions & 6 deletions test/blockchaintest/blockchaintest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,21 @@ class BlockchainGTest : public testing::Test
}
};

void register_test_files(const fs::path& root, evmc::VM& vm)
/// Registers every test under @p root, or prints its path if @p collect_only.
void register_test_files(
const fs::path& root, std::span<const fs::path> ignored, bool collect_only, evmc::VM& vm)
{
if (is_directory(root))
{
for (const auto& [path, suite_name] : evmone::test::collect_test_files(root))
BlockchainGTestFile::register_one(suite_name, path, vm);
auto files = evmone::test::collect_test_files(root);
evmone::test::ignore_test_files(files, ignored);
for (const auto& [path, suite_name] : files)
{
if (collect_only)
std::cout << path.string() << '\n';
else
BlockchainGTestFile::register_one(suite_name, path, vm);
}
}
else // Treat as a file.
{
Expand All @@ -102,7 +111,12 @@ void register_test_files(const fs::path& root, evmc::VM& vm)
{
const auto tests = evmone::test::load_blockchain_tests(f);
for (const auto& test : tests)
BlockchainGTest::register_one(test, root.string(), test.name, root, vm);
{
if (collect_only)
std::cout << root.string() << "::" << test.name << '\n';
else
BlockchainGTest::register_one(test, root.string(), test.name, root, vm);
}
}
catch (const evmone::test::UnsupportedTestFeature& ex)
{
Expand Down Expand Up @@ -131,6 +145,18 @@ int main(int argc, char* argv[])
->required()
->check(CLI::ExistingPath);

std::vector<fs::path> ignored;
app.add_option("--ignore", ignored,
"Path, relative to a test directory, not to collect tests from. May be given more "
"than once. Whole path components are matched, so --ignore bc4895 keeps "
"bc4895-withdrawals.")
// Without this the option is variadic and swallows the positional paths after it.
->allow_extra_args(false);

bool collect_only = false;
app.add_flag("--collect-only", collect_only,
"List the path of each collected test, one per line, and exit.");

bool trace_flag = false;
app.add_flag("--trace", trace_flag, "Enable EVM tracing");

Expand All @@ -142,9 +168,9 @@ int main(int argc, char* argv[])
vm.set_option("trace", "1");

for (const auto& p : paths)
register_test_files(p, vm);
register_test_files(p, ignored, collect_only, vm);

return RUN_ALL_TESTS();
return collect_only ? 0 : RUN_ALL_TESTS();
}
catch (const std::exception& ex)
{
Expand Down
22 changes: 22 additions & 0 deletions test/integration/blockchaintest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,27 @@ set_tests_properties(
PASS_REGULAR_EXPRESSION "SKIPPED \\] \\.unsupported_rlp"
)

# --collect-only lists what would run instead of running it, and --ignore drops a path from that
# list. Over a directory a test is listed as its file.
add_test(
NAME ${PREFIX}/collect_only_directory
COMMAND evmone-blockchaintest ${TESTS1} --collect-only --ignore unsupported_rlp.json
)
set_tests_properties(
${PREFIX}/collect_only_directory PROPERTIES
PASS_REGULAR_EXPRESSION "eip7778_block_gas\\.json"
FAIL_REGULAR_EXPRESSION "unsupported_rlp"
)

# Given the file directly, each test case in it is listed on its own.
add_test(
NAME ${PREFIX}/collect_only_file
COMMAND evmone-blockchaintest ${TESTS1}/test.json --collect-only
)
set_tests_properties(
${PREFIX}/collect_only_file PROPERTIES
PASS_REGULAR_EXPRESSION "test\\.json::[^\n]*-call\\]\n[^\n]*test\\.json::[^\n]*-callcode\\]"
)

get_directory_property(ALL_TESTS TESTS)
set_tests_properties(${ALL_TESTS} PROPERTIES ENVIRONMENT LLVM_PROFILE_FILE=${CMAKE_BINARY_DIR}/integration-%p.profraw)
2 changes: 1 addition & 1 deletion test/integration/export/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ set_tests_properties(
add_test(
NAME ${PREFIX}/execute_exported_state_tests
# TODO: Broken exported tests are filtered out.
COMMAND evmone-statetest ${EXPORT_DIR}/state_tests --gtest_filter=-*block.*
COMMAND evmone-statetest ${EXPORT_DIR}/state_tests --ignore state_transition/block
)
set_tests_properties(
${PREFIX}/execute_exported_state_tests PROPERTIES
Expand Down
51 changes: 24 additions & 27 deletions test/integration/statetest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,52 +19,37 @@ set_tests_properties(
PASS_REGULAR_EXPRESSION "path is required"
)

# SuiteA also holds an index.json and a notes.txt, neither of which is a test. They sort before
# test1.json, so collecting either would show up inside the SuiteA block below.
# A test collected from a directory is listed as its file. SuiteA also holds an index.json and a
# notes.txt, neither of which is a test; both sort before test1.json, so collecting either would
# show up in the listing.
add_test(
NAME ${PREFIX}/tests1_list
COMMAND evmone-statetest ${TESTS1} --gtest_list_tests
COMMAND evmone-statetest ${TESTS1} --collect-only
)
set_tests_properties(
${PREFIX}/tests1_list PROPERTIES
PASS_REGULAR_EXPRESSION [[
B\.
T
SuiteA\.
test1
test2_multi
]]
PASS_REGULAR_EXPRESSION "tests1[^\n]*T\\.json\n[^\n]*tests1[^\n]*test1\\.json\n[^\n]*tests1[^\n]*test2_multi\\.json"
)

# Given the file directly, each test case in it is listed on its own.
add_test(
NAME ${PREFIX}/single_file_list
COMMAND evmone-statetest ${TESTS1}/SuiteA/test1.json --gtest_list_tests
COMMAND evmone-statetest ${TESTS1}/SuiteA/test2_multi.json --collect-only
)
set_tests_properties(
${PREFIX}/single_file_list PROPERTIES
PASS_REGULAR_EXPRESSION [[
.*test/integration/statetest/tests1/SuiteA/test1\.json\.
test1
]]
PASS_REGULAR_EXPRESSION "test2_multi\\.json::test_case_1\n[^\n]*test2_multi\\.json::test_case_2"
)

# Several roots are collected in the order given, not regrouped by suite as gtest listed them.
# T.json holds no test cases, so naming it directly contributes no line.
add_test(
NAME ${PREFIX}/multiple_args_list
COMMAND evmone-statetest ${TESTS1} ${TESTS2} ${TESTS1}/B/T.json ${TESTS1}/SuiteA --gtest_list_tests
COMMAND evmone-statetest ${TESTS1} ${TESTS2} ${TESTS1}/B/T.json ${TESTS1}/SuiteA --collect-only
)
set_tests_properties(
${PREFIX}/multiple_args_list PROPERTIES
PASS_REGULAR_EXPRESSION [[
B\.
T
SuiteA\.
test1
test2_multi
test1
\.
test1
test2_multi
]]
PASS_REGULAR_EXPRESSION "tests1[^\n]*T\\.json\n[^\n]*tests1[^\n]*test1\\.json\n[^\n]*tests1[^\n]*test2_multi\\.json\n[^\n]*tests2[^\n]*test1\\.json\n[^\n]*tests1[^\n]*test1\\.json\n[^\n]*tests1[^\n]*test2_multi\\.json"
)

add_test(
Expand Down Expand Up @@ -149,5 +134,17 @@ set_tests_properties(
FAIL_REGULAR_EXPRESSION "failing_test_case"
)

# --ignore drops a path from the collection. The flags come first, as they do in CI: an --ignore
# that swallowed a positional path would leave the roots after it uncollected.
add_test(
NAME ${PREFIX}/ignore
COMMAND evmone-statetest --ignore B ${TESTS1} ${TESTS2} --collect-only
)
set_tests_properties(
${PREFIX}/ignore PROPERTIES
PASS_REGULAR_EXPRESSION "tests1[^\n]*test1\\.json\n[^\n]*tests1[^\n]*test2_multi\\.json\n[^\n]*tests2[^\n]*test1\\.json"
FAIL_REGULAR_EXPRESSION "T\\.json"
)

get_directory_property(ALL_TESTS TESTS)
set_tests_properties(${ALL_TESTS} PROPERTIES ENVIRONMENT LLVM_PROFILE_FILE=${CMAKE_BINARY_DIR}/integration-%p.profraw)
48 changes: 30 additions & 18 deletions test/statetest/statetest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,21 @@ class StateTest : public testing::Test
}
};

void register_test_files(
const fs::path& root, const std::optional<std::string>& filter, evmc::VM& vm, bool trace)
/// Registers every test under @p root, or prints its path if @p collect_only.
void register_test_files(const fs::path& root, const std::optional<std::string>& filter,
std::span<const fs::path> ignored, bool collect_only, evmc::VM& vm, bool trace)
{
if (is_directory(root))
{
for (const auto& [path, suite_name] : evmone::test::collect_test_files(root))
StateTestFile::register_one(suite_name, path, filter, vm, trace);
auto files = evmone::test::collect_test_files(root);
evmone::test::ignore_test_files(files, ignored);
for (const auto& [path, suite_name] : files)
{
if (collect_only)
std::cout << path.string() << '\n';
else
StateTestFile::register_one(suite_name, path, filter, vm, trace);
}
}
else // Treat as a file.
{
Expand All @@ -108,7 +116,10 @@ void register_test_files(
{
if (filter.has_value() && test.name.find(*filter) == std::string::npos)
continue;
StateTest::register_one(test, root.string(), test.name, root, vm, trace);
if (collect_only)
std::cout << root.string() << "::" << test.name << '\n';
else
StateTest::register_one(test, root.string(), test.name, root, vm, trace);
}
}
}
Expand All @@ -117,17 +128,6 @@ void register_test_files(

int main(int argc, char* argv[])
{
// The default test filter. To enable all tests use `--gtest_filter=*`.
testing::FLAGS_gtest_filter =
"-"
// Slow tests:
"stCreateTest.CreateOOGafterMaxCodesize:" // pass
"stQuadraticComplexityTest.Call50000_sha256:" // pass
"stTimeConsuming.static_Call50000_sha256:" // pass
"stTimeConsuming.CALLBlake2f_MaxRounds:" // pass
"VMTests/vmPerformance.*:" // pass
;

try
{
testing::InitGoogleTest(&argc, argv); // Process GoogleTest flags.
Expand All @@ -148,6 +148,18 @@ int main(int argc, char* argv[])
app.add_option("-k", filter,
"Test name filter. Run only tests with names containing the specified string.");

std::vector<fs::path> ignored;
app.add_option("--ignore", ignored,
"Path, relative to a test directory, not to collect tests from. May be given more "
"than once. Whole path components are matched, so --ignore bc4895 keeps "
"bc4895-withdrawals.")
// Without this the option is variadic and swallows the positional paths after it.
->allow_extra_args(false);

bool collect_only = false;
app.add_flag("--collect-only", collect_only,
"List the path of each collected test, one per line, and exit.");

bool trace = false;
bool trace_summary = false;
const auto trace_opt = app.add_flag("--trace", trace, "Enable EVM tracing");
Expand All @@ -165,9 +177,9 @@ int main(int argc, char* argv[])
}

for (const auto& p : paths)
register_test_files(p, filter, vm, trace || trace_summary);
register_test_files(p, filter, ignored, collect_only, vm, trace || trace_summary);

return RUN_ALL_TESTS();
return collect_only ? 0 : RUN_ALL_TESTS();
}
catch (const std::exception& ex)
{
Expand Down
1 change: 1 addition & 0 deletions test/unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ target_sources(
statetest_logs_hash_test.cpp
statetest_runner_test.cpp
statetest_withdrawals_test.cpp
test_files_test.cpp
test_report_test.cpp
tooling_run_test.cpp
tooling_t8n_test.cpp
Expand Down
Loading