summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-04-06 01:00:07 +0200
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-04-06 01:00:08 +0200
commitce7f14d2e0791acc92622fdc23886a06d6712e90 (patch)
tree5f2b0f0a6c4a37dfaa1f31abf7e58d8a3cec1e3c /tests
parent0998a9d1d53361e572d7377af8cb41a49bbfad72 (diff)
parentf4c41b9797f08f173049502fa7bd465cf5bde938 (diff)
Merge remote-tracking branch 'origin/5.12' into 5.13
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/network/kernel/qhostinfo/BLACKLIST2
-rw-r--r--tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp68
-rw-r--r--tests/manual/dialogs/filedialogpanel.cpp9
3 files changed, 74 insertions, 5 deletions
diff --git a/tests/auto/network/kernel/qhostinfo/BLACKLIST b/tests/auto/network/kernel/qhostinfo/BLACKLIST
index cd4d4eb03c..87c5fe991f 100644
--- a/tests/auto/network/kernel/qhostinfo/BLACKLIST
+++ b/tests/auto/network/kernel/qhostinfo/BLACKLIST
@@ -4,5 +4,3 @@
windows ci
[blockingLookup:a-plus-aaaa]
windows ci
-[reverseLookup:google-public-dns-a.google.com]
-ci
diff --git a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp
index 82825f608c..0a130d363e 100644
--- a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp
+++ b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp
@@ -396,6 +396,68 @@ void tst_QHostInfo::lookupConnectToLambda()
QCOMPARE(tmp.join(' '), expected.join(' '));
}
+static QStringList reverseLookupHelper(const QString &ip)
+{
+ QStringList results;
+
+ const QString pythonCode =
+ "import socket;"
+ "import sys;"
+ "print (socket.getnameinfo((sys.argv[1], 0), 0)[0]);";
+
+ QList<QByteArray> lines;
+ QProcess python;
+ python.setProcessChannelMode(QProcess::ForwardedErrorChannel);
+ python.start("python", QStringList() << QString("-c") << pythonCode << ip);
+ if (python.waitForFinished()) {
+ if (python.exitStatus() == QProcess::NormalExit && python.exitCode() == 0)
+ lines = python.readAllStandardOutput().split('\n');
+ for (QByteArray line : lines) {
+ if (!line.isEmpty())
+ results << line.trimmed();
+ }
+ if (!results.isEmpty())
+ return results;
+ }
+
+ qDebug() << "Python failed, falling back to nslookup";
+ QProcess lookup;
+ lookup.setProcessChannelMode(QProcess::ForwardedErrorChannel);
+ lookup.start("nslookup", QStringList(ip));
+ if (!lookup.waitForFinished()) {
+ results << "nslookup failure";
+ qDebug() << "nslookup failure";
+ return results;
+ }
+ lines = lookup.readAllStandardOutput().split('\n');
+
+ QByteArray name;
+
+ const QByteArray nameMarkerNix("name =");
+ const QByteArray nameMarkerWin("Name:");
+ const QByteArray addressMarkerWin("Address:");
+
+ for (QByteArray line : lines) {
+ int index = -1;
+ if ((index = line.indexOf(nameMarkerNix)) != -1) { // Linux and macOS
+ name = line.mid(index + nameMarkerNix.length()).chopped(1).trimmed();
+ results << name;
+ } else if (line.startsWith(nameMarkerWin)) { // Windows formatting
+ name = line.mid(line.lastIndexOf(" ")).trimmed();
+ } else if (line.startsWith(addressMarkerWin)) {
+ QByteArray address = line.mid(addressMarkerWin.length()).trimmed();
+ if (address == ip) {
+ results << name;
+ }
+ }
+ }
+
+ if (results.isEmpty()) {
+ qDebug() << "Failure to parse nslookup output: " << lines;
+ }
+ return results;
+}
+
void tst_QHostInfo::reverseLookup_data()
{
QTest::addColumn<QString>("address");
@@ -403,8 +465,8 @@ void tst_QHostInfo::reverseLookup_data()
QTest::addColumn<int>("err");
QTest::addColumn<bool>("ipv6");
- QTest::newRow("google-public-dns-a.google.com") << QString("8.8.8.8") << QStringList(QString("google-public-dns-a.google.com")) << 0 << false;
- QTest::newRow("gitorious.org") << QString("87.238.52.168") << QStringList(QString("gitorious.org")) << 0 << false;
+ QTest::newRow("dns.google") << QString("8.8.8.8") << reverseLookupHelper("8.8.8.8") << 0 << false;
+ QTest::newRow("one.one.one.one") << QString("1.1.1.1") << reverseLookupHelper("1.1.1.1") << 0 << false;
QTest::newRow("bogus-name") << QString("1::2::3::4") << QStringList() << 1 << true;
}
@@ -422,6 +484,8 @@ void tst_QHostInfo::reverseLookup()
QHostInfo info = QHostInfo::fromName(address);
if (err == 0) {
+ if (!hostNames.contains(info.hostName()))
+ qDebug() << "Failure: expecting" << hostNames << ",got " << info.hostName();
QVERIFY(hostNames.contains(info.hostName()));
QCOMPARE(info.addresses().first(), QHostAddress(address));
} else {
diff --git a/tests/manual/dialogs/filedialogpanel.cpp b/tests/manual/dialogs/filedialogpanel.cpp
index 800baae45e..25c1e44b8c 100644
--- a/tests/manual/dialogs/filedialogpanel.cpp
+++ b/tests/manual/dialogs/filedialogpanel.cpp
@@ -505,8 +505,15 @@ void FileDialogPanel::accepted()
Q_ASSERT(d);
m_result.clear();
QDebug(&m_result).nospace()
+#if QT_VERSION >= 0x050000
+ << "URLs: " << d->selectedUrls() << '\n'
+#endif
<< "Files: " << d->selectedFiles()
- << "\nDirectory: " << d->directory().absolutePath()
+ << "\nDirectory: "
+#if QT_VERSION >= 0x050000
+ << d->directoryUrl() << ", "
+#endif
+ << d->directory().absolutePath()
<< "\nName filter: " << d->selectedNameFilter();
QTimer::singleShot(0, this, SLOT(showAcceptedResult())); // Avoid problems with the closing (modal) dialog as parent.
}