From 6f3e93e3cb90bb8551132880e0d158eaeb633c07 Mon Sep 17 00:00:00 2001 From: Martin Petersson Date: Mon, 22 Aug 2011 13:44:35 +0200 Subject: [PATCH 1/6] QHttpNetworkReply: Change dataReadProgress to qint64. Task-number: QTBUG-20890 Change-Id: I36d942d26247c99eb70c035da48dc0afa6afc591 Reviewed-on: http://codereview.qt.nokia.com/3316 Reviewed-by: Qt Sanity Bot Reviewed-by: Peter Hartmann --- src/network/access/qhttpnetworkreply_p.h | 3 +-- src/network/access/qhttpthreaddelegate.cpp | 4 ++-- src/network/access/qhttpthreaddelegate_p.h | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/network/access/qhttpnetworkreply_p.h b/src/network/access/qhttpnetworkreply_p.h index 14219d484b7..a6bf3fcc8e4 100644 --- a/src/network/access/qhttpnetworkreply_p.h +++ b/src/network/access/qhttpnetworkreply_p.h @@ -147,8 +147,7 @@ Q_SIGNALS: void finished(); void finishedWithError(QNetworkReply::NetworkError errorCode, const QString &detail = QString()); void headerChanged(); - // FIXME we need to change this to qint64! - void dataReadProgress(int done, int total); + void dataReadProgress(qint64 done, qint64 total); void dataSendProgress(qint64 done, qint64 total); void cacheCredentials(const QHttpNetworkRequest &request, QAuthenticator *authenticator); #ifndef QT_NO_NETWORKPROXY diff --git a/src/network/access/qhttpthreaddelegate.cpp b/src/network/access/qhttpthreaddelegate.cpp index 71227c822ae..d7eeb1c619f 100644 --- a/src/network/access/qhttpthreaddelegate.cpp +++ b/src/network/access/qhttpthreaddelegate.cpp @@ -310,7 +310,7 @@ void QHttpThreadDelegate::startRequest() this, SLOT(finishedWithErrorSlot(QNetworkReply::NetworkError,QString))); // some signals are only interesting when normal asynchronous style is used connect(httpReply,SIGNAL(readyRead()), this, SLOT(readyReadSlot())); - connect(httpReply,SIGNAL(dataReadProgress(int, int)), this, SLOT(dataReadProgressSlot(int,int))); + connect(httpReply,SIGNAL(dataReadProgress(qint64, qint64)), this, SLOT(dataReadProgressSlot(qint64,qint64))); connect(httpReply, SIGNAL(cacheCredentials(QHttpNetworkRequest,QAuthenticator*)), this, SLOT(cacheCredentialsSlot(QHttpNetworkRequest,QAuthenticator*))); #ifndef QT_NO_OPENSSL @@ -507,7 +507,7 @@ void QHttpThreadDelegate::synchronousHeaderChangedSlot() } -void QHttpThreadDelegate::dataReadProgressSlot(int done, int total) +void QHttpThreadDelegate::dataReadProgressSlot(qint64 done, qint64 total) { // If we don't have a download buffer don't attempt to go this codepath // It is not used by QNetworkAccessHttpBackend diff --git a/src/network/access/qhttpthreaddelegate_p.h b/src/network/access/qhttpthreaddelegate_p.h index c49cef242b5..15c76b13fde 100644 --- a/src/network/access/qhttpthreaddelegate_p.h +++ b/src/network/access/qhttpthreaddelegate_p.h @@ -154,7 +154,7 @@ protected slots: void synchronousFinishedWithErrorSlot(QNetworkReply::NetworkError errorCode, const QString &detail = QString()); void headerChangedSlot(); void synchronousHeaderChangedSlot(); - void dataReadProgressSlot(int done, int total); + void dataReadProgressSlot(qint64 done, qint64 total); void cacheCredentialsSlot(const QHttpNetworkRequest &request, QAuthenticator *authenticator); #ifndef QT_NO_OPENSSL void sslErrorsSlot(const QList &errors); From 13df02ad044cca3c0414f5e34c57fe04b69b414c Mon Sep 17 00:00:00 2001 From: Martin Petersson Date: Wed, 24 Aug 2011 17:24:21 +0200 Subject: [PATCH 2/6] QHttpNetworkConnection : Fix the case when we only have one channel For the Happy eyeballs implementation we use two channels for the case where a host lookup gives us both Ipv4 and Ipv6 addresses. In the case where the Connection is setup to only use one channel we can not use this solution, so in this case we should use the old way of connecting with one channel. Task-number: QTBUG-20981 Change-Id: I6590fb4c67d6a8261cd0e4da8f99cd3603bbb524 Reviewed-on: http://codereview.qt.nokia.com/3524 Reviewed-by: Qt Sanity Bot Reviewed-by: Peter Hartmann --- src/network/access/qhttpnetworkconnection.cpp | 71 +++++++++++-------- .../access/qhttpnetworkconnectionchannel.cpp | 6 ++ 2 files changed, 46 insertions(+), 31 deletions(-) diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 0f1132e2a8a..fc4eccc7614 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -189,28 +189,35 @@ bool QHttpNetworkConnectionPrivate::shouldEmitChannelError(QAbstractSocket *sock int i = indexOf(socket); int otherSocket = (i == 0 ? 1 : 0); - if (networkLayerState == QHttpNetworkConnectionPrivate::InProgress) { - if (channels[otherSocket].isSocketBusy() && (channels[otherSocket].state != QHttpNetworkConnectionChannel::ClosingState)) { - // this was the first socket to fail. - channels[i].close(); - emitError = false; - } - else { - // Both connection attempts has failed. + if (channelCount == 1) { + if (networkLayerState == QHttpNetworkConnectionPrivate::InProgress) networkLayerState = QHttpNetworkConnectionPrivate::Unknown; - channels[i].close(); - emitError = true; - } + channels[0].close(); + emitError = true; } else { - if ((networkLayerState == QHttpNetworkConnectionPrivate::IPv4) && (channels[i].networkLayerPreference != QAbstractSocket::IPv4Protocol) - || (networkLayerState == QHttpNetworkConnectionPrivate::IPv6) && (channels[i].networkLayerPreference != QAbstractSocket::IPv6Protocol)) { - // First connection worked so this is the second one to complete and it failed. - channels[i].close(); - QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection); - emitError = false; + if (networkLayerState == QHttpNetworkConnectionPrivate::InProgress) { + if (channels[otherSocket].isSocketBusy() && (channels[otherSocket].state != QHttpNetworkConnectionChannel::ClosingState)) { + // this was the first socket to fail. + channels[i].close(); + emitError = false; + } + else { + // Both connection attempts has failed. + networkLayerState = QHttpNetworkConnectionPrivate::Unknown; + channels[i].close(); + emitError = true; + } + } else { + if ((networkLayerState == QHttpNetworkConnectionPrivate::IPv4) && (channels[i].networkLayerPreference != QAbstractSocket::IPv4Protocol) + || (networkLayerState == QHttpNetworkConnectionPrivate::IPv6) && (channels[i].networkLayerPreference != QAbstractSocket::IPv6Protocol)) { + // First connection worked so this is the second one to complete and it failed. + channels[i].close(); + QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection); + emitError = false; + } + if (networkLayerState == QHttpNetworkConnectionPrivate::Unknown) + qWarning() << "We got a connection error when networkLayerState is Unknown"; } - if (networkLayerState == QHttpNetworkConnectionPrivate::Unknown) - qWarning() << "We got a connection error when networkLayerState is Unknown"; } return emitError; } @@ -917,10 +924,6 @@ void QHttpNetworkConnectionPrivate::readMoreLater(QHttpNetworkReply *reply) // lookup as then the hostinfo will already be in the cache. void QHttpNetworkConnectionPrivate::startHostInfoLookup() { - // At this time all channels should be unconnected. - Q_ASSERT(!channels[0].isSocketBusy()); - Q_ASSERT(!channels[1].isSocketBusy()); - networkLayerState = InProgress; // check if we already now can descide if this is IPv4 or IPv6 @@ -989,17 +992,23 @@ void QHttpNetworkConnectionPrivate::_q_hostLookupFinished(QHostInfo info) // connection will then be disconnected. void QHttpNetworkConnectionPrivate::startNetworkLayerStateLookup() { - // At this time all channels should be unconnected. - Q_ASSERT(!channels[0].isSocketBusy()); - Q_ASSERT(!channels[1].isSocketBusy()); + if (channelCount > 1) { + // At this time all channels should be unconnected. + Q_ASSERT(!channels[0].isSocketBusy()); + Q_ASSERT(!channels[1].isSocketBusy()); - networkLayerState = InProgress; + networkLayerState = InProgress; - channels[0].networkLayerPreference = QAbstractSocket::IPv4Protocol; - channels[1].networkLayerPreference = QAbstractSocket::IPv6Protocol; + channels[0].networkLayerPreference = QAbstractSocket::IPv4Protocol; + channels[1].networkLayerPreference = QAbstractSocket::IPv6Protocol; - channels[0].ensureConnection(); // Possibly delay this one.. - channels[1].ensureConnection(); + channels[0].ensureConnection(); // Possibly delay this one.. + channels[1].ensureConnection(); + } else { + networkLayerState = InProgress; + channels[0].networkLayerPreference = QAbstractSocket::AnyIPProtocol; + channels[0].ensureConnection(); + } } diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 8be876dd486..b1630c7b2b8 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -955,6 +955,12 @@ void QHttpNetworkConnectionChannel::_q_connected() connection->d_func()->networkLayerState = QHttpNetworkConnectionPrivate::IPv4; else if (networkLayerPreference == QAbstractSocket::IPv6Protocol) connection->d_func()->networkLayerState = QHttpNetworkConnectionPrivate::IPv6; + else { + if (socket->peerAddress().protocol() == QAbstractSocket::IPv4Protocol) + connection->d_func()->networkLayerState = QHttpNetworkConnectionPrivate::IPv4; + else + connection->d_func()->networkLayerState = QHttpNetworkConnectionPrivate::IPv6; + } } else { if (((connection->d_func()->networkLayerState == QHttpNetworkConnectionPrivate::IPv4) && (networkLayerPreference != QAbstractSocket::IPv4Protocol)) || ((connection->d_func()->networkLayerState == QHttpNetworkConnectionPrivate::IPv6) && (networkLayerPreference != QAbstractSocket::IPv6Protocol))) { From 22ea360fb952a1043515fbfd4706f057627e6366 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Tue, 30 Aug 2011 14:19:52 +0200 Subject: [PATCH 3/6] Compile fix on Mac OS X MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The file is called shapeitem.cpp (lowercase i), not shapeItem.cpp (with uppercase I) Change-Id: I0dd230158cf8c8323bfa779901475535e7c7d694 Reviewed-on: http://codereview.qt.nokia.com/3883 Reviewed-by: Qt Sanity Bot Reviewed-by: Samuel Rødal --- examples/widgets/tooltips/tooltips.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/widgets/tooltips/tooltips.pro b/examples/widgets/tooltips/tooltips.pro index ab0c98e4a12..823fa0e938b 100644 --- a/examples/widgets/tooltips/tooltips.pro +++ b/examples/widgets/tooltips/tooltips.pro @@ -1,7 +1,7 @@ HEADERS = shapeitem.h \ sortingbox.h SOURCES = main.cpp \ - shapeItem.cpp \ + shapeitem.cpp \ sortingbox.cpp RESOURCES = tooltips.qrc From 68b322270c4881d3d2b5ecc9f28b6b3471ccded4 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 30 Aug 2011 11:33:01 +0200 Subject: [PATCH 4/6] QSslCertificate: blacklist fraudulent *.google.com blacklist the leaf certificate for now. There might well be more fake certificates in the wild, for that either the Diginotar.nl root cert needs to be disabled on the system or OCSP would need to be enabled (not supported by Qt yet). Reviewed-by: Richard J. Moore (cherry picked from commit 70f6a1b91b242174682c30be976c2aa36c450cc7) Change-Id: I7cd3fdc4c6e85202914764f983a60d301e54aa35 Reviewed-on: http://codereview.qt.nokia.com/3893 Reviewed-by: Peter Hartmann --- src/network/ssl/qsslcertificate.cpp | 1 + .../blacklisted-google.com-diginotar.pem | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 tests/auto/qsslcertificate/more-certificates/blacklisted-google.com-diginotar.pem diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp index af265db6e44..bbc60f674c3 100644 --- a/src/network/ssl/qsslcertificate.cpp +++ b/src/network/ssl/qsslcertificate.cpp @@ -901,6 +901,7 @@ static const char *certificate_blacklist[] = { "92:39:d5:34:8f:40:d1:69:5a:74:54:70:e1:f2:3f:43", "b0:b7:13:3e:d0:96:f9:b5:6f:ae:91:c8:74:bd:3a:c0", "d8:f3:5f:4e:b7:87:2b:2d:ab:06:92:e3:15:38:2f:b0", + "05:e2:e6:a4:cd:09:ea:54:d6:65:b0:75:fe:22:a2:56", 0 }; diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted-google.com-diginotar.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted-google.com-diginotar.pem new file mode 100644 index 00000000000..12bbcae0826 --- /dev/null +++ b/tests/auto/qsslcertificate/more-certificates/blacklisted-google.com-diginotar.pem @@ -0,0 +1,30 @@ +-----BEGIN CERTIFICATE----- +MIIFKDCCBBCgAwIBAgIQBeLmpM0J6lTWZbB1/iKiVjANBgkqhkiG9w0BAQUFADBm +MQswCQYDVQQGEwJOTDESMBAGA1UEChMJRGlnaU5vdGFyMSEwHwYDVQQDExhEaWdp +Tm90YXIgUHVibGljIENBIDIwMjUxIDAeBgkqhkiG9w0BCQEWEWluZm9AZGlnaW5v +dGFyLm5sMB4XDTExMDcxMDE5MDYzMFoXDTEzMDcwOTE5MDYzMFowajELMAkGA1UE +BhMCVVMxEzARBgNVBAoTCkdvb2dsZSBJbmMxFjAUBgNVBAcTDU1vdW50YWluIFZp +ZXcxFzAVBgNVBAUTDlBLMDAwMjI5MjAwMDAyMRUwEwYDVQQDEwwqLmdvb2dsZS5j +b20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDNbeKubCV0aCxhOiOS +CSQ/w9HXTYuD5BLKuiqXNw3setdTymeJz2L8aWOHo3nicFNDVwWTgwWomGNr2J6Q +7g1iINNSW0rR4E1l2szRkcnAY6c6i/Eke93nF4i2hDsnIBveolF5yjpuRm73uQQD +ulHjA3BFRF/PTi0fw2/Yt+8ieoMuNcMWN6Eou5Gqt5YZkWv176ofeCbsBmMrP87x +OhhtTDckCapk4VQZG2XrfzZcV6tdzCp5TI8uHdu17cdzXm1imZ8tyvzFeiCEOQN8 +vPNzB/fIr3CJQ5q4uM5aKT3DD5PeVzf4rfJKQNgCTWiIBc9XcWEUuszwAsnmg7e2 +EJRdAgMBAAGjggHMMIIByDA6BggrBgEFBQcBAQQuMCwwKgYIKwYBBQUHMAGGHmh0 +dHA6Ly92YWxpZGF0aW9uLmRpZ2lub3Rhci5ubDAfBgNVHSMEGDAWgBTfM8Cvkv43 +/LbYFhbQ2bGR1fpupTAJBgNVHRMEAjAAMIHGBgNVHSAEgb4wgbswgbgGDmCEEAGH +aQEBAQIEAQICMIGlMCcGCCsGAQUFBwIBFhtodHRwOi8vd3d3LmRpZ2lub3Rhci5u +bC9jcHMwegYIKwYBBQUHAgIwbhpsQ29uZGl0aW9ucywgYXMgbWVudGlvbmVkIG9u +IG91ciB3ZWJzaXRlICh3d3cuZGlnaW5vdGFyLm5sKSwgYXJlIGFwcGxpY2FibGUg +dG8gYWxsIG91ciBwcm9kdWN0cyBhbmQgc2VydmljZXMuMEkGA1UdHwRCMEAwPqA8 +oDqGOGh0dHA6Ly9zZXJ2aWNlLmRpZ2lub3Rhci5ubC9jcmwvcHVibGljMjAyNS9s +YXRlc3RDUkwuY3JsMA4GA1UdDwEB/wQEAwIEsDAbBgNVHREEFDASgRBhZG1pbkBn +b29nbGUuY29tMB0GA1UdDgQWBBQHSn0WJzIo0eMBMQUNsMqN6eF/7TANBgkqhkiG +9w0BAQUFAAOCAQEAAs5dL7N9wzRJkI4Aq4lC5t8j5ZadqnqUcgYLADzSv4ExytNH +UY2nH6iVTihC0UPSsILWraoeApdT7Rphz/8DLQEBRGdeKWAptNM3EbiXtQaZT2uB +pidL8UoafX0kch3f71Y1scpBEjvu5ZZLnjg0A8AL0tnsereOVdDpU98bKqdbbrnM +FRmBlSf7xdaNca6JJHeEpga4E9Ty683CmccrSGXdU2tTCuHEJww+iOAUtPIZcsum +U7/eYeY1pMyGLyIjbNgRY7nDzRwvM/BsbL9eh4/mSQj/4nncqJd22sVQpCggQiVK +baB2sVGcVNBkK55bT8gPqnx8JypubyUvayzZGg== +-----END CERTIFICATE----- From 9be3851eb948a2e7a52273b222334e29d82fa437 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Tue, 30 Aug 2011 12:37:08 +0200 Subject: [PATCH 5/6] Make sure tests/auto/v8.pro doesn't clobber auto.pro The omission of spaces is crucial in order for the regular expressions in configure to be able to detect that v8.pro isn't a "main project" file. Task-number: QTBUG-21168 Change-Id: I2e94736ee3195bed7fd528759b1bc1812f1ae54c Reviewed-on: http://codereview.qt.nokia.com/3878 Reviewed-by: Qt Sanity Bot Reviewed-by: Rohan McGovern --- tests/auto/v8.pro | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/v8.pro b/tests/auto/v8.pro index 226ff7b1186..d751e4cbeb0 100644 --- a/tests/auto/v8.pro +++ b/tests/auto/v8.pro @@ -1,3 +1,3 @@ -TEMPLATE = subdirs -SUBDIRS = \ +TEMPLATE=subdirs +SUBDIRS=\ v8 From 527317748d00739994e3865b8f4e2525fc3ca2c7 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Mon, 29 Aug 2011 16:50:52 +1000 Subject: [PATCH 6/6] Remove ability to run tests in random order. Remove the undocumented feature that allows test functions to be executed in random order. The feature was designed to expose unintended dependencies between test functions -- test functions are only supposed to depend on the initTestCase() and init() functions. Aside from the lack of documentation, there are a number of problems with this feature. Most importantly, running the tests in random order has only a 50% chance of exposing dependencies between test functions. A better strategy would be to run the test functions in reverse order and complain if that produces different results to running the tests in the normal order. Additionally, the random order is not deterministic, so even if a dependency is exposed during a test run, there's no guarantee that it will be exposed again. The feature allows the user to optionally supply a random seed to make the "random" order deterministic, but as rand() implementations are not identical across platforms, even that does not guarantee that dependencies between test functions will be exposed deterministically. Change-Id: I39eac34c532ccb988116778bbc5ab05d835874c5 Reviewed-on: http://codereview.qt.nokia.com/3720 Reviewed-by: Qt Sanity Bot Reviewed-by: Rohan McGovern --- src/testlib/qabstracttestlogger_p.h | 2 - src/testlib/qplaintestlogger.cpp | 22 ++------- src/testlib/qplaintestlogger_p.h | 5 +- src/testlib/qtestcase.cpp | 71 +-------------------------- src/testlib/qtestlightxmlstreamer.cpp | 7 +-- src/testlib/qtestlog.cpp | 9 ---- src/testlib/qtestlog_p.h | 1 - src/testlib/qtestlogger.cpp | 26 ---------- src/testlib/qtestlogger_p.h | 6 --- src/testlib/qtestxmlstreamer.cpp | 9 +--- src/testlib/qxmltestlogger.cpp | 20 +------- src/testlib/qxmltestlogger_p.h | 4 -- 12 files changed, 11 insertions(+), 171 deletions(-) diff --git a/src/testlib/qabstracttestlogger_p.h b/src/testlib/qabstracttestlogger_p.h index e592249e718..3ac6787754f 100644 --- a/src/testlib/qabstracttestlogger_p.h +++ b/src/testlib/qabstracttestlogger_p.h @@ -96,8 +96,6 @@ public: virtual void addMessage(MessageTypes type, const char *message, const char *file = 0, int line = 0) = 0; - virtual void registerRandomSeed(unsigned int seed) = 0; - void outputString(const char *msg); private: diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp index 44ec7924003..bd1bc11582a 100644 --- a/src/testlib/qplaintestlogger.cpp +++ b/src/testlib/qplaintestlogger.cpp @@ -345,7 +345,6 @@ void QPlainTestLogger::printBenchmarkResult(const QBenchmarkResult &result) } QPlainTestLogger::QPlainTestLogger() -: randomSeed(9), hasRandomSeed(false) { #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) InitializeCriticalSection(&QTest::outputCriticalSection); @@ -368,17 +367,10 @@ void QPlainTestLogger::startLogging(const char *filename) QTest::qt_snprintf(buf, sizeof(buf), "Testing %s\n", QTestResult::currentTestObjectName()); } else { - if (hasRandomSeed) { - QTest::qt_snprintf(buf, sizeof(buf), - "********* Start testing of %s *********\n" - "Config: Using QTest library " QTEST_VERSION_STR - ", Qt %s, Random seed %d\n", QTestResult::currentTestObjectName(), qVersion(), randomSeed); - } else { - QTest::qt_snprintf(buf, sizeof(buf), - "********* Start testing of %s *********\n" - "Config: Using QTest library " QTEST_VERSION_STR - ", Qt %s\n", QTestResult::currentTestObjectName(), qVersion()); - } + QTest::qt_snprintf(buf, sizeof(buf), + "********* Start testing of %s *********\n" + "Config: Using QTest library " QTEST_VERSION_STR + ", Qt %s\n", QTestResult::currentTestObjectName(), qVersion()); } outputMessage(buf); } @@ -440,10 +432,4 @@ void QPlainTestLogger::addMessage(MessageTypes type, const char *message, printMessage(QTest::messageType2String(type), message, file, line); } -void QPlainTestLogger::registerRandomSeed(unsigned int seed) -{ - randomSeed = seed; - hasRandomSeed = true; -} - QT_END_NAMESPACE diff --git a/src/testlib/qplaintestlogger_p.h b/src/testlib/qplaintestlogger_p.h index 5fa33e6b514..baa1e248283 100644 --- a/src/testlib/qplaintestlogger_p.h +++ b/src/testlib/qplaintestlogger_p.h @@ -75,11 +75,8 @@ public: void addMessage(MessageTypes type, const char *message, const char *file = 0, int line = 0); - void registerRandomSeed(unsigned int seed); -private: - unsigned int randomSeed; - bool hasRandomSeed; +private: void printMessage(const char *type, const char *msg, const char *file = 0, int line = 0); void outputMessage(const char *str); void printBenchmarkResult(const QBenchmarkResult &result); diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index b6aaa347569..38027942810 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -869,10 +869,7 @@ namespace QTest static int keyDelay = -1; static int mouseDelay = -1; static int eventDelay = -1; - static bool randomOrder = false; static int keyVerbose = -1; - static unsigned int seed = 0; - static bool seedSet = false; #if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) static bool noCrashHandler = false; #endif @@ -958,37 +955,6 @@ int Q_TESTLIB_EXPORT defaultKeyDelay() return keyDelay; } -void seedRandom() -{ - static bool randomSeeded = false; - if (!randomSeeded) { - if (!QTest::seedSet) { - QElapsedTimer timer; - timer.start(); - QTest::seed = timer.msecsSinceReference(); - } - qsrand(QTest::seed); - randomSeeded = true; - } -} - -template -void swap(T * array, int pos, int otherPos) -{ - T tmp = array[pos]; - array[pos] = array[otherPos]; - array[otherPos] = tmp; -} - -template -static void randomizeList(T * array, int size) -{ - for (int i = 0; i != size; i++) { - int pos = qrand() % size; - swap(array, pos, i); - } -} - static bool isValidSlot(const QMetaMethod &sl) { if (sl.access() != QMetaMethod::Private || !sl.parameterTypes().isEmpty() @@ -1046,9 +1012,6 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml) " -v1 : Print enter messages for each testfunction\n" " -v2 : Also print out each QVERIFY/QCOMPARE/QTEST\n" " -vs : Print every signal emitted\n" - " -random : Run testcases within each test in random order\n" - " -seed n : Positive integer to be used as seed for -random. If not specified,\n" - " the current time will be used as seed.\n" " -eventdelay ms : Set default delay for mouse and keyboard simulation to ms milliseconds\n" " -keydelay ms : Set default delay for keyboard simulation to ms milliseconds\n" " -mousedelay ms : Set default delay for mouse simulation to ms milliseconds\n" @@ -1177,22 +1140,6 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml) #endif } else if (strcmp(argv[i], "-eventcounter") == 0) { QBenchmarkGlobalData::current->setMode(QBenchmarkGlobalData::EventCounter); - } else if (strcmp(argv[i], "-random") == 0) { - QTest::randomOrder = true; - } else if (strcmp(argv[i], "-seed") == 0) { - bool argumentOk = false; - if (i + 1 < argc) { - char * endpt = 0; - long longSeed = strtol(argv[++i], &endpt, 10); - argumentOk = (*endpt == '\0' && longSeed >= 0); - QTest::seed = longSeed; - } - if (!argumentOk) { - fprintf(stderr, "-seed needs an extra positive integer parameter to specify the seed\n"); - exit(1); - } else { - QTest::seedSet = true; - } } else if (strcmp(argv[i], "-minimumvalue") == 0) { if (i + 1 >= argc) { fprintf(stderr, "-minimumvalue needs an extra parameter to indicate the minimum time(ms)\n"); @@ -1297,11 +1244,6 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml) QTEST_ASSERT(QTest::testFuncCount < 512); } } - - if (QTest::seedSet && !QTest::randomOrder) { - fprintf(stderr, "-seed requires -random\n"); - exit(1); - } } QBenchmarkResult qMedian(const QList &container) @@ -1596,11 +1538,7 @@ static void qInvokeTestMethods(QObject *testObject) { const QMetaObject *metaObject = testObject->metaObject(); QTEST_ASSERT(metaObject); - if (QTest::randomOrder) { - QTestLog::startLogging(QTest::seed); - } else { - QTestLog::startLogging(); - } + QTestLog::startLogging(); QTestResult::setCurrentTestFunction("initTestCase"); QTestResult::setCurrentTestLocation(QTestResult::DataFunc); QTestTable::globalTestTable(); @@ -1617,8 +1555,6 @@ static void qInvokeTestMethods(QObject *testObject) if(!QTestResult::skipCurrentTest() && !previousFailed) { if (QTest::testFuncs) { - if (QTest::randomOrder) - randomizeList(QTest::testFuncs, QTest::testFuncCount); for (int i = 0; i != QTest::testFuncCount; i++) { if (!qInvokeTestMethod(metaObject->method(QTest::testFuncs[i].function()).signature(), QTest::testFuncs[i].data())) { @@ -1631,8 +1567,6 @@ static void qInvokeTestMethods(QObject *testObject) QMetaMethod *testMethods = new QMetaMethod[methodCount]; for (int i = 0; i != methodCount; i++) testMethods[i] = metaObject->method(i); - if (QTest::randomOrder) - randomizeList(testMethods, methodCount); for (int i = 0; i != methodCount; i++) { if (!isValidSlot(testMethods[i])) continue; @@ -1840,9 +1774,6 @@ int QTest::qExec(QObject *testObject, int argc, char **argv) QTestResult::setCurrentTestObject(metaObject->className()); qtest_qParseArgs(argc, argv, false); - if (QTest::randomOrder) { - seedRandom(); - } #ifdef QTESTLIB_USE_VALGRIND if (QBenchmarkGlobalData::current->mode() == QBenchmarkGlobalData::CallgrindParentProcess) { const QStringList origAppArgs(QCoreApplication::arguments()); diff --git a/src/testlib/qtestlightxmlstreamer.cpp b/src/testlib/qtestlightxmlstreamer.cpp index 8ac4e03d771..c0010cc5229 100644 --- a/src/testlib/qtestlightxmlstreamer.cpp +++ b/src/testlib/qtestlightxmlstreamer.cpp @@ -165,13 +165,8 @@ void QTestLightXmlStreamer::formatBeforeAttributes(const QTestElement *element, void QTestLightXmlStreamer::output(QTestElement *element) const { QTestCharBuffer buf; - if (logger()->hasRandomSeed()) { - QTest::qt_asprintf(&buf, "\n %s\n %s\n %d\n", - qVersion(), QTEST_VERSION_STR, logger()->randomSeed() ); - } else { - QTest::qt_asprintf(&buf, "\n %s\n %s\n", + QTest::qt_asprintf(&buf, "\n %s\n %s\n", qVersion(), QTEST_VERSION_STR ); - } outputString(buf.constData()); QTest::qt_asprintf(&buf, "\n"); diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp index 36b69e1155b..0a87a4ce148 100644 --- a/src/testlib/qtestlog.cpp +++ b/src/testlib/qtestlog.cpp @@ -281,15 +281,6 @@ void QTestLog::addBenchmarkResult(const QBenchmarkResult &result) QTest::testLogger->addBenchmarkResult(result); } -void QTestLog::startLogging(unsigned int randomSeed) -{ - QTEST_ASSERT(!QTest::testLogger); - QTest::initLogger(); - QTest::testLogger->registerRandomSeed(randomSeed); - QTest::testLogger->startLogging(QTest::outFile); - QTest::oldMessageHandler = qInstallMsgHandler(QTest::messageHandler); -} - void QTestLog::startLogging() { QTEST_ASSERT(!QTest::testLogger); diff --git a/src/testlib/qtestlog_p.h b/src/testlib/qtestlog_p.h index 006b3ac12fa..9b580eb8cca 100644 --- a/src/testlib/qtestlog_p.h +++ b/src/testlib/qtestlog_p.h @@ -82,7 +82,6 @@ public: static void info(const char *msg, const char *file, int line); static void startLogging(); - static void startLogging(unsigned int randomSeed); static void stopLogging(); static void setLogMode(LogMode mode); diff --git a/src/testlib/qtestlogger.cpp b/src/testlib/qtestlogger.cpp index d53a9687196..385fb866c2d 100644 --- a/src/testlib/qtestlogger.cpp +++ b/src/testlib/qtestlogger.cpp @@ -62,8 +62,6 @@ QTestLogger::QTestLogger(int fm) , testCounter(0) , failureCounter(0) , errorCounter(0) - , randomSeed_(0) - , hasRandomSeed_(false) { } @@ -128,14 +126,6 @@ void QTestLogger::stopLogging() property->addAttribute(QTest::AI_PropertyValue, qVersion()); properties->addLogElement(property); - if (hasRandomSeed()) { - property = new QTestElement(QTest::LET_Property); - property->addAttribute(QTest::AI_Name, "RandomSeed"); - QTest::qt_snprintf(buf, sizeof(buf), "%i", randomSeed()); - property->addAttribute(QTest::AI_PropertyValue, buf); - properties->addLogElement(property); - } - currentLogElement->addLogElement(properties); currentLogElement->addLogElement(iterator); @@ -349,21 +339,5 @@ void QTestLogger::addMessage(MessageTypes type, const char *message, const char } } -void QTestLogger::registerRandomSeed(unsigned int seed) -{ - randomSeed_ = seed; - hasRandomSeed_ = true; -} - -unsigned int QTestLogger::randomSeed() const -{ - return randomSeed_; -} - -bool QTestLogger::hasRandomSeed() const -{ - return hasRandomSeed_; -} - QT_END_NAMESPACE diff --git a/src/testlib/qtestlogger_p.h b/src/testlib/qtestlogger_p.h index eef5b92d2b5..5e5b0f2f3f0 100644 --- a/src/testlib/qtestlogger_p.h +++ b/src/testlib/qtestlogger_p.h @@ -87,10 +87,6 @@ class QTestLogger : public QAbstractTestLogger void addMessage(MessageTypes type, const char *message, const char *file = 0, int line = 0); - void registerRandomSeed(unsigned int seed); - unsigned int randomSeed() const; - bool hasRandomSeed() const; - private: QTestElement *listOfTestcases; QTestElement *currentLogElement; @@ -101,8 +97,6 @@ class QTestLogger : public QAbstractTestLogger int testCounter; int failureCounter; int errorCounter; - unsigned int randomSeed_; - bool hasRandomSeed_; }; QT_END_NAMESPACE diff --git a/src/testlib/qtestxmlstreamer.cpp b/src/testlib/qtestxmlstreamer.cpp index 7a4115262b0..47c4463b5a0 100644 --- a/src/testlib/qtestxmlstreamer.cpp +++ b/src/testlib/qtestxmlstreamer.cpp @@ -205,13 +205,8 @@ void QTestXmlStreamer::output(QTestElement *element) const quotedTc.constData()); outputString(buf.constData()); - if (logger()->hasRandomSeed()) { - QTest::qt_asprintf(&buf, "\n %s\n %s\n %d\n", - qVersion(), QTEST_VERSION_STR, logger()->randomSeed() ); - } else { - QTest::qt_asprintf(&buf, "\n %s\n %s\n", - qVersion(), QTEST_VERSION_STR ); - } + QTest::qt_asprintf(&buf, "\n %s\n %s\n", + qVersion(), QTEST_VERSION_STR ); outputString(buf.constData()); QTest::qt_asprintf(&buf, "\n"); diff --git a/src/testlib/qxmltestlogger.cpp b/src/testlib/qxmltestlogger.cpp index 15b5c84fd5e..5ed7079ab66 100644 --- a/src/testlib/qxmltestlogger.cpp +++ b/src/testlib/qxmltestlogger.cpp @@ -93,9 +93,8 @@ namespace QTest { QXmlTestLogger::QXmlTestLogger(XmlMode mode ) - :xmlmode(mode), randomSeed(0), hasRandomSeed(false) + : xmlmode(mode) { - } QXmlTestLogger::~QXmlTestLogger() @@ -116,20 +115,11 @@ void QXmlTestLogger::startLogging(const char *filename) outputString(buf.constData()); } - if (hasRandomSeed) { - QTest::qt_asprintf(&buf, - "\n" - " %s\n" - " "QTEST_VERSION_STR"\n" - " %d\n" - "\n", qVersion(), randomSeed); - } else { - QTest::qt_asprintf(&buf, + QTest::qt_asprintf(&buf, "\n" " %s\n" " "QTEST_VERSION_STR"\n" "\n", qVersion()); - } outputString(buf.constData()); } @@ -450,10 +440,4 @@ int QXmlTestLogger::xmlCdata(QTestCharBuffer* str, char const* src) return allocateStringFn(str, src, QXmlTestLogger::xmlCdata); } -void QXmlTestLogger::registerRandomSeed(unsigned int seed) -{ - randomSeed = seed; - hasRandomSeed = true; -} - QT_END_NAMESPACE diff --git a/src/testlib/qxmltestlogger_p.h b/src/testlib/qxmltestlogger_p.h index ad510d5ce0e..c08f5e469e7 100644 --- a/src/testlib/qxmltestlogger_p.h +++ b/src/testlib/qxmltestlogger_p.h @@ -79,8 +79,6 @@ public: void addMessage(MessageTypes type, const char *message, const char *file = 0, int line = 0); - void registerRandomSeed(unsigned int seed); - static int xmlCdata(QTestCharBuffer *dest, char const* src); static int xmlQuote(QTestCharBuffer *dest, char const* src); static int xmlCdata(QTestCharBuffer *dest, char const* src, size_t n); @@ -88,8 +86,6 @@ public: private: XmlMode xmlmode; - unsigned int randomSeed; - bool hasRandomSeed; }; QT_END_NAMESPACE