summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/kernel
diff options
context:
space:
mode:
authorJason McDonald <jason.mcdonald@nokia.com>2011-10-04 11:51:31 +1000
committerQt by Nokia <qt-info@nokia.com>2011-10-05 03:04:31 +0200
commit7cfad460c56319ba89c4a3a0bbcb2e54ab1cdbc6 (patch)
tree5df8fca668dace17eea7b6c5ed82db8e87180105 /tests/auto/corelib/kernel
parentc46f59fadf63b661d8611e5896f09fb85c17a00c (diff)
Avoid using QSKIP in lieu of compile-time checks
QSKIP is intended to be used to skip test functions that are found at run-time to be inapplicable or unsafe. If a test function can be determined to be inapplicable at compile-time, the entire test function should be omitted instead of replacing the body of the test function with a QSKIP, which only serves to slow down test runs and to inflate test run-rates with empty, inapplicable tests. Task-number: QTQAINFRA-278 Change-Id: Ib2025339422749cf216e87ac414a3056250bf8f9 Reviewed-on: http://codereview.qt-project.org/5942 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Diffstat (limited to 'tests/auto/corelib/kernel')
-rw-r--r--tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp17
-rw-r--r--tests/auto/corelib/kernel/qobject/tst_qobject.cpp8
-rw-r--r--tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp9
-rw-r--r--tests/auto/corelib/kernel/qtipc/qsharedmemory/tst_qsharedmemory.cpp43
-rw-r--r--tests/auto/corelib/kernel/qtipc/qsystemsemaphore/tst_qsystemsemaphore.cpp9
5 files changed, 47 insertions, 39 deletions
diff --git a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp
index 10ed84750a..2e1f914497 100644
--- a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp
+++ b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp
@@ -195,7 +195,9 @@ private slots:
// This test *must* run first. See the definition for why.
void processEvents();
void exec();
+#if !defined(QT_NO_EXCEPTIONS) && !defined(Q_OS_WINCE_WM)
void throwInExec();
+#endif
void reexec();
void exit();
void execAfterExit();
@@ -339,16 +341,14 @@ void tst_QEventLoop::exec()
}
}
+// This test needs exceptions to be enabled.
+// Windows Mobile cannot handle cross library exceptions
+// qobject.cpp will try to rethrow the exception after handling
+// which causes gwes.exe to crash
+#if !defined(QT_NO_EXCEPTIONS) && !defined(Q_OS_WINCE_WM)
void tst_QEventLoop::throwInExec()
{
-#if defined(QT_NO_EXCEPTIONS) || defined(NO_EVENTLOOP_EXCEPTIONS)
- QSKIP("Exceptions are disabled", SkipAll);
-#elif defined(Q_OS_WINCE_WM)
- // Windows Mobile cannot handle cross library exceptions
- // qobject.cpp will try to rethrow the exception after handling
- // which causes gwes.exe to crash
- QSKIP("This platform doesn't support propagating exceptions through the event loop", SkipAll);
-#elif defined(Q_OS_LINUX)
+#if defined(Q_OS_LINUX)
// C++ exceptions can't be passed through glib callbacks. Skip the test if
// we're using the glib event loop.
QByteArray dispatcher = QAbstractEventDispatcher::instance()->metaObject()->className();
@@ -385,6 +385,7 @@ void tst_QEventLoop::throwInExec()
QCOMPARE(caughtExceptions, 2);
}
}
+#endif
void tst_QEventLoop::reexec()
{
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
index 3ed3d25eeb..56d63f2e09 100644
--- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
@@ -110,7 +110,9 @@ private slots:
void floatProperty();
void qrealProperty();
void property();
+#ifndef QT_NO_PROCESS
void recursiveSignalEmission();
+#endif
void blockingQueuedConnection();
void compatibilityChildInsertedEvents();
void installEventFilter();
@@ -2804,18 +2806,16 @@ void tst_QObject::dynamicProperties()
QVERIFY(obj.dynamicPropertyNames().isEmpty());
}
+#ifndef QT_NO_PROCESS
void tst_QObject::recursiveSignalEmission()
{
-#if defined(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
}
+#endif
void tst_QObject::blockingQueuedConnection()
{
diff --git a/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp b/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp
index d31ad64e09..bcde9828e8 100644
--- a/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp
+++ b/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp
@@ -72,7 +72,9 @@ public:
private slots:
void unexpectedDisconnection();
void mixingWithTimers();
+#ifdef Q_OS_UNIX
void posixSockets();
+#endif
void bogusFds();
};
@@ -257,12 +259,9 @@ void tst_QSocketNotifier::mixingWithTimers()
QCOMPARE(helper.socketActivated, true);
}
+#ifdef Q_OS_UNIX
void tst_QSocketNotifier::posixSockets()
{
-#ifndef Q_OS_UNIX
- QSKIP("test only for posix", SkipAll);
-#else
-
QTcpServer server;
QVERIFY(server.listen(QHostAddress::LocalHost, 0));
@@ -310,8 +309,8 @@ void tst_QSocketNotifier::posixSockets()
QCOMPARE(passive->readAll(), QByteArray("goodbye",8));
}
qt_safe_close(posixSocket);
-#endif
}
+#endif
void tst_QSocketNotifier::bogusFds()
{
diff --git a/tests/auto/corelib/kernel/qtipc/qsharedmemory/tst_qsharedmemory.cpp b/tests/auto/corelib/kernel/qtipc/qsharedmemory/tst_qsharedmemory.cpp
index 34374806b4..4aa2912ad6 100644
--- a/tests/auto/corelib/kernel/qtipc/qsharedmemory/tst_qsharedmemory.cpp
+++ b/tests/auto/corelib/kernel/qtipc/qsharedmemory/tst_qsharedmemory.cpp
@@ -83,14 +83,20 @@ private slots:
void lock();
// custom edge cases
+#ifndef Q_OS_HPUX
void removeWhileAttached();
+#endif
void emptyMemory();
+#ifndef Q_OS_WIN
void readOnly();
+#endif
// basics all together
+#ifndef Q_OS_HPUX
void simpleProducerConsumer_data();
void simpleProducerConsumer();
void simpleDoubleProducerConsumer();
+#endif
// with threads
void simpleThreadedProducerConsumer_data();
@@ -102,7 +108,9 @@ private slots:
// extreme cases
void useTooMuchMemory();
+#if !defined(Q_OS_HPUX) && !defined(Q_OS_WINCE)
void attachTooMuch();
+#endif
// unique keys
void uniqueKey_data();
@@ -381,11 +389,10 @@ void tst_QSharedMemory::lock()
Other shared memory are allowed to be attached after we remove,
but new shared memory are not allowed to attach after a remove.
*/
+// HPUX doesn't allow for multiple attaches per process.
+#ifndef Q_OS_HPUX
void tst_QSharedMemory::removeWhileAttached()
{
-#ifdef Q_OS_HPUX
- QSKIP("HPUX doesn't allow for multiple attaches per process", SkipAll);
-#endif
rememberKey("one");
// attach 1
@@ -407,6 +414,7 @@ void tst_QSharedMemory::removeWhileAttached()
QVERIFY(!smThree.attach());
QCOMPARE(smThree.error(), QSharedMemory::NotFound);
}
+#endif
/*!
The memory should be set to 0 after created.
@@ -426,11 +434,10 @@ void tst_QSharedMemory::emptyMemory()
Verify that attach with ReadOnly is actually read only
by writing to data and causing a segfault.
*/
+// This test opens a crash dialog on Windows.
+#ifndef Q_OS_WIN
void tst_QSharedMemory::readOnly()
{
-#ifdef Q_OS_WIN
- QSKIP("This test opens a crash dialog on Windows", SkipSingle);
-#endif
QString program = LACKEYDIR "/lackey";
QStringList arguments;
rememberKey("readonly_segfault");
@@ -443,6 +450,7 @@ void tst_QSharedMemory::readOnly()
p.waitForFinished();
QCOMPARE(p.error(), QProcess::Crashed);
}
+#endif
/*!
Keep making shared memory until the kernel stops us.
@@ -490,15 +498,13 @@ void tst_QSharedMemory::useTooMuchMemory()
Create one shared memory (government) and see how many other shared memories (wars) we can
attach before the system runs out of resources.
*/
+// HPUX doesn't allow for multiple attaches per process.
+// For WinCE, this test nearly kills the system, so skip it.
+#if !defined(Q_OS_HPUX) && !defined(Q_OS_WINCE)
void tst_QSharedMemory::attachTooMuch()
{
QSKIP("disabled", SkipAll);
-#ifdef Q_OS_HPUX
- QSKIP("HPUX doesn't allow for multiple attaches per process", SkipAll);
-#endif
-#ifdef Q_OS_WINCE
- QSKIP("This nearly kills the system itself, so skip for Qt/WinCE", SkipAll);
-#endif
+
QSharedMemory government(rememberKey("government"));
QVERIFY(government.create(1024));
while (true) {
@@ -519,7 +525,10 @@ void tst_QSharedMemory::attachTooMuch()
}
}
}
+#endif
+// HPUX doesn't allow for multiple attaches per process.
+#ifndef Q_OS_HPUX
void tst_QSharedMemory::simpleProducerConsumer_data()
{
QTest::addColumn<QSharedMemory::AccessMode>("mode");
@@ -537,9 +546,6 @@ void tst_QSharedMemory::simpleProducerConsumer_data()
*/
void tst_QSharedMemory::simpleProducerConsumer()
{
-#ifdef Q_OS_HPUX
- QSKIP("HPUX doesn't allow for multiple attaches per process", SkipAll);
-#endif
QFETCH(QSharedMemory::AccessMode, mode);
rememberKey(QLatin1String("market"));
@@ -562,12 +568,12 @@ void tst_QSharedMemory::simpleProducerConsumer()
}
QVERIFY(consumer.detach());
}
+#endif
+// HPUX doesn't allow for multiple attaches per process.
+#ifndef Q_OS_HPUX
void tst_QSharedMemory::simpleDoubleProducerConsumer()
{
-#ifdef Q_OS_HPUX
- QSKIP("HPUX doesn't allow for multiple attaches per process", SkipAll);
-#endif
rememberKey(QLatin1String("market"));
QSharedMemory producer(QLatin1String("market"));
int size = 512;
@@ -580,6 +586,7 @@ void tst_QSharedMemory::simpleDoubleProducerConsumer()
QVERIFY(consumer.attach());
}
}
+#endif
class Consumer : public QThread
{
diff --git a/tests/auto/corelib/kernel/qtipc/qsystemsemaphore/tst_qsystemsemaphore.cpp b/tests/auto/corelib/kernel/qtipc/qsystemsemaphore/tst_qsystemsemaphore.cpp
index 935f2f6041..a8af8600c1 100644
--- a/tests/auto/corelib/kernel/qtipc/qsystemsemaphore/tst_qsystemsemaphore.cpp
+++ b/tests/auto/corelib/kernel/qtipc/qsystemsemaphore/tst_qsystemsemaphore.cpp
@@ -77,7 +77,9 @@ private slots:
void processes_data();
void processes();
+#ifndef Q_OS_WIN
void undo();
+#endif
void initialValue();
private:
@@ -257,12 +259,10 @@ void tst_QSystemSemaphore::processes()
}
}
+// This test only checks a unix behavior.
+#ifndef Q_OS_WIN
void tst_QSystemSemaphore::undo()
{
-#if defined(Q_OS_WIN)
- QSKIP("This test only checks a unix behavior", SkipSingle);
-#endif
-
QSystemSemaphore sem("store", 1, QSystemSemaphore::Create);
QStringList acquireArguments = QStringList() << acquire_js();
@@ -278,6 +278,7 @@ void tst_QSystemSemaphore::undo()
acquire.waitForFinished(LACKYWAITTIME);
QVERIFY(acquire.state()== QProcess::NotRunning);
}
+#endif
void tst_QSystemSemaphore::initialValue()
{