summaryrefslogtreecommitdiffstats
path: root/tests/auto/network/socket
diff options
context:
space:
mode:
authorShane Kearns <ext-shane.2.kearns@nokia.com>2012-02-20 18:48:10 +0000
committerQt by Nokia <qt-info@nokia.com>2012-03-01 00:09:57 +0100
commit46e4a9d5231e2d9e35424259858713ca539b8e30 (patch)
treee047636b446959812473c2da31658141b3db18ad /tests/auto/network/socket
parentb147da00c5fec9d89a2b60d10e82ac28766e2a5b (diff)
Windows - fix getsockopt calls for narrower than int options
Windows unhelpfully writes to only one byte of the output buffer when getsockopt is called for a boolean option. Therefore we have to zero initialise the int rather than initialising to -1 as was done before. This in general only works for little endian architecture, because the word would look like 0x01000000 on big endian. So I have added some compile time asserts in the assumption that windows is always little endian. This is ok for comparisons with 0/false, but not comparisons with true or nonzero values. In the case of IPV6_V6ONLY, it is documented as DWORD (unsigned int) but on some windows versions it is returned as a boolean triggering the warning. I removed the warning, as the conversion to int works on both LE and BE since it is only compared with zero. Task-number: QTBUG-23488 Change-Id: I3c586d1ada76465fc045a82661f289920c657a4c Reviewed-by: Richard J. Moore <rich@kde.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com> Reviewed-by: Andreas Holzammer <andreas.holzammer@kdab.com>
Diffstat (limited to 'tests/auto/network/socket')
-rw-r--r--tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
index 2c2b551257..8b65c312bc 100644
--- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
+++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
@@ -201,6 +201,8 @@ private slots:
void qtbug14268_peek();
+ void setSocketOption();
+
protected slots:
void nonBlockingIMAP_hostFound();
@@ -2699,7 +2701,41 @@ void tst_QTcpSocket::qtbug14268_peek()
QVERIFY(incoming->read(128*1024) == QByteArray("abc\ndef\nghi\n"));
}
+void tst_QTcpSocket::setSocketOption()
+{
+ QFETCH_GLOBAL(bool, setProxy);
+ if (setProxy)
+ return;
+
+ SocketPair socketPair;
+ QVERIFY(socketPair.create());
+ QTcpSocket *outgoing = socketPair.endPoints[0];
+ QTcpSocket *incoming = socketPair.endPoints[1];
+
+ QVERIFY(incoming->state() == QTcpSocket::ConnectedState);
+ QVERIFY(outgoing->state() == QTcpSocket::ConnectedState);
+
+ outgoing->setSocketOption(QAbstractSocket::LowDelayOption, true);
+ QVariant v = outgoing->socketOption(QAbstractSocket::LowDelayOption);
+ QVERIFY(v.isValid() && v.toBool());
+ outgoing->setSocketOption(QAbstractSocket::KeepAliveOption, true);
+ v = outgoing->socketOption(QAbstractSocket::KeepAliveOption);
+ QVERIFY(v.isValid() && v.toBool());
+ outgoing->setSocketOption(QAbstractSocket::LowDelayOption, false);
+ v = outgoing->socketOption(QAbstractSocket::LowDelayOption);
+ QVERIFY(v.isValid() && !v.toBool());
+ outgoing->setSocketOption(QAbstractSocket::KeepAliveOption, false);
+ v = outgoing->socketOption(QAbstractSocket::KeepAliveOption);
+ QVERIFY(v.isValid() && !v.toBool());
+
+#ifdef Q_OS_WIN
+ QEXPECT_FAIL("", "QTBUG-23323", Abort);
+#endif
+ outgoing->setSocketOption(QAbstractSocket::TypeOfServiceOption, 32); //high priority
+ v = outgoing->socketOption(QAbstractSocket::TypeOfServiceOption);
+ QVERIFY(v.isValid() && v.toInt() == 32);
+}
QTEST_MAIN(tst_QTcpSocket)
#include "tst_qtcpsocket.moc"