From f622184d40d4f9deee49b4a6b8bd7f1a99a06603 Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Tue, 2 Apr 2024 15:29:43 -0400 Subject: [PATCH 1/2] allow more than one BOOST_AUTO_TEST_SUITE() in a file --- unittests/CMakeLists.txt | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt index c1e3eed7a2..65c3a66d28 100644 --- a/unittests/CMakeLists.txt +++ b/unittests/CMakeLists.txt @@ -88,20 +88,23 @@ target_include_directories( unit_test PUBLIC add_test(NAME protocol_feature_digest_unit_test COMMAND unit_test --run_test=protocol_feature_digest_tests --report_level=detailed --color_output) set(ctest_tests "protocol_feature_digest_tests") foreach(TEST_SUITE ${UNIT_TESTS}) # create an independent target for each test suite - execute_process(COMMAND sh -c "grep -E 'BOOST_AUTO_TEST_SUITE\\s*[(]' '${TEST_SUITE}' | grep -vE '//.*BOOST_AUTO_TEST_SUITE\\s*[(]' | cut -d ')' -f 1 | cut -d '(' -f 2" OUTPUT_VARIABLE SUITE_NAME OUTPUT_STRIP_TRAILING_WHITESPACE) # get the test suite name from the *.cpp file - if (NOT "" STREQUAL "${SUITE_NAME}") # ignore empty lines - execute_process(COMMAND sh -c "echo ${SUITE_NAME} | sed -e 's/s$//' | sed -e 's/_test$//'" OUTPUT_VARIABLE TRIMMED_SUITE_NAME OUTPUT_STRIP_TRAILING_WHITESPACE) # trim "_test" or "_tests" from the end of ${SUITE_NAME} - # to run unit_test with all log from blockchain displayed, put "--verbose" after "--", i.e. "unit_test -- --verbose" - foreach(RUNTIME ${EOSIO_WASM_RUNTIMES}) - add_test(NAME ${TRIMMED_SUITE_NAME}_unit_test_${RUNTIME} COMMAND unit_test --run_test=${SUITE_NAME} --report_level=detailed --color_output -- --${RUNTIME}) - # build list of tests to run during coverage testing - if(ctest_tests) - string(APPEND ctest_tests "|") - endif() - string(APPEND ctest_tests ${TRIMMED_SUITE_NAME}_unit_test_$RUNTIME) - endforeach() - endif() -endforeach(TEST_SUITE) + execute_process(COMMAND sh -c "grep -E 'BOOST_AUTO_TEST_SUITE\\s*[(]' '${TEST_SUITE}' | grep -vE '//.*BOOST_AUTO_TEST_SUITE\\s*[(]' | cut -d ')' -f 1 | cut -d '(' -f 2" OUTPUT_VARIABLE SUITE_NAMES OUTPUT_STRIP_TRAILING_WHITESPACE) # get the test suite name from the *.cpp file + string(REPLACE "\n" ";" SUITE_NAMES "${SUITE_NAMES}") + foreach(SUITE_NAME IN LISTS SUITE_NAMES) + if (NOT "" STREQUAL "${SUITE_NAME}") # ignore empty lines + execute_process(COMMAND sh -c "echo ${SUITE_NAME} | sed -e 's/s$//' | sed -e 's/_test$//'" OUTPUT_VARIABLE TRIMMED_SUITE_NAME OUTPUT_STRIP_TRAILING_WHITESPACE) # trim "_test" or "_tests" from the end of ${SUITE_NAME} + # to run unit_test with all log from blockchain displayed, put "--verbose" after "--", i.e. "unit_test -- --verbose" + foreach(RUNTIME ${EOSIO_WASM_RUNTIMES}) + add_test(NAME ${TRIMMED_SUITE_NAME}_unit_test_${RUNTIME} COMMAND unit_test --run_test=${SUITE_NAME} --report_level=detailed --color_output -- --${RUNTIME}) + # build list of tests to run during coverage testing + if(ctest_tests) + string(APPEND ctest_tests "|") + endif() + string(APPEND ctest_tests ${TRIMMED_SUITE_NAME}_unit_test_$RUNTIME) + endforeach() + endif() + endforeach() +endforeach() set(ctest_tests "'${ctest_tests}' -j8") # surround test list string in apostrophies # The following tests are known to take the longest, bump up their cost (priority) so that they'll run first From a19d126c61f5ed53d958a422348a1a42e7659b4a Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Tue, 2 Apr 2024 15:31:06 -0400 Subject: [PATCH 2/2] split eosio.system_tests in to two parts --- unittests/eosio.system_tests.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/unittests/eosio.system_tests.cpp b/unittests/eosio.system_tests.cpp index 3d2a408f28..28f389e855 100644 --- a/unittests/eosio.system_tests.cpp +++ b/unittests/eosio.system_tests.cpp @@ -25,11 +25,11 @@ FC_REFLECT( connector, (balance)(weight) ); using namespace eosio_system; -BOOST_AUTO_TEST_SUITE(eosio_system_tests) - bool within_error(int64_t a, int64_t b, int64_t err) { return std::abs(a - b) <= err; }; bool within_one(int64_t a, int64_t b) { return within_error(a, b, 1); } +BOOST_AUTO_TEST_SUITE(eosio_system_part1_tests) + BOOST_FIXTURE_TEST_CASE( buysell, eosio_system_tester ) try { using namespace eosio::chain; @@ -1240,6 +1240,10 @@ BOOST_FIXTURE_TEST_CASE( proxy_actions_affect_producers, eosio_system_tester, * } FC_LOG_AND_RETHROW() +BOOST_AUTO_TEST_SUITE_END() + +BOOST_AUTO_TEST_SUITE(eosio_system_part2_tests) + BOOST_FIXTURE_TEST_CASE(multiple_producer_votepay_share, eosio_system_tester, * boost::unit_test::tolerance(1e-10)) try { const asset net = core_from_string("80.0000");