summaryrefslogtreecommitdiffstats
path: root/tests/auto/qfile/tst_qfile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qfile/tst_qfile.cpp')
-rw-r--r--tests/auto/qfile/tst_qfile.cpp28
1 files changed, 20 insertions, 8 deletions
diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp
index 8d9c2be..66f29dd 100644
--- a/tests/auto/qfile/tst_qfile.cpp
+++ b/tests/auto/qfile/tst_qfile.cpp
@@ -382,6 +382,12 @@ void tst_QFile::open()
QFETCH( bool, ok );
+#ifdef Q_OS_UNIX
+ if (::getuid() == 0)
+ // root and Chuck Norris don't care for file permissions. Skip.
+ QSKIP("Running this test as root doesn't make sense", SkipAll);
+#endif
+
#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
QEXPECT_FAIL("noreadfile", "Windows does not currently support non-readable files.", Abort);
#endif
@@ -2493,14 +2499,20 @@ void tst_QFile::map()
file.close();
- // Change permissions on a file, just to confirm it would fail
- QFile::Permissions originalPermissions = file.permissions();
- QVERIFY(file.setPermissions(QFile::ReadOther));
- QVERIFY(!file.open(QFile::ReadWrite));
- memory = file.map(offset, size);
- QCOMPARE(file.error(), QFile::PermissionsError);
- QVERIFY(!memory);
- QVERIFY(file.setPermissions(originalPermissions));
+#ifdef Q_OS_UNIX
+ if (::getuid() != 0)
+ // root always has permissions
+#endif
+ {
+ // Change permissions on a file, just to confirm it would fail
+ QFile::Permissions originalPermissions = file.permissions();
+ QVERIFY(file.setPermissions(QFile::ReadOther));
+ QVERIFY(!file.open(QFile::ReadWrite));
+ memory = file.map(offset, size);
+ QCOMPARE(file.error(), QFile::PermissionsError);
+ QVERIFY(!memory);
+ QVERIFY(file.setPermissions(originalPermissions));
+ }
QVERIFY(file.remove());
}