From a1e94bcfbb7b2814340f481b632ebab224eddda5 Mon Sep 17 00:00:00 2001 From: Sami Nurmenniemi Date: Tue, 18 Apr 2017 13:29:04 +0300 Subject: 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 Reviewed-by: Thiago Macieira --- .../access/qnetworkreply/tst_qnetworkreply.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp') 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 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 -- cgit v1.2.3