From 7f403f368eac8a0ebba83a1c30e83ff0a3963acb Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Thu, 9 Feb 2012 10:36:08 +1000 Subject: [PATCH] Fixed qfile unittest rename() failing as root When run as root was able to move file to /etc directory but was expecting a failure. Change-Id: Ic2ac5506253f2a3395ed56e88a856542bf82ad6d Reviewed-by: Rohan McGovern Reviewed-by: Jason McDonald --- tests/auto/corelib/io/qfile/tst_qfile.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index 67a4f71f54..0ed1b8ed5a 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -2349,6 +2349,13 @@ void tst_QFile::rename() QFETCH(QString, destination); QFETCH(bool, result); +#if defined(Q_OS_UNIX) + if (strcmp(QTest::currentDataTag(), "renamefile -> /etc/renamefile") == 0) { + if (::getuid() == 0) + QSKIP("Running this test as root doesn't make sense"); + } +#endif + QFile::remove("renamedfile"); QFile f("renamefile"); f.open(QFile::WriteOnly);