summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-05-07 13:07:34 +0200
committerLiang Qi <liang.qi@qt.io>2017-05-07 13:08:18 +0200
commitd1ea4813458b383e66ce4df69d1833b8b6a279c4 (patch)
tree3bdc16da993e5de56b669e6774fb0748075ddd90 /tests/auto/corelib/io
parent1c87d4e1a1d0e1972f6dc85e55ea9be8a42797ba (diff)
parent0b1ec78c2d4871afcc89d5b046926b88f0819a7c (diff)
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts: src/network/access/qnetworkreply.cpp tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp Change-Id: Iadf766269454087e69fb216fc3857d85b0ddfaad
Diffstat (limited to 'tests/auto/corelib/io')
-rw-r--r--tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp26
-rw-r--r--tests/auto/corelib/io/qstandardpaths/qstandardpaths.pro2
-rw-r--r--tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp16
-rw-r--r--tests/auto/corelib/io/qtemporarydir/qtemporarydir.pro2
-rw-r--r--tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp8
-rw-r--r--tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp33
6 files changed, 70 insertions, 17 deletions
diff --git a/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp b/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp
index 0a74dc64c0..1643eed3d2 100644
--- a/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp
+++ b/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp
@@ -202,18 +202,15 @@ private slots:
QLoggingRegistry registry;
registry.init();
- QCOMPARE(registry.apiRules.size(), 0);
- QCOMPARE(registry.configRules.size(), 0);
- QCOMPARE(registry.envRules.size(), 1);
-
- QCOMPARE(registry.rules.size(), 1);
+ QCOMPARE(registry.ruleSets[QLoggingRegistry::ApiRules].size(), 0);
+ QCOMPARE(registry.ruleSets[QLoggingRegistry::ConfigRules].size(), 0);
+ QCOMPARE(registry.ruleSets[QLoggingRegistry::EnvironmentRules].size(), 1);
// check that QT_LOGGING_RULES take precedence
qputenv("QT_LOGGING_RULES", "Digia.*=true");
registry.init();
- QCOMPARE(registry.envRules.size(), 2);
- QCOMPARE(registry.envRules.at(1).enabled, true);
- QCOMPARE(registry.rules.size(), 2);
+ QCOMPARE(registry.ruleSets[QLoggingRegistry::EnvironmentRules].size(), 2);
+ QCOMPARE(registry.ruleSets[QLoggingRegistry::EnvironmentRules].at(1).enabled, true);
}
void QLoggingRegistry_config()
@@ -238,7 +235,7 @@ private slots:
QLoggingRegistry registry;
registry.init();
- QCOMPARE(registry.configRules.size(), 1);
+ QCOMPARE(registry.ruleSets[QLoggingRegistry::ConfigRules].size(), 1);
// remove file again
QVERIFY(file.remove());
@@ -260,10 +257,9 @@ private slots:
QLoggingRegistry *registry = QLoggingRegistry::instance();
// empty all rules , check default
- registry->rules.clear();
- registry->apiRules.clear();
- registry->configRules.clear();
- registry->envRules.clear();
+ registry->ruleSets[QLoggingRegistry::ApiRules].clear();
+ registry->ruleSets[QLoggingRegistry::ConfigRules].clear();
+ registry->ruleSets[QLoggingRegistry::EnvironmentRules].clear();
registry->updateRules();
QVERIFY(cat.isWarningEnabled());
@@ -271,7 +267,7 @@ private slots:
// set Config rule
QLoggingSettingsParser parser;
parser.setContent("[Rules]\nDigia.*=false");
- registry->configRules=parser.rules();
+ registry->ruleSets[QLoggingRegistry::ConfigRules] = parser.rules();
registry->updateRules();
QVERIFY(!cat.isWarningEnabled());
@@ -283,7 +279,7 @@ private slots:
// set Env rule, should overwrite Config one
parser.setContent("Digia.*=false");
- registry->envRules=parser.rules();
+ registry->ruleSets[QLoggingRegistry::EnvironmentRules] = parser.rules();
registry->updateRules();
QVERIFY(!cat.isWarningEnabled());
diff --git a/tests/auto/corelib/io/qstandardpaths/qstandardpaths.pro b/tests/auto/corelib/io/qstandardpaths/qstandardpaths.pro
index c72d9e4fad..9fd7047405 100644
--- a/tests/auto/corelib/io/qstandardpaths/qstandardpaths.pro
+++ b/tests/auto/corelib/io/qstandardpaths/qstandardpaths.pro
@@ -1,5 +1,7 @@
CONFIG += testcase
TARGET = tst_qstandardpaths
QT = core testlib
+INCLUDEPATH += ../../../../shared/
+HEADERS += ../../../../shared/emulationdetector.h
SOURCES = tst_qstandardpaths.cpp
TESTDATA += tst_qstandardpaths.cpp qstandardpaths.pro
diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
index 0a00e00d83..3de777653e 100644
--- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
+++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
@@ -46,6 +46,8 @@
#define Q_XDG_PLATFORM
#endif
+#include "emulationdetector.h"
+
// Update this when adding new enum values; update enumNames too
static const int MaxStandardLocation = QStandardPaths::AppConfigLocation;
@@ -485,14 +487,24 @@ void tst_qstandardpaths::testCustomRuntimeDirectory()
EnvVarRestorer restorer;
// When $XDG_RUNTIME_DIR points to a directory with wrong ownership, QStandardPaths should warn
- qputenv("XDG_RUNTIME_DIR", QFile::encodeName("/tmp"));
+ QByteArray rootOwnedFileName = "/tmp";
+ if (EmulationDetector::isRunningArmOnX86()) {
+ // Directory "tmp" under toolchain sysroot is detected by qemu and has same uid as current user.
+ // Try /opt instead, it might not be located in the sysroot.
+ QFileInfo rootOwnedFile = QFileInfo(QString::fromLatin1(rootOwnedFileName));
+ if (rootOwnedFile.ownerId() == ::geteuid()) {
+ rootOwnedFileName = "/opt";
+ }
+ }
+ qputenv("XDG_RUNTIME_DIR", QFile::encodeName(rootOwnedFileName));
+
// It's very unlikely that /tmp is 0600 or that we can chmod it
// The call below outputs
// "QStandardPaths: wrong ownership on runtime directory /tmp, 0 instead of $UID"
// but we can't reliably expect that it's owned by uid 0, I think.
const uid_t uid = geteuid();
QTest::ignoreMessage(QtWarningMsg,
- qPrintable(QString::fromLatin1("QStandardPaths: wrong ownership on runtime directory /tmp, 0 instead of %1").arg(uid)));
+ qPrintable(QString::fromLatin1("QStandardPaths: wrong ownership on runtime directory " + rootOwnedFileName + ", 0 instead of %1").arg(uid)));
const QString runtimeDir = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
QVERIFY2(runtimeDir.isEmpty(), qPrintable(runtimeDir));
diff --git a/tests/auto/corelib/io/qtemporarydir/qtemporarydir.pro b/tests/auto/corelib/io/qtemporarydir/qtemporarydir.pro
index 4a69971f78..351e263093 100644
--- a/tests/auto/corelib/io/qtemporarydir/qtemporarydir.pro
+++ b/tests/auto/corelib/io/qtemporarydir/qtemporarydir.pro
@@ -1,5 +1,7 @@
CONFIG += testcase
TARGET = tst_qtemporarydir
SOURCES += tst_qtemporarydir.cpp
+INCLUDEPATH += ../../../../shared/
+HEADERS += ../../../../shared/emulationdetector.h
QT = core testlib
diff --git a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
index 758bbead84..4bed8d0fd6 100644
--- a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
+++ b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
@@ -42,6 +42,7 @@
# include <sys/types.h>
# include <unistd.h>
#endif
+#include "emulationdetector.h"
class tst_QTemporaryDir : public QObject
{
@@ -316,6 +317,13 @@ void tst_QTemporaryDir::nonWritableCurrentDir()
const QFileInfo nonWritableDirFi = QFileInfo(QLatin1String(nonWritableDir));
QVERIFY(nonWritableDirFi.isDir());
+
+ if (EmulationDetector::isRunningArmOnX86()) {
+ if (nonWritableDirFi.ownerId() == ::geteuid()) {
+ QSKIP("Sysroot directories are owned by the current user");
+ }
+ }
+
QVERIFY(!nonWritableDirFi.isWritable());
ChdirOnReturn cor(QDir::currentPath());
diff --git a/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp b/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp
index f5835ec5f4..bcf6d6c32b 100644
--- a/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp
+++ b/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp
@@ -650,6 +650,31 @@ void tst_QUrlInternal::ace_testsuite_data()
<< "xn--djrptm67aikb.xn--kpry57d"
<< "."
<< taiwaneseIDN;
+
+ // violations / invalids
+ QTest::newRow("invalid-punycode") << "xn--z" << "xn--z" << "xn--z" << "xn--z";
+
+ // U+00A0 NO-BREAK SPACE encodes to Punycode "6a"
+ // but it is prohibited and should have caused encoding failure
+ QTest::newRow("invalid-nameprep-prohibited") << "xn--6a" << "xn--6a" << "xn--6a" << "xn--6a";
+
+ // U+00AD SOFT HYPHEN between "a" and "b" encodes to Punycode "ab-5da"
+ // but it should have been removed in the nameprep stage
+ QTest::newRow("invalid-nameprep-maptonothing") << "xn-ab-5da" << "xn-ab-5da" << "xn-ab-5da" << "xn-ab-5da";
+
+ // U+00C1 LATIN CAPITAL LETTER A WITH ACUTE encodes to Punycode "4ba"
+ // but it should have nameprepped to lowercase first
+ QTest::newRow("invalid-nameprep-uppercase") << "xn--4ba" << "xn--4ba" << "xn--4ba" << "xn--4ba";
+
+ // U+00B5 MICRO SIGN encodes to Punycode "sba"
+ // but is should have nameprepped to NFKC U+03BC GREEK SMALL LETTER MU
+ QTest::newRow("invalid-nameprep-nonnfkc") << "xn--sba" << "xn--sba" << "xn--sba" << "xn--sba";
+
+ // U+04CF CYRILLIC SMALL LETTER PALOCHKA encodes to "s5a"
+ // but it's not in RFC 3454's allowed character list (Unicode 3.2)
+ QTest::newRow("invalid-nameprep-unassigned") << "xn--s5a" << "xn--s5a" << "xn--s5a" << "xn--s5a";
+ // same character, see QTBUG-60364
+ QTest::newRow("invalid-nameprep-unassigned2") << "xn--80ak6aa92e" << "xn--80ak6aa92e" << "xn--80ak6aa92e" << "xn--80ak6aa92e";
}
void tst_QUrlInternal::ace_testsuite()
@@ -670,6 +695,14 @@ void tst_QUrlInternal::ace_testsuite()
QCOMPARE(QUrl::fromAce(domain.toLatin1()), fromace + suffix);
QCOMPARE(QUrl::fromAce(QUrl::toAce(domain)), unicode + suffix);
+ QUrl u;
+ u.setHost(domain);
+ QVERIFY(u.isValid());
+ QCOMPARE(u.host(), unicode + suffix);
+ QCOMPARE(u.host(QUrl::EncodeUnicode), toace + suffix);
+ QCOMPARE(u.toEncoded(), "//" + toace.toLatin1() + suffix);
+ QCOMPARE(u.toDisplayString(), "//" + unicode + suffix);
+
domain = in + (suffix ? ".troll.No" : "");
QCOMPARE(QString::fromLatin1(QUrl::toAce(domain)), toace + suffix);
if (fromace != ".")