Fix QDnsLookup autotest failure in CI environment
authorShane Kearns <ext-shane.2.kearns@nokia.com>
Mon, 12 Mar 2012 18:46:21 +0000 (18:46 +0000)
committerQt by Nokia <qt-info@nokia.com>
Thu, 15 Mar 2012 17:05:05 +0000 (18:05 +0100)
The DNS server can legitimately include NS and A records for
the authoritative name server in addition to the DNS records
that were requested.
These are now ignored when checking the reply (we only check
results that match the query, rather than failing if a result
is for a different host name than the query).

Task-number: QTBUG-24698
Change-Id: I327f31d58cdca50c7df6b32b275d7f28b56405f0
Reviewed-by: Jeremy Lainé <jeremy.laine@m4x.org>
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp

index 249ccd3..c1400b8 100644 (file)
@@ -159,8 +159,9 @@ void tst_QDnsLookup::lookup()
     const QString hostName = cname.isEmpty() ? domain : cname;
     QStringList addresses;
     foreach (const QDnsHostAddressRecord &record, lookup.hostAddressRecords()) {
-        QCOMPARE(record.name(), hostName);
-        addresses << record.value().toString().toLower();
+        //reply may include A & AAAA records for nameservers, ignore them and only look at records matching the query
+        if (record.name() == hostName)
+            addresses << record.value().toString().toLower();
     }
     addresses.sort();
     QCOMPARE(addresses.join(" "), host);
@@ -176,8 +177,9 @@ void tst_QDnsLookup::lookup()
     // name servers
     QStringList nameServers;
     foreach (const QDnsDomainNameRecord &record, lookup.nameServerRecords()) {
-        QCOMPARE(record.name(), domain);
-        nameServers << record.value();
+        //reply may include NS records for authoritative nameservers, ignore them and only look at records matching the query
+        if (record.name() == domain)
+            nameServers << record.value();
     }
     nameServers.sort();
     QCOMPARE(nameServers.join(" "), ns);