summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io
diff options
context:
space:
mode:
authorAlex Trotsenko <alex1973tr@gmail.com>2015-08-13 18:59:03 +0300
committerAlex Trotsenko <alex1973tr@gmail.com>2015-08-16 14:22:32 +0000
commit6dde874c3203464f76170834234c026e02dc7abc (patch)
tree7befa97dfd373dfbbb71b61dbc3fc1d7873a8df1 /tests/auto/corelib/io
parentf029468b8d822da378a20577f7b8c16a447e4e1b (diff)
QProcess: discard unwanted output from the child process
Drop process output to nullDevice(), if an application does not request forwarding, redirecting or reading from the device channel. This prevents from accumulation of unnecessary data which can not be read. Change-Id: Ia311a8c658a46cf580ffa9484c5369f3fc5f98a7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Diffstat (limited to 'tests/auto/corelib/io')
-rw-r--r--tests/auto/corelib/io/qprocess/tst_qprocess.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
index 0ffac21186..e810f48d6c 100644
--- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
@@ -122,6 +122,7 @@ private slots:
void removeFileWhileProcessIsRunning();
void fileWriterProcess();
void switchReadChannels();
+ void discardUnwantedOutput();
void setWorkingDirectory();
void setNonExistentWorkingDirectory();
#endif // not Q_OS_WINCE
@@ -2228,6 +2229,25 @@ void tst_QProcess::switchReadChannels()
}
#endif
+#ifndef Q_OS_WINCE
+// Reading and writing to a process is not supported on Qt/CE
+void tst_QProcess::discardUnwantedOutput()
+{
+ QProcess process;
+
+ process.setProgram("testProcessEcho2/testProcessEcho2");
+ process.start(QIODevice::WriteOnly);
+ process.write("Hello, World");
+ process.closeWriteChannel();
+ QVERIFY(process.waitForFinished(5000));
+
+ process.setReadChannel(QProcess::StandardOutput);
+ QCOMPARE(process.bytesAvailable(), Q_INT64_C(0));
+ process.setReadChannel(QProcess::StandardError);
+ QCOMPARE(process.bytesAvailable(), Q_INT64_C(0));
+}
+#endif
+
//-----------------------------------------------------------------------------
#ifndef Q_OS_WINCE
// Q_OS_WIN - setWorkingDirectory will chdir before starting the process on unices