Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.5.0
-
None
-
Succeeds on:
* Linux (Ubuntu 15.04 tested)
* Mac OS X (10.10 tested)
Fails on:
* Windows (8.1 tested)
Description
Consider the following test case:
TestSocketBug.cpp
#include <QTcpServer> #include <QTcpSocket> #include <QTest> class TestSocketBug : public QObject { Q_OBJECT private Q_SLOTS: void testBug(); }; void TestSocketBug::testBug() { QTcpServer server; QVERIFY(server.listen(QHostAddress::LocalHost)); QTcpSocket clientSocket; clientSocket.connectToHost(server.serverAddress(), server.serverPort()); QTRY_COMPARE(clientSocket.state(), QAbstractSocket::ConnectedState); QTcpSocket *serverSocket = server.nextPendingConnection(); serverSocket->write("test"); serverSocket->close(); clientSocket.write("something"); QTRY_COMPARE(clientSocket.bytesAvailable(), 4); } QTEST_MAIN(TestSocketBug) #include "TestSocketBug.moc"
The test case can be compiled with the following build script:
CMakeLists.txt
cmake_minimum_required(VERSION 2.8.11) project(socketbug) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) find_package(Qt5Network REQUIRED) find_package(Qt5Test REQUIRED) add_executable(socketbug TestSocketBug.cpp) qt5_use_modules(socketbug Network Test)
When run, the test fails on Windows since no data is available for reading on clientSocket. However, if the clientSocket.write() line is commented out, the test passes.