OpenCoverage

qhostinfo_unix.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/network/kernel/qhostinfo_unix.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtNetwork module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40//#define QHOSTINFO_DEBUG-
41-
42#include "qplatformdefs.h"-
43-
44#include "qhostinfo_p.h"-
45#include "private/qnativesocketengine_p.h"-
46#include "qiodevice.h"-
47#include <qbytearray.h>-
48#include <qlibrary.h>-
49#include <qbasicatomic.h>-
50#include <qurl.h>-
51#include <qfile.h>-
52#include <private/qnet_unix_p.h>-
53-
54#include <sys/types.h>-
55#include <netdb.h>-
56#include <arpa/inet.h>-
57#if defined(Q_OS_VXWORKS)-
58# include <hostLib.h>-
59#else-
60# include <resolv.h>-
61#endif-
62-
63#if defined(__GNU_LIBRARY__) && !defined(__UCLIBC__)-
64# include <gnu/lib-names.h>-
65#endif-
66-
67#if defined (QT_NO_GETADDRINFO)-
68static QBasicMutex getHostByNameMutex;-
69#endif-
70-
71QT_BEGIN_NAMESPACE-
72-
73// Almost always the same. If not, specify in qplatformdefs.h.-
74#if !defined(QT_SOCKOPTLEN_T)-
75# define QT_SOCKOPTLEN_T QT_SOCKLEN_T-
76#endif-
77-
78// HP-UXi has a bug in getaddrinfo(3) that makes it thread-unsafe-
79// with this flag. So disable it in that platform.-
80#if defined(AI_ADDRCONFIG) && !defined(Q_OS_HPUX)-
81# define Q_ADDRCONFIG AI_ADDRCONFIG-
82#endif-
83-
84typedef struct __res_state *res_state_ptr;-
85-
86typedef int (*res_init_proto)(void);-
87static res_init_proto local_res_init = 0;-
88typedef int (*res_ninit_proto)(res_state_ptr);-
89static res_ninit_proto local_res_ninit = 0;-
90typedef void (*res_nclose_proto)(res_state_ptr);-
91static res_nclose_proto local_res_nclose = 0;-
92static res_state_ptr local_res = 0;-
93-
94static bool resolveLibraryInternal()-
95{-
96#if !defined(QT_NO_LIBRARY) && !defined(Q_OS_QNX)-
97 QLibrary lib;-
98#ifdef LIBRESOLV_SO-
99 lib.setFileName(QStringLiteral(LIBRESOLV_SO));
executed 24 times by 24 tests: return qstring_literal_temp;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_Spdy
  • tst_lancelot - unknown status
  • tst_platformsocketengine - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qiodevice - unknown status
  • tst_qobject - unknown status
  • tst_qprocess - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qtextstream - unknown status
24
100 if (!lib.load())
!lib.load()Description
TRUEnever evaluated
FALSEevaluated 24 times by 24 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_Spdy
  • tst_lancelot - unknown status
  • tst_platformsocketengine - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qiodevice - unknown status
  • tst_qobject - unknown status
  • tst_qprocess - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qtextstream - unknown status
0-24
101#endif-
102 {-
103 lib.setFileName(QLatin1String("resolv"));-
104 if (!lib.load())
!lib.load()Description
TRUEnever evaluated
FALSEnever evaluated
0
105 return false;
never executed: return false;
0
106 }
never executed: end of block
0
107-
108 local_res_init = res_init_proto(lib.resolve("__res_init"));-
109 if (!local_res_init)
!local_res_initDescription
TRUEnever evaluated
FALSEevaluated 24 times by 24 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_Spdy
  • tst_lancelot - unknown status
  • tst_platformsocketengine - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qiodevice - unknown status
  • tst_qobject - unknown status
  • tst_qprocess - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qtextstream - unknown status
0-24
110 local_res_init = res_init_proto(lib.resolve("res_init"));
never executed: local_res_init = res_init_proto(lib.resolve("res_init"));
0
111-
112 local_res_ninit = res_ninit_proto(lib.resolve("__res_ninit"));-
113 if (!local_res_ninit)
!local_res_ninitDescription
TRUEnever evaluated
FALSEevaluated 24 times by 24 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_Spdy
  • tst_lancelot - unknown status
  • tst_platformsocketengine - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qiodevice - unknown status
  • tst_qobject - unknown status
  • tst_qprocess - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qtextstream - unknown status
0-24
114 local_res_ninit = res_ninit_proto(lib.resolve("res_ninit"));
never executed: local_res_ninit = res_ninit_proto(lib.resolve("res_ninit"));
0
115-
116 if (!local_res_ninit) {
!local_res_ninitDescription
TRUEnever evaluated
FALSEevaluated 24 times by 24 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_Spdy
  • tst_lancelot - unknown status
  • tst_platformsocketengine - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qiodevice - unknown status
  • tst_qobject - unknown status
  • tst_qprocess - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qtextstream - unknown status
0-24
117 // if we can't get a thread-safe context, we have to use the global _res state-
118 local_res = res_state_ptr(lib.resolve("_res"));-
119 } else {
never executed: end of block
0
120 local_res_nclose = res_nclose_proto(lib.resolve("res_nclose"));-
121 if (!local_res_nclose)
!local_res_ncloseDescription
TRUEevaluated 24 times by 24 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_Spdy
  • tst_lancelot - unknown status
  • tst_platformsocketengine - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qiodevice - unknown status
  • tst_qobject - unknown status
  • tst_qprocess - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qtextstream - unknown status
FALSEnever evaluated
0-24
122 local_res_nclose = res_nclose_proto(lib.resolve("__res_nclose"));
executed 24 times by 24 tests: local_res_nclose = res_nclose_proto(lib.resolve("__res_nclose"));
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_Spdy
  • tst_lancelot - unknown status
  • tst_platformsocketengine - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qiodevice - unknown status
  • tst_qobject - unknown status
  • tst_qprocess - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qtextstream - unknown status
24
123 if (!local_res_nclose)
!local_res_ncloseDescription
TRUEnever evaluated
FALSEevaluated 24 times by 24 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_Spdy
  • tst_lancelot - unknown status
  • tst_platformsocketengine - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qiodevice - unknown status
  • tst_qobject - unknown status
  • tst_qprocess - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qtextstream - unknown status
0-24
124 local_res_ninit = 0;
never executed: local_res_ninit = 0;
0
125 }
executed 24 times by 24 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_Spdy
  • tst_lancelot - unknown status
  • tst_platformsocketengine - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qiodevice - unknown status
  • tst_qobject - unknown status
  • tst_qprocess - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qtextstream - unknown status
24
126#endif-
127-
128 return true;
executed 24 times by 24 tests: return true;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_Spdy
  • tst_lancelot - unknown status
  • tst_platformsocketengine - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qiodevice - unknown status
  • tst_qobject - unknown status
  • tst_qprocess - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qtextstream - unknown status
24
129}-
130Q_GLOBAL_STATIC_WITH_ARGS(bool, resolveLibrary, (resolveLibraryInternal()))
executed 24 times by 24 tests: end of block
Executed by:
  • tst_lancelot - unknown status
  • tst_networkselftest - unknown status
  • tst_platformsocketengine - unknown status
  • tst_qabstractnetworkcache - unknown status
  • tst_qftp - unknown status
  • tst_qhostinfo - unknown status
  • tst_qhttpnetworkconnection - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qiodevice - unknown status
  • tst_qnetworkaccessmanager_and_qprogressdialog - unknown status
  • tst_qnetworkdiskcache - unknown status
  • tst_qnetworkinterface - unknown status
  • tst_qnetworkproxyfactory - unknown status
  • tst_qobject - unknown status
  • tst_qprocess - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpserver - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qtextstream - unknown status
  • tst_qudpsocket - unknown status
  • tst_spdy - unknown status
executed 24 times by 24 tests: guard.store(QtGlobalStatic::Destroyed);
Executed by:
  • tst_lancelot - unknown status
  • tst_networkselftest - unknown status
  • tst_platformsocketengine - unknown status
  • tst_qabstractnetworkcache - unknown status
  • tst_qftp - unknown status
  • tst_qhostinfo - unknown status
  • tst_qhttpnetworkconnection - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qiodevice - unknown status
  • tst_qnetworkaccessmanager_and_qprogressdialog - unknown status
  • tst_qnetworkdiskcache - unknown status
  • tst_qnetworkinterface - unknown status
  • tst_qnetworkproxyfactory - unknown status
  • tst_qobject - unknown status
  • tst_qprocess - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpserver - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qtextstream - unknown status
  • tst_qudpsocket - unknown status
  • tst_spdy - unknown status
executed 2446 times by 25 tests: return &holder.value;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_Spdy
  • tst_lancelot - unknown status
  • tst_platformsocketengine - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qiodevice - unknown status
  • tst_qobject - unknown status
  • tst_qprocess - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qtextstream - unknown status
guard.load() =...c::InitializedDescription
TRUEevaluated 24 times by 24 tests
Evaluated by:
  • tst_lancelot - unknown status
  • tst_networkselftest - unknown status
  • tst_platformsocketengine - unknown status
  • tst_qabstractnetworkcache - unknown status
  • tst_qftp - unknown status
  • tst_qhostinfo - unknown status
  • tst_qhttpnetworkconnection - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qiodevice - unknown status
  • tst_qnetworkaccessmanager_and_qprogressdialog - unknown status
  • tst_qnetworkdiskcache - unknown status
  • tst_qnetworkinterface - unknown status
  • tst_qnetworkproxyfactory - unknown status
  • tst_qobject - unknown status
  • tst_qprocess - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpserver - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qtextstream - unknown status
  • tst_qudpsocket - unknown status
  • tst_spdy - unknown status
FALSEnever evaluated
0-2446
131-
132QHostInfo QHostInfoAgent::fromName(const QString &hostName)-
133{-
134 QHostInfo results;-
135-
136#if defined(QHOSTINFO_DEBUG)-
137 qDebug("QHostInfoAgent::fromName(%s) looking up...",-
138 hostName.toLatin1().constData());-
139#endif-
140-
141 // Load res_init on demand.-
142 resolveLibrary();-
143-
144 // If res_init is available, poll it.-
145 if (local_res_init)
local_res_initDescription
TRUEevaluated 2444 times by 25 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_Spdy
  • tst_lancelot - unknown status
  • tst_platformsocketengine - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qiodevice - unknown status
  • tst_qobject - unknown status
  • tst_qprocess - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qtextstream - unknown status
FALSEnever evaluated
0-2444
146 local_res_init();
executed 2444 times by 25 tests: local_res_init();
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_Spdy
  • tst_lancelot - unknown status
  • tst_platformsocketengine - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qiodevice - unknown status
  • tst_qobject - unknown status
  • tst_qprocess - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qtextstream - unknown status
2444
147-
148 QHostAddress address;-
149 if (address.setAddress(hostName)) {
address.setAddress(hostName)Description
TRUEevaluated 33 times by 1 test
Evaluated by:
  • tst_QHostInfo
FALSEevaluated 2411 times by 25 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_Spdy
  • tst_lancelot - unknown status
  • tst_platformsocketengine - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qiodevice - unknown status
  • tst_qobject - unknown status
  • tst_qprocess - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qtextstream - unknown status
33-2411
150 // Reverse lookup-
151// Reverse lookups using getnameinfo are broken on darwin, use gethostbyaddr instead.-
152#if !defined (QT_NO_GETADDRINFO) && !defined (Q_OS_DARWIN)-
153 sockaddr_in sa4;-
154 sockaddr_in6 sa6;-
155 sockaddr *sa = 0;-
156 QT_SOCKLEN_T saSize = 0;-
157 if (address.protocol() == QAbstractSocket::IPv4Protocol) {
address.protoc...::IPv4ProtocolDescription
TRUEevaluated 25 times by 1 test
Evaluated by:
  • tst_QHostInfo
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_QHostInfo
8-25
158 sa = (sockaddr *)&sa4;-
159 saSize = sizeof(sa4);-
160 memset(&sa4, 0, sizeof(sa4));-
161 sa4.sin_family = AF_INET;-
162 sa4.sin_addr.s_addr = htonl(address.toIPv4Address());-
163 }
executed 25 times by 1 test: end of block
Executed by:
  • tst_QHostInfo
25
164 else {-
165 sa = (sockaddr *)&sa6;-
166 saSize = sizeof(sa6);-
167 memset(&sa6, 0, sizeof(sa6));-
168 sa6.sin6_family = AF_INET6;-
169 memcpy(sa6.sin6_addr.s6_addr, address.toIPv6Address().c, sizeof(sa6.sin6_addr.s6_addr));-
170 }
executed 8 times by 1 test: end of block
Executed by:
  • tst_QHostInfo
8
171-
172 char hbuf[NI_MAXHOST];-
173 if (sa && getnameinfo(sa, saSize, hbuf, sizeof(hbuf), 0, 0, 0) == 0)
saDescription
TRUEevaluated 33 times by 1 test
Evaluated by:
  • tst_QHostInfo
FALSEnever evaluated
getnameinfo(sa... 0, 0, 0) == 0Description
TRUEevaluated 33 times by 1 test
Evaluated by:
  • tst_QHostInfo
FALSEnever evaluated
0-33
174 results.setHostName(QString::fromLatin1(hbuf));
executed 33 times by 1 test: results.setHostName(QString::fromLatin1(hbuf));
Executed by:
  • tst_QHostInfo
33
175#else-
176 in_addr_t inetaddr = qt_safe_inet_addr(hostName.toLatin1().constData());-
177 struct hostent *ent = gethostbyaddr((const char *)&inetaddr, sizeof(inetaddr), AF_INET);-
178 if (ent)-
179 results.setHostName(QString::fromLatin1(ent->h_name));-
180#endif-
181-
182 if (results.hostName().isEmpty())
results.hostName().isEmpty()Description
TRUEnever evaluated
FALSEevaluated 33 times by 1 test
Evaluated by:
  • tst_QHostInfo
0-33
183 results.setHostName(address.toString());
never executed: results.setHostName(address.toString());
0
184 results.setAddresses(QList<QHostAddress>() << address);-
185 return results;
executed 33 times by 1 test: return results;
Executed by:
  • tst_QHostInfo
33
186 }-
187-
188 // IDN support-
189 QByteArray aceHostname = QUrl::toAce(hostName);-
190 results.setHostName(hostName);-
191 if (aceHostname.isEmpty()) {
aceHostname.isEmpty()Description
TRUEevaluated 28 times by 2 tests
Evaluated by:
  • tst_QHostInfo
  • tst_Spdy
FALSEevaluated 2383 times by 25 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_Spdy
  • tst_lancelot - unknown status
  • tst_platformsocketengine - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qiodevice - unknown status
  • tst_qobject - unknown status
  • tst_qprocess - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qtextstream - unknown status
28-2383
192 results.setError(QHostInfo::HostNotFound);-
193 results.setErrorString(hostName.isEmpty() ?-
194 QCoreApplication::translate("QHostInfoAgent", "No host name given") :-
195 QCoreApplication::translate("QHostInfoAgent", "Invalid hostname"));-
196 return results;
executed 28 times by 2 tests: return results;
Executed by:
  • tst_QHostInfo
  • tst_Spdy
28
197 }-
198-
199#if !defined (QT_NO_GETADDRINFO)-
200 // Call getaddrinfo, and place all IPv4 addresses at the start and-
201 // the IPv6 addresses at the end of the address list in results.-
202 addrinfo *res = 0;-
203 struct addrinfo hints;-
204 memset(&hints, 0, sizeof(hints));-
205 hints.ai_family = PF_UNSPEC;-
206#ifdef Q_ADDRCONFIG-
207 hints.ai_flags = Q_ADDRCONFIG;-
208#endif-
209-
210 int result = getaddrinfo(aceHostname.constData(), 0, &hints, &res);-
211# ifdef Q_ADDRCONFIG-
212 if (result == EAI_BADFLAGS) {
result == -1Description
TRUEnever evaluated
FALSEevaluated 2383 times by 26 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_Spdy
  • tst_lancelot - unknown status
  • tst_platformsocketengine - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qiodevice - unknown status
  • tst_qobject - unknown status
  • tst_qprocess - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qtextstream - unknown status
  • ...
0-2383
213 // if the lookup failed with AI_ADDRCONFIG set, try again without it-
214 hints.ai_flags = 0;-
215 result = getaddrinfo(aceHostname.constData(), 0, &hints, &res);-
216 }
never executed: end of block
0
217# endif-
218-
219 if (result == 0) {
result == 0Description
TRUEevaluated 2235 times by 23 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_Spdy
  • tst_platformsocketengine - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qiodevice - unknown status
  • tst_qobject - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qtextstream - unknown status
FALSEevaluated 148 times by 13 tests
Evaluated by:
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_QTcpServer
  • tst_Spdy
  • tst_lancelot - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qprocess - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qudpsocket - unknown status
148-2235
220 addrinfo *node = res;-
221 QList<QHostAddress> addresses;-
222 while (node) {
nodeDescription
TRUEevaluated 7227 times by 23 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_Spdy
  • tst_platformsocketengine - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qiodevice - unknown status
  • tst_qobject - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qtextstream - unknown status
FALSEevaluated 2235 times by 23 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_Spdy
  • tst_platformsocketengine - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qiodevice - unknown status
  • tst_qobject - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qtextstream - unknown status
2235-7227
223#ifdef QHOSTINFO_DEBUG-
224 qDebug() << "getaddrinfo node: flags:" << node->ai_flags << "family:" << node->ai_family << "ai_socktype:" << node->ai_socktype << "ai_protocol:" << node->ai_protocol << "ai_addrlen:" << node->ai_addrlen;-
225#endif-
226 if (node->ai_family == AF_INET) {
node->ai_family == 2Description
TRUEevaluated 6831 times by 23 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_Spdy
  • tst_platformsocketengine - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qiodevice - unknown status
  • tst_qobject - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qtextstream - unknown status
FALSEevaluated 396 times by 11 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QFtp
  • tst_QHostInfo
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_qobject - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
396-6831
227 QHostAddress addr;-
228 addr.setAddress(ntohl(((sockaddr_in *) node->ai_addr)->sin_addr.s_addr));-
229 if (!addresses.contains(addr))
!addresses.contains(addr)Description
TRUEevaluated 2277 times by 23 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_Spdy
  • tst_platformsocketengine - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qiodevice - unknown status
  • tst_qobject - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qtextstream - unknown status
FALSEevaluated 4554 times by 23 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_Spdy
  • tst_platformsocketengine - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qiodevice - unknown status
  • tst_qobject - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qtextstream - unknown status
2277-4554
230 addresses.append(addr);
executed 2277 times by 23 tests: addresses.append(addr);
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_Spdy
  • tst_platformsocketengine - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qiodevice - unknown status
  • tst_qobject - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qtextstream - unknown status
2277
231 }
executed 6831 times by 23 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_Spdy
  • tst_platformsocketengine - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qiodevice - unknown status
  • tst_qobject - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qtextstream - unknown status
6831
232 else if (node->ai_family == AF_INET6) {
node->ai_family == 10Description
TRUEevaluated 396 times by 11 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QFtp
  • tst_QHostInfo
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_qobject - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
FALSEnever evaluated
0-396
233 QHostAddress addr;-
234 sockaddr_in6 *sa6 = (sockaddr_in6 *) node->ai_addr;-
235 addr.setAddress(sa6->sin6_addr.s6_addr);-
236 if (sa6->sin6_scope_id)
sa6->sin6_scope_idDescription
TRUEnever evaluated
FALSEevaluated 396 times by 11 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QFtp
  • tst_QHostInfo
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_qobject - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
0-396
237 addr.setScopeId(QString::number(sa6->sin6_scope_id));
never executed: addr.setScopeId(QString::number(sa6->sin6_scope_id));
0
238 if (!addresses.contains(addr))
!addresses.contains(addr)Description
TRUEevaluated 132 times by 11 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QFtp
  • tst_QHostInfo
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_qobject - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
FALSEevaluated 264 times by 11 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QFtp
  • tst_QHostInfo
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_qobject - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
132-264
239 addresses.append(addr);
executed 132 times by 11 tests: addresses.append(addr);
Executed by:
  • tst_NetworkSelfTest
  • tst_QFtp
  • tst_QHostInfo
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_qobject - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
132
240 }
executed 396 times by 11 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QFtp
  • tst_QHostInfo
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_qobject - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
396
241 node = node->ai_next;-
242 }
executed 7227 times by 23 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_Spdy
  • tst_platformsocketengine - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qiodevice - unknown status
  • tst_qobject - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qtextstream - unknown status
7227
243 if (addresses.isEmpty() && node == 0) {
addresses.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 2235 times by 23 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_Spdy
  • tst_platformsocketengine - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qiodevice - unknown status
  • tst_qobject - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qtextstream - unknown status
node == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-2235
244 // Reached the end of the list, but no addresses were found; this-
245 // means the list contains one or more unknown address types.-
246 results.setError(QHostInfo::UnknownError);-
247 results.setErrorString(tr("Unknown address type"));-
248 }
never executed: end of block
0
249-
250 results.setAddresses(addresses);-
251 freeaddrinfo(res);-
252 } else if (result == EAI_NONAME
executed 2235 times by 23 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_Spdy
  • tst_platformsocketengine - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qiodevice - unknown status
  • tst_qobject - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qtextstream - unknown status
result == -2Description
TRUEevaluated 140 times by 9 tests
Evaluated by:
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_QTcpServer
  • tst_Spdy
  • tst_lancelot - unknown status
  • tst_qprocess - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qudpsocket - unknown status
FALSEevaluated 8 times by 4 tests
Evaluated by:
  • tst_QFtp
  • tst_qhttpsocketengine - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
8-2235
253 || result == EAI_FAIL
result == -4Description
TRUEnever evaluated
FALSEevaluated 8 times by 4 tests
Evaluated by:
  • tst_QFtp
  • tst_qhttpsocketengine - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
0-8
254#ifdef EAI_NODATA-
255 // EAI_NODATA is deprecated in RFC 3493-
256 || result == EAI_NODATA
result == -5Description
TRUEevaluated 8 times by 4 tests
Evaluated by:
  • tst_QFtp
  • tst_qhttpsocketengine - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
FALSEnever evaluated
0-8
257#endif-
258 ) {-
259 results.setError(QHostInfo::HostNotFound);-
260 results.setErrorString(tr("Host not found"));-
261 } else {
executed 148 times by 13 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkReply
  • tst_QTcpServer
  • tst_Spdy
  • tst_lancelot - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qprocess - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qudpsocket - unknown status
148
262 results.setError(QHostInfo::UnknownError);-
263 results.setErrorString(QString::fromLocal8Bit(gai_strerror(result)));-
264 }
never executed: end of block
0
265-
266#else-
267 // Fall back to gethostbyname for platforms that don't define-
268 // getaddrinfo. gethostbyname does not support IPv6, and it's not-
269 // reentrant on all platforms. For now this is okay since we only-
270 // use one QHostInfoAgent, but if more agents are introduced, locking-
271 // must be provided.-
272 QMutexLocker locker(&getHostByNameMutex);-
273 hostent *result = gethostbyname(aceHostname.constData());-
274 if (result) {-
275 if (result->h_addrtype == AF_INET) {-
276 QList<QHostAddress> addresses;-
277 for (char **p = result->h_addr_list; *p != 0; p++) {-
278 QHostAddress addr;-
279 addr.setAddress(ntohl(*((quint32 *)*p)));-
280 if (!addresses.contains(addr))-
281 addresses.prepend(addr);-
282 }-
283 results.setAddresses(addresses);-
284 } else {-
285 results.setError(QHostInfo::UnknownError);-
286 results.setErrorString(tr("Unknown address type"));-
287 }-
288#if !defined(Q_OS_VXWORKS)-
289 } else if (h_errno == HOST_NOT_FOUND || h_errno == NO_DATA-
290 || h_errno == NO_ADDRESS) {-
291 results.setError(QHostInfo::HostNotFound);-
292 results.setErrorString(tr("Host not found"));-
293#endif-
294 } else {-
295 results.setError(QHostInfo::UnknownError);-
296 results.setErrorString(tr("Unknown error"));-
297 }-
298#endif // !defined (QT_NO_GETADDRINFO)-
299-
300#if defined(QHOSTINFO_DEBUG)-
301 if (results.error() != QHostInfo::NoError) {-
302 qDebug("QHostInfoAgent::fromName(): error #%d %s",-
303 h_errno, results.errorString().toLatin1().constData());-
304 } else {-
305 QString tmp;-
306 QList<QHostAddress> addresses = results.addresses();-
307 for (int i = 0; i < addresses.count(); ++i) {-
308 if (i != 0) tmp += ", ";-
309 tmp += addresses.at(i).toString();-
310 }-
311 qDebug("QHostInfoAgent::fromName(): found %i entries for \"%s\": {%s}",-
312 addresses.count(), hostName.toLatin1().constData(),-
313 tmp.toLatin1().constData());-
314 }-
315#endif-
316 return results;
executed 2383 times by 26 tests: return results;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_Spdy
  • tst_lancelot - unknown status
  • tst_platformsocketengine - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qiodevice - unknown status
  • tst_qobject - unknown status
  • tst_qprocess - unknown status
  • tst_qsocks5socketengine - unknown status
  • tst_qsslsocket - unknown status
  • tst_qsslsocket_onDemandCertificates_member - unknown status
  • tst_qsslsocket_onDemandCertificates_static - unknown status
  • tst_qtcpsocket - unknown status
  • tst_qtextstream - unknown status
  • ...
2383
317}-
318-
319QString QHostInfo::localDomainName()-
320{-
321#if !defined(Q_OS_VXWORKS) && !defined(Q_OS_ANDROID)-
322 resolveLibrary();-
323 if (local_res_ninit) {
local_res_ninitDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QHostInfo
FALSEnever evaluated
0-2
324 // using thread-safe version-
325 res_state_ptr state = res_state_ptr(malloc(sizeof(*state)));-
326 Q_CHECK_PTR(state);
never executed: qt_check_pointer(__FILE__,326);
!(state)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QHostInfo
0-2
327 memset(state, 0, sizeof(*state));-
328 local_res_ninit(state);-
329 QString domainName = QUrl::fromAce(state->defdname);-
330 if (domainName.isEmpty())
domainName.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QHostInfo
0-2
331 domainName = QUrl::fromAce(state->dnsrch[0]);
never executed: domainName = QUrl::fromAce(state->dnsrch[0]);
0
332 local_res_nclose(state);-
333 free(state);-
334-
335 return domainName;
executed 2 times by 1 test: return domainName;
Executed by:
  • tst_QHostInfo
2
336 }-
337-
338 if (local_res_init && local_res) {
local_res_initDescription
TRUEnever evaluated
FALSEnever evaluated
local_resDescription
TRUEnever evaluated
FALSEnever evaluated
0
339 // using thread-unsafe version-
340-
341#if defined(QT_NO_GETADDRINFO)-
342 // We have to call res_init to be sure that _res was initialized-
343 // So, for systems without getaddrinfo (which is thread-safe), we lock the mutex too-
344 QMutexLocker locker(&getHostByNameMutex);-
345#endif-
346 local_res_init();-
347 QString domainName = QUrl::fromAce(local_res->defdname);-
348 if (domainName.isEmpty())
domainName.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
349 domainName = QUrl::fromAce(local_res->dnsrch[0]);
never executed: domainName = QUrl::fromAce(local_res->dnsrch[0]);
0
350 return domainName;
never executed: return domainName;
0
351 }-
352#endif-
353 // nothing worked, try doing it by ourselves:-
354 QFile resolvconf;-
355#if defined(_PATH_RESCONF)-
356 resolvconf.setFileName(QFile::decodeName(_PATH_RESCONF));-
357#else-
358 resolvconf.setFileName(QLatin1String("/etc/resolv.conf"));-
359#endif-
360 if (!resolvconf.open(QIODevice::ReadOnly))
!resolvconf.op...ice::ReadOnly)Description
TRUEnever evaluated
FALSEnever evaluated
0
361 return QString(); // failure
never executed: return QString();
0
362-
363 QString domainName;-
364 while (!resolvconf.atEnd()) {
!resolvconf.atEnd()Description
TRUEnever evaluated
FALSEnever evaluated
0
365 QByteArray line = resolvconf.readLine().trimmed();-
366 if (line.startsWith("domain "))
line.startsWith("domain ")Description
TRUEnever evaluated
FALSEnever evaluated
0
367 return QUrl::fromAce(line.mid(sizeof "domain " - 1).trimmed());
never executed: return QUrl::fromAce(line.mid(sizeof "domain " - 1).trimmed());
0
368-
369 // in case there's no "domain" line, fall back to the first "search" entry-
370 if (domainName.isEmpty() && line.startsWith("search ")) {
domainName.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
line.startsWith("search ")Description
TRUEnever evaluated
FALSEnever evaluated
0
371 QByteArray searchDomain = line.mid(sizeof "search " - 1).trimmed();-
372 int pos = searchDomain.indexOf(' ');-
373 if (pos != -1)
pos != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
374 searchDomain.truncate(pos);
never executed: searchDomain.truncate(pos);
0
375 domainName = QUrl::fromAce(searchDomain);-
376 }
never executed: end of block
0
377 }
never executed: end of block
0
378-
379 // return the fallen-back-to searched domain-
380 return domainName;
never executed: return domainName;
0
381}-
382-
383QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9