Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions test/sample_consensus/test_sample_consensus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,43 +111,33 @@ TYPED_TEST(SacTest, InfiniteLoop)
SampleConsensusModelSpherePtr model (new SampleConsensusModelSphere<PointXYZ> (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<TypeParam, LeastMedianSquares<PointXYZ>>::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<std::mutex> lock (mtx);
done = true;
cv.notify_one ();
});


// Waits for the delay
std::unique_lock<std::mutex> 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
Expand Down
Loading