Increase timeout in tst_NetworkSelfTest.
Try to fix frequently failing test: FAIL! : tst_NetworkSelfTest::ftpProxyServer() Failed to receive data in step 32: timeout tst_networkselftest.cpp(230) : failure location on Windows. Introduce timeout constant, add message. Change-Id: I709f0b34cd1cfe5d3c64cf61ccb7907bd616bc54 Reviewed-by: Peter Hartmann <phartmann@blackberry.com> Reviewed-by: Richard J. Moore <rich@kde.org>
This commit is contained in:
parent
b7f013bf19
commit
e9a93e888d
@ -170,7 +170,9 @@ static QString prettyByteArray(const QByteArray &array)
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool doSocketRead(QTcpSocket *socket, int minBytesAvailable, int timeout = 4000)
|
||||
enum { defaultReadTimeoutMS = 4000 };
|
||||
|
||||
static bool doSocketRead(QTcpSocket *socket, int minBytesAvailable, int timeout = defaultReadTimeoutMS)
|
||||
{
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
@ -185,6 +187,15 @@ static bool doSocketRead(QTcpSocket *socket, int minBytesAvailable, int timeout
|
||||
}
|
||||
}
|
||||
|
||||
static QByteArray msgDoSocketReadFailed(const QString &host, quint16 port,
|
||||
int step, int minBytesAvailable)
|
||||
{
|
||||
return "Failed to receive "
|
||||
+ QByteArray::number(minBytesAvailable) + " bytes from "
|
||||
+ host.toLatin1() + ':' + QByteArray::number(port)
|
||||
+ " in step " + QByteArray::number(step) + ": timeout";
|
||||
}
|
||||
|
||||
static bool doSocketFlush(QTcpSocket *socket, int timeout = 4000)
|
||||
{
|
||||
#ifndef QT_NO_SSL
|
||||
@ -226,8 +237,8 @@ static void netChat(int port, const QList<Chat> &chat)
|
||||
switch (it->type) {
|
||||
case Chat::Expect: {
|
||||
qDebug() << i << "Expecting" << prettyByteArray(it->data);
|
||||
if (!doSocketRead(&socket, it->data.length()))
|
||||
QFAIL(QString("Failed to receive data in step %1: timeout").arg(i).toLocal8Bit());
|
||||
if (!doSocketRead(&socket, it->data.length(), 3 * defaultReadTimeoutMS))
|
||||
QFAIL(msgDoSocketReadFailed(QtNetworkSettings::serverName(), port, i, it->data.length()));
|
||||
|
||||
// pop that many bytes off the socket
|
||||
QByteArray received = socket.read(it->data.length());
|
||||
@ -245,7 +256,7 @@ static void netChat(int port, const QList<Chat> &chat)
|
||||
while (true) {
|
||||
// scan the buffer until we have our string
|
||||
if (!doSocketRead(&socket, it->data.length()))
|
||||
QFAIL(QString("Failed to receive data in step %1: timeout").arg(i).toLocal8Bit());
|
||||
QFAIL(msgDoSocketReadFailed(QtNetworkSettings::serverName(), port, i, it->data.length()));
|
||||
|
||||
QByteArray buffer;
|
||||
buffer.resize(socket.bytesAvailable());
|
||||
@ -266,7 +277,7 @@ static void netChat(int port, const QList<Chat> &chat)
|
||||
case Chat::SkipBytes: {
|
||||
qDebug() << i << "Skipping" << it->value << "bytes";
|
||||
if (!doSocketRead(&socket, it->value))
|
||||
QFAIL(QString("Failed to receive data in step %1: timeout").arg(i).toLocal8Bit());
|
||||
QFAIL(msgDoSocketReadFailed(QtNetworkSettings::serverName(), port, i, it->value));
|
||||
|
||||
// now discard the bytes
|
||||
QByteArray buffer = socket.read(it->value);
|
||||
|
Loading…
x
Reference in New Issue
Block a user