mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-20 22:31:31 +02:00
fix(test): fix flaky test
This commit is contained in:
@@ -86,7 +86,10 @@ namespace
|
||||
|
||||
void run()
|
||||
{
|
||||
_data.clear();
|
||||
{
|
||||
Poco::FastMutex::ScopedLock lock(_mutex);
|
||||
_data.clear();
|
||||
}
|
||||
StreamSocket& ss = socket();
|
||||
try
|
||||
{
|
||||
@@ -94,7 +97,10 @@ namespace
|
||||
int n = ss.receiveBytes(buffer, sizeof(buffer));
|
||||
while (n > 0)
|
||||
{
|
||||
_data.append(buffer, n);
|
||||
{
|
||||
Poco::FastMutex::ScopedLock lock(_mutex);
|
||||
_data.append(buffer, n);
|
||||
}
|
||||
n = ss.receiveBytes(buffer, sizeof(buffer));
|
||||
}
|
||||
}
|
||||
@@ -104,15 +110,18 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
static const std::string& data()
|
||||
static const std::string data()
|
||||
{
|
||||
Poco::FastMutex::ScopedLock lock(_mutex);
|
||||
return _data;
|
||||
}
|
||||
|
||||
private:
|
||||
static Poco::FastMutex _mutex;
|
||||
static std::string _data;
|
||||
};
|
||||
|
||||
Poco::FastMutex CopyToStringConnection::_mutex;
|
||||
std::string CopyToStringConnection::_data;
|
||||
}
|
||||
|
||||
@@ -269,6 +278,7 @@ void SecureStreamSocketTest::testSendFile()
|
||||
{
|
||||
Poco::Thread::sleep(100);
|
||||
}
|
||||
srv.stop();
|
||||
|
||||
assertTrue (CopyToStringConnection::data() == sentData);
|
||||
}
|
||||
@@ -306,6 +316,7 @@ void SecureStreamSocketTest::testSendFileLarge()
|
||||
{
|
||||
Poco::Thread::sleep(100);
|
||||
}
|
||||
srv.stop();
|
||||
|
||||
assertTrue (CopyToStringConnection::data() == sentData);
|
||||
}
|
||||
@@ -346,6 +357,7 @@ void SecureStreamSocketTest::testSendFileRange()
|
||||
{
|
||||
Poco::Thread::sleep(100);
|
||||
}
|
||||
srv.stop();
|
||||
|
||||
assertTrue (CopyToStringConnection::data() == fileData.substr(offset, count));
|
||||
}
|
||||
|
Reference in New Issue
Block a user