From 91ab70d17f892f3ff6b2019632fda3920d045dcb Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 3 Jun 2019 16:16:14 +0200 Subject: tst_qnetworkreply - QSKIP/disable tests that deadlock on Windows We use global object to store errors found by q_X509Callback. Thus, we also use a lock/mutex. It would appear all tests involving in-process server and QNAM are prone to intermittent failures on our Windows VMs - it's always about timeouts due to the client socket (QNAM) locking and the server socket blocking main thread while trying to acquire the same lock. The real fix is to get rid of global variable/locking, we'll have it later (quite a change and requires a lot of accuracy). Task-number: QTBUG-76247 Change-Id: Iffc90d9e16783f17f62e836e01c35f22681bdd39 Reviewed-by: Timur Pocheptsov --- .../access/qnetworkreply/tst_qnetworkreply.cpp | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp') diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 8627a37e12..9a2c62b955 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -5031,6 +5031,9 @@ public: // very similar to ioPostToHttpUploadProgress but for SSL void tst_QNetworkReply::ioPostToHttpsUploadProgress() { +#ifdef Q_OS_WIN + QSKIP("QTBUG-76157: get rid of locking in TLS handshake (QSslSocket)"); +#endif //QFile sourceFile(testDataDir + "/bigfile"); //QVERIFY(sourceFile.open(QIODevice::ReadOnly)); qint64 wantedSize = 2*1024*1024; // 2 MB @@ -6412,6 +6415,10 @@ void tst_QNetworkReply::encrypted() void tst_QNetworkReply::abortOnEncrypted() { +#ifdef Q_OS_WIN + QSKIP("QTBUG-76157: get rid of locking in TLS handshake (QSslSocket)"); +#endif + SslServer server; server.listen(); if (!server.isListening()) @@ -8489,7 +8496,9 @@ void tst_QNetworkReply::ioHttpRedirectErrors_data() QTest::newRow("too-many-redirects") << "http://localhost" << tempRedirectReply << QNetworkReply::TooManyRedirectsError; #if QT_CONFIG(ssl) +#ifndef Q_OS_WIN // QTBUG-76157 QTest::newRow("insecure-redirect") << "https://localhost" << tempRedirectReply << QNetworkReply::InsecureRedirectError; +#endif // Q_OS_WIN #endif QTest::newRow("unknown-redirect") << "http://localhost"<< tempRedirectReply.replace("http", "bad_protocol") << QNetworkReply::ProtocolUnknownError; } @@ -8566,9 +8575,11 @@ void tst_QNetworkReply::ioHttpRedirectPolicy_data() QTest::newRow("nolesssafe-nossl") << QNetworkRequest::NoLessSafeRedirectPolicy << false << 1 << 200; QTest::newRow("same-origin-nossl") << QNetworkRequest::SameOriginRedirectPolicy << false << 1 << 200; #if QT_CONFIG(ssl) +#ifndef Q_OS_WIN // QTBUG-76157 QTest::newRow("manual-ssl") << QNetworkRequest::ManualRedirectPolicy << true << 0 << 307; QTest::newRow("nolesssafe-ssl") << QNetworkRequest::NoLessSafeRedirectPolicy << true << 1 << 200; QTest::newRow("same-origin-ssl") << QNetworkRequest::SameOriginRedirectPolicy << true << 1 << 200; +#endif // Q_OS_WIN #endif } @@ -8622,33 +8633,41 @@ void tst_QNetworkReply::ioHttpRedirectPolicyErrors_data() QTest::newRow("nolesssafe-nossl-nossl-too-many") << QNetworkRequest::NoLessSafeRedirectPolicy << false << QString("http://localhost:%1") << 0 << QNetworkReply::TooManyRedirectsError; #if QT_CONFIG(ssl) +#ifndef Q_OS_WIN // QTBUG-76157 QTest::newRow("nolesssafe-ssl-ssl-too-many") << QNetworkRequest::NoLessSafeRedirectPolicy << true << QString("https:/localhost:%1") << 0 << QNetworkReply::TooManyRedirectsError; QTest::newRow("nolesssafe-ssl-nossl-insecure-redirect") << QNetworkRequest::NoLessSafeRedirectPolicy << true << QString("http://localhost:%1") << 50 << QNetworkReply::InsecureRedirectError; +#endif // Q_OS_WIN #endif // 2. SameOriginRedirectsPolicy QTest::newRow("same-origin-nossl-nossl-too-many") << QNetworkRequest::SameOriginRedirectPolicy << false << QString("http://localhost:%1") << 0 << QNetworkReply::TooManyRedirectsError; #if QT_CONFIG(ssl) +#ifndef Q_OS_WIN // QTBUG-76157 QTest::newRow("same-origin-ssl-ssl-too-many") << QNetworkRequest::SameOriginRedirectPolicy << true << QString("https://localhost:%1") << 0 << QNetworkReply::TooManyRedirectsError; QTest::newRow("same-origin-https-http-wrong-protocol") << QNetworkRequest::SameOriginRedirectPolicy << true << QString("http://localhost:%1") << 50 << QNetworkReply::InsecureRedirectError; +#endif // Q_OS_WIN #endif QTest::newRow("same-origin-http-https-wrong-protocol") << QNetworkRequest::SameOriginRedirectPolicy << false << QString("https://localhost:%1") << 50 << QNetworkReply::InsecureRedirectError; QTest::newRow("same-origin-http-http-wrong-host") << QNetworkRequest::SameOriginRedirectPolicy << false << QString("http://not-so-localhost:%1") << 50 << QNetworkReply::InsecureRedirectError; #if QT_CONFIG(ssl) +#ifndef Q_OS_WIN // QTBUG-76157 QTest::newRow("same-origin-https-https-wrong-host") << QNetworkRequest::SameOriginRedirectPolicy << true << QString("https://not-so-localhost:%1") << 50 << QNetworkReply::InsecureRedirectError; +#endif // Q_OS_WIN #endif QTest::newRow("same-origin-http-http-wrong-port") << QNetworkRequest::SameOriginRedirectPolicy << false << QString("http://localhost/%1") << 50 << QNetworkReply::InsecureRedirectError; #if QT_CONFIG(ssl) +#ifndef Q_OS_WIN // QTBUG-76157 QTest::newRow("same-origin-https-https-wrong-port") << QNetworkRequest::SameOriginRedirectPolicy << true << QString("https://localhost/%1") << 50 << QNetworkReply::InsecureRedirectError; +#endif // Q_OS_WIN #endif } @@ -9123,6 +9142,10 @@ void tst_QNetworkReply::putWithServerClosingConnectionImmediately() for (int s = 0; s <= 1; s++) { withSsl = (s == 1); +#ifdef Q_OS_WIN + if (withSsl) + QSKIP("QTBUG-76157: get rid of locking in TLS handshake (QSslSocket)"); +#endif // Q_OS_WIN // Test also needs to run several times because of 9c2ecf89 for (int j = 0; j < 20; j++) { // emulate a minimal https server -- cgit v1.2.3 From d2ed1074d051c870e7191d0a31f48fae9759e9d7 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 19 May 2019 23:10:38 +0200 Subject: tests: remove the last uses of Java-style iterators ... except where they are actually the component under test. Java-style iterators are scheduled for deprecation. Change-Id: If4399f7f74c5ffc0f7e65205e422edfa1d908ee8 Reviewed-by: Lars Knoll --- tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp') diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 550d80501e..3e5f38d4bc 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -4147,10 +4147,10 @@ void tst_QNetworkReply::ioGetFromHttpWithCache() request.setAttribute(QNetworkRequest::CacheSaveControlAttribute, false); QFETCH(QStringList, extraHttpHeaders); - QStringListIterator it(extraHttpHeaders); - while (it.hasNext()) { - QString header = it.next(); - QString value = it.next(); + QVERIFY(extraHttpHeaders.size() % 2 == 0); + for (auto it = extraHttpHeaders.cbegin(), end = extraHttpHeaders.cend(); it != end; /*double-stepping*/) { + QString header = *it++; + QString value = *it++; request.setRawHeader(header.toLatin1(), value.toLatin1()); // To latin1? Deal with it! } -- cgit v1.2.3 From 16cc3ea585f26bc403e051f105df677a6da79dd5 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Mon, 10 Jun 2019 16:49:19 +0200 Subject: test: migrate QNetworkReply test to QRegularExpression This is part of the migration of qtbase from QRexExp to QRegularExpression. Task-number: QTBUG-72587 Change-Id: Ibdd3f63d9069c3f01dfe8431bcc64bde4f2aa569 Reviewed-by: Timur Pocheptsov Reviewed-by: Edward Welbourne --- tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp') diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index ca870f1cbb..8867e4dbaa 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -34,6 +34,8 @@ #include #include #include +#include +#include #include #include #include @@ -7917,9 +7919,10 @@ void tst_QNetworkReply::synchronousAuthenticationCache() "Content-Type: text/plain\r\n" "\r\n" "auth"; - QRegExp rx("Authorization: Basic ([^\r\n]*)\r\n"); - if (rx.indexIn(receivedData) > 0) { - if (QByteArray::fromBase64(rx.cap(1).toLatin1()) == "login:password") { + QRegularExpression rx("Authorization: Basic ([^\r\n]*)\r\n"); + QRegularExpressionMatch match = rx.match(receivedData); + if (match.hasMatch()) { + if (QByteArray::fromBase64(match.captured(1).toLatin1()) == "login:password") { dataToTransmit = "HTTP/1.0 200 OK\r\n" "Content-Type: text/plain\r\n" -- cgit v1.2.3 From 84e89c1e9e00d4fab576b876cfa80e92b5602982 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 12 Jun 2019 18:06:23 +0200 Subject: Convert uses of QTime as a timer to QElapsedTimer Change-Id: I2297f61efa5adf9ea5194c7f3ff68574cbcf452c Reviewed-by: Friedemann Kleint --- .../access/qnetworkreply/tst_qnetworkreply.cpp | 23 +++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp') diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 8867e4dbaa..e85147095c 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -1149,7 +1150,7 @@ protected: } // now write in "blocking mode", this is where the rate measuring starts - QTime timer; + QElapsedTimer timer; timer.start(); //const qint64 writtenBefore = dataIndex; //qint64 measuredTotalBytes = wantedSize - writtenBefore; @@ -1248,7 +1249,7 @@ protected: } qint64 bytesRead = 0; - QTime stopWatch; + QElapsedTimer stopWatch; stopWatch.start(); do { if (device->bytesAvailable() == 0) { @@ -5153,8 +5154,8 @@ void tst_QNetworkReply::ioGetFromBuiltinHttp() const int rate = 200; // in kB per sec RateControlledReader reader(server, reply.data(), rate, bufferSize); - QTime loopTime; - loopTime.start(); + QElapsedTimer loopTimer; + loopTimer.start(); const int result = waitForFinish(reply); if (notEnoughDataForFastSender) { @@ -5164,7 +5165,7 @@ void tst_QNetworkReply::ioGetFromBuiltinHttp() QVERIFY2(result == Success, msgWaitForFinished(reply)); - const int elapsedTime = loopTime.elapsed(); + const int elapsedTime = loopTimer.elapsed(); server.wait(); reader.wrapUp(); @@ -5450,12 +5451,12 @@ void tst_QNetworkReply::rateControl() RateControlledReader reader(sender, reply.data(), rate, 20); // this test is designed to run for 25 seconds at most - QTime loopTime; - loopTime.start(); + QElapsedTimer loopTimer; + loopTimer.start(); QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply)); - int elapsedTime = loopTime.elapsed(); + int elapsedTime = loopTimer.elapsed(); if (!errorSpy.isEmpty()) { qDebug() << "ERROR!" << errorSpy[0][0] << reply->errorString(); @@ -6125,8 +6126,8 @@ void tst_QNetworkReply::httpConnectionCount() } int pendingConnectionCount = 0; - QTime time; - time.start(); + QElapsedTimer timer; + timer.start(); while(pendingConnectionCount <= 20) { QTestEventLoop::instance().enterLoop(1); @@ -6138,7 +6139,7 @@ void tst_QNetworkReply::httpConnectionCount() } // at max. wait 10 sec - if (time.elapsed() > 10000) + if (timer.elapsed() > 10000) break; } -- cgit v1.2.3