From 00c91880cc7cc89d55abfcaa8c8f1d08bcdf56b0 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Sat, 7 Jul 2018 03:01:33 -0500 Subject: [PATCH] Segregate obnoxiously slow test The main test driver should run fairly quickly; extremely slow tests should be moved to a separate driver so developer time isn't wasted waiting for many runs of a slow test. Really more tests should be moved over, but I'm too lazy right now. --- tests/CMakeLists.txt | 4 ++ .../call_order_tests.cpp | 0 tests/slow_tests/main.cpp | 40 +++++++++++++++++++ 3 files changed, 44 insertions(+) rename tests/{tests => slow_tests}/call_order_tests.cpp (100%) create mode 100644 tests/slow_tests/main.cpp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5fd06115fd..ccdfc93d70 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -13,6 +13,10 @@ if(MSVC) set_source_files_properties( tests/serialization_tests.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) endif(MSVC) +file(GLOB SLOW_UNIT_TESTS "slow_tests/*.cpp") +add_executable( slow_chain_test ${SLOW_UNIT_TESTS} ${COMMON_SOURCES} ) +target_link_libraries( slow_chain_test graphene_chain graphene_app graphene_account_history graphene_elasticsearch graphene_egenesis_none fc graphene_wallet ${PLATFORM_SPECIFIC_LIBS} ) + file(GLOB PERFORMANCE_TESTS "performance/*.cpp") add_executable( performance_test ${PERFORMANCE_TESTS} ${COMMON_SOURCES} ) target_link_libraries( performance_test graphene_chain graphene_app graphene_account_history graphene_elasticsearch graphene_egenesis_none fc ${PLATFORM_SPECIFIC_LIBS} ) diff --git a/tests/tests/call_order_tests.cpp b/tests/slow_tests/call_order_tests.cpp similarity index 100% rename from tests/tests/call_order_tests.cpp rename to tests/slow_tests/call_order_tests.cpp diff --git a/tests/slow_tests/main.cpp b/tests/slow_tests/main.cpp new file mode 100644 index 0000000000..405e7c1059 --- /dev/null +++ b/tests/slow_tests/main.cpp @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2015 Cryptonomex, Inc., and contributors. + * + * The MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#include +#include +#include + +extern uint32_t GRAPHENE_TESTING_GENESIS_TIMESTAMP; + +boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { + std::srand(time(NULL)); + std::cout << "Random number generator seeded to " << time(NULL) << std::endl; + const char* genesis_timestamp_str = getenv("GRAPHENE_TESTING_GENESIS_TIMESTAMP"); + if( genesis_timestamp_str != nullptr ) + { + GRAPHENE_TESTING_GENESIS_TIMESTAMP = std::stoul( genesis_timestamp_str ); + } + std::cout << "GRAPHENE_TESTING_GENESIS_TIMESTAMP is " << GRAPHENE_TESTING_GENESIS_TIMESTAMP << std::endl; + return nullptr; +}