diff options
author | Mathias Hasselmann <mathias.hasselmann@kdab.com> | 2013-11-15 01:01:26 +0100 |
---|---|---|
committer | Mathias Hasselmann <mathias.hasselmann@kdab.com> | 2013-11-15 01:01:26 +0100 |
commit | 0187fcd0c63172f07781456f99bd76acca1d78e9 (patch) | |
tree | da0b485510d3b58d2d87ce28bc07182aabd33b40 /tests/testutils | |
parent | c6daa77860f0d656796b5f38f965a58a8e6a1bcd (diff) |
Enable core dumps for tests
Diffstat (limited to 'tests/testutils')
-rw-r--r-- | tests/testutils/testcontext.cpp | 35 | ||||
-rw-r--r-- | tests/testutils/testcontext.h | 21 | ||||
-rw-r--r-- | tests/testutils/testutils.pro | 10 |
3 files changed, 66 insertions, 0 deletions
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 + |