summaryrefslogtreecommitdiffstats
path: root/tests/auto/network
diff options
context:
space:
mode:
authorSami Nurmenniemi <sami.nurmenniemi@qt.io>2017-04-18 13:29:04 +0300
committerSami Nurmenniemi <sami.nurmenniemi@qt.io>2017-04-26 09:12:12 +0000
commita1e94bcfbb7b2814340f481b632ebab224eddda5 (patch)
tree358f911f69ced345d274f315399d124f6d3aeb79 /tests/auto/network
parent9b52cfd64c089901b2e3fa0a19d6f342adad6025 (diff)
Fix tests that assume system files are owned by root for qemu
If QEMU is provided sysroot with QEMU_LD_PREFIX, it opens files from there. If their owner is the current user, testing their access rights based on assumption that they are root fails. Skip the tests in that case similarly as is already done when the tests are run as root. This fixes following tests: - tst_QTemporaryDir::nonWritableCurrentDir - tst_QNetworkReply::getErrors(file-permissions) - tst_qstandardpaths::testCustomRuntimeDirectory Task-number: QTBUG-59966 Change-Id: I972ce37b4b5a7747cdd732a8e4a737ef09cbc6a5 Reviewed-by: Teemu Holappa <teemu.holappa@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/network')
-rw-r--r--tests/auto/network/access/qnetworkreply/test/test.pro2
-rw-r--r--tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp20
2 files changed, 20 insertions, 2 deletions
diff --git a/tests/auto/network/access/qnetworkreply/test/test.pro b/tests/auto/network/access/qnetworkreply/test/test.pro
index 8aeec88fd2..0dcf5a250c 100644
--- a/tests/auto/network/access/qnetworkreply/test/test.pro
+++ b/tests/auto/network/access/qnetworkreply/test/test.pro
@@ -1,6 +1,8 @@
CONFIG += testcase
testcase.timeout = 600 # this test is slow
CONFIG -= debug_and_release_target
+INCLUDEPATH += ../../../../../shared/
+HEADERS += ../../../../../shared/emulationdetector.h
SOURCES += ../tst_qnetworkreply.cpp
TARGET = ../tst_qnetworkreply
diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
index fbd8f5a780..855b1f9041 100644
--- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -96,6 +96,8 @@ Q_DECLARE_METATYPE(QAuthenticator*)
Q_DECLARE_METATYPE(QNetworkProxyQuery)
#endif
+#include "emulationdetector.h"
+
typedef QSharedPointer<QNetworkReply> QNetworkReplyPtr;
class MyCookieJar;
@@ -135,6 +137,7 @@ class tst_QNetworkReply: public QObject
}
static const QByteArray httpEmpty200Response;
+ static const QString filePermissionFileName;
QEventLoop *loop;
enum RunSimpleRequestReturn { Timeout = 0, Success, Failure };
@@ -499,6 +502,8 @@ private:
const QByteArray tst_QNetworkReply::httpEmpty200Response =
"HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n";
+const QString tst_QNetworkReply::filePermissionFileName = "/etc/shadow";
+
bool tst_QNetworkReply::seedCreated = false;
#define RUN_REQUEST(call) \
@@ -1915,8 +1920,10 @@ void tst_QNetworkReply::getErrors_data()
QTest::newRow("file-is-wronly") << QUrl::fromLocalFile(wronlyFileName).toString()
<< int(QNetworkReply::ContentAccessDenied) << 0 << true;
#endif
- if (QFile::exists("/etc/shadow"))
- QTest::newRow("file-permissions") << "file:/etc/shadow"
+
+
+ if (QFile::exists(filePermissionFileName))
+ QTest::newRow("file-permissions") << "file:" + filePermissionFileName
<< int(QNetworkReply::ContentAccessDenied) << 0 << true;
// ftp: errors
@@ -1952,6 +1959,15 @@ void tst_QNetworkReply::getErrors()
(qstrcmp(QTest::currentDataTag(), "file-permissions") == 0)) {
if (::getuid() == 0)
QSKIP("Running this test as root doesn't make sense");
+
+ }
+
+ if (EmulationDetector::isRunningArmOnX86()
+ && qstrcmp(QTest::currentDataTag(), "file-permissions") == 0) {
+ QFileInfo filePermissionFile = QFileInfo(filePermissionFileName.toLatin1());
+ if (filePermissionFile.ownerId() == ::geteuid()) {
+ QSKIP("Sysroot directories are owned by the current user");
+ }
}
#endif