diff --git a/test/sample_consensus/test_sample_consensus.cpp b/test/sample_consensus/test_sample_consensus.cpp index faf33cc8e97..86565f9355f 100644 --- a/test/sample_consensus/test_sample_consensus.cpp +++ b/test/sample_consensus/test_sample_consensus.cpp @@ -111,27 +111,19 @@ TYPED_TEST(SacTest, InfiniteLoop) SampleConsensusModelSpherePtr model (new SampleConsensusModelSphere (cloud.makeShared ())); TypeParam sac (model, 0.03); - // This test sometimes fails for LMedS on azure, but always passes when run locally. - // Enable all output for LMedS, so that when it fails next time, we hopefully see why. - // This can be removed again when the failure reason is found and fixed. - int debug_verbosity_level = 0; - const auto previous_verbosity_level = pcl::console::getVerbosityLevel(); - if (std::is_same>::value) { - debug_verbosity_level = 2; - pcl::console::setVerbosityLevel(pcl::console::L_VERBOSE); - } - // Set up timed conditions std::condition_variable cv; std::mutex mtx; + bool done = false; // set to true when computeModel() has returned // Create the RANSAC object std::thread thread ([&] () { - sac.computeModel (debug_verbosity_level); + sac.computeModel (0); // Notify things are done std::lock_guard lock (mtx); + done = true; cv.notify_one (); }); @@ -139,15 +131,13 @@ TYPED_TEST(SacTest, InfiniteLoop) // Waits for the delay std::unique_lock lock (mtx); #if defined(DEBUG) || defined(_DEBUG) - EXPECT_EQ (std::cv_status::no_timeout, cv.wait_for (lock, 15s)); + ASSERT_TRUE (cv.wait_for (lock, 15s, [&done]{ return done; })); #else - EXPECT_EQ (std::cv_status::no_timeout, cv.wait_for (lock, 2s)); + ASSERT_TRUE (cv.wait_for (lock, 2s, [&done]{ return done; })); #endif // release lock to avoid deadlock lock.unlock(); thread.join (); - - pcl::console::setVerbosityLevel(previous_verbosity_level); // reset verbosity level } int