Fix tst_dnslookup compilation when udpsocket is disabled
Guard the UDP socket includes and uses with feature flag. Task-number: QTBUG-136101 Pick-to: 6.8 Change-Id: I1fe27244e6aa029407b07ebc06de137ec8b280af Reviewed-by: Mate Barany <mate.barany@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 6816273f0ed620ef28b407eb24d53212ea08dd77) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
b9d95d7982
commit
a55c9dbabc
@ -11,8 +11,10 @@
|
|||||||
#include <QtCore/QElapsedTimer>
|
#include <QtCore/QElapsedTimer>
|
||||||
#include <QtCore/QRandomGenerator>
|
#include <QtCore/QRandomGenerator>
|
||||||
#include <QtNetwork/QHostAddress>
|
#include <QtNetwork/QHostAddress>
|
||||||
|
#if QT_CONFIG(udpsocket)
|
||||||
#include <QtNetwork/QNetworkDatagram>
|
#include <QtNetwork/QNetworkDatagram>
|
||||||
#include <QtNetwork/QUdpSocket>
|
#include <QtNetwork/QUdpSocket>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if QT_CONFIG(networkproxy)
|
#if QT_CONFIG(networkproxy)
|
||||||
# include <QtNetwork/QNetworkProxyFactory>
|
# include <QtNetwork/QNetworkProxyFactory>
|
||||||
@ -157,6 +159,7 @@ static QList<QHostAddress> globalPublicNameservers(QDnsLookup::Protocol proto)
|
|||||||
};
|
};
|
||||||
|
|
||||||
auto udpSendAndReceive = [](const QHostAddress &addr, QByteArray &data) {
|
auto udpSendAndReceive = [](const QHostAddress &addr, QByteArray &data) {
|
||||||
|
#if QT_CONFIG(udpsocket)
|
||||||
QUdpSocket socket;
|
QUdpSocket socket;
|
||||||
socket.connectToHost(addr, 53);
|
socket.connectToHost(addr, 53);
|
||||||
if (socket.waitForConnected(1))
|
if (socket.waitForConnected(1))
|
||||||
@ -171,6 +174,9 @@ static QList<QHostAddress> globalPublicNameservers(QDnsLookup::Protocol proto)
|
|||||||
|
|
||||||
data = dgram.data();
|
data = dgram.data();
|
||||||
return QString();
|
return QString();
|
||||||
|
#else
|
||||||
|
return u"UDP socket support not compiled in"_s;
|
||||||
|
#endif // QT_CONFIG(udpsocket)
|
||||||
};
|
};
|
||||||
|
|
||||||
auto tlsSendAndReceive = [](const QHostAddress &addr, QByteArray &data) {
|
auto tlsSendAndReceive = [](const QHostAddress &addr, QByteArray &data) {
|
||||||
@ -701,6 +707,9 @@ void tst_QDnsLookup::lookupAbortRetry()
|
|||||||
|
|
||||||
void tst_QDnsLookup::setNameserverLoopback()
|
void tst_QDnsLookup::setNameserverLoopback()
|
||||||
{
|
{
|
||||||
|
#if !QT_CONFIG(udpsocket)
|
||||||
|
QSKIP("UDP socket not enabled");
|
||||||
|
#else
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
// Windows doesn't like sending DNS requests to ports other than 53, so
|
// Windows doesn't like sending DNS requests to ports other than 53, so
|
||||||
// let's try it first.
|
// let's try it first.
|
||||||
@ -754,6 +763,7 @@ void tst_QDnsLookup::setNameserverLoopback()
|
|||||||
QVERIFY(!QTestEventLoop::instance().timeout());
|
QVERIFY(!QTestEventLoop::instance().timeout());
|
||||||
QCOMPARE(spy.size(), 1);
|
QCOMPARE(spy.size(), 1);
|
||||||
QCOMPARE(lookup.error(), QDnsLookup::NotFoundError);
|
QCOMPARE(lookup.error(), QDnsLookup::NotFoundError);
|
||||||
|
#endif // QT_CONFIG(udpsocket)
|
||||||
}
|
}
|
||||||
|
|
||||||
template <QDnsLookup::Protocol Protocol>
|
template <QDnsLookup::Protocol Protocol>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user