mirror of
https://github.com/pocoproject/poco.git
synced 2025-03-18 19:37:51 +01:00
fix(test): fix flaky test
This commit is contained in:
parent
24ff931071
commit
db88e0ec00
@ -63,7 +63,10 @@ namespace
|
||||
|
||||
void run()
|
||||
{
|
||||
_data.clear();
|
||||
{
|
||||
Poco::FastMutex::ScopedLock lock(_mutex);
|
||||
_data.clear();
|
||||
}
|
||||
StreamSocket& ss = socket();
|
||||
try
|
||||
{
|
||||
@ -71,7 +74,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));
|
||||
}
|
||||
}
|
||||
@ -81,15 +87,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;
|
||||
}
|
||||
|
||||
@ -746,6 +755,7 @@ void SocketTest::testSendFile()
|
||||
{
|
||||
Poco::Thread::sleep(100);
|
||||
}
|
||||
srv.stop();
|
||||
|
||||
assertTrue (CopyToStringConnection::data() == sentData);
|
||||
}
|
||||
@ -783,6 +793,7 @@ void SocketTest::testSendFileLarge()
|
||||
{
|
||||
Poco::Thread::sleep(100);
|
||||
}
|
||||
srv.stop();
|
||||
|
||||
assertTrue (CopyToStringConnection::data() == sentData);
|
||||
}
|
||||
@ -823,6 +834,7 @@ void SocketTest::testSendFileRange()
|
||||
{
|
||||
Poco::Thread::sleep(100);
|
||||
}
|
||||
srv.stop();
|
||||
|
||||
assertTrue (CopyToStringConnection::data() == sentData.substr(offset, count));
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user