From b73b3f8a5cb566ff8219b14647f0ceae29cfe6b2 Mon Sep 17 00:00:00 2001 From: Sami Nurmenniemi Date: Mon, 26 Jun 2017 10:01:16 +0300 Subject: Enable tests for boot2qt Websocket tests for boot2qt were disabled with commit 1a75da8d514c90cf1af250ba3eaa764df4838775. The tests can be enabled since qtdeclarative now fallbacks to software renderer if OpenGL is not supported. Qemu still has missing syscall support so some tests need to be skipped if that condition is detected. Change-Id: I39dba91cb35cc17a9a9263c90a739cbf95efa582 Reviewed-by: Simon Hausmann --- .../qwebsocketserver/qwebsocketserver.pro | 1 + .../qwebsocketserver/tst_qwebsocketserver.cpp | 57 +++++++++++++++++++++- tests/auto/websockets/websockets.pro | 3 -- 3 files changed, 57 insertions(+), 4 deletions(-) (limited to 'tests/auto/websockets') diff --git a/tests/auto/websockets/qwebsocketserver/qwebsocketserver.pro b/tests/auto/websockets/qwebsocketserver/qwebsocketserver.pro index e166f50..178fd88 100644 --- a/tests/auto/websockets/qwebsocketserver/qwebsocketserver.pro +++ b/tests/auto/websockets/qwebsocketserver/qwebsocketserver.pro @@ -12,3 +12,4 @@ SOURCES += tst_qwebsocketserver.cpp RESOURCES += $$PWD/../shared/qwebsocketshared.qrc +boot2qt: DEFINES += SHOULD_CHECK_SYSCALL_SUPPORT diff --git a/tests/auto/websockets/qwebsocketserver/tst_qwebsocketserver.cpp b/tests/auto/websockets/qwebsocketserver/tst_qwebsocketserver.cpp index 82e2013..8f3e293 100644 --- a/tests/auto/websockets/qwebsocketserver/tst_qwebsocketserver.cpp +++ b/tests/auto/websockets/qwebsocketserver/tst_qwebsocketserver.cpp @@ -112,9 +112,15 @@ private Q_SLOTS: void tst_serverDestroyedWhileSocketConnected(); void tst_scheme(); // qtbug-55927 void tst_handleConnection(); + +private: + bool m_shouldSkipUnsupportedIpv6Test; +#ifdef SHOULD_CHECK_SYSCALL_SUPPORT + bool ipv6GetsockoptionMissing(int level, int optname); +#endif }; -tst_QWebSocketServer::tst_QWebSocketServer() +tst_QWebSocketServer::tst_QWebSocketServer() : m_shouldSkipUnsupportedIpv6Test(false) { } @@ -132,8 +138,42 @@ void tst_QWebSocketServer::init() #endif } +#ifdef SHOULD_CHECK_SYSCALL_SUPPORT +#include +#include +#include +#include + +bool tst_QWebSocketServer::ipv6GetsockoptionMissing(int level, int optname) +{ + int testSocket; + + testSocket = socket(PF_INET6, SOCK_STREAM, 0); + + // If we can't test here, assume it's not missing + if (testSocket == -1) + return false; + + bool result = false; + if (getsockopt(testSocket, level, optname, nullptr, 0) == -1) { + if (errno == EOPNOTSUPP) { + result = true; + } + } + + close(testSocket); + return result; +} + +#endif //SHOULD_CHECK_SYSCALL_SUPPORT + void tst_QWebSocketServer::initTestCase() { +#ifdef SHOULD_CHECK_SYSCALL_SUPPORT + // Qemu does not have required support for IPV6 socket options. + // If this is detected, skip the test + m_shouldSkipUnsupportedIpv6Test = ipv6GetsockoptionMissing(SOL_IPV6, IPV6_V6ONLY); +#endif } void tst_QWebSocketServer::cleanupTestCase() @@ -283,6 +323,9 @@ void tst_QWebSocketServer::tst_listening() void tst_QWebSocketServer::tst_connectivity() { + if (m_shouldSkipUnsupportedIpv6Test) + QSKIP("Syscalls needed for ipv6 sockoptions missing functionality"); + QWebSocketServer server(QString(), QWebSocketServer::NonSecureMode); QSignalSpy serverConnectionSpy(&server, SIGNAL(newConnection())); QSignalSpy serverErrorSpy(&server, @@ -325,6 +368,9 @@ void tst_QWebSocketServer::tst_connectivity() void tst_QWebSocketServer::tst_preSharedKey() { + if (m_shouldSkipUnsupportedIpv6Test) + QSKIP("Syscalls needed for ipv6 sockoptions missing functionality"); + #ifndef QT_NO_OPENSSL QWebSocketServer server(QString(), QWebSocketServer::SecureMode); @@ -403,6 +449,9 @@ void tst_QWebSocketServer::tst_preSharedKey() void tst_QWebSocketServer::tst_maxPendingConnections() { + if (m_shouldSkipUnsupportedIpv6Test) + QSKIP("Syscalls needed for ipv6 sockoptions missing functionality"); + //tests if maximum connections are respected //also checks if there are no side-effects like signals that are unexpectedly thrown QWebSocketServer server(QString(), QWebSocketServer::NonSecureMode); @@ -481,6 +530,9 @@ void tst_QWebSocketServer::tst_maxPendingConnections() void tst_QWebSocketServer::tst_serverDestroyedWhileSocketConnected() { + if (m_shouldSkipUnsupportedIpv6Test) + QSKIP("Syscalls needed for ipv6 sockoptions missing functionality"); + QWebSocketServer * server = new QWebSocketServer(QString(), QWebSocketServer::NonSecureMode); QSignalSpy serverConnectionSpy(server, SIGNAL(newConnection())); QSignalSpy corsAuthenticationSpy(server, @@ -515,6 +567,9 @@ void tst_QWebSocketServer::tst_serverDestroyedWhileSocketConnected() void tst_QWebSocketServer::tst_scheme() { + if (m_shouldSkipUnsupportedIpv6Test) + QSKIP("Syscalls needed for ipv6 sockoptions missing functionality"); + QWebSocketServer plainServer(QString(), QWebSocketServer::NonSecureMode); QSignalSpy plainServerConnectionSpy(&plainServer, SIGNAL(newConnection())); diff --git a/tests/auto/websockets/websockets.pro b/tests/auto/websockets/websockets.pro index 4b7ee4e..b000229 100644 --- a/tests/auto/websockets/websockets.pro +++ b/tests/auto/websockets/websockets.pro @@ -14,6 +14,3 @@ qtConfig(private_tests): SUBDIRS += \ SUBDIRS += \ qwebsocket \ qwebsocketserver - -# QTBUG-60268 -boot2qt: SUBDIRS -= qwebsocketserver -- cgit v1.2.1