summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qprocess
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-08-10 17:43:12 +0200
committerLiang Qi <liang.qi@qt.io>2016-08-10 17:43:13 +0200
commit8ba384a5645aebbefe34b814828024d511171497 (patch)
tree6f6cfe1b849b6e0e02de15ee74ad0f3d5fc740b6 /tests/auto/corelib/io/qprocess
parente694ced803589b3504b6bdb2fc8bf97bc891c794 (diff)
parent25b72a63fffe800f2005b21d254b0b191d263b10 (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Diffstat (limited to 'tests/auto/corelib/io/qprocess')
-rw-r--r--tests/auto/corelib/io/qprocess/tst_qprocess.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
index 1f0ace0dd3..59f271d727 100644
--- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
@@ -763,6 +763,7 @@ void tst_QProcess::restartProcess()
// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::closeWriteChannel()
{
+ QByteArray testData("Data to read");
QProcess more;
more.start("testProcessEOF/testProcessEOF");
@@ -770,19 +771,21 @@ void tst_QProcess::closeWriteChannel()
QVERIFY(!more.waitForReadyRead(250));
QCOMPARE(more.error(), QProcess::Timedout);
- QVERIFY(more.write("Data to read") != -1);
+ QCOMPARE(more.write(testData), qint64(testData.size()));
QVERIFY(!more.waitForReadyRead(250));
QCOMPARE(more.error(), QProcess::Timedout);
more.closeWriteChannel();
-
- QVERIFY(more.waitForReadyRead(5000));
- QVERIFY(more.readAll().startsWith("Data to read"));
+ // During closeWriteChannel() call, we might also get an I/O completion
+ // on the read pipe. So, take this into account before waiting for
+ // the new incoming data.
+ while (more.bytesAvailable() < testData.size())
+ QVERIFY(more.waitForReadyRead(5000));
+ QCOMPARE(more.readAll(), testData);
if (more.state() == QProcess::Running)
- more.write("q");
- QVERIFY(more.waitForFinished(5000));
+ QVERIFY(more.waitForFinished(5000));
QCOMPARE(more.exitStatus(), QProcess::NormalExit);
QCOMPARE(more.exitCode(), 0);
}