summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorRohan McGovern <rohan.mcgovern@nokia.com>2012-05-31 11:16:10 +1000
committerQt by Nokia <qt-info@nokia.com>2012-05-31 05:37:25 +0200
commitaf8fa2794b4d1580ad69ac7de40761634cb0fa39 (patch)
treef252705fcb5635f04f1aec112de08d1ef6bb7fd3 /tests/auto
parent26631bec9ffda88a2aad23e7400a4bc441b87a93 (diff)
Make tst_qtextstream parallel-safe.
Write to a QTemporaryDir instead of the test's build directory. Change-Id: Ib65a0d58fbdf8caf8f2cb7002aeed1ce34742183 Reviewed-by: Toby Tomkins <toby.tomkins@nokia.com> Reviewed-by: Kalle Lehtonen <kalle.ju.lehtonen@nokia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/io/qtextstream/test/test.pro1
-rw-r--r--tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp28
2 files changed, 21 insertions, 8 deletions
diff --git a/tests/auto/corelib/io/qtextstream/test/test.pro b/tests/auto/corelib/io/qtextstream/test/test.pro
index 93fb6d232f..df0bb137b8 100644
--- a/tests/auto/corelib/io/qtextstream/test/test.pro
+++ b/tests/auto/corelib/io/qtextstream/test/test.pro
@@ -1,4 +1,5 @@
CONFIG += testcase
+CONFIG += parallel_test
TARGET = ../tst_qtextstream
QT = core network testlib
SOURCES = ../tst_qtextstream.cpp
diff --git a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp
index 6e330faa85..b22723a00c 100644
--- a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp
+++ b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp
@@ -50,14 +50,13 @@
#include <QDebug>
#include <QFile>
#include <QTcpSocket>
+#include <QTemporaryDir>
#include <QTextStream>
#include <QTextCodec>
#include <QProcess>
#include "../../../network-settings.h"
-static const char *TestFileName = "testfile";
-
Q_DECLARE_METATYPE(qlonglong)
Q_DECLARE_METATYPE(qulonglong)
Q_DECLARE_METATYPE(QList<int>)
@@ -71,6 +70,9 @@ class tst_QTextStream : public QObject
{
Q_OBJECT
+public:
+ tst_QTextStream();
+
public slots:
void initTestCase();
void cleanup();
@@ -239,12 +241,22 @@ private:
void generateRealNumbersData(bool for_QString);
void generateStringData(bool for_QString);
void generateRealNumbersDataWrite();
+
+ QTemporaryDir tempDir;
+ QString testFileName;
};
+tst_QTextStream::tst_QTextStream()
+ : tempDir(QDir::tempPath() + "/tst_qtextstream.XXXXXX")
+{
+}
+
void tst_QTextStream::initTestCase()
{
QVERIFY(QtNetworkSettings::verifyTestNetworkSettings());
+ testFileName = tempDir.path() + "/testfile";
+
// chdir into the testdata dir and refer to our helper apps with relative paths
QString testdata_dir = QFileInfo(QFINDTESTDATA("stdinProcess")).absolutePath();
QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir));
@@ -488,8 +500,8 @@ void tst_QTextStream::readLineFromDevice()
QFETCH(QByteArray, data);
QFETCH(QStringList, lines);
- QFile::remove(TestFileName);
- QFile file(TestFileName);
+ QFile::remove(testFileName);
+ QFile file(testFileName);
QVERIFY(file.open(QFile::ReadWrite));
QCOMPARE(file.write(data), qlonglong(data.size()));
QVERIFY(file.flush());
@@ -1340,7 +1352,7 @@ void tst_QTextStream::pos2()
void tst_QTextStream::pos3LargeFile()
{
{
- QFile file(TestFileName);
+ QFile file(testFileName);
file.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream out( &file );
// NOTE: The unusual spacing is to ensure non-1-character whitespace.
@@ -1351,7 +1363,7 @@ void tst_QTextStream::pos3LargeFile()
out << lineString;
// File is automatically flushed and closed on destruction.
}
- QFile file(TestFileName);
+ QFile file(testFileName);
file.open(QIODevice::ReadOnly | QIODevice::Text);
QTextStream in( &file );
const int testValues[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
@@ -1677,8 +1689,8 @@ void tst_QTextStream::utf8IncompleteAtBufferBoundary_data()
void tst_QTextStream::utf8IncompleteAtBufferBoundary()
{
- QFile::remove(TestFileName);
- QFile data(TestFileName);
+ QFile::remove(testFileName);
+ QFile data(testFileName);
QTextCodec *utf8Codec = QTextCodec::codecForMib(106);
QString lineContents = QString::fromUtf8("\342\200\223" // U+2013 EN DASH