summaryrefslogtreecommitdiffstats
path: root/tests/auto/testlib
diff options
context:
space:
mode:
authorRohan McGovern <rohan.mcgovern@nokia.com>2012-05-29 10:58:41 +1000
committerQt by Nokia <qt-info@nokia.com>2012-05-29 09:39:18 +0200
commitb1e59467fb37c6d21c3ade0b6758b422a9d09c92 (patch)
tree6e903e57246389a0e6081c36120f4c62f17fe95e /tests/auto/testlib
parent70ad49d66116c97b42b2528d532cc683dccd7885 (diff)
Make tst_selftests parallel-safe.
Use a QTemporaryDir for temporary files, instead of the current working directory. Change-Id: Ifeb2944238f785a1f7beb0dc2a7c1e092d121db5 Reviewed-by: Kalle Lehtonen <kalle.ju.lehtonen@nokia.com> Reviewed-by: Toby Tomkins <toby.tomkins@nokia.com>
Diffstat (limited to 'tests/auto/testlib')
-rw-r--r--tests/auto/testlib/selftests/test/test.pro1
-rw-r--r--tests/auto/testlib/selftests/tst_selftests.cpp20
2 files changed, 18 insertions, 3 deletions
diff --git a/tests/auto/testlib/selftests/test/test.pro b/tests/auto/testlib/selftests/test/test.pro
index a395ecea47..30f18b1bbb 100644
--- a/tests/auto/testlib/selftests/test/test.pro
+++ b/tests/auto/testlib/selftests/test/test.pro
@@ -1,4 +1,5 @@
CONFIG += testcase
+CONFIG += parallel_test
SOURCES += ../tst_selftests.cpp
QT = core xml testlib-private
diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp
index 26ccd826ca..4eff3f7cdc 100644
--- a/tests/auto/testlib/selftests/tst_selftests.cpp
+++ b/tests/auto/testlib/selftests/tst_selftests.cpp
@@ -43,13 +43,19 @@
#include <QtCore/QXmlStreamReader>
#include <QtCore/QFileInfo>
#include <QtCore/QDir>
+#include <QtCore/QTemporaryDir>
#include <QtTest/QtTest>
#include <private/cycle_p.h>
+struct LoggerSet;
+
class tst_Selftests: public QObject
{
Q_OBJECT
+public:
+ tst_Selftests();
+
private slots:
void initTestCase();
void runSubTest_data();
@@ -58,6 +64,10 @@ private slots:
private:
void doRunSubTest(QString const& subdir, QStringList const& loggers, QStringList const& arguments);
+ QString logName(const QString &logger) const;
+ QList<LoggerSet> allLoggerSets() const;
+
+ QTemporaryDir tempDir;
};
struct BenchmarkResult
@@ -153,9 +163,9 @@ static inline QString logFormat(const QString &logger)
}
// Return the log file name, or an empty string if the log goes to stdout.
-static inline QString logName(const QString &logger)
+QString tst_Selftests::logName(const QString &logger) const
{
- return (logger.startsWith("stdout") ? "" : QString("test_output." + logger));
+ return (logger.startsWith("stdout") ? "" : QString(tempDir.path() + "/test_output." + logger));
}
// Load the expected test output for the nominated test (subdir) and logger
@@ -184,7 +194,7 @@ struct LoggerSet
// This function returns a list of all sets of loggers to be used for
// running each subtest.
-static QList<LoggerSet> allLoggerSets()
+QList<LoggerSet> tst_Selftests::allLoggerSets() const
{
// Note that in order to test XML output to standard output, the subtests
// must not send output directly to stdout, bypassing Qt's output mechanisms
@@ -289,6 +299,10 @@ static QList<LoggerSet> allLoggerSets()
;
}
+tst_Selftests::tst_Selftests()
+ : tempDir(QDir::tempPath() + "/tst_selftests.XXXXXX")
+{}
+
void tst_Selftests::initTestCase()
{
//Detect the location of the sub programs