summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Hasselmann <mathias.hasselmann@kdab.com>2013-11-15 01:01:26 +0100
committerMathias Hasselmann <mathias.hasselmann@kdab.com>2013-11-15 01:01:26 +0100
commit0187fcd0c63172f07781456f99bd76acca1d78e9 (patch)
treeda0b485510d3b58d2d87ce28bc07182aabd33b40
parentc6daa77860f0d656796b5f38f965a58a8e6a1bcd (diff)
downloadqtquickstreamer-0187fcd0c63172f07781456f99bd76acca1d78e9.tar.gz
qtquickstreamer-0187fcd0c63172f07781456f99bd76acca1d78e9.tar.xz
Enable core dumps for tests
-rw-r--r--tests/tests.pri8
-rw-r--r--tests/tests.pro12
-rw-r--r--tests/testutils/testcontext.cpp35
-rw-r--r--tests/testutils/testcontext.h21
-rw-r--r--tests/testutils/testutils.pro10
-rw-r--r--tests/tst_metaobject/tst_metaobjecttest.cpp4
-rw-r--r--tests/tst_qml/tst_qmltest.cpp25
7 files changed, 88 insertions, 27 deletions
diff --git a/tests/tests.pri b/tests/tests.pri
index fd2a1d7..85b528b 100644
--- a/tests/tests.pri
+++ b/tests/tests.pri
@@ -11,5 +11,9 @@ DEFINES += \
OUTDIR=\\\"$$OUT_PWD/\\\" \
SRCDIR=\\\"$$PWD/\\\"
-INCLUDEPATH += $$TOP_SRCDIR/src
-message($$TOP_SRCDIR/src)
+INCLUDEPATH += \
+ $$TOP_SRCDIR/src \
+ $$TOP_SRCDIR/tests
+
+LIBS += $$TOP_OUTDIR/tests/testutils/libtestutils.a
+PRE_TARGETDEPS += $$TOP_OUTDIR/tests/testutils/libtestutils.a
diff --git a/tests/tests.pro b/tests/tests.pro
index da8e580..bd87abf 100644
--- a/tests/tests.pro
+++ b/tests/tests.pro
@@ -1,8 +1,18 @@
TEMPLATE = subdirs
-SUBDIRS += \
+TESTDIRS += \
tst_metaobject \
tst_qml
+SUBDIRS += \
+ $$TESTDIRS \
+ testutils
+
+for(t, TESTDIRS) {
+ eval($${t}.depends += testutils)
+}
+
+message($$tst_qml.depends)
+
OTHER_FILES += \
tests.pri
diff --git a/tests/testutils/testcontext.cpp b/tests/testutils/testcontext.cpp
new file mode 100644
index 0000000..daf5e1f
--- /dev/null
+++ b/tests/testutils/testcontext.cpp
@@ -0,0 +1,35 @@
+#include "testcontext.h"
+
+#include <sys/time.h>
+#include <sys/resource.h>
+
+TestContext::TestContext(const QByteArray &sourceDir, const QByteArray &topSourceDir,
+ const QByteArray &outputDir, const QByteArray &topOutputDir)
+ : m_sourceDir(sourceDir)
+ , m_topSourceDir(topSourceDir)
+ , m_outputDir(outputDir)
+ , m_topOutputDir(topOutputDir)
+{
+ rlimit unlimited = {
+ std::numeric_limits<rlim_t>::max(),
+ std::numeric_limits<rlim_t>::max()
+ };
+
+ if (setrlimit(RLIMIT_CORE, &unlimited)) {
+ const char *const lastError = strerror(errno);
+ qWarning("Cannot have unlimited core files: %s", lastError);
+ }
+
+ const char importPathVarName[] = "QML2_IMPORT_PATH";
+ QByteArray importPath = qgetenv(importPathVarName);
+
+ if (not importPath.isEmpty())
+ importPath = ':' + importPath;
+
+ qputenv(importPathVarName, m_topOutputDir + "/src" + importPath);
+}
+
+const char *TestContext::sourceDir() const
+{
+ return m_sourceDir.constData();
+}
diff --git a/tests/testutils/testcontext.h b/tests/testutils/testcontext.h
new file mode 100644
index 0000000..625c417
--- /dev/null
+++ b/tests/testutils/testcontext.h
@@ -0,0 +1,21 @@
+#ifndef TESTCONTEXT_H
+#define TESTCONTEXT_H
+
+#include <QByteArray>
+
+class TestContext
+{
+public:
+ explicit TestContext(const QByteArray &sourceDir, const QByteArray &topSourceDir,
+ const QByteArray &outputDir, const QByteArray &topOutputDir);
+
+ const char *sourceDir() const;
+
+private:
+ const QByteArray m_sourceDir;
+ const QByteArray m_topSourceDir;
+ const QByteArray m_outputDir;
+ const QByteArray m_topOutputDir;
+};
+
+#endif // TESTCONTEXT_H
diff --git a/tests/testutils/testutils.pro b/tests/testutils/testutils.pro
new file mode 100644
index 0000000..5ed071d
--- /dev/null
+++ b/tests/testutils/testutils.pro
@@ -0,0 +1,10 @@
+TEMPLATE = lib
+CONFIG += c++11 static
+QT = core
+
+HEADERS += \
+ testcontext.h
+
+SOURCES += \
+ testcontext.cpp
+
diff --git a/tests/tst_metaobject/tst_metaobjecttest.cpp b/tests/tst_metaobject/tst_metaobjecttest.cpp
index 485d937..4ae89fe 100644
--- a/tests/tst_metaobject/tst_metaobjecttest.cpp
+++ b/tests/tst_metaobject/tst_metaobjecttest.cpp
@@ -18,6 +18,7 @@
// Author: Mathias Hasselmann <mathias@taschenorakel.de>
//
#include "QuickStreamer/item.h"
+#include "testutils/testcontext.h"
#include <gst/gst.h>
@@ -27,7 +28,7 @@
using QQuickStreamer::Item;
-class MetaObjectTest : public QObject
+class MetaObjectTest : public QObject, TestContext
{
Q_OBJECT
@@ -35,6 +36,7 @@ class MetaObjectTest : public QObject
public:
MetaObjectTest()
+ : TestContext(SRCDIR, TOP_SRCDIR, OUTDIR, TOP_OUTDIR)
{
}
diff --git a/tests/tst_qml/tst_qmltest.cpp b/tests/tst_qml/tst_qmltest.cpp
index f5c1f2b..973b7ed 100644
--- a/tests/tst_qml/tst_qmltest.cpp
+++ b/tests/tst_qml/tst_qmltest.cpp
@@ -17,28 +17,7 @@
//
// Author: Mathias Hasselmann <mathias@taschenorakel.de>
//
-#define QUICK_TEST_SOURCE_DIR Context().testSourceDir()
-
+#define QUICK_TEST_SOURCE_DIR TestContext(SRCDIR, TOP_SRCDIR, OUTDIR, TOP_OUTDIR).sourceDir()
#include <QtQuickTest/QtQuickTest>
-
-class Context
-{
-public:
- Context()
- {
- const char importPathVarName[] = "QML2_IMPORT_PATH";
- QByteArray importPath = qgetenv(importPathVarName);
-
- if (not importPath.isEmpty())
- importPath = ':' + importPath;
-
- qputenv(importPathVarName, TOP_OUTDIR "/src" + importPath);
- }
-
- const char *testSourceDir() const
- {
- return SRCDIR;
- }
-};
-
+#include "testutils/testcontext.h"
QUICK_TEST_MAIN()