Test: refactor tst_QProcess
Remove QSKIP and instead omit the whole tests when appropriate. Remove QSKIP from crashTest, crashTest2 and exitStatus on Windows, the tests are now passing. Add a guard in testForwarding to check if QT_NO_PROCESS is defined. Change-Id: Icba4d773315e3bf87764a381742168b51cf169c0 Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
This commit is contained in:
parent
9c0544f884
commit
2eefa819c4
@ -43,6 +43,7 @@
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
#ifndef QT_NO_PROCESS
|
||||||
QProcess process;
|
QProcess process;
|
||||||
process.setProcessChannelMode(QProcess::ForwardedChannels);
|
process.setProcessChannelMode(QProcess::ForwardedChannels);
|
||||||
if (process.processChannelMode() != QProcess::ForwardedChannels)
|
if (process.processChannelMode() != QProcess::ForwardedChannels)
|
||||||
@ -62,6 +63,6 @@ int main()
|
|||||||
|
|
||||||
process.closeWriteChannel();
|
process.closeWriteChannel();
|
||||||
process.waitForFinished(5000);
|
process.waitForFinished(5000);
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,8 @@ class tst_QProcess : public QObject
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void initTestCase();
|
void initTestCase();
|
||||||
|
void cleanupTestCase();
|
||||||
|
|
||||||
#ifndef QT_NO_PROCESS
|
#ifndef QT_NO_PROCESS
|
||||||
private slots:
|
private slots:
|
||||||
void getSetCheck();
|
void getSetCheck();
|
||||||
@ -84,27 +86,23 @@ private slots:
|
|||||||
void startDetached();
|
void startDetached();
|
||||||
void crashTest();
|
void crashTest();
|
||||||
void crashTest2();
|
void crashTest2();
|
||||||
|
#ifndef Q_OS_WINCE
|
||||||
void echoTest_data();
|
void echoTest_data();
|
||||||
void echoTest();
|
void echoTest();
|
||||||
void echoTest2();
|
void echoTest2();
|
||||||
#if defined Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
void echoTestGui();
|
void echoTestGui();
|
||||||
void batFiles_data();
|
void batFiles_data();
|
||||||
void batFiles();
|
void batFiles();
|
||||||
#endif
|
#endif
|
||||||
void exitStatus_data();
|
|
||||||
void exitStatus();
|
|
||||||
void loopBackTest();
|
void loopBackTest();
|
||||||
void readTimeoutAndThenCrash();
|
void readTimeoutAndThenCrash();
|
||||||
void waitForFinished();
|
|
||||||
void deadWhileReading();
|
void deadWhileReading();
|
||||||
void restartProcessDeadlock();
|
void restartProcessDeadlock();
|
||||||
void closeWriteChannel();
|
void closeWriteChannel();
|
||||||
void closeReadChannel();
|
void closeReadChannel();
|
||||||
void openModes();
|
void openModes();
|
||||||
void emitReadyReadOnlyWhenNewDataArrives();
|
void emitReadyReadOnlyWhenNewDataArrives();
|
||||||
void hardExit();
|
|
||||||
void softExit();
|
|
||||||
void softExitInSlots_data();
|
void softExitInSlots_data();
|
||||||
void softExitInSlots();
|
void softExitInSlots();
|
||||||
void mergedChannels();
|
void mergedChannels();
|
||||||
@ -112,25 +110,14 @@ private slots:
|
|||||||
void forwardedChannelsOutput();
|
void forwardedChannelsOutput();
|
||||||
void atEnd();
|
void atEnd();
|
||||||
void atEnd2();
|
void atEnd2();
|
||||||
void processInAThread();
|
|
||||||
void processesInMultipleThreads();
|
|
||||||
void waitForFinishedWithTimeout();
|
void waitForFinishedWithTimeout();
|
||||||
void waitForReadyReadInAReadyReadSlot();
|
void waitForReadyReadInAReadyReadSlot();
|
||||||
void waitForBytesWrittenInABytesWrittenSlot();
|
void waitForBytesWrittenInABytesWrittenSlot();
|
||||||
void spaceArgsTest_data();
|
|
||||||
void spaceArgsTest();
|
|
||||||
#if defined(Q_OS_WIN)
|
|
||||||
void nativeArguments();
|
|
||||||
#endif
|
|
||||||
void exitCodeTest();
|
|
||||||
void setEnvironment_data();
|
void setEnvironment_data();
|
||||||
void setEnvironment();
|
void setEnvironment();
|
||||||
void setProcessEnvironment_data();
|
void setProcessEnvironment_data();
|
||||||
void setProcessEnvironment();
|
void setProcessEnvironment();
|
||||||
void systemEnvironment();
|
|
||||||
void spaceInName();
|
void spaceInName();
|
||||||
void lockupsInStartDetached();
|
|
||||||
void waitForReadyReadForNonexistantProcess();
|
|
||||||
void setStandardInputFile();
|
void setStandardInputFile();
|
||||||
void setStandardOutputFile_data();
|
void setStandardOutputFile_data();
|
||||||
void setStandardOutputFile();
|
void setStandardOutputFile();
|
||||||
@ -138,9 +125,29 @@ private slots:
|
|||||||
void setStandardOutputProcess();
|
void setStandardOutputProcess();
|
||||||
void removeFileWhileProcessIsRunning();
|
void removeFileWhileProcessIsRunning();
|
||||||
void fileWriterProcess();
|
void fileWriterProcess();
|
||||||
void detachedWorkingDirectoryAndPid();
|
|
||||||
void switchReadChannels();
|
void switchReadChannels();
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
void setWorkingDirectory();
|
void setWorkingDirectory();
|
||||||
|
#endif // Q_OS_WIN
|
||||||
|
#endif // not Q_OS_WINCE
|
||||||
|
|
||||||
|
void exitStatus_data();
|
||||||
|
void exitStatus();
|
||||||
|
void waitForFinished();
|
||||||
|
void hardExit();
|
||||||
|
void softExit();
|
||||||
|
void processInAThread();
|
||||||
|
void processesInMultipleThreads();
|
||||||
|
void spaceArgsTest_data();
|
||||||
|
void spaceArgsTest();
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
void nativeArguments();
|
||||||
|
#endif
|
||||||
|
void exitCodeTest();
|
||||||
|
void systemEnvironment();
|
||||||
|
void lockupsInStartDetached();
|
||||||
|
void waitForReadyReadForNonexistantProcess();
|
||||||
|
void detachedWorkingDirectoryAndPid();
|
||||||
void startFinishStartFinish();
|
void startFinishStartFinish();
|
||||||
void invalidProgramString_data();
|
void invalidProgramString_data();
|
||||||
void invalidProgramString();
|
void invalidProgramString();
|
||||||
@ -155,14 +162,16 @@ private slots:
|
|||||||
protected slots:
|
protected slots:
|
||||||
void readFromProcess();
|
void readFromProcess();
|
||||||
void exitLoopSlot();
|
void exitLoopSlot();
|
||||||
|
#ifndef Q_OS_WINCE
|
||||||
void restartProcess();
|
void restartProcess();
|
||||||
void waitForReadyReadInAReadyReadSlotSlot();
|
void waitForReadyReadInAReadyReadSlotSlot();
|
||||||
void waitForBytesWrittenInABytesWrittenSlotSlot();
|
void waitForBytesWrittenInABytesWrittenSlotSlot();
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QProcess *process;
|
QProcess *process;
|
||||||
qint64 bytesAvailable;
|
qint64 bytesAvailable;
|
||||||
#endif
|
#endif //QT_NO_PROCESS
|
||||||
};
|
};
|
||||||
|
|
||||||
void tst_QProcess::initTestCase()
|
void tst_QProcess::initTestCase()
|
||||||
@ -176,6 +185,13 @@ void tst_QProcess::initTestCase()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QProcess::cleanupTestCase()
|
||||||
|
{
|
||||||
|
#ifdef QT_NO_PROCESS
|
||||||
|
QSKIP("This test requires QProcess support");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_PROCESS
|
#ifndef QT_NO_PROCESS
|
||||||
|
|
||||||
// Testing get/set functions
|
// Testing get/set functions
|
||||||
@ -299,9 +315,6 @@ void tst_QProcess::readFromProcess()
|
|||||||
void tst_QProcess::crashTest()
|
void tst_QProcess::crashTest()
|
||||||
{
|
{
|
||||||
qRegisterMetaType<QProcess::ProcessState>("QProcess::ProcessState");
|
qRegisterMetaType<QProcess::ProcessState>("QProcess::ProcessState");
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
QSKIP("This test opens a crash dialog on Windows");
|
|
||||||
#endif
|
|
||||||
process = new QProcess;
|
process = new QProcess;
|
||||||
QSignalSpy stateSpy(process, SIGNAL(stateChanged(QProcess::ProcessState)));
|
QSignalSpy stateSpy(process, SIGNAL(stateChanged(QProcess::ProcessState)));
|
||||||
QVERIFY(stateSpy.isValid());
|
QVERIFY(stateSpy.isValid());
|
||||||
@ -339,9 +352,6 @@ void tst_QProcess::crashTest()
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void tst_QProcess::crashTest2()
|
void tst_QProcess::crashTest2()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
QSKIP("This test opens a crash dialog on Windows");
|
|
||||||
#endif
|
|
||||||
process = new QProcess;
|
process = new QProcess;
|
||||||
process->start("testProcessCrash/testProcessCrash");
|
process->start("testProcessCrash/testProcessCrash");
|
||||||
QVERIFY(process->waitForStarted(5000));
|
QVERIFY(process->waitForStarted(5000));
|
||||||
@ -373,6 +383,8 @@ void tst_QProcess::crashTest2()
|
|||||||
process = 0;
|
process = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef Q_OS_WINCE
|
||||||
|
//Reading and writing to a process is not supported on Qt/CE
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void tst_QProcess::echoTest_data()
|
void tst_QProcess::echoTest_data()
|
||||||
{
|
{
|
||||||
@ -389,12 +401,9 @@ void tst_QProcess::echoTest_data()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
void tst_QProcess::echoTest()
|
void tst_QProcess::echoTest()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WINCE
|
|
||||||
QSKIP("Reading and writing to a process is not supported on Qt/CE");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QFETCH(QByteArray, input);
|
QFETCH(QByteArray, input);
|
||||||
|
|
||||||
process = new QProcess;
|
process = new QProcess;
|
||||||
@ -435,6 +444,7 @@ void tst_QProcess::echoTest()
|
|||||||
delete process;
|
delete process;
|
||||||
process = 0;
|
process = 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void tst_QProcess::exitLoopSlot()
|
void tst_QProcess::exitLoopSlot()
|
||||||
@ -443,11 +453,11 @@ void tst_QProcess::exitLoopSlot()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifndef Q_OS_WINCE
|
||||||
|
// Reading and writing to a process is not supported on Qt/CE
|
||||||
void tst_QProcess::echoTest2()
|
void tst_QProcess::echoTest2()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WINCE
|
|
||||||
QSKIP("Reading and writing to a process is not supported on Qt/CE");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
process = new QProcess;
|
process = new QProcess;
|
||||||
connect(process, SIGNAL(readyRead()), this, SLOT(exitLoopSlot()));
|
connect(process, SIGNAL(readyRead()), this, SLOT(exitLoopSlot()));
|
||||||
@ -491,15 +501,14 @@ void tst_QProcess::echoTest2()
|
|||||||
delete process;
|
delete process;
|
||||||
process = 0;
|
process = 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined Q_OS_WIN
|
#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()
|
void tst_QProcess::echoTestGui()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WINCE
|
|
||||||
QSKIP("Reading and writing to a process is not supported on Qt/CE");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QProcess process;
|
QProcess process;
|
||||||
|
|
||||||
process.start("testProcessEchoGui/testProcessEchoGui");
|
process.start("testProcessEchoGui/testProcessEchoGui");
|
||||||
@ -513,8 +522,11 @@ void tst_QProcess::echoTestGui()
|
|||||||
QCOMPARE(process.readAllStandardOutput(), QByteArray("Hello"));
|
QCOMPARE(process.readAllStandardOutput(), QByteArray("Hello"));
|
||||||
QCOMPARE(process.readAllStandardError(), QByteArray("Hello"));
|
QCOMPARE(process.readAllStandardError(), QByteArray("Hello"));
|
||||||
}
|
}
|
||||||
|
#endif // !Q_OS_WINCE && Q_OS_WIN
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
|
||||||
|
//Batch files are not supported on Winfows CE
|
||||||
void tst_QProcess::batFiles_data()
|
void tst_QProcess::batFiles_data()
|
||||||
{
|
{
|
||||||
QTest::addColumn<QString>("batFile");
|
QTest::addColumn<QString>("batFile");
|
||||||
@ -526,9 +538,6 @@ void tst_QProcess::batFiles_data()
|
|||||||
|
|
||||||
void tst_QProcess::batFiles()
|
void tst_QProcess::batFiles()
|
||||||
{
|
{
|
||||||
#if defined(Q_OS_WINCE)
|
|
||||||
QSKIP("Batch files are not supported on Windows CE");
|
|
||||||
#endif
|
|
||||||
QFETCH(QString, batFile);
|
QFETCH(QString, batFile);
|
||||||
QFETCH(QByteArray, output);
|
QFETCH(QByteArray, output);
|
||||||
|
|
||||||
@ -542,8 +551,7 @@ void tst_QProcess::batFiles()
|
|||||||
|
|
||||||
QVERIFY(proc.readAll().startsWith(output));
|
QVERIFY(proc.readAll().startsWith(output));
|
||||||
}
|
}
|
||||||
|
#endif // !Q_OS_WINCE && Q_OS_WIN
|
||||||
#endif
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void tst_QProcess::exitStatus_data()
|
void tst_QProcess::exitStatus_data()
|
||||||
@ -576,11 +584,6 @@ void tst_QProcess::exitStatus()
|
|||||||
QFETCH(QStringList, processList);
|
QFETCH(QStringList, processList);
|
||||||
QFETCH(QList<QProcess::ExitStatus>, exitStatus);
|
QFETCH(QList<QProcess::ExitStatus>, exitStatus);
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
if (exitStatus.contains(QProcess::CrashExit))
|
|
||||||
QSKIP("This test opens a crash dialog on Windows");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QCOMPARE(exitStatus.count(), processList.count());
|
QCOMPARE(exitStatus.count(), processList.count());
|
||||||
for (int i = 0; i < processList.count(); ++i) {
|
for (int i = 0; i < processList.count(); ++i) {
|
||||||
process->start(processList.at(i));
|
process->start(processList.at(i));
|
||||||
@ -594,11 +597,10 @@ void tst_QProcess::exitStatus()
|
|||||||
process = 0;
|
process = 0;
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
#ifndef Q_OS_WINCE
|
||||||
|
// Reading and writing to a process is not supported on Qt/CE
|
||||||
void tst_QProcess::loopBackTest()
|
void tst_QProcess::loopBackTest()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WINCE
|
|
||||||
QSKIP("Reading and writing to a process is not supported on Qt/CE");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
process = new QProcess;
|
process = new QProcess;
|
||||||
process->start("testProcessEcho/testProcessEcho");
|
process->start("testProcessEcho/testProcessEcho");
|
||||||
@ -618,13 +620,13 @@ void tst_QProcess::loopBackTest()
|
|||||||
delete process;
|
delete process;
|
||||||
process = 0;
|
process = 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
#ifndef Q_OS_WINCE
|
||||||
|
// Reading and writing to a process is not supported on Qt/CE
|
||||||
void tst_QProcess::readTimeoutAndThenCrash()
|
void tst_QProcess::readTimeoutAndThenCrash()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WINCE
|
|
||||||
QSKIP("Reading and writing to a process is not supported on Qt/CE");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
process = new QProcess;
|
process = new QProcess;
|
||||||
process->start("testProcessEcho/testProcessEcho");
|
process->start("testProcessEcho/testProcessEcho");
|
||||||
@ -652,6 +654,7 @@ void tst_QProcess::readTimeoutAndThenCrash()
|
|||||||
delete process;
|
delete process;
|
||||||
process = 0;
|
process = 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void tst_QProcess::waitForFinished()
|
void tst_QProcess::waitForFinished()
|
||||||
{
|
{
|
||||||
@ -677,12 +680,10 @@ void tst_QProcess::waitForFinished()
|
|||||||
QCOMPARE(process.error(), QProcess::FailedToStart);
|
QCOMPARE(process.error(), QProcess::FailedToStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef Q_OS_WINCE
|
||||||
|
// Reading and writing to a process is not supported on Qt/CE
|
||||||
void tst_QProcess::deadWhileReading()
|
void tst_QProcess::deadWhileReading()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WINCE
|
|
||||||
QSKIP("Reading and writing to a process is not supported on Qt/CE");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QProcess process;
|
QProcess process;
|
||||||
|
|
||||||
process.start("testProcessDeadWhileReading/testProcessDeadWhileReading");
|
process.start("testProcessDeadWhileReading/testProcessDeadWhileReading");
|
||||||
@ -696,13 +697,13 @@ void tst_QProcess::deadWhileReading()
|
|||||||
QCOMPARE(output.count("\n"), 10*1024);
|
QCOMPARE(output.count("\n"), 10*1024);
|
||||||
process.waitForFinished();
|
process.waitForFinished();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
#ifndef Q_OS_WINCE
|
||||||
|
// Reading and writing to a process is not supported on Qt/CE
|
||||||
void tst_QProcess::restartProcessDeadlock()
|
void tst_QProcess::restartProcessDeadlock()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WINCE
|
|
||||||
QSKIP("Reading and writing to a process is not supported on Qt/CE");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// The purpose of this test is to detect whether restarting a
|
// The purpose of this test is to detect whether restarting a
|
||||||
// process in the finished() connected slot causes a deadlock
|
// process in the finished() connected slot causes a deadlock
|
||||||
@ -726,14 +727,13 @@ void tst_QProcess::restartProcess()
|
|||||||
{
|
{
|
||||||
process->start("testProcessEcho/testProcessEcho");
|
process->start("testProcessEcho/testProcessEcho");
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void tst_QProcess::closeWriteChannel()
|
|
||||||
{
|
|
||||||
#ifdef Q_OS_WINCE
|
|
||||||
QSKIP("Reading and writing to a process is not supported on Qt/CE");
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
#ifndef Q_OS_WINCE
|
||||||
|
// Reading and writing to a process is not supported on Qt/CE
|
||||||
|
void tst_QProcess::closeWriteChannel()
|
||||||
|
{
|
||||||
QProcess more;
|
QProcess more;
|
||||||
more.start("testProcessEOF/testProcessEOF");
|
more.start("testProcessEOF/testProcessEOF");
|
||||||
|
|
||||||
@ -755,14 +755,13 @@ void tst_QProcess::closeWriteChannel()
|
|||||||
more.write("q");
|
more.write("q");
|
||||||
QVERIFY(more.waitForFinished(5000));
|
QVERIFY(more.waitForFinished(5000));
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void tst_QProcess::closeReadChannel()
|
|
||||||
{
|
|
||||||
#ifdef Q_OS_WINCE
|
|
||||||
QSKIP("Reading and writing to a process is not supported on Qt/CE");
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
#ifndef Q_OS_WINCE
|
||||||
|
// Reading and writing to a process is not supported on Qt/CE"
|
||||||
|
void tst_QProcess::closeReadChannel()
|
||||||
|
{
|
||||||
for (int i = 0; i < 10; ++i) {
|
for (int i = 0; i < 10; ++i) {
|
||||||
QProcess::ProcessChannel channel1 = QProcess::StandardOutput;
|
QProcess::ProcessChannel channel1 = QProcess::StandardOutput;
|
||||||
QProcess::ProcessChannel channel2 = QProcess::StandardError;
|
QProcess::ProcessChannel channel2 = QProcess::StandardError;
|
||||||
@ -788,14 +787,13 @@ void tst_QProcess::closeReadChannel()
|
|||||||
QVERIFY(proc.waitForFinished(5000));
|
QVERIFY(proc.waitForFinished(5000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void tst_QProcess::openModes()
|
|
||||||
{
|
|
||||||
#ifdef Q_OS_WINCE
|
|
||||||
QSKIP("Reading and writing to a process is not supported on Qt/CE");
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
#ifndef Q_OS_WINCE
|
||||||
|
// Reading and writing to a process is not supported on Qt/CE
|
||||||
|
void tst_QProcess::openModes()
|
||||||
|
{
|
||||||
QProcess proc;
|
QProcess proc;
|
||||||
QVERIFY(!proc.isOpen());
|
QVERIFY(!proc.isOpen());
|
||||||
QVERIFY(proc.openMode() == QProcess::NotOpen);
|
QVERIFY(proc.openMode() == QProcess::NotOpen);
|
||||||
@ -834,13 +832,13 @@ void tst_QProcess::openModes()
|
|||||||
QVERIFY(!proc.isWritable());
|
QVERIFY(!proc.isWritable());
|
||||||
QCOMPARE(proc.state(), QProcess::NotRunning);
|
QCOMPARE(proc.state(), QProcess::NotRunning);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
#ifndef Q_OS_WINCE
|
||||||
|
// Reading and writing to a process is not supported on Qt/CE
|
||||||
void tst_QProcess::emitReadyReadOnlyWhenNewDataArrives()
|
void tst_QProcess::emitReadyReadOnlyWhenNewDataArrives()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WINCE
|
|
||||||
QSKIP("Reading and writing to a process is not supported on Qt/CE");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QProcess proc;
|
QProcess proc;
|
||||||
connect(&proc, SIGNAL(readyRead()), this, SLOT(exitLoopSlot()));
|
connect(&proc, SIGNAL(readyRead()), this, SLOT(exitLoopSlot()));
|
||||||
@ -870,6 +868,7 @@ void tst_QProcess::emitReadyReadOnlyWhenNewDataArrives()
|
|||||||
proc.write("", 1);
|
proc.write("", 1);
|
||||||
QVERIFY(proc.waitForFinished(5000));
|
QVERIFY(proc.waitForFinished(5000));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void tst_QProcess::hardExit()
|
void tst_QProcess::hardExit()
|
||||||
@ -914,6 +913,8 @@ void tst_QProcess::softExit()
|
|||||||
QCOMPARE(int(proc.error()), int(QProcess::UnknownError));
|
QCOMPARE(int(proc.error()), int(QProcess::UnknownError));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef Q_OS_WINCE
|
||||||
|
// Reading and writing to a process is not supported on Qt/CE
|
||||||
class SoftExitProcess : public QProcess
|
class SoftExitProcess : public QProcess
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -1011,14 +1012,10 @@ void tst_QProcess::softExitInSlots_data()
|
|||||||
#endif
|
#endif
|
||||||
QTest::newRow("console app") << "testProcessEcho2/testProcessEcho2";
|
QTest::newRow("console app") << "testProcessEcho2/testProcessEcho2";
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
void tst_QProcess::softExitInSlots()
|
void tst_QProcess::softExitInSlots()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WINCE
|
|
||||||
QSKIP("Reading and writing to a process is not supported on Qt/CE");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QFETCH(QString, appName);
|
QFETCH(QString, appName);
|
||||||
|
|
||||||
for (int i = 0; i < 5; ++i) {
|
for (int i = 0; i < 5; ++i) {
|
||||||
@ -1029,14 +1026,13 @@ void tst_QProcess::softExitInSlots()
|
|||||||
QCOMPARE(proc.state(), QProcess::NotRunning);
|
QCOMPARE(proc.state(), QProcess::NotRunning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void tst_QProcess::mergedChannels()
|
|
||||||
{
|
|
||||||
#ifdef Q_OS_WINCE
|
|
||||||
QSKIP("Reading and writing to a process is not supported on Qt/CE");
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
#ifndef Q_OS_WINCE
|
||||||
|
// Reading and writing to a process is not supported on Qt/CE
|
||||||
|
void tst_QProcess::mergedChannels()
|
||||||
|
{
|
||||||
QProcess process;
|
QProcess process;
|
||||||
process.setReadChannelMode(QProcess::MergedChannels);
|
process.setReadChannelMode(QProcess::MergedChannels);
|
||||||
QCOMPARE(process.readChannelMode(), QProcess::MergedChannels);
|
QCOMPARE(process.readChannelMode(), QProcess::MergedChannels);
|
||||||
@ -1055,14 +1051,13 @@ void tst_QProcess::mergedChannels()
|
|||||||
process.closeWriteChannel();
|
process.closeWriteChannel();
|
||||||
QVERIFY(process.waitForFinished(5000));
|
QVERIFY(process.waitForFinished(5000));
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void tst_QProcess::forwardedChannels()
|
|
||||||
{
|
|
||||||
#ifdef Q_OS_WINCE
|
|
||||||
QSKIP("Reading and writing to a process is not supported on Qt/CE");
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
#ifndef Q_OS_WINCE
|
||||||
|
// Reading and writing to a process is not supported on Qt/CE
|
||||||
|
void tst_QProcess::forwardedChannels()
|
||||||
|
{
|
||||||
QProcess process;
|
QProcess process;
|
||||||
process.setReadChannelMode(QProcess::ForwardedChannels);
|
process.setReadChannelMode(QProcess::ForwardedChannels);
|
||||||
QCOMPARE(process.readChannelMode(), QProcess::ForwardedChannels);
|
QCOMPARE(process.readChannelMode(), QProcess::ForwardedChannels);
|
||||||
@ -1077,13 +1072,12 @@ void tst_QProcess::forwardedChannels()
|
|||||||
process.closeWriteChannel();
|
process.closeWriteChannel();
|
||||||
QVERIFY(process.waitForFinished(5000));
|
QVERIFY(process.waitForFinished(5000));
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QProcess::forwardedChannelsOutput()
|
|
||||||
{
|
|
||||||
#ifdef Q_OS_WINCE
|
|
||||||
QSKIP("Reading and writing to a process is not supported on Qt/CE");
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef Q_OS_WINCE
|
||||||
|
// Reading and writing to a process is not supported on Qt/CE
|
||||||
|
void tst_QProcess::forwardedChannelsOutput()
|
||||||
|
{
|
||||||
QProcess process;
|
QProcess process;
|
||||||
process.start("testForwarding/testForwarding");
|
process.start("testForwarding/testForwarding");
|
||||||
QVERIFY(process.waitForStarted(5000));
|
QVERIFY(process.waitForStarted(5000));
|
||||||
@ -1093,14 +1087,13 @@ void tst_QProcess::forwardedChannelsOutput()
|
|||||||
QVERIFY(!data.isEmpty());
|
QVERIFY(!data.isEmpty());
|
||||||
QVERIFY(data.contains("forwarded"));
|
QVERIFY(data.contains("forwarded"));
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void tst_QProcess::atEnd()
|
|
||||||
{
|
|
||||||
#ifdef Q_OS_WINCE
|
|
||||||
QSKIP("Reading and writing to a process is not supported on Qt/CE");
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
#ifndef Q_OS_WINCE
|
||||||
|
// Reading and writing to a process is not supported on Qt/CE
|
||||||
|
void tst_QProcess::atEnd()
|
||||||
|
{
|
||||||
QProcess process;
|
QProcess process;
|
||||||
|
|
||||||
process.start("testProcessEcho/testProcessEcho");
|
process.start("testProcessEcho/testProcessEcho");
|
||||||
@ -1118,6 +1111,7 @@ void tst_QProcess::atEnd()
|
|||||||
process.write("", 1);
|
process.write("", 1);
|
||||||
QVERIFY(process.waitForFinished(5000));
|
QVERIFY(process.waitForFinished(5000));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
class TestThread : public QThread
|
class TestThread : public QThread
|
||||||
{
|
{
|
||||||
@ -1190,12 +1184,10 @@ void tst_QProcess::processesInMultipleThreads()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
#ifndef Q_OS_WINCE
|
||||||
|
// Reading and writing to a process is not supported on Qt/CE
|
||||||
void tst_QProcess::waitForFinishedWithTimeout()
|
void tst_QProcess::waitForFinishedWithTimeout()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WINCE
|
|
||||||
QSKIP("Reading and writing to a process is not supported on Qt/CE");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
process = new QProcess(this);
|
process = new QProcess(this);
|
||||||
|
|
||||||
process->start("testProcessEcho/testProcessEcho");
|
process->start("testProcessEcho/testProcessEcho");
|
||||||
@ -1210,14 +1202,13 @@ void tst_QProcess::waitForFinishedWithTimeout()
|
|||||||
delete process;
|
delete process;
|
||||||
process = 0;
|
process = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void tst_QProcess::waitForReadyReadInAReadyReadSlot()
|
|
||||||
{
|
|
||||||
#ifdef Q_OS_WINCE
|
|
||||||
QSKIP("Reading and writing to a process is not supported on Qt/CE");
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
#ifndef Q_OS_WINCE
|
||||||
|
// Reading and writing to a process is not supported on Qt/CE
|
||||||
|
void tst_QProcess::waitForReadyReadInAReadyReadSlot()
|
||||||
|
{
|
||||||
process = new QProcess(this);
|
process = new QProcess(this);
|
||||||
connect(process, SIGNAL(readyRead()), this, SLOT(waitForReadyReadInAReadyReadSlotSlot()));
|
connect(process, SIGNAL(readyRead()), this, SLOT(waitForReadyReadInAReadyReadSlotSlot()));
|
||||||
connect(process, SIGNAL(finished(int)), this, SLOT(exitLoopSlot()));
|
connect(process, SIGNAL(finished(int)), this, SLOT(exitLoopSlot()));
|
||||||
@ -1240,27 +1231,25 @@ void tst_QProcess::waitForReadyReadInAReadyReadSlot()
|
|||||||
delete process;
|
delete process;
|
||||||
process = 0;
|
process = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void tst_QProcess::waitForReadyReadInAReadyReadSlotSlot()
|
|
||||||
{
|
|
||||||
#ifdef Q_OS_WINCE
|
|
||||||
QSKIP("Reading and writing to a process is not supported on Qt/CE");
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
#ifndef Q_OS_WINCE
|
||||||
|
// Reading and writing to a process is not supported on Qt/CE
|
||||||
|
void tst_QProcess::waitForReadyReadInAReadyReadSlotSlot()
|
||||||
|
{
|
||||||
bytesAvailable = process->bytesAvailable();
|
bytesAvailable = process->bytesAvailable();
|
||||||
process->write("bar", 4);
|
process->write("bar", 4);
|
||||||
QVERIFY(process->waitForReadyRead(5000));
|
QVERIFY(process->waitForReadyRead(5000));
|
||||||
QTestEventLoop::instance().exitLoop();
|
QTestEventLoop::instance().exitLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void tst_QProcess::waitForBytesWrittenInABytesWrittenSlot()
|
|
||||||
{
|
|
||||||
#ifdef Q_OS_WINCE
|
|
||||||
QSKIP("Reading and writing to a process is not supported on Qt/CE");
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
#ifndef Q_OS_WINCE
|
||||||
|
// Reading and writing to a process is not supported on Qt/CE
|
||||||
|
void tst_QProcess::waitForBytesWrittenInABytesWrittenSlot()
|
||||||
|
{
|
||||||
process = new QProcess(this);
|
process = new QProcess(this);
|
||||||
connect(process, SIGNAL(bytesWritten(qint64)), this, SLOT(waitForBytesWrittenInABytesWrittenSlotSlot()));
|
connect(process, SIGNAL(bytesWritten(qint64)), this, SLOT(waitForBytesWrittenInABytesWrittenSlotSlot()));
|
||||||
bytesAvailable = 0;
|
bytesAvailable = 0;
|
||||||
@ -1282,19 +1271,18 @@ void tst_QProcess::waitForBytesWrittenInABytesWrittenSlot()
|
|||||||
delete process;
|
delete process;
|
||||||
process = 0;
|
process = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void tst_QProcess::waitForBytesWrittenInABytesWrittenSlotSlot()
|
|
||||||
{
|
|
||||||
#ifdef Q_OS_WINCE
|
|
||||||
QSKIP("Reading and writing to a process is not supported on Qt/CE");
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
#ifndef Q_OS_WINCE
|
||||||
|
// Reading and writing to a process is not supported on Qt/CE
|
||||||
|
void tst_QProcess::waitForBytesWrittenInABytesWrittenSlotSlot()
|
||||||
|
{
|
||||||
process->write("b");
|
process->write("b");
|
||||||
QVERIFY(process->waitForBytesWritten(5000));
|
QVERIFY(process->waitForBytesWritten(5000));
|
||||||
QTestEventLoop::instance().exitLoop();
|
QTestEventLoop::instance().exitLoop();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void tst_QProcess::spaceArgsTest_data()
|
void tst_QProcess::spaceArgsTest_data()
|
||||||
{
|
{
|
||||||
@ -1604,12 +1592,10 @@ void tst_QProcess::failToStartWithEventLoop()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
#ifndef Q_OS_WINCE
|
||||||
|
// Reading and writing to a process is not supported on Qt/CE
|
||||||
void tst_QProcess::removeFileWhileProcessIsRunning()
|
void tst_QProcess::removeFileWhileProcessIsRunning()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WINCE
|
|
||||||
QSKIP("Reading and writing to a process is not supported on Qt/CE");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QFile file("removeFile.txt");
|
QFile file("removeFile.txt");
|
||||||
QVERIFY(file.open(QFile::WriteOnly));
|
QVERIFY(file.open(QFile::WriteOnly));
|
||||||
|
|
||||||
@ -1623,8 +1609,10 @@ void tst_QProcess::removeFileWhileProcessIsRunning()
|
|||||||
process.write("", 1);
|
process.write("", 1);
|
||||||
QVERIFY(process.waitForFinished(5000));
|
QVERIFY(process.waitForFinished(5000));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
#ifndef Q_OS_WINCE
|
||||||
|
// OS doesn't support environment variables
|
||||||
void tst_QProcess::setEnvironment_data()
|
void tst_QProcess::setEnvironment_data()
|
||||||
{
|
{
|
||||||
QTest::addColumn<QString>("name");
|
QTest::addColumn<QString>("name");
|
||||||
@ -1644,10 +1632,6 @@ void tst_QProcess::setEnvironment_data()
|
|||||||
|
|
||||||
void tst_QProcess::setEnvironment()
|
void tst_QProcess::setEnvironment()
|
||||||
{
|
{
|
||||||
#if defined (Q_OS_WINCE)
|
|
||||||
QSKIP("OS doesn't support environment variables");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// make sure our environment variables are correct
|
// make sure our environment variables are correct
|
||||||
QVERIFY(qgetenv("tst_QProcess").isEmpty());
|
QVERIFY(qgetenv("tst_QProcess").isEmpty());
|
||||||
QVERIFY(!qgetenv("PATH").isEmpty());
|
QVERIFY(!qgetenv("PATH").isEmpty());
|
||||||
@ -1703,8 +1687,10 @@ void tst_QProcess::setEnvironment()
|
|||||||
QCOMPARE(process.readAll(), value.toLocal8Bit());
|
QCOMPARE(process.readAll(), value.toLocal8Bit());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
#ifndef Q_OS_WINCE
|
||||||
|
// OS doesn't support environment variables
|
||||||
void tst_QProcess::setProcessEnvironment_data()
|
void tst_QProcess::setProcessEnvironment_data()
|
||||||
{
|
{
|
||||||
setEnvironment_data();
|
setEnvironment_data();
|
||||||
@ -1712,10 +1698,6 @@ void tst_QProcess::setProcessEnvironment_data()
|
|||||||
|
|
||||||
void tst_QProcess::setProcessEnvironment()
|
void tst_QProcess::setProcessEnvironment()
|
||||||
{
|
{
|
||||||
#if defined (Q_OS_WINCE)
|
|
||||||
QSKIP("OS doesn't support environment variables");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// make sure our environment variables are correct
|
// make sure our environment variables are correct
|
||||||
QVERIFY(qgetenv("tst_QProcess").isEmpty());
|
QVERIFY(qgetenv("tst_QProcess").isEmpty());
|
||||||
QVERIFY(!qgetenv("PATH").isEmpty());
|
QVERIFY(!qgetenv("PATH").isEmpty());
|
||||||
@ -1746,6 +1728,7 @@ void tst_QProcess::setProcessEnvironment()
|
|||||||
QCOMPARE(process.readAll(), value.toLocal8Bit());
|
QCOMPARE(process.readAll(), value.toLocal8Bit());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void tst_QProcess::systemEnvironment()
|
void tst_QProcess::systemEnvironment()
|
||||||
{
|
{
|
||||||
@ -1763,17 +1746,17 @@ void tst_QProcess::systemEnvironment()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
#ifndef Q_OS_WINCE
|
||||||
|
// Reading and writing to a process is not supported on Qt/CE
|
||||||
void tst_QProcess::spaceInName()
|
void tst_QProcess::spaceInName()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WINCE
|
|
||||||
QSKIP("Reading and writing to a process is not supported on Qt/CE");
|
|
||||||
#endif
|
|
||||||
QProcess process;
|
QProcess process;
|
||||||
process.start("test Space In Name/testSpaceInName", QStringList());
|
process.start("test Space In Name/testSpaceInName", QStringList());
|
||||||
QVERIFY(process.waitForStarted());
|
QVERIFY(process.waitForStarted());
|
||||||
process.write("", 1);
|
process.write("", 1);
|
||||||
QVERIFY(process.waitForFinished());
|
QVERIFY(process.waitForFinished());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void tst_QProcess::lockupsInStartDetached()
|
void tst_QProcess::lockupsInStartDetached()
|
||||||
@ -1790,12 +1773,10 @@ void tst_QProcess::lockupsInStartDetached()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
#ifndef Q_OS_WINCE
|
||||||
|
// Reading and writing to a process is not supported on Qt/CE
|
||||||
void tst_QProcess::atEnd2()
|
void tst_QProcess::atEnd2()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WINCE
|
|
||||||
QSKIP("Reading and writing to a process is not supported on Qt/CE");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QProcess process;
|
QProcess process;
|
||||||
|
|
||||||
process.start("testProcessEcho/testProcessEcho");
|
process.start("testProcessEcho/testProcessEcho");
|
||||||
@ -1808,6 +1789,7 @@ void tst_QProcess::atEnd2()
|
|||||||
}
|
}
|
||||||
QCOMPARE(lines.size(), 7);
|
QCOMPARE(lines.size(), 7);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void tst_QProcess::waitForReadyReadForNonexistantProcess()
|
void tst_QProcess::waitForReadyReadForNonexistantProcess()
|
||||||
@ -1835,12 +1817,10 @@ void tst_QProcess::waitForReadyReadForNonexistantProcess()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
#ifndef Q_OS_WINCE
|
||||||
|
// Reading and writing to a process is not supported on Qt/CE
|
||||||
void tst_QProcess::setStandardInputFile()
|
void tst_QProcess::setStandardInputFile()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WINCE
|
|
||||||
QSKIP("Reading and writing to a process is not supported on Qt/CE");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static const char data[] = "A bunch\1of\2data\3\4\5\6\7...";
|
static const char data[] = "A bunch\1of\2data\3\4\5\6\7...";
|
||||||
QProcess process;
|
QProcess process;
|
||||||
QFile file("data");
|
QFile file("data");
|
||||||
@ -1857,8 +1837,11 @@ void tst_QProcess::setStandardInputFile()
|
|||||||
QCOMPARE(all.size(), int(sizeof data) - 1); // testProcessEcho drops the ending \0
|
QCOMPARE(all.size(), int(sizeof data) - 1); // testProcessEcho drops the ending \0
|
||||||
QVERIFY(all == data);
|
QVERIFY(all == data);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
#ifndef Q_OS_WINCE
|
||||||
|
// Reading and writing to a process is not supported on Qt/CE
|
||||||
void tst_QProcess::setStandardOutputFile_data()
|
void tst_QProcess::setStandardOutputFile_data()
|
||||||
{
|
{
|
||||||
QTest::addColumn<int>("channelToTest");
|
QTest::addColumn<int>("channelToTest");
|
||||||
@ -1889,10 +1872,6 @@ void tst_QProcess::setStandardOutputFile_data()
|
|||||||
|
|
||||||
void tst_QProcess::setStandardOutputFile()
|
void tst_QProcess::setStandardOutputFile()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WINCE
|
|
||||||
QSKIP("Reading and writing to a process is not supported on Qt/CE");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static const char data[] = "Original data. ";
|
static const char data[] = "Original data. ";
|
||||||
static const char testdata[] = "Test data.";
|
static const char testdata[] = "Test data.";
|
||||||
|
|
||||||
@ -1939,8 +1918,11 @@ void tst_QProcess::setStandardOutputFile()
|
|||||||
|
|
||||||
QCOMPARE(all.size(), expectedsize);
|
QCOMPARE(all.size(), expectedsize);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
#ifndef Q_OS_WINCE
|
||||||
|
// Reading and writing to a process is not supported on Qt/CE
|
||||||
void tst_QProcess::setStandardOutputProcess_data()
|
void tst_QProcess::setStandardOutputProcess_data()
|
||||||
{
|
{
|
||||||
QTest::addColumn<bool>("merged");
|
QTest::addColumn<bool>("merged");
|
||||||
@ -1950,9 +1932,6 @@ void tst_QProcess::setStandardOutputProcess_data()
|
|||||||
|
|
||||||
void tst_QProcess::setStandardOutputProcess()
|
void tst_QProcess::setStandardOutputProcess()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WINCE
|
|
||||||
QSKIP("Reading and writing to a process is not supported on Qt/CE");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QProcess source;
|
QProcess source;
|
||||||
QProcess sink;
|
QProcess sink;
|
||||||
@ -1976,14 +1955,13 @@ void tst_QProcess::setStandardOutputProcess()
|
|||||||
else
|
else
|
||||||
QCOMPARE(all, QByteArray("HHeelllloo,, WWoorrlldd"));
|
QCOMPARE(all, QByteArray("HHeelllloo,, WWoorrlldd"));
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void tst_QProcess::fileWriterProcess()
|
|
||||||
{
|
|
||||||
#ifdef Q_OS_WINCE
|
|
||||||
QSKIP("Reading and writing to a process is not supported on Qt/CE");
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
#ifndef Q_OS_WINCE
|
||||||
|
// Reading and writing to a process is not supported on Qt/CE
|
||||||
|
void tst_QProcess::fileWriterProcess()
|
||||||
|
{
|
||||||
QString stdinStr;
|
QString stdinStr;
|
||||||
for (int i = 0; i < 5000; ++i)
|
for (int i = 0; i < 5000; ++i)
|
||||||
stdinStr += QString::fromLatin1("%1 -- testing testing 1 2 3\n").arg(i);
|
stdinStr += QString::fromLatin1("%1 -- testing testing 1 2 3\n").arg(i);
|
||||||
@ -2005,6 +1983,7 @@ void tst_QProcess::fileWriterProcess()
|
|||||||
QCOMPARE(QFile("fileWriterProcess.txt").size(), qint64(stdinStr.size()));
|
QCOMPARE(QFile("fileWriterProcess.txt").size(), qint64(stdinStr.size()));
|
||||||
} while (stopWatch.elapsed() < 3000);
|
} while (stopWatch.elapsed() < 3000);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void tst_QProcess::detachedWorkingDirectoryAndPid()
|
void tst_QProcess::detachedWorkingDirectoryAndPid()
|
||||||
@ -2051,11 +2030,10 @@ void tst_QProcess::detachedWorkingDirectoryAndPid()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
#ifndef Q_OS_WINCE
|
||||||
|
// Reading and writing to a process is not supported on Qt/CE
|
||||||
void tst_QProcess::switchReadChannels()
|
void tst_QProcess::switchReadChannels()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WINCE
|
|
||||||
QSKIP("Reading and writing to a process is not supported on Qt/CE");
|
|
||||||
#endif
|
|
||||||
const char data[] = "ABCD";
|
const char data[] = "ABCD";
|
||||||
|
|
||||||
QProcess process;
|
QProcess process;
|
||||||
@ -2080,16 +2058,14 @@ void tst_QProcess::switchReadChannels()
|
|||||||
process.setReadChannel(QProcess::StandardOutput);
|
process.setReadChannel(QProcess::StandardOutput);
|
||||||
QCOMPARE(process.read(1), QByteArray("D"));
|
QCOMPARE(process.read(1), QByteArray("D"));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
|
||||||
|
// Q_OS_WIN - setWorkingDirectory will chdir before starting the process on unices
|
||||||
|
// Windows CE does not support working directory logic
|
||||||
void tst_QProcess::setWorkingDirectory()
|
void tst_QProcess::setWorkingDirectory()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WINCE
|
|
||||||
QSKIP("Windows CE does not support working directory logic");
|
|
||||||
#endif
|
|
||||||
#ifndef Q_OS_WIN
|
|
||||||
QSKIP("setWorkingDirectory will chdir before starting the process on unices");
|
|
||||||
#endif
|
|
||||||
process = new QProcess;
|
process = new QProcess;
|
||||||
process->setWorkingDirectory("test");
|
process->setWorkingDirectory("test");
|
||||||
process->start("testSetWorkingDirectory/testSetWorkingDirectory");
|
process->start("testSetWorkingDirectory/testSetWorkingDirectory");
|
||||||
@ -2101,6 +2077,7 @@ void tst_QProcess::setWorkingDirectory()
|
|||||||
delete process;
|
delete process;
|
||||||
process = 0;
|
process = 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void tst_QProcess::startFinishStartFinish()
|
void tst_QProcess::startFinishStartFinish()
|
||||||
@ -2173,7 +2150,7 @@ void tst_QProcess::onlyOneStartedSignal()
|
|||||||
QCOMPARE(spyFinished.count(), 1);
|
QCOMPARE(spyFinished.count(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif //QT_NO_PROCESS
|
||||||
|
|
||||||
QTEST_MAIN(tst_QProcess)
|
QTEST_MAIN(tst_QProcess)
|
||||||
#include "tst_qprocess.moc"
|
#include "tst_qprocess.moc"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user