summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/thread/qthreadstorage
diff options
context:
space:
mode:
authorRohan McGovern <rohan.mcgovern@nokia.com>2012-02-29 09:18:59 +1000
committerRohan McGovern <rohan.mcgovern@nokia.com>2012-02-29 09:23:14 +1000
commit98dd1781d9256f68025d2a2db408f4f5947f3214 (patch)
treedbe1424abd90014edb5546c920ca585ed62b46e3 /tests/auto/corelib/thread/qthreadstorage
parent6c1bdc1854a7700c2b3a345b95f6a2fdca84037d (diff)
parentfa1b9070af66edb81b2a3735c1951f78b22bd666 (diff)
Merge master -> api_changes
Includes fixes for tst_qfiledialog2, tst_qtextedit autotests on mac. Change-Id: I49cac26894d31291a8339ccc1eb80b6a940f0827
Diffstat (limited to 'tests/auto/corelib/thread/qthreadstorage')
-rw-r--r--tests/auto/corelib/thread/qthreadstorage/crashOnExit.pro8
-rw-r--r--tests/auto/corelib/thread/qthreadstorage/crashonexit/crashOnExit.cpp (renamed from tests/auto/corelib/thread/qthreadstorage/crashOnExit.cpp)0
-rw-r--r--tests/auto/corelib/thread/qthreadstorage/crashonexit/crashonexit.pro9
-rw-r--r--tests/auto/corelib/thread/qthreadstorage/qthreadstorage.pro6
-rw-r--r--tests/auto/corelib/thread/qthreadstorage/test/test.pro6
-rw-r--r--tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp54
-rw-r--r--tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.pro4
7 files changed, 62 insertions, 25 deletions
diff --git a/tests/auto/corelib/thread/qthreadstorage/crashOnExit.pro b/tests/auto/corelib/thread/qthreadstorage/crashOnExit.pro
deleted file mode 100644
index 68d0f1202b..0000000000
--- a/tests/auto/corelib/thread/qthreadstorage/crashOnExit.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-SOURCES += crashOnExit.cpp
-QT = core
-CONFIG-=app_bundle
-CONFIG+=console
-
-# This app is testdata for tst_qthreadstorage
-target.path = $$[QT_INSTALL_TESTS]/tst_qthreadstorage
-INSTALLS += target
diff --git a/tests/auto/corelib/thread/qthreadstorage/crashOnExit.cpp b/tests/auto/corelib/thread/qthreadstorage/crashonexit/crashOnExit.cpp
index 388c233d84..388c233d84 100644
--- a/tests/auto/corelib/thread/qthreadstorage/crashOnExit.cpp
+++ b/tests/auto/corelib/thread/qthreadstorage/crashonexit/crashOnExit.cpp
diff --git a/tests/auto/corelib/thread/qthreadstorage/crashonexit/crashonexit.pro b/tests/auto/corelib/thread/qthreadstorage/crashonexit/crashonexit.pro
new file mode 100644
index 0000000000..94a0a01e94
--- /dev/null
+++ b/tests/auto/corelib/thread/qthreadstorage/crashonexit/crashonexit.pro
@@ -0,0 +1,9 @@
+SOURCES += crashOnExit.cpp
+DESTDIR = ./
+QT = core
+CONFIG -= app_bundle
+CONFIG += console
+
+# This app is testdata for tst_qthreadstorage
+target.path = $$[QT_INSTALL_TESTS]/tst_qthreadstorage/$$TARGET
+INSTALLS += target
diff --git a/tests/auto/corelib/thread/qthreadstorage/qthreadstorage.pro b/tests/auto/corelib/thread/qthreadstorage/qthreadstorage.pro
index 0dc8d086df..2fa973d2f7 100644
--- a/tests/auto/corelib/thread/qthreadstorage/qthreadstorage.pro
+++ b/tests/auto/corelib/thread/qthreadstorage/qthreadstorage.pro
@@ -1,5 +1,5 @@
TEMPLATE = subdirs
SUBDIRS = \
- tst_qthreadstorage.pro \
- crashOnExit.pro
-CONFIG += parallel_test
+ crashonexit \
+ test
+CONFIG += ordered parallel_test
diff --git a/tests/auto/corelib/thread/qthreadstorage/test/test.pro b/tests/auto/corelib/thread/qthreadstorage/test/test.pro
new file mode 100644
index 0000000000..a7d8eb0106
--- /dev/null
+++ b/tests/auto/corelib/thread/qthreadstorage/test/test.pro
@@ -0,0 +1,6 @@
+CONFIG += testcase
+TARGET = ../tst_qthreadstorage
+CONFIG -= app_bundle
+CONFIG += console
+QT = core testlib
+SOURCES = ../tst_qthreadstorage.cpp
diff --git a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp b/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp
index fff361ea2a..0529e67e0f 100644
--- a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp
+++ b/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp
@@ -46,6 +46,8 @@
#include <qthread.h>
#include <qwaitcondition.h>
#include <qthreadstorage.h>
+#include <qdir.h>
+#include <qfileinfo.h>
#ifdef Q_OS_UNIX
#include <pthread.h>
@@ -61,6 +63,7 @@ class tst_QThreadStorage : public QObject
{
Q_OBJECT
private slots:
+ void initTestCase();
void hasLocalData();
void localData();
void localData_const();
@@ -72,6 +75,9 @@ private slots:
void leakInDestructor();
void resetInDestructor();
void valueBased();
+
+private:
+ QString m_crashOnExit;
};
class Pointer
@@ -83,6 +89,20 @@ public:
};
int Pointer::count = 0;
+void tst_QThreadStorage::initTestCase()
+{
+ const QString crashOnExitDir = QFINDTESTDATA("crashonexit");
+ QVERIFY2(!crashOnExitDir.isEmpty(),
+ qPrintable(QString::fromLatin1("Could not find 'crashonexit' starting from '%1'")
+ .arg(QDir::toNativeSeparators(QDir::currentPath()))));
+ m_crashOnExit = crashOnExitDir + QStringLiteral("/crashonexit");
+#ifdef Q_OS_WIN
+ m_crashOnExit += QStringLiteral(".exe");
+#endif
+ QVERIFY2(QFileInfo(m_crashOnExit).isExecutable(),
+ qPrintable(QDir::toNativeSeparators(m_crashOnExit) + QStringLiteral(" does not exist or is not executable.")));
+}
+
void tst_QThreadStorage::hasLocalData()
{
QThreadStorage<Pointer *> pointers;
@@ -285,18 +305,32 @@ void tst_QThreadStorage::ensureCleanupOrder()
QVERIFY(First::order < Second::order);
}
-void tst_QThreadStorage::crashOnExit()
+static inline bool runCrashOnExit(const QString &binary, QString *errorMessage)
{
+ const int timeout = 60000;
QProcess process;
- // crashOnExit is always expected to be in the same directory
- // as this test binary
-#ifdef Q_OS_MAC
- process.start(QCoreApplication::applicationDirPath() + "/../../../crashOnExit");
-#else
- process.start(QCoreApplication::applicationDirPath() + "/crashOnExit");
-#endif
- QVERIFY(process.waitForFinished());
- QVERIFY(process.exitStatus() != QProcess::CrashExit);
+ process.start(binary);
+ if (!process.waitForStarted()) {
+ *errorMessage = QString::fromLatin1("Could not start '%1': %2").arg(binary, process.errorString());
+ return false;
+ }
+ if (!process.waitForFinished(timeout)) {
+ process.kill();
+ *errorMessage = QString::fromLatin1("Timeout (%1ms) waiting for %2.").arg(timeout).arg(binary);
+ return false;
+ }
+ if (process.exitStatus() != QProcess::NormalExit) {
+ *errorMessage = binary + QStringLiteral(" crashed.");
+ return false;
+ }
+ return true;
+}
+
+void tst_QThreadStorage::crashOnExit()
+{
+ QString errorMessage;
+ QVERIFY2(runCrashOnExit(m_crashOnExit, &errorMessage),
+ qPrintable(errorMessage));
}
// S stands for thread Safe.
diff --git a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.pro b/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.pro
deleted file mode 100644
index 15ced107d3..0000000000
--- a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.pro
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qthreadstorage
-QT = core testlib
-SOURCES = tst_qthreadstorage.cpp