mirror of
https://github.com/introlab/rtabmap.git
synced 2026-10-04 00:57:46 +08:00
fixing flaky tests in mac and windows
This commit is contained in:
@@ -460,13 +460,29 @@ TEST(ULoggerTest, ThreadIdFilterVector)
|
||||
ULogger::registerCurrentThread("FilterThread");
|
||||
OtherThread otherThread;
|
||||
otherThread.start();
|
||||
|
||||
|
||||
// OtherThread registers itself from inside mainLoopBegin(), which runs
|
||||
// asynchronously after start(). setTreadIdFilter() resolves names against
|
||||
// the current registeredThreads_ map, so we have to wait for the other
|
||||
// thread to register before applying the filter -- otherwise only
|
||||
// "FilterThread" ends up in the filter set (intermittent failure on slow
|
||||
// Windows runners).
|
||||
for(int i = 0; i < 200; ++i)
|
||||
{
|
||||
const std::map<std::string, unsigned long> regs = ULogger::getRegisteredThreads();
|
||||
if(regs.find(otherThread.name()) != regs.end())
|
||||
{
|
||||
break;
|
||||
}
|
||||
uSleep(10);
|
||||
}
|
||||
|
||||
std::vector<std::string> threadNames;
|
||||
threadNames.push_back(otherThread.name());
|
||||
threadNames.push_back("FilterThread");
|
||||
|
||||
|
||||
ULogger::setTreadIdFilter(threadNames);
|
||||
|
||||
|
||||
const std::set<unsigned long>& retrieved = ULogger::getTreadIdFilter();
|
||||
EXPECT_EQ(retrieved.size(), 2u);
|
||||
|
||||
|
||||
@@ -116,8 +116,9 @@ TEST(USemaphoreTest, AcquireTry)
|
||||
result = sem.acquireTry();
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_EQ(sem.value(), 0);
|
||||
// Semaphore is exhausted: the next non-blocking try must fail.
|
||||
result = sem.acquireTry();
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_FALSE(result);
|
||||
#else
|
||||
int result = sem.acquireTry(1);
|
||||
EXPECT_TRUE(result);
|
||||
|
||||
Reference in New Issue
Block a user