summaryrefslogtreecommitdiffstats
path: root/tests/auto/qfile
diff options
context:
space:
mode:
authorHarald Fernengel <harald@trolltech.com>2009-07-21 11:19:49 (GMT)
committerHarald Fernengel <harald@trolltech.com>2009-07-21 11:20:03 (GMT)
commit31e358f2290c145b839fc5b7b277922c1ab6e19b (patch)
tree6569829854abd6c2011f740c3d91f6fe9e890836 /tests/auto/qfile
parent2db22b1b12cc7579d08a83ad889efe7f8f07c843 (diff)
downloadQt-31e358f2290c145b839fc5b7b277922c1ab6e19b.zip
Qt-31e358f2290c145b839fc5b7b277922c1ab6e19b.tar.gz
Qt-31e358f2290c145b839fc5b7b277922c1ab6e19b.tar.bz2
fix tests for QT_NO_PROCESS and when running tests as root
Diffstat (limited to 'tests/auto/qfile')
-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());
}