From fa4ea997b4da1ae0afafba223fff9efbeefaf555 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Wed, 20 May 2020 11:34:31 -0400 Subject: [PATCH 1/2] init: Setup scheduler in tests and init in exactly the same way --- src/init.cpp | 3 +-- src/test/util/setup_common.cpp | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 025ae0652..786e03262 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1317,8 +1317,7 @@ bool AppInitMain(const util::Ref& context, NodeContext& node) node.scheduler = MakeUnique(); // Start the lightweight task scheduler thread - CScheduler::Function serviceLoop = [&node]{ node.scheduler->serviceQueue(); }; - threadGroup.create_thread(std::bind(&TraceThread, "scheduler", serviceLoop)); + threadGroup.create_thread([&] { TraceThread("scheduler", [&] { node.scheduler->serviceQueue(); }); }); // Gather some entropy once per minute. node.scheduler->scheduleEvery([]{ diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp index 86dac55b2..37cdbf2dd 100644 --- a/src/test/util/setup_common.cpp +++ b/src/test/util/setup_common.cpp @@ -129,7 +129,7 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vectorserviceQueue(); }); + threadGroup.create_thread([&] { TraceThread("scheduler", [&] { m_node.scheduler->serviceQueue(); }); }); GetMainSignals().RegisterBackgroundSignalScheduler(*m_node.scheduler); pblocktree.reset(new CBlockTreeDB(1 << 20, true)); From 99993489da9bc003b823bcab10e5f5297b369431 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Wed, 20 May 2020 11:21:55 -0400 Subject: [PATCH 2/2] test: Set -logthreadnames in unit tests --- src/test/util/setup_common.cpp | 2 ++ src/test/util_threadnames_tests.cpp | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp index 37cdbf2dd..9b6911354 100644 --- a/src/test/util/setup_common.cpp +++ b/src/test/util/setup_common.cpp @@ -74,11 +74,13 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName, const std::ve "dummy", "-printtoconsole=0", "-logtimemicros", + "-logthreadnames", "-debug", "-debugexclude=libevent", "-debugexclude=leveldb", }, extra_args); + util::ThreadRename("test"); fs::create_directories(m_path_root); gArgs.ForceSetArg("-datadir", m_path_root.string()); ClearDatadirCache(); diff --git a/src/test/util_threadnames_tests.cpp b/src/test/util_threadnames_tests.cpp index 4dcc080b2..f3f9fb2bf 100644 --- a/src/test/util_threadnames_tests.cpp +++ b/src/test/util_threadnames_tests.cpp @@ -53,8 +53,6 @@ std::set RenameEnMasse(int num_threads) */ BOOST_AUTO_TEST_CASE(util_threadnames_test_rename_threaded) { - BOOST_CHECK_EQUAL(util::ThreadGetInternalName(), ""); - #if !defined(HAVE_THREAD_LOCAL) // This test doesn't apply to platforms where we don't have thread_local. return;