summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/io/qprocess/tst_qprocess.cpp')
-rw-r--r--tests/auto/corelib/io/qprocess/tst_qprocess.cpp151
1 files changed, 6 insertions, 145 deletions
diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
index c47e88b0e6..1da9cf38a1 100644
--- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
@@ -66,7 +66,6 @@ private slots:
void startDetached();
void crashTest();
void crashTest2();
-#ifndef Q_OS_WINCE
void echoTest_data();
void echoTest();
void echoTest2();
@@ -112,7 +111,6 @@ private slots:
void discardUnwantedOutput();
void setWorkingDirectory();
void setNonExistentWorkingDirectory();
-#endif // not Q_OS_WINCE
void exitStatus_data();
void exitStatus();
@@ -156,11 +154,9 @@ protected slots:
void readFromProcess();
void exitLoopSlot();
void processApplicationEvents();
-#ifndef Q_OS_WINCE
void restartProcess();
void waitForReadyReadInAReadyReadSlotSlot();
void waitForBytesWrittenInABytesWrittenSlotSlot();
-#endif
private:
qint64 bytesAvailable;
@@ -411,8 +407,6 @@ void tst_QProcess::crashTest2()
QCOMPARE(process.exitStatus(), QProcess::CrashExit);
}
-#ifndef Q_OS_WINCE
-//Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::echoTest_data()
{
QTest::addColumn<QByteArray>("input");
@@ -467,7 +461,6 @@ void tst_QProcess::echoTest()
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QCOMPARE(process.exitCode(), 0);
}
-#endif
void tst_QProcess::exitLoopSlot()
{
@@ -479,8 +472,6 @@ void tst_QProcess::processApplicationEvents()
QCoreApplication::processEvents();
}
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::echoTest2()
{
@@ -528,10 +519,8 @@ void tst_QProcess::echoTest2()
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QCOMPARE(process.exitCode(), 0);
}
-#endif
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
-// Reading and writing to a process is not supported on Qt/CE
+#if defined(Q_OS_WIN)
void tst_QProcess::echoTestGui()
{
QProcess process;
@@ -560,10 +549,9 @@ void tst_QProcess::testSetNamedPipeHandleState()
QCOMPARE(process.exitCode(), 0);
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
}
-#endif // !Q_OS_WINCE && Q_OS_WIN
+#endif // Q_OS_WIN
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
-// Batch files are not supported on Windows CE
+#if defined(Q_OS_WIN)
void tst_QProcess::batFiles_data()
{
QTest::addColumn<QString>("batFile");
@@ -590,7 +578,7 @@ void tst_QProcess::batFiles()
QVERIFY(proc.readAll().startsWith(output));
}
-#endif // !Q_OS_WINCE && Q_OS_WIN
+#endif // Q_OS_WIN
void tst_QProcess::exitStatus_data()
{
@@ -632,8 +620,6 @@ void tst_QProcess::exitStatus()
}
}
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::loopBackTest()
{
@@ -654,10 +640,7 @@ void tst_QProcess::loopBackTest()
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QCOMPARE(process.exitCode(), 0);
}
-#endif
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::readTimeoutAndThenCrash()
{
@@ -688,7 +671,6 @@ void tst_QProcess::readTimeoutAndThenCrash()
QCOMPARE(spy2.count(), 1);
QCOMPARE(*static_cast<const QProcess::ProcessError *>(spy2.at(0).at(0).constData()), QProcess::Crashed);
}
-#endif
void tst_QProcess::waitForFinished()
{
@@ -699,9 +681,6 @@ void tst_QProcess::waitForFinished()
QVERIFY(process.waitForFinished());
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
-#if defined (Q_OS_WINCE)
- QEXPECT_FAIL("", "Reading and writing to a process is not supported on Qt/CE", Continue);
-#endif
QString output = process.readAll();
QCOMPARE(output.count("\n"), 10*1024);
@@ -713,8 +692,6 @@ void tst_QProcess::waitForFinished()
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()
{
QProcess process;
@@ -732,10 +709,7 @@ void tst_QProcess::deadWhileReading()
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QCOMPARE(process.exitCode(), 0);
}
-#endif
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::restartProcessDeadlock()
{
@@ -765,10 +739,7 @@ void tst_QProcess::restartProcess()
QVERIFY(process);
process->start("testProcessEcho/testProcessEcho");
}
-#endif
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::closeWriteChannel()
{
QProcess more;
@@ -794,10 +765,7 @@ void tst_QProcess::closeWriteChannel()
QCOMPARE(more.exitStatus(), QProcess::NormalExit);
QCOMPARE(more.exitCode(), 0);
}
-#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) {
@@ -827,10 +795,7 @@ void tst_QProcess::closeReadChannel()
QCOMPARE(proc.exitCode(), 0);
}
}
-#endif
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::openModes()
{
QProcess proc;
@@ -871,10 +836,7 @@ void tst_QProcess::openModes()
QVERIFY(!proc.isWritable());
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()
{
@@ -908,17 +870,12 @@ void tst_QProcess::emitReadyReadOnlyWhenNewDataArrives()
QCOMPARE(proc.exitStatus(), QProcess::NormalExit);
QCOMPARE(proc.exitCode(), 0);
}
-#endif
void tst_QProcess::hardExit()
{
QProcess proc;
-#if defined(Q_OS_WINCE)
- proc.start("testSoftExit/testSoftExit");
-#else
proc.start("testProcessEcho/testProcessEcho");
-#endif
QVERIFY2(proc.waitForStarted(), qPrintable(proc.errorString()));
proc.kill();
@@ -935,9 +892,7 @@ void tst_QProcess::softExit()
proc.start("testSoftExit/testSoftExit");
QVERIFY(proc.waitForStarted(10000));
-#if !defined(Q_OS_WINCE)
QVERIFY(proc.waitForReadyRead(10000));
-#endif
QVERIFY(proc.processId() > 0);
@@ -948,8 +903,6 @@ void tst_QProcess::softExit()
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
{
Q_OBJECT
@@ -1071,10 +1024,7 @@ void tst_QProcess::softExitInSlots()
QTRY_VERIFY_WITH_TIMEOUT(proc.waitedForFinished, 10000);
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::mergedChannels()
{
QProcess process;
@@ -1097,10 +1047,6 @@ void tst_QProcess::mergedChannels()
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QCOMPARE(process.exitCode(), 0);
}
-#endif
-
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::forwardedChannels_data()
{
@@ -1153,10 +1099,7 @@ void tst_QProcess::forwardedChannels()
QCOMPARE(process.readAllStandardOutput(), outdata);
QCOMPARE(process.readAllStandardError(), errdata);
}
-#endif
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::atEnd()
{
QProcess process;
@@ -1178,7 +1121,6 @@ void tst_QProcess::atEnd()
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QCOMPARE(process.exitCode(), 0);
}
-#endif
class TestThread : public QThread
{
@@ -1200,9 +1142,7 @@ protected:
process.start("testProcessEcho/testProcessEcho");
-#if !defined(Q_OS_WINCE)
QCOMPARE(process.write("abc\0", 4), qint64(4));
-#endif
exitCode = exec();
}
@@ -1251,8 +1191,6 @@ void tst_QProcess::processesInMultipleThreads()
}
}
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::waitForFinishedWithTimeout()
{
QProcess process;
@@ -1266,10 +1204,7 @@ void tst_QProcess::waitForFinishedWithTimeout()
QVERIFY(process.waitForFinished());
}
-#endif
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::waitForReadyReadInAReadyReadSlot()
{
QProcess process;
@@ -1295,10 +1230,7 @@ void tst_QProcess::waitForReadyReadInAReadyReadSlot()
QCOMPARE(process.exitCode(), 0);
QVERIFY(process.bytesAvailable() > bytesAvailable);
}
-#endif
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::waitForReadyReadInAReadyReadSlotSlot()
{
QProcess *process = qobject_cast<QProcess *>(sender());
@@ -1308,10 +1240,7 @@ void tst_QProcess::waitForReadyReadInAReadyReadSlotSlot()
QVERIFY(process->waitForReadyRead(5000));
QTestEventLoop::instance().exitLoop();
}
-#endif
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::waitForBytesWrittenInABytesWrittenSlot()
{
QProcess process;
@@ -1334,10 +1263,7 @@ void tst_QProcess::waitForBytesWrittenInABytesWrittenSlot()
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QCOMPARE(process.exitCode(), 0);
}
-#endif
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::waitForBytesWrittenInABytesWrittenSlotSlot()
{
QProcess *process = qobject_cast<QProcess *>(sender());
@@ -1346,7 +1272,6 @@ void tst_QProcess::waitForBytesWrittenInABytesWrittenSlotSlot()
QVERIFY(process->waitForBytesWritten(5000));
QTestEventLoop::instance().exitLoop();
}
-#endif
void tst_QProcess::spaceArgsTest_data()
{
@@ -1425,14 +1350,12 @@ void tst_QProcess::spaceArgsTest()
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QCOMPARE(process.exitCode(), 0);
-#if !defined(Q_OS_WINCE)
QStringList actual = QString::fromLatin1(process.readAll()).split("|");
QVERIFY(!actual.isEmpty());
// not interested in the program name, it might be different.
actual.removeFirst();
QCOMPARE(actual, args);
-#endif
if (program.contains(QLatin1Char(' ')))
program = QLatin1Char('"') + program + QLatin1Char('"');
@@ -1449,14 +1372,12 @@ void tst_QProcess::spaceArgsTest()
QVERIFY2(started, errorMessage.constData());
QVERIFY(process.waitForFinished(5000));
-#if !defined(Q_OS_WINCE)
actual = QString::fromLatin1(process.readAll()).split("|");
QVERIFY(!actual.isEmpty());
// not interested in the program name, it might be different.
actual.removeFirst();
QCOMPARE(actual, args);
-#endif
}
}
@@ -1477,26 +1398,12 @@ void tst_QProcess::nativeArguments()
QCOMPARE(proc.exitStatus(), QProcess::NormalExit);
QCOMPARE(proc.exitCode(), 0);
-#if defined(Q_OS_WINCE)
- // WinCE test outputs to a file, so check that
- FILE* file = fopen("\\temp\\qprocess_args_test.txt","r");
- QVERIFY(file);
- char buf[256];
- fgets(buf, 256, file);
- fclose(file);
- QStringList actual = QString::fromLatin1(buf).split(QLatin1Char('|'));
-#else
QStringList actual = QString::fromLatin1(proc.readAll()).split(QLatin1Char('|'));
-#endif
QVERIFY(!actual.isEmpty());
// not interested in the program name, it might be different.
actual.removeFirst();
QStringList expected;
-#if defined(Q_OS_WINCE)
- expected << "hello" << "kitty," << "\"*\"!"; // Weird, weird ...
-#else
expected << "hello" << "kitty," << "*!";
-#endif
QCOMPARE(actual, expected);
}
@@ -1715,8 +1622,6 @@ void tst_QProcess::failToStartEmptyArgs()
QCOMPARE(process.error(), QProcess::FailedToStart);
}
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::removeFileWhileProcessIsRunning()
{
QFile file(m_temporaryDir.path() + QLatin1String("/removeFile.txt"));
@@ -1734,9 +1639,7 @@ void tst_QProcess::removeFileWhileProcessIsRunning()
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QCOMPARE(process.exitCode(), 0);
}
-#endif
-#ifndef Q_OS_WINCE
-// OS doesn't support environment variables
+
void tst_QProcess::setEnvironment_data()
{
QTest::addColumn<QString>("name");
@@ -1811,9 +1714,7 @@ void tst_QProcess::setEnvironment()
QCOMPARE(process.readAll(), value.toLocal8Bit());
}
}
-#endif
-#ifndef Q_OS_WINCE
-// OS doesn't support environment variables
+
void tst_QProcess::setProcessEnvironment_data()
{
setEnvironment_data();
@@ -1851,25 +1752,16 @@ void tst_QProcess::setProcessEnvironment()
QCOMPARE(process.readAll(), value.toLocal8Bit());
}
}
-#endif
void tst_QProcess::systemEnvironment()
{
-#if defined (Q_OS_WINCE)
- // there is no concept of system variables on Windows CE as there is no console
- QVERIFY(QProcess::systemEnvironment().isEmpty());
- QVERIFY(QProcessEnvironment::systemEnvironment().isEmpty());
-#else
QVERIFY(!QProcess::systemEnvironment().isEmpty());
QVERIFY(!QProcessEnvironment::systemEnvironment().isEmpty());
QVERIFY(QProcessEnvironment::systemEnvironment().contains("PATH"));
QVERIFY(!QProcess::systemEnvironment().filter(QRegExp("^PATH=", Qt::CaseInsensitive)).isEmpty());
-#endif
}
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::spaceInName()
{
QProcess process;
@@ -1880,7 +1772,6 @@ void tst_QProcess::spaceInName()
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QCOMPARE(process.exitCode(), 0);
}
-#endif
void tst_QProcess::lockupsInStartDetached()
{
@@ -1895,8 +1786,6 @@ void tst_QProcess::lockupsInStartDetached()
QProcess::startDetached("yjhbrty");
}
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::atEnd2()
{
QProcess process;
@@ -1911,7 +1800,6 @@ void tst_QProcess::atEnd2()
}
QCOMPARE(lines.size(), 7);
}
-#endif
void tst_QProcess::waitForReadyReadForNonexistantProcess()
{
@@ -1944,8 +1832,6 @@ void tst_QProcess::waitForReadyReadForNonexistantProcess()
QCOMPARE(finishedSpy2.count(), 0);
}
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::setStandardInputFile()
{
static const char data[] = "A bunch\1of\2data\3\4\5\6\7...";
@@ -1973,10 +1859,7 @@ void tst_QProcess::setStandardInputFile()
all = process2.readAll();
QCOMPARE(all.size(), 0);
}
-#endif
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::setStandardOutputFile_data()
{
QTest::addColumn<int>("channelToTest");
@@ -2094,10 +1977,7 @@ void tst_QProcess::setStandardOutputFileAndWaitForBytesWritten()
QCOMPARE(all, QByteArray::fromRawData(testdata, sizeof testdata - 1));
}
-#endif
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::setStandardOutputProcess_data()
{
QTest::addColumn<bool>("merged");
@@ -2138,10 +2018,7 @@ void tst_QProcess::setStandardOutputProcess()
else
QCOMPARE(all, QByteArray("HHeelllloo,, WWoorrlldd"));
}
-#endif
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::fileWriterProcess()
{
const QByteArray line = QByteArrayLiteral(" -- testing testing 1 2 3\n");
@@ -2175,16 +2052,11 @@ void tst_QProcess::fileWriterProcess()
QCOMPARE(QFile(fileName).size(), qint64(stdinStr.size()));
} while (stopWatch.elapsed() < 3000);
}
-#endif
void tst_QProcess::detachedWorkingDirectoryAndPid()
{
qint64 pid;
-#ifdef Q_OS_WINCE
- QTest::qSleep(1000);
-#endif
-
QFile infoFile(m_temporaryDir.path() + QLatin1String("/detachedinfo.txt"));
if (infoFile.exists())
QVERIFY(infoFile.remove());
@@ -2221,8 +2093,6 @@ void tst_QProcess::detachedWorkingDirectoryAndPid()
QCOMPARE(actualPid, pid);
}
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::switchReadChannels()
{
const char data[] = "ABCD";
@@ -2251,10 +2121,7 @@ void tst_QProcess::switchReadChannels()
process.setReadChannel(QProcess::StandardOutput);
QCOMPARE(process.read(1), QByteArray("D"));
}
-#endif
-#ifndef Q_OS_WINCE
-// Reading and writing to a process is not supported on Qt/CE
void tst_QProcess::discardUnwantedOutput()
{
QProcess process;
@@ -2272,11 +2139,8 @@ void tst_QProcess::discardUnwantedOutput()
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
-// Windows CE does not support working directory logic
void tst_QProcess::setWorkingDirectory()
{
QProcess process;
@@ -2315,7 +2179,6 @@ void tst_QProcess::setNonExistentWorkingDirectory()
QVERIFY2(process.errorString().startsWith("chdir:"), process.errorString().toLocal8Bit());
#endif
}
-#endif
void tst_QProcess::startFinishStartFinish()
{
@@ -2325,11 +2188,9 @@ void tst_QProcess::startFinishStartFinish()
QCOMPARE(process.state(), QProcess::NotRunning);
process.start("testProcessOutput/testProcessOutput");
-#if !defined(Q_OS_WINCE)
QVERIFY(process.waitForReadyRead(10000));
QCOMPARE(QString::fromLatin1(process.readLine().trimmed()),
QString("0 -this is a number"));
-#endif
if (process.state() != QProcess::NotRunning) {
QVERIFY(process.waitForFinished(10000));
QCOMPARE(process.exitStatus(), QProcess::NormalExit);