Skip to content

Commit e1b20e2

Browse files
committed
Merge #19028: test: Set -logthreadnames in unit tests
9999348 test: Set -logthreadnames in unit tests (MarcoFalke) fa4ea99 init: Setup scheduler in tests and init in exactly the same way (MarcoFalke) Pull request description: Generally the unit tests are single threaded, with the exception of the script check threads, the schedule, and optionally indexer threads. Like the functional tests, the thread name can serve additional debug information, so set `-logthreadnames` in unit tests. Can be tested with ``` ./src/test/test_bitcoin -l test_suite -t validation_tests/test_combiner_all -- DEBUG_LOG_OUT ACKs for top commit: laanwj: ACK 9999348 Tree-SHA512: 3bdbfc211da146da64b50b0826246aff5c611a84b69ab896a55b3c9d1adc92c5975da36ab92aee577df82e229c4326b477f4105bfdd1a5df4c9a0b018cf61602
2 parents 9d92ee1 + 9999348 commit e1b20e2

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

src/init.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,8 +1317,7 @@ bool AppInitMain(const util::Ref& context, NodeContext& node)
13171317
node.scheduler = MakeUnique<CScheduler>();
13181318

13191319
// Start the lightweight task scheduler thread
1320-
CScheduler::Function serviceLoop = [&node]{ node.scheduler->serviceQueue(); };
1321-
threadGroup.create_thread(std::bind(&TraceThread<CScheduler::Function>, "scheduler", serviceLoop));
1320+
threadGroup.create_thread([&] { TraceThread("scheduler", [&] { node.scheduler->serviceQueue(); }); });
13221321

13231322
// Gather some entropy once per minute.
13241323
node.scheduler->scheduleEvery([]{

src/test/util/setup_common.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,13 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName, const std::ve
7575
"dummy",
7676
"-printtoconsole=0",
7777
"-logtimemicros",
78+
"-logthreadnames",
7879
"-debug",
7980
"-debugexclude=libevent",
8081
"-debugexclude=leveldb",
8182
},
8283
extra_args);
84+
util::ThreadRename("test");
8385
fs::create_directories(m_path_root);
8486
gArgs.ForceSetArg("-datadir", m_path_root.string());
8587
ClearDatadirCache();
@@ -130,7 +132,7 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector<const
130132

131133
// We have to run a scheduler thread to prevent ActivateBestChain
132134
// from blocking due to queue overrun.
133-
threadGroup.create_thread([&]{ m_node.scheduler->serviceQueue(); });
135+
threadGroup.create_thread([&] { TraceThread("scheduler", [&] { m_node.scheduler->serviceQueue(); }); });
134136
GetMainSignals().RegisterBackgroundSignalScheduler(*m_node.scheduler);
135137

136138
pblocktree.reset(new CBlockTreeDB(1 << 20, true));

src/test/util_threadnames_tests.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ std::set<std::string> RenameEnMasse(int num_threads)
5353
*/
5454
BOOST_AUTO_TEST_CASE(util_threadnames_test_rename_threaded)
5555
{
56-
BOOST_CHECK_EQUAL(util::ThreadGetInternalName(), "");
57-
5856
#if !defined(HAVE_THREAD_LOCAL)
5957
// This test doesn't apply to platforms where we don't have thread_local.
6058
return;

0 commit comments

Comments
 (0)