From 29b0a565e9e420a6dc34aaaf3b66976bb75edcb0 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 9 Dec 2013 11:24:56 +0100 Subject: fix Windows CE comments Change-Id: Ib42c456c236f59727dddd6a111dfe0946fff1aef Reviewed-by: Friedemann Kleint --- tests/auto/corelib/io/qprocess/tst_qprocess.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'tests/auto/corelib/io') diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index d248f022ed..d141c11a90 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -538,7 +538,6 @@ void tst_QProcess::echoTest2() #endif #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) -//Batch files are not supported on Winfows CE // Reading and writing to a process is not supported on Qt/CE //----------------------------------------------------------------------------- void tst_QProcess::echoTestGui() @@ -560,7 +559,7 @@ void tst_QProcess::echoTestGui() //----------------------------------------------------------------------------- #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) -//Batch files are not supported on Winfows CE +// Batch files are not supported on Windows CE void tst_QProcess::batFiles_data() { QTest::addColumn("batFile"); -- cgit v1.2.3 From 7009843ae3b12fe86d21040ad96add335c7df5a5 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 9 Dec 2013 10:54:12 +0100 Subject: QProcess/Win: allow child processes to change modes of the stdin pipe To be able to call SetNamedPipeHandleState on stdin in a child process, we must create a read-end pipe handle with the FILE_WRITE_ATTRIBUTES flag set. This can't be done with CreateNamedPipe but only with CreateFile. Therefore we're creating the handles for the child process always with CreateFile now. Besides, it's conceptually cleaner to have the server handle of the named pipe in the calling process. [ChangeLog][QtCore][Windows] Fix regression from Qt4 in QProcess. It wasn't possible anymore to alter pipe modes of stdin in child processes. Task-number: QTBUG-35357 Change-Id: I85f09753d0c924bdc8a6cef1ea5dbe6b2299c604 Reviewed-by: Friedemann Kleint Reviewed-by: Oswald Buddenhagen --- tests/auto/corelib/io/qprocess/qprocess.pro | 6 ++- .../qprocess/testSetNamedPipeHandleState/main.cpp | 50 ++++++++++++++++++++++ .../testSetNamedPipeHandleState.pro | 4 ++ tests/auto/corelib/io/qprocess/tst_qprocess.cpp | 12 ++++++ 4 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 tests/auto/corelib/io/qprocess/testSetNamedPipeHandleState/main.cpp create mode 100644 tests/auto/corelib/io/qprocess/testSetNamedPipeHandleState/testSetNamedPipeHandleState.pro (limited to 'tests/auto/corelib/io') diff --git a/tests/auto/corelib/io/qprocess/qprocess.pro b/tests/auto/corelib/io/qprocess/qprocess.pro index 4155e3f73d..6ba54b1e92 100644 --- a/tests/auto/corelib/io/qprocess/qprocess.pro +++ b/tests/auto/corelib/io/qprocess/qprocess.pro @@ -8,7 +8,11 @@ SUBDIRS += testProcessSpacesArgs/nospace.pro \ testProcessSpacesArgs/twospaces.pro \ testSpaceInName -win32:!wince*:SUBDIRS+=testProcessEchoGui +win32:!wince* { + SUBDIRS += \ + testProcessEchoGui \ + testSetNamedPipeHandleState +} test.depends += $$SUBDIRS SUBDIRS += test diff --git a/tests/auto/corelib/io/qprocess/testSetNamedPipeHandleState/main.cpp b/tests/auto/corelib/io/qprocess/testSetNamedPipeHandleState/main.cpp new file mode 100644 index 0000000000..b2cc793b51 --- /dev/null +++ b/tests/auto/corelib/io/qprocess/testSetNamedPipeHandleState/main.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +int main() +{ + DWORD mode = PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT; + if (SetNamedPipeHandleState(GetStdHandle(STD_INPUT_HANDLE), &mode, NULL, NULL)) + return 0; + return GetLastError(); +} diff --git a/tests/auto/corelib/io/qprocess/testSetNamedPipeHandleState/testSetNamedPipeHandleState.pro b/tests/auto/corelib/io/qprocess/testSetNamedPipeHandleState/testSetNamedPipeHandleState.pro new file mode 100644 index 0000000000..e236e05c7d --- /dev/null +++ b/tests/auto/corelib/io/qprocess/testSetNamedPipeHandleState/testSetNamedPipeHandleState.pro @@ -0,0 +1,4 @@ +SOURCES = main.cpp +CONFIG -= qt app_bundle +CONFIG += console +DESTDIR = ./ diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index d141c11a90..37f224ff28 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -93,6 +93,7 @@ private slots: void echoTest2(); #ifdef Q_OS_WIN void echoTestGui(); + void testSetNamedPipeHandleState(); void batFiles_data(); void batFiles(); #endif @@ -555,6 +556,17 @@ void tst_QProcess::echoTestGui() QCOMPARE(process.readAllStandardOutput(), QByteArray("Hello")); QCOMPARE(process.readAllStandardError(), QByteArray("Hello")); } + +void tst_QProcess::testSetNamedPipeHandleState() +{ + QProcess process; + process.setProcessChannelMode(QProcess::SeparateChannels); + process.start("testSetNamedPipeHandleState/testSetNamedPipeHandleState"); + QVERIFY2(process.waitForStarted(5000), qPrintable(process.errorString())); + QVERIFY(process.waitForFinished(5000)); + QCOMPARE(process.exitCode(), 0); + QCOMPARE(process.exitStatus(), QProcess::NormalExit); +} #endif // !Q_OS_WINCE && Q_OS_WIN //----------------------------------------------------------------------------- -- cgit v1.2.3