diff options
author | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2013-09-03 22:06:26 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-05 21:17:44 +0200 |
commit | 50a8a5e7959ca315e812413661a76576b7c3bbb8 (patch) | |
tree | fadd591bb515323705ee372ea069b58471eedb07 /tests/auto | |
parent | fba0a307914772b286e8f315e0d1dec5ce7935f8 (diff) |
add QProcess::InputChannelMode
this enables forwarding standard input from the parent process.
Change-Id: I7ee72b9842acc96320d4da693b95dd15d9a7b4d4
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/corelib/io/qprocess/testForwarding/main.cpp | 9 | ||||
-rw-r--r-- | tests/auto/corelib/io/qprocess/tst_qprocess.cpp | 17 |
2 files changed, 19 insertions, 7 deletions
diff --git a/tests/auto/corelib/io/qprocess/testForwarding/main.cpp b/tests/auto/corelib/io/qprocess/testForwarding/main.cpp index deff2b95ad..42394f6414 100644 --- a/tests/auto/corelib/io/qprocess/testForwarding/main.cpp +++ b/tests/auto/corelib/io/qprocess/testForwarding/main.cpp @@ -48,7 +48,7 @@ int main(int argc, char **argv) { QCoreApplication app(argc, argv); - if (argc < 2) + if (argc < 3) return 13; #ifndef QT_NO_PROCESS @@ -59,12 +59,17 @@ int main(int argc, char **argv) if (process.processChannelMode() != mode) return 1; + QProcess::InputChannelMode inmode = (QProcess::InputChannelMode)atoi(argv[2]); + process.setInputChannelMode(inmode); + if (process.inputChannelMode() != inmode) + return 11; + process.start("testProcessEcho2/testProcessEcho2"); if (!process.waitForStarted(5000)) return 2; - if (process.write("forwarded") != 9) + if (inmode == QProcess::ManagedInputChannel && process.write("forwarded") != 9) return 3; process.closeWriteChannel(); diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index e03c1fb75e..d248f022ed 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -1094,33 +1094,40 @@ void tst_QProcess::mergedChannels() void tst_QProcess::forwardedChannels_data() { QTest::addColumn<int>("mode"); + QTest::addColumn<int>("inmode"); QTest::addColumn<QByteArray>("outdata"); QTest::addColumn<QByteArray>("errdata"); - QTest::newRow("separate") << int(QProcess::SeparateChannels) + QTest::newRow("separate") << int(QProcess::SeparateChannels) << int(QProcess::ManagedInputChannel) << QByteArray() << QByteArray(); - QTest::newRow("forwarded") << int(QProcess::ForwardedChannels) + QTest::newRow("forwarded") << int(QProcess::ForwardedChannels) << int(QProcess::ManagedInputChannel) << QByteArray("forwarded") << QByteArray("forwarded"); - QTest::newRow("stdout") << int(QProcess::ForwardedOutputChannel) + QTest::newRow("stdout") << int(QProcess::ForwardedOutputChannel) << int(QProcess::ManagedInputChannel) << QByteArray("forwarded") << QByteArray(); - QTest::newRow("stderr") << int(QProcess::ForwardedErrorChannel) + QTest::newRow("stderr") << int(QProcess::ForwardedErrorChannel) << int(QProcess::ManagedInputChannel) << QByteArray() << QByteArray("forwarded"); + QTest::newRow("fwdinput") << int(QProcess::ForwardedErrorChannel) << int(QProcess::ForwardedInputChannel) + << QByteArray() << QByteArray("input"); } void tst_QProcess::forwardedChannels() { QFETCH(int, mode); + QFETCH(int, inmode); QFETCH(QByteArray, outdata); QFETCH(QByteArray, errdata); QProcess process; - process.start("testForwarding/testForwarding", QStringList() << QString::number(mode)); + process.start("testForwarding/testForwarding", QStringList() << QString::number(mode) << QString::number(inmode)); QVERIFY(process.waitForStarted(5000)); + QCOMPARE(process.write("input"), 5); + process.closeWriteChannel(); QVERIFY(process.waitForFinished(5000)); const char *err; switch (process.exitCode()) { case 0: err = "ok"; break; case 1: err = "processChannelMode is wrong"; break; + case 11: err = "inputChannelMode is wrong"; break; case 2: err = "failed to start"; break; case 3: err = "failed to write"; break; case 4: err = "did not finish"; break; |