From 23100ee61e33680d20f934dcbc96b57e8da29bf9 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 19 Nov 2020 16:06:05 +0100 Subject: Revert "Allow QWindowsPipe{Reader,Writer} to work with foreign event loops" This reverts commit ee122077b09430da54ca09750589b37326a22d85. Reason for revert: This causes QProcess::readAll() to sometimes return nothing after the process has ended. Fixes: QTBUG-88624 Pick-to: 6.0 dev Change-Id: I34fa27ae7fb38cc7c3a1e8eb2fdae2a5775584c2 Reviewed-by: Lars Knoll Reviewed-by: Paul Wicking --- tests/benchmarks/network/socket/CMakeLists.txt | 1 - .../network/socket/qlocalsocket/CMakeLists.txt | 16 -- .../network/socket/qlocalsocket/qlocalsocket.pro | 8 - .../socket/qlocalsocket/tst_qlocalsocket.cpp | 224 --------------------- tests/benchmarks/network/socket/socket.pro | 1 - 5 files changed, 250 deletions(-) delete mode 100644 tests/benchmarks/network/socket/qlocalsocket/CMakeLists.txt delete mode 100644 tests/benchmarks/network/socket/qlocalsocket/qlocalsocket.pro delete mode 100644 tests/benchmarks/network/socket/qlocalsocket/tst_qlocalsocket.cpp (limited to 'tests/benchmarks') diff --git a/tests/benchmarks/network/socket/CMakeLists.txt b/tests/benchmarks/network/socket/CMakeLists.txt index 7c122a73ef..6d54bc05f5 100644 --- a/tests/benchmarks/network/socket/CMakeLists.txt +++ b/tests/benchmarks/network/socket/CMakeLists.txt @@ -1,5 +1,4 @@ # Generated from socket.pro. -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 deleted file mode 100644 index 08f36787a8..0000000000 --- a/tests/benchmarks/network/socket/qlocalsocket/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -# Generated from qlocalsocket.pro. - -##################################################################### -## tst_bench_qlocalsocket Binary: -##################################################################### - -qt_internal_add_benchmark(tst_bench_qlocalsocket - SOURCES - tst_qlocalsocket.cpp - PUBLIC_LIBRARIES - Qt::Network - Qt::Test -) - -#### Keys ignored in scope 1:.:.:qlocalsocket.pro:: -# TEMPLATE = "app" diff --git a/tests/benchmarks/network/socket/qlocalsocket/qlocalsocket.pro b/tests/benchmarks/network/socket/qlocalsocket/qlocalsocket.pro deleted file mode 100644 index 5c6f25ea61..0000000000 --- a/tests/benchmarks/network/socket/qlocalsocket/qlocalsocket.pro +++ /dev/null @@ -1,8 +0,0 @@ -TEMPLATE = app -TARGET = tst_bench_qlocalsocket - -QT = network testlib - -CONFIG += release - -SOURCES += tst_qlocalsocket.cpp diff --git a/tests/benchmarks/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/benchmarks/network/socket/qlocalsocket/tst_qlocalsocket.cpp deleted file mode 100644 index adedc25dc2..0000000000 --- a/tests/benchmarks/network/socket/qlocalsocket/tst_qlocalsocket.cpp +++ /dev/null @@ -1,224 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class tst_QLocalSocket : public QObject -{ - Q_OBJECT - -private slots: - void pingPong_data(); - void pingPong(); - void dataExchange_data(); - void dataExchange(); -}; - -class ServerThread : public QThread -{ -public: - QSemaphore running; - - explicit ServerThread(int chunkSize) - { - buffer.resize(chunkSize); - } - - void run() override - { - QLocalServer server; - - connect(&server, &QLocalServer::newConnection, [this, &server]() { - auto socket = server.nextPendingConnection(); - - connect(socket, &QLocalSocket::readyRead, [this, socket]() { - const qint64 bytesAvailable = socket->bytesAvailable(); - Q_ASSERT(bytesAvailable <= this->buffer.size()); - - QCOMPARE(socket->read(this->buffer.data(), bytesAvailable), bytesAvailable); - QCOMPARE(socket->write(this->buffer.data(), bytesAvailable), bytesAvailable); - }); - }); - - QVERIFY(server.listen("foo")); - running.release(); - exec(); - } - -protected: - QByteArray buffer; -}; - -class SocketFactory : public QObject -{ - Q_OBJECT - -public: - bool stopped = false; - - explicit SocketFactory(int chunkSize, int connections) - { - buffer.resize(chunkSize); - for (int i = 0; i < connections; ++i) { - QLocalSocket *socket = new QLocalSocket(this); - Q_CHECK_PTR(socket); - - connect(this, &SocketFactory::start, [this, socket]() { - QCOMPARE(socket->write(this->buffer), this->buffer.size()); - }); - - connect(socket, &QLocalSocket::readyRead, [i, this, socket]() { - const qint64 bytesAvailable = socket->bytesAvailable(); - Q_ASSERT(bytesAvailable <= this->buffer.size()); - - QCOMPARE(socket->read(this->buffer.data(), bytesAvailable), bytesAvailable); - emit this->bytesReceived(i, bytesAvailable); - - if (!this->stopped) - QCOMPARE(socket->write(this->buffer.data(), bytesAvailable), bytesAvailable); - }); - - socket->connectToServer("foo"); - QCOMPARE(socket->state(), QLocalSocket::ConnectedState); - } - } - -signals: - void start(); - void bytesReceived(int channel, qint64 bytes); - -protected: - QByteArray buffer; -}; - -void tst_QLocalSocket::pingPong_data() -{ - QTest::addColumn("connections"); - for (int value : {10, 50, 100, 1000, 5000}) - QTest::addRow("connections: %d", value) << value; -} - -void tst_QLocalSocket::pingPong() -{ - QFETCH(int, connections); - - const int iterations = 100000; - Q_ASSERT(iterations >= connections && connections > 0); - - ServerThread serverThread(1); - serverThread.start(); - // Wait for server to start. - QVERIFY(serverThread.running.tryAcquire(1, 3000)); - - SocketFactory factory(1, connections); - QEventLoop eventLoop; - QVector bytesToRead; - QElapsedTimer timer; - - bytesToRead.fill(iterations / connections, connections); - connect(&factory, &SocketFactory::bytesReceived, - [&bytesToRead, &connections, &factory, &eventLoop](int channel, qint64 bytes) { - Q_UNUSED(bytes); - - if (--bytesToRead[channel] == 0 && --connections == 0) { - factory.stopped = true; - eventLoop.quit(); - } - }); - - timer.start(); - emit factory.start(); - eventLoop.exec(); - - qDebug("Elapsed time: %.1f s", timer.elapsed() / 1000.0); - serverThread.quit(); - serverThread.wait(); -} - -void tst_QLocalSocket::dataExchange_data() -{ - QTest::addColumn("connections"); - QTest::addColumn("chunkSize"); - for (int connections : {1, 5, 10}) { - for (int chunkSize : {100, 1000, 10000, 100000}) { - QTest::addRow("connections: %d, chunk size: %d", - connections, chunkSize) << connections << chunkSize; - } - } -} - -void tst_QLocalSocket::dataExchange() -{ - QFETCH(int, connections); - QFETCH(int, chunkSize); - - Q_ASSERT(chunkSize > 0 && connections > 0); - const qint64 timeToTest = 5000; - - ServerThread serverThread(chunkSize); - serverThread.start(); - // Wait for server to start. - QVERIFY(serverThread.running.tryAcquire(1, 3000)); - - SocketFactory factory(chunkSize, connections); - QEventLoop eventLoop; - qint64 totalReceived = 0; - QElapsedTimer timer; - - connect(&factory, &SocketFactory::bytesReceived, - [&totalReceived, &timer, timeToTest, &factory, &eventLoop](int channel, qint64 bytes) { - Q_UNUSED(channel); - - totalReceived += bytes; - if (timer.elapsed() >= timeToTest) { - factory.stopped = true; - eventLoop.quit(); - } - }); - - timer.start(); - emit factory.start(); - eventLoop.exec(); - - qDebug("Transfer rate: %.1f MB/s", totalReceived / 1048.576 / timer.elapsed()); - serverThread.quit(); - serverThread.wait(); -} - -QTEST_MAIN(tst_QLocalSocket) - -#include "tst_qlocalsocket.moc" diff --git a/tests/benchmarks/network/socket/socket.pro b/tests/benchmarks/network/socket/socket.pro index 1cc67cffd7..d428a4d973 100644 --- a/tests/benchmarks/network/socket/socket.pro +++ b/tests/benchmarks/network/socket/socket.pro @@ -1,5 +1,4 @@ TEMPLATE = subdirs SUBDIRS = \ - qlocalsocket \ qtcpserver \ qudpsocket -- cgit v1.2.3