diff options
Diffstat (limited to 'tests/benchmarks/network')
27 files changed, 372 insertions, 346 deletions
diff --git a/tests/benchmarks/network/CMakeLists.txt b/tests/benchmarks/network/CMakeLists.txt index 4f20fb5ccd..50558e6999 100644 --- a/tests/benchmarks/network/CMakeLists.txt +++ b/tests/benchmarks/network/CMakeLists.txt @@ -1,6 +1,6 @@ -# Generated from network.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause -# special case begin # SSL library include path is not propagated with private tests which results in # test not being able to find the ssl header when they are not in the standard # include paths @@ -13,7 +13,6 @@ if (QT_FEATURE_private_tests) include_directories($<TARGET_PROPERTY:WrapOpenSSLHeaders::WrapOpenSSLHeaders,INTERFACE_INCLUDE_DIRECTORIES>) endif() endif() -# special case end add_subdirectory(access) add_subdirectory(kernel) diff --git a/tests/benchmarks/network/access/CMakeLists.txt b/tests/benchmarks/network/access/CMakeLists.txt index 3069505252..bc5148af55 100644 --- a/tests/benchmarks/network/access/CMakeLists.txt +++ b/tests/benchmarks/network/access/CMakeLists.txt @@ -1,9 +1,13 @@ -# Generated from access.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause add_subdirectory(qfile_vs_qnetworkaccessmanager) +add_subdirectory(qhttpheaders) add_subdirectory(qnetworkreply) -add_subdirectory(qnetworkreply_from_cache) -add_subdirectory(qnetworkdiskcache) +if(QT_FEATURE_networkdiskcache) + add_subdirectory(qnetworkreply_from_cache) + add_subdirectory(qnetworkdiskcache) +endif() if(QT_FEATURE_private_tests) add_subdirectory(qdecompresshelper) endif() diff --git a/tests/benchmarks/network/access/qdecompresshelper/CMakeLists.txt b/tests/benchmarks/network/access/qdecompresshelper/CMakeLists.txt index 92a729d373..d2ca8db69d 100644 --- a/tests/benchmarks/network/access/qdecompresshelper/CMakeLists.txt +++ b/tests/benchmarks/network/access/qdecompresshelper/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qdecompresshelper.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## qdecompresshelper Binary: @@ -8,12 +9,8 @@ qt_internal_add_benchmark(qdecompresshelper SOURCES main.cpp DEFINES - SRC_DIR=${CMAKE_CURRENT_SOURCE_DIR} # special case - PUBLIC_LIBRARIES + SRC_DIR=${CMAKE_CURRENT_SOURCE_DIR} + LIBRARIES Qt::NetworkPrivate Qt::Test ) - -#### Keys ignored in scope 1:.:.:decompresshelper.pro:<TRUE>: -# TEMPLATE = "app" -# _REQUIREMENTS = "qtConfig(private_tests)" diff --git a/tests/benchmarks/network/access/qdecompresshelper/main.cpp b/tests/benchmarks/network/access/qdecompresshelper/main.cpp index 3c651b16dd..7f8b09ef0e 100644 --- a/tests/benchmarks/network/access/qdecompresshelper/main.cpp +++ b/tests/benchmarks/network/access/qdecompresshelper/main.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QtNetwork/private/qdecompresshelper_p.h> @@ -76,13 +51,14 @@ void tst_QDecompressHelper::decompress() file.seek(0); QDecompressHelper helper; helper.setEncoding(encoding); + helper.setDecompressedSafetyCheckThreshold(-1); QVERIFY(helper.isValid()); helper.feed(file.readAll()); qsizetype bytes = 0; + QByteArray out(64 * 1024, Qt::Uninitialized); while (helper.hasData()) { - QByteArray out(64 * 1024, Qt::Uninitialized); qsizetype bytesRead = helper.read(out.data(), out.size()); bytes += bytesRead; } diff --git a/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/CMakeLists.txt b/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/CMakeLists.txt index 929e87908b..fd1592ad17 100644 --- a/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/CMakeLists.txt +++ b/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qfile_vs_qnetworkaccessmanager.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_bench_qfile_vs_qnetworkaccessmanager Binary: @@ -7,10 +8,7 @@ qt_internal_add_benchmark(tst_bench_qfile_vs_qnetworkaccessmanager SOURCES main.cpp - PUBLIC_LIBRARIES + LIBRARIES Qt::Network Qt::Test ) - -#### Keys ignored in scope 1:.:.:qfile_vs_qnetworkaccessmanager.pro:<TRUE>: -# TEMPLATE = "app" diff --git a/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/main.cpp b/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/main.cpp index d0ed0f9b00..372158163f 100644 --- a/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/main.cpp +++ b/tests/benchmarks/network/access/qfile_vs_qnetworkaccessmanager/main.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QDebug> #include <qtest.h> #include <QTest> diff --git a/tests/benchmarks/network/access/qhttpheaders/CMakeLists.txt b/tests/benchmarks/network/access/qhttpheaders/CMakeLists.txt new file mode 100644 index 0000000000..6e89259141 --- /dev/null +++ b/tests/benchmarks/network/access/qhttpheaders/CMakeLists.txt @@ -0,0 +1,10 @@ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +qt_internal_add_benchmark(tst_bench_qhttpheaders + SOURCES + tst_bench_qhttpheaders.cpp + LIBRARIES + Qt::Test + Qt::Network +) diff --git a/tests/benchmarks/network/access/qhttpheaders/tst_bench_qhttpheaders.cpp b/tests/benchmarks/network/access/qhttpheaders/tst_bench_qhttpheaders.cpp new file mode 100644 index 0000000000..424b475b27 --- /dev/null +++ b/tests/benchmarks/network/access/qhttpheaders/tst_bench_qhttpheaders.cpp @@ -0,0 +1,266 @@ +// Copyright (C) 2024 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QtNetwork/qhttpheaders.h> + +#include <QtCore/qstring.h> +#include <QTest> + +using namespace Qt::StringLiterals; + +class tst_QHttpHeaders : public QObject +{ + Q_OBJECT +private slots: + void initTestCase(); + + void append_enum(); + void append_string_data(); + void append_string(); + + void contains_enum_data() { setupBasicEnumData(); } + void contains_enum(); + void contains_string_data() { setupBasicStringData(); } + void contains_string(); + + void values_enum_data() { setupBasicEnumData(); } + void values_enum(); + void values_string_data() { setupBasicStringData(); } + void values_string(); + + void combinedValue_enum_data() { setupBasicEnumData(); } + void combinedValue_enum(); + void combinedValue_string_data() { setupBasicStringData(); } + void combinedValue_string(); + + void removeAll_enum_data() { setupBasicEnumData(); } + void removeAll_enum(); + void removeAll_string_data() { setupBasicStringData(); } + void removeAll_string(); + +private: + using WKH = QHttpHeaders::WellKnownHeader; + + void setupBasicEnumData() + { + QTest::addColumn<WKH>("name"); + QTest::addColumn<bool>("exists"); + + QTest::newRow("Nonexistent enum") << WKH::CDNLoop << false; + QTest::newRow("Existent enum") << WKH::Accept << true; + } + + void setupBasicStringData() + { + QTest::addColumn<QString>("name"); + QTest::addColumn<bool>("exists"); + + QTest::newRow("Nonexistent string") << "cdn-loop" << false; + QTest::newRow("Existent wellknown string") << "accept" << true; + QTest::newRow("Existent custom string") << "customheader" << true; + } + + const QString customNameLowCase = u"customm-name"_s; // Not a typo, same length as knownName + const QString customNameMixCase = u"Customm-Name"_s; + const QString knownNameLowCase = u"content-type"_s; + const QString knownNameMixCase = u"Content-Type"_s; + static constexpr QAnyStringView value1{"value1"}; + static constexpr QAnyStringView value2{"value2"}; + static constexpr QAnyStringView value3{"value3"}; + static constexpr QAnyStringView value4{"value4"}; + + QHttpHeaders m_complexHeaders; + QHttpHeaders m_simpleHeaders; +}; + +void tst_QHttpHeaders::initTestCase() +{ + // A mix of known and custom headers in non-alphabetical order. + // "accept" (wellknown header) and "customheader" (custom header) + // have four values and in same order: value3, value1, value2, value4 + m_complexHeaders.append(WKH::Upgrade, value1); + m_complexHeaders.append("timeout", value1); + m_complexHeaders.append(WKH::KeepAlive, value1); + m_complexHeaders.append("nel", value1); + m_complexHeaders.append(WKH::Date, value1); + m_complexHeaders.append("accept", value3); + m_complexHeaders.append("customheader", value3); + m_complexHeaders.append(WKH::SoapAction, value1); + m_complexHeaders.append("foobar", value1); + m_complexHeaders.append(WKH::Accept, value1); + m_complexHeaders.append("customheader", value1); + m_complexHeaders.append(WKH::Cookie, value1); + m_complexHeaders.append("cookie", value1); + m_complexHeaders.append(WKH::ProxyStatus, value1); + m_complexHeaders.append("cookie", value1); + m_complexHeaders.append(WKH::Accept, value2); + m_complexHeaders.append("customheader", value2); + m_complexHeaders.append(WKH::Authorization, value1); + m_complexHeaders.append("content-type", value1); + m_complexHeaders.append(WKH::Destination, value1); + m_complexHeaders.append("rover", value1); + m_complexHeaders.append("accept", value4); + m_complexHeaders.append("customheader", value4); + m_complexHeaders.append(WKH::Range, value1); + m_complexHeaders.append("destination", value1); + m_complexHeaders.append(WKH::Location, value1); + m_complexHeaders.append("font", value1); + + // Simple headers with one value-less entry; having at least one entry ensures + // we don't include initial memory allocation into a test, and having + // as few as possible reduces cost of copying (header re-set) + m_simpleHeaders.append(WKH::Accept, ""); +} + +void tst_QHttpHeaders::append_enum() +{ + QHttpHeaders headers; + QBENCHMARK { + headers = m_simpleHeaders; // (Re-)set as we'll modify the headers + headers.append(WKH::Link, value1); + } + QCOMPARE(headers.size(), m_simpleHeaders.size() + 1); + QCOMPARE(headers.nameAt(headers.size() - 1), "link"); +} + +void tst_QHttpHeaders::append_string_data() +{ + QTest::addColumn<QString>("name"); + QTest::newRow("Custom lowcase string") << customNameLowCase; + QTest::newRow("WellKnown lowcase string") << knownNameLowCase; + QTest::newRow("Custom mixcase string") << customNameMixCase; + QTest::newRow("WellKnown mixcase string") << knownNameMixCase; +} + +void tst_QHttpHeaders::append_string() +{ + QFETCH(QString, name); + + QHttpHeaders headers; + QBENCHMARK { + headers = m_simpleHeaders; // (Re-)set as we'll modify the headers + headers.append(name, value1); + } + QCOMPARE(headers.size(), m_simpleHeaders.size() + 1); + QCOMPARE(headers.nameAt(headers.size() - 1), name.toLower()); +} + +void tst_QHttpHeaders::contains_enum() +{ + QFETCH(WKH, name); + QFETCH(bool, exists); + + bool result; + QBENCHMARK { + result = m_complexHeaders.contains(name); + } + QCOMPARE(result, exists); +} + +void tst_QHttpHeaders::contains_string() +{ + QFETCH(QString, name); + QFETCH(bool, exists); + + bool result; + QBENCHMARK { + result = m_complexHeaders.contains(name); + } + QCOMPARE(result, exists); +} + +void tst_QHttpHeaders::values_enum() +{ + QFETCH(WKH, name); + QFETCH(bool, exists); + + QList<QByteArray> result; + const QList<QByteArray> expectedResult{"value3", "value1", "value2", "value4"}; + QBENCHMARK { + result = m_complexHeaders.values(name); + } + if (exists) + QCOMPARE(result, expectedResult); + else + QVERIFY(result.isEmpty()); +} + +void tst_QHttpHeaders::values_string() +{ + QFETCH(QString, name); + QFETCH(bool, exists); + + QList<QByteArray> result; + const QList<QByteArray> expectedResult{"value3", "value1", "value2", "value4"}; + QBENCHMARK { + result = m_complexHeaders.values(name); + } + if (exists) + QCOMPARE(result, expectedResult); + else + QVERIFY(result.isEmpty()); +} + +void tst_QHttpHeaders::combinedValue_enum() +{ + QFETCH(WKH, name); + QFETCH(bool, exists); + + QByteArray result; + constexpr QByteArrayView expectedResult = "value3, value1, value2, value4"; + QBENCHMARK { + result = m_complexHeaders.combinedValue(name); + } + if (exists) + QCOMPARE(result, expectedResult); + else + QVERIFY(result.isEmpty()); +} + +void tst_QHttpHeaders::combinedValue_string() +{ + QFETCH(QString, name); + QFETCH(bool, exists); + + QByteArray result; + constexpr QByteArrayView expectedResult = "value3, value1, value2, value4"; + QBENCHMARK { + result = m_complexHeaders.combinedValue(name); + } + if (exists) + QCOMPARE(result, expectedResult); + else + QVERIFY(result.isEmpty()); +} + +void tst_QHttpHeaders::removeAll_enum() +{ + QFETCH(WKH, name); + QFETCH(bool, exists); + + QHttpHeaders headers = m_complexHeaders; + QCOMPARE(headers.contains(name), exists); + QBENCHMARK { + headers = m_complexHeaders; // Restore as we'll modify the headers + headers.removeAll(name); + } + QVERIFY(!headers.contains(name)); +} + +void tst_QHttpHeaders::removeAll_string() +{ + QFETCH(QString, name); + QFETCH(bool, exists); + + QHttpHeaders headers = m_complexHeaders; + QCOMPARE(headers.contains(name), exists); + QBENCHMARK { + headers = m_complexHeaders; // Restore as we'll modify the headers + headers.removeAll(name); + } + QVERIFY(!headers.contains(name)); +} + +QTEST_MAIN(tst_QHttpHeaders) + +#include "tst_bench_qhttpheaders.moc" diff --git a/tests/benchmarks/network/access/qnetworkdiskcache/CMakeLists.txt b/tests/benchmarks/network/access/qnetworkdiskcache/CMakeLists.txt index 4b8f3f4406..e049b221ff 100644 --- a/tests/benchmarks/network/access/qnetworkdiskcache/CMakeLists.txt +++ b/tests/benchmarks/network/access/qnetworkdiskcache/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qnetworkdiskcache.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_bench_qnetworkdiskcache Binary: @@ -7,10 +8,7 @@ qt_internal_add_benchmark(tst_bench_qnetworkdiskcache SOURCES tst_qnetworkdiskcache.cpp - PUBLIC_LIBRARIES + LIBRARIES Qt::Network Qt::Test ) - -#### Keys ignored in scope 1:.:.:qnetworkdiskcache.pro:<TRUE>: -# TEMPLATE = "app" diff --git a/tests/benchmarks/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp b/tests/benchmarks/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp index 113cef2cba..c70248f590 100644 --- a/tests/benchmarks/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp +++ b/tests/benchmarks/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QNetworkDiskCache> #include <QNetworkCacheMetaData> diff --git a/tests/benchmarks/network/access/qnetworkreply/CMakeLists.txt b/tests/benchmarks/network/access/qnetworkreply/CMakeLists.txt index ad0224e82c..1d13192d97 100644 --- a/tests/benchmarks/network/access/qnetworkreply/CMakeLists.txt +++ b/tests/benchmarks/network/access/qnetworkreply/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qnetworkreply.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_bench_qnetworkreply Binary: @@ -7,12 +8,9 @@ qt_internal_add_benchmark(tst_bench_qnetworkreply SOURCES tst_qnetworkreply.cpp - PUBLIC_LIBRARIES + LIBRARIES Qt::CorePrivate Qt::Network Qt::NetworkPrivate Qt::Test ) - -#### Keys ignored in scope 1:.:.:qnetworkreply.pro:<TRUE>: -# TEMPLATE = "app" diff --git a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp index 92d9972b4e..bab2743513 100644 --- a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only // This file contains benchmarks for QNetworkReply functions. #include <QDebug> @@ -46,6 +21,8 @@ #include <QtNetwork/private/qhostinfo_p.h> #endif +using namespace std::chrono_literals; + Q_DECLARE_METATYPE(QSharedPointer<char>) class TimedSender: public QThread @@ -481,7 +458,7 @@ void tst_qnetworkreply::httpLatency() QNetworkRequest request(QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/")); QNetworkReply* reply = manager.get(request); connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); - QTestEventLoop::instance().enterLoop(5); + QTestEventLoop::instance().enterLoop(5s); QVERIFY(!QTestEventLoop::instance().timeout()); delete reply; } @@ -495,7 +472,7 @@ QPair<QNetworkReply *, qint64> tst_qnetworkreply::runGetRequest( QNetworkReply *reply = manager->get(request); connect(reply, SIGNAL(sslErrors(QList<QSslError>)), reply, SLOT(ignoreSslErrors())); connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); - QTestEventLoop::instance().enterLoop(20); + QTestEventLoop::instance().enterLoop(20s); qint64 elapsed = timer.elapsed(); return qMakePair(reply, elapsed); } @@ -526,7 +503,7 @@ void tst_qnetworkreply::echoPerformance() QNetworkReply* reply = manager.post(request, data); connect(reply, SIGNAL(sslErrors(QList<QSslError>)), reply, SLOT(ignoreSslErrors())); connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); - QTestEventLoop::instance().enterLoop(5); + QTestEventLoop::instance().enterLoop(5s); QVERIFY(!QTestEventLoop::instance().timeout()); QVERIFY(reply->error() == QNetworkReply::NoError); delete reply; @@ -535,7 +512,7 @@ void tst_qnetworkreply::echoPerformance() void tst_qnetworkreply::preConnectEncrypted() { - QFETCH(int, sleepTime); + QFETCH(std::chrono::milliseconds, sleepTime); QString hostName = QLatin1String("www.google.com"); QNetworkAccessManager manager; @@ -566,7 +543,7 @@ void tst_qnetworkreply::preConnectEncrypted() // now try to make the connection beforehand manager.connectToHostEncrypted(hostName); - QTestEventLoop::instance().enterLoopMSecs(sleepTime); + QTestEventLoop::instance().enterLoop(sleepTime); // now make another request and hopefully use the existing connection QPair<QNetworkReply *, qint64> preConnectResult = runGetRequest(&manager, request); @@ -584,12 +561,12 @@ void tst_qnetworkreply::preConnectEncrypted() void tst_qnetworkreply::preConnectEncrypted_data() { #ifndef QT_NO_OPENSSL - QTest::addColumn<int>("sleepTime"); + QTest::addColumn<std::chrono::milliseconds>("sleepTime"); // start a new normal request after preconnecting is done - QTest::newRow("HTTPS-2secs") << 2000; + QTest::newRow("HTTPS-2secs") << 2000ms; // start a new normal request while preconnecting is in-flight - QTest::newRow("HTTPS-100ms") << 100; + QTest::newRow("HTTPS-100ms") << 100ms; #endif // QT_NO_OPENSSL } @@ -940,9 +917,9 @@ void tst_qnetworkreply::preConnect() manager.clearAccessCache(); // now try to make the connection beforehand - QFETCH(int, sleepTime); + QFETCH(std::chrono::milliseconds, sleepTime); manager.connectToHost(hostName); - QTestEventLoop::instance().enterLoopMSecs(sleepTime); + QTestEventLoop::instance().enterLoop(sleepTime); // now make another request and hopefully use the existing connection QPair<QNetworkReply *, qint64> preConnectResult = runGetRequest(&manager, request); diff --git a/tests/benchmarks/network/access/qnetworkreply_from_cache/CMakeLists.txt b/tests/benchmarks/network/access/qnetworkreply_from_cache/CMakeLists.txt index ced1a0850e..3e9bf3d23e 100644 --- a/tests/benchmarks/network/access/qnetworkreply_from_cache/CMakeLists.txt +++ b/tests/benchmarks/network/access/qnetworkreply_from_cache/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qnetworkreply_from_cache.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_bench_qnetworkreply_from_cache Binary: @@ -7,7 +8,7 @@ qt_internal_add_benchmark(tst_bench_qnetworkreply_from_cache SOURCES tst_qnetworkreply_from_cache.cpp - PUBLIC_LIBRARIES + LIBRARIES Qt::Network Qt::Test ) diff --git a/tests/benchmarks/network/access/qnetworkreply_from_cache/tst_qnetworkreply_from_cache.cpp b/tests/benchmarks/network/access/qnetworkreply_from_cache/tst_qnetworkreply_from_cache.cpp index 1d7dd79fe2..c18daa8195 100644 --- a/tests/benchmarks/network/access/qnetworkreply_from_cache/tst_qnetworkreply_from_cache.cpp +++ b/tests/benchmarks/network/access/qnetworkreply_from_cache/tst_qnetworkreply_from_cache.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Hewlett-Packard Development Company, L.P. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2012 Hewlett-Packard Development Company, L.P. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QTest> #include <QBuffer> diff --git a/tests/benchmarks/network/kernel/CMakeLists.txt b/tests/benchmarks/network/kernel/CMakeLists.txt index 13a7caecdb..4310cdc1ee 100644 --- a/tests/benchmarks/network/kernel/CMakeLists.txt +++ b/tests/benchmarks/network/kernel/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from kernel.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause if(QT_FEATURE_private_tests) add_subdirectory(qhostinfo) diff --git a/tests/benchmarks/network/kernel/qhostinfo/CMakeLists.txt b/tests/benchmarks/network/kernel/qhostinfo/CMakeLists.txt index 7611998c26..83b63ca501 100644 --- a/tests/benchmarks/network/kernel/qhostinfo/CMakeLists.txt +++ b/tests/benchmarks/network/kernel/qhostinfo/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qhostinfo.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_bench_qhostinfo Binary: @@ -7,12 +8,9 @@ qt_internal_add_benchmark(tst_bench_qhostinfo SOURCES main.cpp - PUBLIC_LIBRARIES + LIBRARIES Qt::CorePrivate Qt::Network Qt::NetworkPrivate Qt::Test ) - -#### Keys ignored in scope 1:.:.:qhostinfo.pro:<TRUE>: -# TEMPLATE = "app" diff --git a/tests/benchmarks/network/kernel/qhostinfo/main.cpp b/tests/benchmarks/network/kernel/qhostinfo/main.cpp index 88112908d5..66e4f52ec2 100644 --- a/tests/benchmarks/network/kernel/qhostinfo/main.cpp +++ b/tests/benchmarks/network/kernel/qhostinfo/main.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QDebug> diff --git a/tests/benchmarks/network/socket/CMakeLists.txt b/tests/benchmarks/network/socket/CMakeLists.txt index 7c122a73ef..411a933dbb 100644 --- a/tests/benchmarks/network/socket/CMakeLists.txt +++ b/tests/benchmarks/network/socket/CMakeLists.txt @@ -1,5 +1,12 @@ -# Generated from socket.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +if(QT_FEATURE_localserver) + add_subdirectory(qlocalsocket) +endif() + +if(QT_FEATURE_udpsocket) + add_subdirectory(qudpsocket) +endif() -add_subdirectory(qlocalsocket) add_subdirectory(qtcpserver) -add_subdirectory(qudpsocket) diff --git a/tests/benchmarks/network/socket/qlocalsocket/CMakeLists.txt b/tests/benchmarks/network/socket/qlocalsocket/CMakeLists.txt index 7c56b0b946..660f2ee5b4 100644 --- a/tests/benchmarks/network/socket/qlocalsocket/CMakeLists.txt +++ b/tests/benchmarks/network/socket/qlocalsocket/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + ##################################################################### ## tst_bench_qlocalsocket Binary: ##################################################################### @@ -5,10 +8,7 @@ qt_internal_add_benchmark(tst_bench_qlocalsocket SOURCES tst_qlocalsocket.cpp - PUBLIC_LIBRARIES + LIBRARIES Qt::Network Qt::Test ) - -#### Keys ignored in scope 1:.:.:qlocalsocket.pro:<TRUE>: -# TEMPLATE = "app" diff --git a/tests/benchmarks/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/benchmarks/network/socket/qlocalsocket/tst_qlocalsocket.cpp index 7130895f51..a28869f24c 100644 --- a/tests/benchmarks/network/socket/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/benchmarks/network/socket/qlocalsocket/tst_qlocalsocket.cpp @@ -1,31 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Copyright (C) 2021 Alex Trotsenko <alex1973tr@gmail.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// Copyright (C) 2021 Alex Trotsenko <alex1973tr@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QTest> #include <QtTest/qtesteventloop.h> @@ -39,6 +14,8 @@ #include <QtNetwork/qlocalsocket.h> #include <QtNetwork/qlocalserver.h> +using namespace std::chrono_literals; + class tst_QLocalSocket : public QObject { Q_OBJECT @@ -200,7 +177,7 @@ void tst_QLocalSocket::dataExchange() QFETCH(int, chunkSize); Q_ASSERT(chunkSize > 0 && connections > 0); - const qint64 timeToTest = 5000; + const auto timeToTest = 5000ms; ServerThread serverThread(chunkSize); serverThread.start(); @@ -212,12 +189,11 @@ void tst_QLocalSocket::dataExchange() qint64 totalReceived = 0; QElapsedTimer timer; - connect(&factory, &SocketFactory::bytesReceived, - [&totalReceived, &timer, timeToTest, &factory, &eventLoop](int channel, qint64 bytes) { + connect(&factory, &SocketFactory::bytesReceived, [&](int channel, qint64 bytes) { Q_UNUSED(channel); totalReceived += bytes; - if (timer.elapsed() >= timeToTest) { + if (timer.elapsed() >= timeToTest.count()) { factory.stopped = true; eventLoop.exitLoop(); } @@ -225,7 +201,7 @@ void tst_QLocalSocket::dataExchange() timer.start(); emit factory.start(); - eventLoop.enterLoopMSecs(timeToTest * 2); + eventLoop.enterLoop(timeToTest * 2); if (!QTest::currentTestFailed()) qDebug("Transfer rate: %.1f MB/s", totalReceived / 1048.576 / timer.elapsed()); diff --git a/tests/benchmarks/network/socket/qtcpserver/CMakeLists.txt b/tests/benchmarks/network/socket/qtcpserver/CMakeLists.txt index f566c4f341..ae2f491df0 100644 --- a/tests/benchmarks/network/socket/qtcpserver/CMakeLists.txt +++ b/tests/benchmarks/network/socket/qtcpserver/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qtcpserver.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_bench_qtcpserver Binary: @@ -7,10 +8,7 @@ qt_internal_add_benchmark(tst_bench_qtcpserver SOURCES tst_qtcpserver.cpp - PUBLIC_LIBRARIES + LIBRARIES Qt::Network Qt::Test ) - -#### Keys ignored in scope 1:.:.:qtcpserver.pro:<TRUE>: -# TEMPLATE = "app" diff --git a/tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp b/tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp index 06643dd1fd..68d60261d5 100644 --- a/tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp +++ b/tests/benchmarks/network/socket/qtcpserver/tst_qtcpserver.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QTest> #include <QtCore/QElapsedTimer> diff --git a/tests/benchmarks/network/socket/qudpsocket/CMakeLists.txt b/tests/benchmarks/network/socket/qudpsocket/CMakeLists.txt index 02293cdae6..0a39e8fc0c 100644 --- a/tests/benchmarks/network/socket/qudpsocket/CMakeLists.txt +++ b/tests/benchmarks/network/socket/qudpsocket/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qudpsocket.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_bench_qudpsocket Binary: @@ -7,10 +8,7 @@ qt_internal_add_benchmark(tst_bench_qudpsocket SOURCES tst_qudpsocket.cpp - PUBLIC_LIBRARIES + LIBRARIES Qt::Network Qt::Test ) - -#### Keys ignored in scope 1:.:.:qudpsocket.pro:<TRUE>: -# TEMPLATE = "app" diff --git a/tests/benchmarks/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/benchmarks/network/socket/qudpsocket/tst_qudpsocket.cpp index f2fd297414..d3ef636e74 100644 --- a/tests/benchmarks/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/benchmarks/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QTest> #include <QtCore/qglobal.h> diff --git a/tests/benchmarks/network/ssl/CMakeLists.txt b/tests/benchmarks/network/ssl/CMakeLists.txt index bc469359f1..579816e153 100644 --- a/tests/benchmarks/network/ssl/CMakeLists.txt +++ b/tests/benchmarks/network/ssl/CMakeLists.txt @@ -1,3 +1,4 @@ -# Generated from ssl.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause add_subdirectory(qsslsocket) diff --git a/tests/benchmarks/network/ssl/qsslsocket/CMakeLists.txt b/tests/benchmarks/network/ssl/qsslsocket/CMakeLists.txt index 95bbda6758..70e4448b73 100644 --- a/tests/benchmarks/network/ssl/qsslsocket/CMakeLists.txt +++ b/tests/benchmarks/network/ssl/qsslsocket/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qsslsocket.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_bench_qsslsocket Binary: @@ -7,10 +8,7 @@ qt_internal_add_benchmark(tst_bench_qsslsocket SOURCES tst_qsslsocket.cpp - PUBLIC_LIBRARIES + LIBRARIES Qt::Network Qt::Test ) - -#### Keys ignored in scope 1:.:.:qsslsocket.pro:<TRUE>: -# TEMPLATE = "app" diff --git a/tests/benchmarks/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/benchmarks/network/ssl/qsslsocket/tst_qsslsocket.cpp index 96f6ad87e7..fd5f49863a 100644 --- a/tests/benchmarks/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/benchmarks/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QTest> |