From 31e358f2290c145b839fc5b7b277922c1ab6e19b Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Tue, 21 Jul 2009 13:19:49 +0200 Subject: fix tests for QT_NO_PROCESS and when running tests as root --- tests/auto/bic/tst_bic.cpp | 6 ++++- .../auto/compilerwarnings/tst_compilerwarnings.cpp | 6 ++++- tests/auto/moc/tst_moc.cpp | 20 ++++++++-------- tests/auto/qapplication/tst_qapplication.cpp | 2 ++ tests/auto/qbytearray/tst_qbytearray.cpp | 2 ++ tests/auto/qclipboard/tst_qclipboard.cpp | 2 ++ tests/auto/qcopchannel/tst_qcopchannel.cpp | 2 +- tests/auto/qdir/tst_qdir.cpp | 17 ++++++++++--- tests/auto/qdirectpainter/tst_qdirectpainter.cpp | 4 ++++ tests/auto/qfile/tst_qfile.cpp | 28 +++++++++++++++------- tests/auto/qobject/tst_qobject.cpp | 4 ++++ tests/auto/qprocess/tst_qprocess.cpp | 5 ++++ tests/auto/qsettings/tst_qsettings.cpp | 6 +++-- tests/auto/qtextcodec/tst_qtextcodec.cpp | 4 ++++ 14 files changed, 82 insertions(+), 26 deletions(-) diff --git a/tests/auto/bic/tst_bic.cpp b/tests/auto/bic/tst_bic.cpp index cec5e76..36c35ff 100644 --- a/tests/auto/bic/tst_bic.cpp +++ b/tests/auto/bic/tst_bic.cpp @@ -43,6 +43,10 @@ #include #include +#ifdef QT_NO_PROCESS +QTEST_NOOP_MAIN +#else + #include "qbic.h" #include @@ -367,4 +371,4 @@ void tst_Bic::sizesAndVTables() QTEST_APPLESS_MAIN(tst_Bic) #include "tst_bic.moc" - +#endif diff --git a/tests/auto/compilerwarnings/tst_compilerwarnings.cpp b/tests/auto/compilerwarnings/tst_compilerwarnings.cpp index 57795c9..d5fef1b 100644 --- a/tests/auto/compilerwarnings/tst_compilerwarnings.cpp +++ b/tests/auto/compilerwarnings/tst_compilerwarnings.cpp @@ -47,6 +47,10 @@ #include +#ifdef QT_NO_PROCESS +QTEST_NOOP_MAIN +#else + #include QT_USE_NAMESPACE @@ -248,4 +252,4 @@ void tst_CompilerWarnings::warnings() QTEST_APPLESS_MAIN(tst_CompilerWarnings) #include "tst_compilerwarnings.moc" - +#endif // QT_NO_PROCESS diff --git a/tests/auto/moc/tst_moc.cpp b/tests/auto/moc/tst_moc.cpp index 3a40ae0..898cfe1 100644 --- a/tests/auto/moc/tst_moc.cpp +++ b/tests/auto/moc/tst_moc.cpp @@ -510,7 +510,7 @@ private: void tst_Moc::initTestCase() { -#if defined(Q_OS_UNIX) +#if defined(Q_OS_UNIX) && !defined(QT_NO_PROCESS) QProcess proc; proc.start("qmake", QStringList() << "-query" << "QT_INSTALL_HEADERS"); QVERIFY(proc.waitForFinished()); @@ -555,7 +555,7 @@ void tst_Moc::oldStyleCasts() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled", SkipAll); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) QProcess proc; proc.start("moc", QStringList(srcify("/oldstyle-casts.h"))); QVERIFY(proc.waitForFinished()); @@ -585,7 +585,7 @@ void tst_Moc::warnOnExtraSignalSlotQualifiaction() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled", SkipAll); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) QProcess proc; proc.start("moc", QStringList(srcify("extraqualification.h"))); QVERIFY(proc.waitForFinished()); @@ -627,7 +627,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled", SkipAll); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) QProcess proc; proc.setWorkingDirectory(QString(SRCDIR) + "/task71021"); proc.start("moc", QStringList("../Header")); @@ -835,7 +835,7 @@ void tst_Moc::warnOnMultipleInheritance() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled", SkipAll); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) QProcess proc; QStringList args; args << "-I" << qtIncludePath + "/QtGui" @@ -858,7 +858,7 @@ void tst_Moc::forgottenQInterface() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled", SkipAll); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) QProcess proc; QStringList args; args << "-I" << qtIncludePath + "/QtCore" @@ -940,7 +940,7 @@ void tst_Moc::frameworkSearchPath() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled", SkipAll); #endif -#if defined(Q_OS_UNIX) +#if defined(Q_OS_UNIX) && !defined(QT_NO_PROCESS) QStringList args; args << "-F" << srcify(".") << srcify("interface-from-framework.h") @@ -978,7 +978,7 @@ void tst_Moc::templateGtGt() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled", SkipAll); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) QProcess proc; proc.start("moc", QStringList(srcify("template-gtgt.h"))); QVERIFY(proc.waitForFinished()); @@ -994,7 +994,7 @@ void tst_Moc::templateGtGt() void tst_Moc::defineMacroViaCmdline() { -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) QProcess proc; QStringList args; @@ -1082,7 +1082,7 @@ void tst_Moc::warnOnPropertyWithoutREAD() #ifdef MOC_CROSS_COMPILED QSKIP("Not tested when cross-compiled", SkipAll); #endif -#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) +#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS) QProcess proc; proc.start("moc", QStringList(srcify("warn-on-property-without-read.h"))); QVERIFY(proc.waitForFinished()); diff --git a/tests/auto/qapplication/tst_qapplication.cpp b/tests/auto/qapplication/tst_qapplication.cpp index 8532723..7cb6bfa 100644 --- a/tests/auto/qapplication/tst_qapplication.cpp +++ b/tests/auto/qapplication/tst_qapplication.cpp @@ -1382,6 +1382,7 @@ void tst_QApplication::testDeleteLaterProcessEvents() */ void tst_QApplication::desktopSettingsAware() { +#ifndef QT_NO_PROCESS QProcess testProcess; #ifdef Q_OS_WINCE int argc = 0; @@ -1399,6 +1400,7 @@ void tst_QApplication::desktopSettingsAware() QVERIFY(testProcess.waitForFinished(10000)); QCOMPARE(int(testProcess.state()), int(QProcess::NotRunning)); QVERIFY(int(testProcess.error()) != int(QProcess::Crashed)); +#endif } void tst_QApplication::setActiveWindow() diff --git a/tests/auto/qbytearray/tst_qbytearray.cpp b/tests/auto/qbytearray/tst_qbytearray.cpp index 78fbf32..b7e4717 100644 --- a/tests/auto/qbytearray/tst_qbytearray.cpp +++ b/tests/auto/qbytearray/tst_qbytearray.cpp @@ -235,6 +235,8 @@ void tst_QByteArray::qUncompress() QSKIP("Corrupt data causes this tests to lock up on HP-UX / PA-RISC with gcc", SkipAll); #elif defined Q_OS_SOLARIS QSKIP("Corrupt data causes this tests to lock up on Solaris", SkipAll); +#elif defined Q_OS_QNX + QSKIP("Currupt data cuases this test to lock up on QNX", SkipAll); #endif QTEST(::qUncompress(in), "out"); diff --git a/tests/auto/qclipboard/tst_qclipboard.cpp b/tests/auto/qclipboard/tst_qclipboard.cpp index f400754..bcdf043 100644 --- a/tests/auto/qclipboard/tst_qclipboard.cpp +++ b/tests/auto/qclipboard/tst_qclipboard.cpp @@ -192,6 +192,7 @@ void tst_QClipboard::testSignals() */ void tst_QClipboard::copy_exit_paste() { +#ifndef QT_NO_PROCESS #if defined Q_WS_X11 || defined Q_WS_QWS QSKIP("This test does not make sense on X11 and embedded, copied data disappears from the clipboard when the application exits ", SkipAll); // ### It's still possible to test copy/paste - just keep the apps running @@ -205,6 +206,7 @@ void tst_QClipboard::copy_exit_paste() QTest::qWait(100); #endif QCOMPARE(QProcess::execute("paster/paster", stringArgument), 0); +#endif } void tst_QClipboard::setMimeData() diff --git a/tests/auto/qcopchannel/tst_qcopchannel.cpp b/tests/auto/qcopchannel/tst_qcopchannel.cpp index d07898a..ce97eae 100644 --- a/tests/auto/qcopchannel/tst_qcopchannel.cpp +++ b/tests/auto/qcopchannel/tst_qcopchannel.cpp @@ -42,7 +42,7 @@ #include -#ifdef Q_WS_QWS +#if defined(Q_WS_QWS) && !defined(QT_NO_PROCESS) //TESTED_CLASS= //TESTED_FILES= diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp index 1fd5e88..e5b23ab 100644 --- a/tests/auto/qdir/tst_qdir.cpp +++ b/tests/auto/qdir/tst_qdir.cpp @@ -571,10 +571,21 @@ void tst_QDir::entryList() return; } - for (int i=0; i 100); // sanity check proc.kill(); +#endif } class MyObject : public QObject 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()); } diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp index 8ce7c3a..4f25af6 100644 --- a/tests/auto/qobject/tst_qobject.cpp +++ b/tests/auto/qobject/tst_qobject.cpp @@ -2426,11 +2426,15 @@ void tst_QObject::dynamicProperties() void tst_QObject::recursiveSignalEmission() { +#ifdef QT_NO_PROCESS + QSKIP("Test requires QProcess", SkipAll); +#else QProcess proc; proc.start("./signalbug"); QVERIFY(proc.waitForFinished()); QVERIFY(proc.exitStatus() == QProcess::NormalExit); QCOMPARE(proc.exitCode(), 0); +#endif } void tst_QObject::blockingQueuedConnection() diff --git a/tests/auto/qprocess/tst_qprocess.cpp b/tests/auto/qprocess/tst_qprocess.cpp index c19d0a5..d235dff 100644 --- a/tests/auto/qprocess/tst_qprocess.cpp +++ b/tests/auto/qprocess/tst_qprocess.cpp @@ -50,6 +50,10 @@ #include #include +#ifdef QT_NO_PROCESS +QTEST_NOOP_MAIN +#else + #if defined(Q_OS_WIN) #include #endif @@ -2132,3 +2136,4 @@ void tst_QProcess::invalidProgramString() QTEST_MAIN(tst_QProcess) #include "tst_qprocess.moc" +#endif diff --git a/tests/auto/qsettings/tst_qsettings.cpp b/tests/auto/qsettings/tst_qsettings.cpp index 77fef1f..5b9e9e1 100644 --- a/tests/auto/qsettings/tst_qsettings.cpp +++ b/tests/auto/qsettings/tst_qsettings.cpp @@ -716,6 +716,9 @@ void tst_QSettings::testErrorHandling() #ifdef QT_BUILD_INTERNAL #ifdef Q_OS_WIN QSKIP("Windows doesn't support most file modes, including read-only directories, so this test is moot.", SkipAll); +#elif defined(Q_OS_UNIX) + if (::getuid() == 0) + QSKIP("Running this test as root doesn't work, since file perms do not bother him", SkipAll); #else QFETCH(int, filePerms); QFETCH(int, dirPerms); @@ -724,8 +727,7 @@ void tst_QSettings::testErrorHandling() QFETCH(int, statusAfterGet); QFETCH(int, statusAfterSetAndSync); - - system(QString("chmod 700 %1 2>/dev/null").arg(settingsPath("someDir")).toLatin1()); + system(QString("chmod 700 %1 2>/dev/null").arg(settingsPath("someDir")).toLatin1()); system(QString("chmod -R u+rwx %1 2>/dev/null").arg(settingsPath("someDir")).toLatin1()); system(QString("rm -fr %1").arg(settingsPath("someDir")).toLatin1()); diff --git a/tests/auto/qtextcodec/tst_qtextcodec.cpp b/tests/auto/qtextcodec/tst_qtextcodec.cpp index f2da1ec..9f51805 100644 --- a/tests/auto/qtextcodec/tst_qtextcodec.cpp +++ b/tests/auto/qtextcodec/tst_qtextcodec.cpp @@ -1875,6 +1875,9 @@ void tst_QTextCodec::codecForUtfText() #ifdef Q_OS_UNIX void tst_QTextCodec::toLocal8Bit() { +#ifdef QT_NO_PROCESS + QSKIP("This test requires QProcess", SkipAll); +#else QProcess process; process.start("echo/echo"); QString string(QChar(0x410)); @@ -1884,6 +1887,7 @@ void tst_QTextCodec::toLocal8Bit() process.waitForFinished(); QCOMPARE(process.exitStatus(), QProcess::NormalExit); QCOMPARE(process.exitCode(), 0); +#endif } #endif -- cgit v0.12