From b623f6e3f0a47b4df734a983ad83f055bdf1f07c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= <hugo@beauzee.fr> Date: Wed, 26 Jan 2022 14:31:55 +0100 Subject: [PATCH] test: samples: Fix potential test timeout If the discoverer signals its completion right after the parser, we'd ignore the parser completion, causing the test to hand until it times out. --- test/samples/Tester.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/samples/Tester.cpp b/test/samples/Tester.cpp index ed1b16458..99f9b1fb0 100644 --- a/test/samples/Tester.cpp +++ b/test/samples/Tester.cpp @@ -61,7 +61,7 @@ bool MockCallback::waitForParsingComplete() std::unique_lock<compat::Mutex> lock{ m_parsingMutex }; // Wait for a while, generating snapshots can be heavy... return m_parsingCompleteVar.wait_for( lock, std::chrono::seconds{ 20 }, [this]() { - return m_parserDone; + return m_parserDone && m_discoveryCompleted; }); } @@ -109,18 +109,18 @@ void MockCallback::onDiscoveryCompleted() { std::lock_guard<compat::Mutex> lock( m_parsingMutex ); m_discoveryCompleted = true; + m_parsingCompleteVar.notify_all(); } void MockCallback::onParsingStatsUpdated( uint32_t done, uint32_t scheduled ) { - if ( done == scheduled ) - { - std::lock_guard<compat::Mutex> lock( m_parsingMutex ); - if ( m_discoveryCompleted == false ) - return; - m_parserDone = true; - m_parsingCompleteVar.notify_all(); - } + std::lock_guard<compat::Mutex> lock( m_parsingMutex ); + + m_parserDone = done == scheduled; + if ( m_parserDone == false ) + return; + + m_parsingCompleteVar.notify_all(); } void MockCallback::onMediaThumbnailReady( MediaPtr media, ThumbnailSizeType, -- GitLab