Fixed qdir unittest to handle being run as root

- Added checks to see if running as root and skip as needed

Change-Id: I4f94d5bfe511c6dfda315854b7cd1f64efe6e4f4
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
This commit is contained in:
Kurt Korbatits 2012-02-09 11:15:32 +10:00 committed by Qt by Nokia
parent 7f403f368e
commit 951c0b7afa

View File

@ -385,6 +385,10 @@ void tst_QDir::removeRecursively()
void tst_QDir::removeRecursivelyFailure()
{
#ifdef Q_OS_UNIX
if (::getuid() == 0)
QSKIP("Running this test as root doesn't make sense");
#endif
const QString tmpdir = QDir::currentPath() + "/tmpdir/";
const QString path = tmpdir + "undeletable";
QDir().mkpath(path);
@ -1932,6 +1936,10 @@ void tst_QDir::isRelative()
void tst_QDir::isReadable()
{
#ifdef Q_OS_UNIX
if (::getuid() == 0)
QSKIP("Running this test as root doesn't make sense");
#endif
QDir dir;
QVERIFY(dir.isReadable());
@ -1961,7 +1969,10 @@ void tst_QDir::cdBelowRoot()
QCOMPARE(root.path(), ROOT);
QVERIFY(root.cd(CD_INTO));
QCOMPARE(root.path(), DIR);
#ifdef Q_OS_UNIX
if (::getuid() == 0)
QSKIP("Running this test as root doesn't make sense");
#endif
QDir dir(DIR);
QVERIFY(!dir.cd("../.."));
QCOMPARE(dir.path(), DIR);