tst_qprocess: Improve handling of helpers.
Verify exit status and code where applicable. Avoid unnecessary data conversions in fileWriterProcess. Improve error handling in helper processes. Task-number: QTBUG-47370 Task-number: QTBUG-48455 Change-Id: Ib5c4f546027131db02caaa05154a5880edac5cf7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
78f9b16d60
commit
a2995c180b
@ -33,20 +33,26 @@
|
|||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
QCoreApplication ca(argc, argv);
|
QCoreApplication ca(argc, argv);
|
||||||
QFile f;
|
QFile f;
|
||||||
f.open(stdin, QIODevice::ReadOnly);
|
f.open(stdin, QIODevice::ReadOnly);
|
||||||
QString input;
|
QByteArray input;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
qint64 len;
|
qint64 len;
|
||||||
while ((len = f.read(buf, 1024)) > 0)
|
while ((len = f.read(buf, 1024)) > 0)
|
||||||
input += QByteArray(buf, len);
|
input.append(buf, len);
|
||||||
f.close();
|
f.close();
|
||||||
QFile f2("fileWriterProcess.txt");
|
QFile f2("fileWriterProcess.txt");
|
||||||
f2.open(QIODevice::WriteOnly | QIODevice::Truncate);
|
if (!f2.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
||||||
f2.write(input.toLatin1());
|
fprintf(stderr, "Cannot open %s for writing: %s\n",
|
||||||
|
qPrintable(f2.fileName()), qPrintable(f2.errorString()));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
f2.write(input);
|
||||||
f2.close();
|
f2.close();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,8 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
QFile f(args.at(1));
|
QFile f(args.at(1));
|
||||||
if (!f.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) {
|
if (!f.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) {
|
||||||
fprintf(stderr, "Cannot open %s for writing", qPrintable(f.fileName()));
|
fprintf(stderr, "Cannot open %s for writing: %s\n",
|
||||||
|
qPrintable(f.fileName()), qPrintable(f.errorString()));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,8 +33,8 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
int main(int /* argc */, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
return atoi(argv[1]);
|
return argc >= 2 ? atoi(argv[1]) : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,9 +333,8 @@ void tst_QProcess::execute()
|
|||||||
|
|
||||||
void tst_QProcess::startDetached()
|
void tst_QProcess::startDetached()
|
||||||
{
|
{
|
||||||
QProcess proc;
|
QVERIFY(QProcess::startDetached("testProcessNormal/testProcessNormal",
|
||||||
QVERIFY(proc.startDetached("testProcessNormal/testProcessNormal",
|
QStringList() << "arg1" << "arg2"));
|
||||||
QStringList() << "arg1" << "arg2"));
|
|
||||||
#ifdef QPROCESS_USE_SPAWN
|
#ifdef QPROCESS_USE_SPAWN
|
||||||
QEXPECT_FAIL("", "QProcess cannot detect failure to start when using posix_spawn()", Continue);
|
QEXPECT_FAIL("", "QProcess cannot detect failure to start when using posix_spawn()", Continue);
|
||||||
#endif
|
#endif
|
||||||
@ -479,6 +478,8 @@ void tst_QProcess::echoTest()
|
|||||||
process.write("", 1);
|
process.write("", 1);
|
||||||
|
|
||||||
QVERIFY(process.waitForFinished(5000));
|
QVERIFY(process.waitForFinished(5000));
|
||||||
|
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||||
|
QCOMPARE(process.exitCode(), 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -530,6 +531,8 @@ void tst_QProcess::echoTest2()
|
|||||||
|
|
||||||
process.write("", 1);
|
process.write("", 1);
|
||||||
QVERIFY(process.waitForFinished(5000));
|
QVERIFY(process.waitForFinished(5000));
|
||||||
|
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||||
|
QCOMPARE(process.exitCode(), 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -546,6 +549,8 @@ void tst_QProcess::echoTestGui()
|
|||||||
process.write("q");
|
process.write("q");
|
||||||
|
|
||||||
QVERIFY(process.waitForFinished(50000));
|
QVERIFY(process.waitForFinished(50000));
|
||||||
|
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||||
|
QCOMPARE(process.exitCode(), 0);
|
||||||
|
|
||||||
QCOMPARE(process.readAllStandardOutput(), QByteArray("Hello"));
|
QCOMPARE(process.readAllStandardOutput(), QByteArray("Hello"));
|
||||||
QCOMPARE(process.readAllStandardError(), QByteArray("Hello"));
|
QCOMPARE(process.readAllStandardError(), QByteArray("Hello"));
|
||||||
@ -584,6 +589,8 @@ void tst_QProcess::batFiles()
|
|||||||
proc.start(batFile, QStringList());
|
proc.start(batFile, QStringList());
|
||||||
|
|
||||||
QVERIFY(proc.waitForFinished(5000));
|
QVERIFY(proc.waitForFinished(5000));
|
||||||
|
QCOMPARE(proc.exitStatus(), QProcess::NormalExit);
|
||||||
|
QCOMPARE(proc.exitCode(), 0);
|
||||||
|
|
||||||
QVERIFY(proc.bytesAvailable() > 0);
|
QVERIFY(proc.bytesAvailable() > 0);
|
||||||
|
|
||||||
@ -650,6 +657,8 @@ void tst_QProcess::loopBackTest()
|
|||||||
|
|
||||||
process.write("", 1);
|
process.write("", 1);
|
||||||
QVERIFY(process.waitForFinished(5000));
|
QVERIFY(process.waitForFinished(5000));
|
||||||
|
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||||
|
QCOMPARE(process.exitCode(), 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -730,6 +739,8 @@ void tst_QProcess::deadWhileReading()
|
|||||||
|
|
||||||
QCOMPARE(output.count("\n"), 10*1024);
|
QCOMPARE(output.count("\n"), 10*1024);
|
||||||
process.waitForFinished();
|
process.waitForFinished();
|
||||||
|
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||||
|
QCOMPARE(process.exitCode(), 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -754,6 +765,8 @@ void tst_QProcess::restartProcessDeadlock()
|
|||||||
|
|
||||||
QCOMPARE(process.write("", 1), qlonglong(1));
|
QCOMPARE(process.write("", 1), qlonglong(1));
|
||||||
QVERIFY(process.waitForFinished(5000));
|
QVERIFY(process.waitForFinished(5000));
|
||||||
|
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||||
|
QCOMPARE(process.exitCode(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QProcess::restartProcess()
|
void tst_QProcess::restartProcess()
|
||||||
@ -788,6 +801,8 @@ void tst_QProcess::closeWriteChannel()
|
|||||||
if (more.state() == QProcess::Running)
|
if (more.state() == QProcess::Running)
|
||||||
more.write("q");
|
more.write("q");
|
||||||
QVERIFY(more.waitForFinished(5000));
|
QVERIFY(more.waitForFinished(5000));
|
||||||
|
QCOMPARE(more.exitStatus(), QProcess::NormalExit);
|
||||||
|
QCOMPARE(more.exitCode(), 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -818,6 +833,8 @@ void tst_QProcess::closeReadChannel()
|
|||||||
|
|
||||||
proc.write("", 1);
|
proc.write("", 1);
|
||||||
QVERIFY(proc.waitForFinished(5000));
|
QVERIFY(proc.waitForFinished(5000));
|
||||||
|
QCOMPARE(proc.exitStatus(), QProcess::NormalExit);
|
||||||
|
QCOMPARE(proc.exitCode(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -898,6 +915,8 @@ void tst_QProcess::emitReadyReadOnlyWhenNewDataArrives()
|
|||||||
|
|
||||||
proc.write("", 1);
|
proc.write("", 1);
|
||||||
QVERIFY(proc.waitForFinished(5000));
|
QVERIFY(proc.waitForFinished(5000));
|
||||||
|
QCOMPARE(proc.exitStatus(), QProcess::NormalExit);
|
||||||
|
QCOMPARE(proc.exitCode(), 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1078,6 +1097,8 @@ void tst_QProcess::mergedChannels()
|
|||||||
|
|
||||||
process.closeWriteChannel();
|
process.closeWriteChannel();
|
||||||
QVERIFY(process.waitForFinished(5000));
|
QVERIFY(process.waitForFinished(5000));
|
||||||
|
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||||
|
QCOMPARE(process.exitCode(), 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1116,6 +1137,8 @@ void tst_QProcess::forwardedChannels()
|
|||||||
QCOMPARE(process.write("input"), 5);
|
QCOMPARE(process.write("input"), 5);
|
||||||
process.closeWriteChannel();
|
process.closeWriteChannel();
|
||||||
QVERIFY(process.waitForFinished(5000));
|
QVERIFY(process.waitForFinished(5000));
|
||||||
|
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||||
|
QCOMPARE(process.exitCode(), 0);
|
||||||
const char *err;
|
const char *err;
|
||||||
switch (process.exitCode()) {
|
switch (process.exitCode()) {
|
||||||
case 0: err = "ok"; break;
|
case 0: err = "ok"; break;
|
||||||
@ -1155,6 +1178,8 @@ void tst_QProcess::atEnd()
|
|||||||
|
|
||||||
process.write("", 1);
|
process.write("", 1);
|
||||||
QVERIFY(process.waitForFinished(5000));
|
QVERIFY(process.waitForFinished(5000));
|
||||||
|
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||||
|
QCOMPARE(process.exitCode(), 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1269,6 +1294,8 @@ void tst_QProcess::waitForReadyReadInAReadyReadSlot()
|
|||||||
|
|
||||||
process.disconnect();
|
process.disconnect();
|
||||||
QVERIFY(process.waitForFinished(5000));
|
QVERIFY(process.waitForFinished(5000));
|
||||||
|
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||||
|
QCOMPARE(process.exitCode(), 0);
|
||||||
QVERIFY(process.bytesAvailable() > bytesAvailable);
|
QVERIFY(process.bytesAvailable() > bytesAvailable);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1307,6 +1334,8 @@ void tst_QProcess::waitForBytesWrittenInABytesWrittenSlot()
|
|||||||
process.write("", 1);
|
process.write("", 1);
|
||||||
process.disconnect();
|
process.disconnect();
|
||||||
QVERIFY(process.waitForFinished());
|
QVERIFY(process.waitForFinished());
|
||||||
|
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||||
|
QCOMPARE(process.exitCode(), 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1401,6 +1430,8 @@ void tst_QProcess::spaceArgsTest()
|
|||||||
errorMessage = startFailMessage(program, process);
|
errorMessage = startFailMessage(program, process);
|
||||||
QVERIFY2(started, errorMessage.constData());
|
QVERIFY2(started, errorMessage.constData());
|
||||||
QVERIFY(process.waitForFinished(timeOutMS));
|
QVERIFY(process.waitForFinished(timeOutMS));
|
||||||
|
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||||
|
QCOMPARE(process.exitCode(), 0);
|
||||||
|
|
||||||
#if !defined(Q_OS_WINCE)
|
#if !defined(Q_OS_WINCE)
|
||||||
QStringList actual = QString::fromLatin1(process.readAll()).split("|");
|
QStringList actual = QString::fromLatin1(process.readAll()).split("|");
|
||||||
@ -1460,6 +1491,8 @@ void tst_QProcess::nativeArguments()
|
|||||||
QVERIFY(proc.waitForStarted(10000));
|
QVERIFY(proc.waitForStarted(10000));
|
||||||
QVERIFY(proc.waitForFinished(10000));
|
QVERIFY(proc.waitForFinished(10000));
|
||||||
#endif
|
#endif
|
||||||
|
QCOMPARE(proc.exitStatus(), QProcess::NormalExit);
|
||||||
|
QCOMPARE(proc.exitCode(), 0);
|
||||||
|
|
||||||
#if defined(Q_OS_WINCE)
|
#if defined(Q_OS_WINCE)
|
||||||
// WinCE test outputs to a file, so check that
|
// WinCE test outputs to a file, so check that
|
||||||
@ -1696,6 +1729,8 @@ void tst_QProcess::removeFileWhileProcessIsRunning()
|
|||||||
|
|
||||||
process.write("", 1);
|
process.write("", 1);
|
||||||
QVERIFY(process.waitForFinished(5000));
|
QVERIFY(process.waitForFinished(5000));
|
||||||
|
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||||
|
QCOMPARE(process.exitCode(), 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifndef Q_OS_WINCE
|
#ifndef Q_OS_WINCE
|
||||||
@ -1840,6 +1875,8 @@ void tst_QProcess::spaceInName()
|
|||||||
QVERIFY(process.waitForStarted());
|
QVERIFY(process.waitForStarted());
|
||||||
process.write("", 1);
|
process.write("", 1);
|
||||||
QVERIFY(process.waitForFinished());
|
QVERIFY(process.waitForFinished());
|
||||||
|
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||||
|
QCOMPARE(process.exitCode(), 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1921,6 +1958,8 @@ void tst_QProcess::setStandardInputFile()
|
|||||||
process.start("testProcessEcho/testProcessEcho");
|
process.start("testProcessEcho/testProcessEcho");
|
||||||
|
|
||||||
QPROCESS_VERIFY(process, waitForFinished());
|
QPROCESS_VERIFY(process, waitForFinished());
|
||||||
|
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||||
|
QCOMPARE(process.exitCode(), 0);
|
||||||
QByteArray all = process.readAll();
|
QByteArray all = process.readAll();
|
||||||
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);
|
||||||
@ -1993,6 +2032,8 @@ void tst_QProcess::setStandardOutputFile()
|
|||||||
process.start("testProcessEcho2/testProcessEcho2");
|
process.start("testProcessEcho2/testProcessEcho2");
|
||||||
process.write(testdata, sizeof testdata);
|
process.write(testdata, sizeof testdata);
|
||||||
QPROCESS_VERIFY(process,waitForFinished());
|
QPROCESS_VERIFY(process,waitForFinished());
|
||||||
|
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||||
|
QCOMPARE(process.exitCode(), 0);
|
||||||
|
|
||||||
// open the file again and verify the data
|
// open the file again and verify the data
|
||||||
QVERIFY(file.open(QIODevice::ReadOnly));
|
QVERIFY(file.open(QIODevice::ReadOnly));
|
||||||
@ -2022,6 +2063,8 @@ void tst_QProcess::setStandardOutputFileNullDevice()
|
|||||||
process.start("testProcessEcho2/testProcessEcho2");
|
process.start("testProcessEcho2/testProcessEcho2");
|
||||||
process.write(testdata, sizeof testdata);
|
process.write(testdata, sizeof testdata);
|
||||||
QPROCESS_VERIFY(process,waitForFinished());
|
QPROCESS_VERIFY(process,waitForFinished());
|
||||||
|
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||||
|
QCOMPARE(process.exitCode(), 0);
|
||||||
QCOMPARE(process.bytesAvailable(), Q_INT64_C(0));
|
QCOMPARE(process.bytesAvailable(), Q_INT64_C(0));
|
||||||
|
|
||||||
QVERIFY(!QFileInfo(QProcess::nullDevice()).isFile());
|
QVERIFY(!QFileInfo(QProcess::nullDevice()).isFile());
|
||||||
@ -2038,6 +2081,8 @@ void tst_QProcess::setStandardOutputFileAndWaitForBytesWritten()
|
|||||||
process.write(testdata, sizeof testdata);
|
process.write(testdata, sizeof testdata);
|
||||||
process.waitForBytesWritten();
|
process.waitForBytesWritten();
|
||||||
QPROCESS_VERIFY(process, waitForFinished());
|
QPROCESS_VERIFY(process, waitForFinished());
|
||||||
|
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||||
|
QCOMPARE(process.exitCode(), 0);
|
||||||
|
|
||||||
// open the file again and verify the data
|
// open the file again and verify the data
|
||||||
QVERIFY(file.open(QIODevice::ReadOnly));
|
QVERIFY(file.open(QIODevice::ReadOnly));
|
||||||
@ -2078,7 +2123,11 @@ void tst_QProcess::setStandardOutputProcess()
|
|||||||
source.waitForBytesWritten();
|
source.waitForBytesWritten();
|
||||||
source.closeWriteChannel();
|
source.closeWriteChannel();
|
||||||
QPROCESS_VERIFY(source, waitForFinished());
|
QPROCESS_VERIFY(source, waitForFinished());
|
||||||
|
QCOMPARE(source.exitStatus(), QProcess::NormalExit);
|
||||||
|
QCOMPARE(source.exitCode(), 0);
|
||||||
QPROCESS_VERIFY(sink, waitForFinished());
|
QPROCESS_VERIFY(sink, waitForFinished());
|
||||||
|
QCOMPARE(sink.exitStatus(), QProcess::NormalExit);
|
||||||
|
QCOMPARE(sink.exitCode(), 0);
|
||||||
QByteArray all = sink.readAll();
|
QByteArray all = sink.readAll();
|
||||||
|
|
||||||
if (!merged)
|
if (!merged)
|
||||||
@ -2092,25 +2141,34 @@ void tst_QProcess::setStandardOutputProcess()
|
|||||||
// Reading and writing to a process is not supported on Qt/CE
|
// Reading and writing to a process is not supported on Qt/CE
|
||||||
void tst_QProcess::fileWriterProcess()
|
void tst_QProcess::fileWriterProcess()
|
||||||
{
|
{
|
||||||
QString stdinStr;
|
const QByteArray line = QByteArrayLiteral(" -- testing testing 1 2 3\n");
|
||||||
for (int i = 0; i < 5000; ++i)
|
QByteArray stdinStr;
|
||||||
stdinStr += QString::fromLatin1("%1 -- testing testing 1 2 3\n").arg(i);
|
stdinStr.reserve(5000 * (4 + line.size()) + 1);
|
||||||
|
for (int i = 0; i < 5000; ++i) {
|
||||||
|
stdinStr += QByteArray::number(i);
|
||||||
|
stdinStr += line;
|
||||||
|
}
|
||||||
|
|
||||||
QTime stopWatch;
|
QTime stopWatch;
|
||||||
stopWatch.start();
|
stopWatch.start();
|
||||||
|
const QString fileName = QLatin1String("fileWriterProcess.txt");
|
||||||
|
|
||||||
do {
|
do {
|
||||||
QFile::remove("fileWriterProcess.txt");
|
if (QFile::exists(fileName))
|
||||||
|
QVERIFY(QFile::remove(fileName));
|
||||||
QProcess process;
|
QProcess process;
|
||||||
process.start("fileWriterProcess/fileWriterProcess",
|
process.start("fileWriterProcess/fileWriterProcess",
|
||||||
QIODevice::ReadWrite | QIODevice::Text);
|
QIODevice::ReadWrite | QIODevice::Text);
|
||||||
process.write(stdinStr.toLatin1());
|
process.write(stdinStr);
|
||||||
process.closeWriteChannel();
|
process.closeWriteChannel();
|
||||||
while (process.bytesToWrite()) {
|
while (process.bytesToWrite()) {
|
||||||
QVERIFY(stopWatch.elapsed() < 3500);
|
QVERIFY(stopWatch.elapsed() < 3500);
|
||||||
QVERIFY(process.waitForBytesWritten(2000));
|
QVERIFY(process.waitForBytesWritten(2000));
|
||||||
}
|
}
|
||||||
QVERIFY(process.waitForFinished());
|
QVERIFY(process.waitForFinished());
|
||||||
QCOMPARE(QFile("fileWriterProcess.txt").size(), qint64(stdinStr.size()));
|
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||||
|
QCOMPARE(process.exitCode(), 0);
|
||||||
|
QCOMPARE(QFile(fileName).size(), qint64(stdinStr.size()));
|
||||||
} while (stopWatch.elapsed() < 3000);
|
} while (stopWatch.elapsed() < 3000);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -2170,6 +2228,8 @@ void tst_QProcess::switchReadChannels()
|
|||||||
process.write(data);
|
process.write(data);
|
||||||
process.closeWriteChannel();
|
process.closeWriteChannel();
|
||||||
QVERIFY(process.waitForFinished(5000));
|
QVERIFY(process.waitForFinished(5000));
|
||||||
|
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||||
|
QCOMPARE(process.exitCode(), 0);
|
||||||
|
|
||||||
for (int i = 0; i < 4; ++i) {
|
for (int i = 0; i < 4; ++i) {
|
||||||
process.setReadChannel(QProcess::StandardOutput);
|
process.setReadChannel(QProcess::StandardOutput);
|
||||||
@ -2199,6 +2259,8 @@ void tst_QProcess::discardUnwantedOutput()
|
|||||||
process.write("Hello, World");
|
process.write("Hello, World");
|
||||||
process.closeWriteChannel();
|
process.closeWriteChannel();
|
||||||
QVERIFY(process.waitForFinished(5000));
|
QVERIFY(process.waitForFinished(5000));
|
||||||
|
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||||
|
QCOMPARE(process.exitCode(), 0);
|
||||||
|
|
||||||
process.setReadChannel(QProcess::StandardOutput);
|
process.setReadChannel(QProcess::StandardOutput);
|
||||||
QCOMPARE(process.bytesAvailable(), Q_INT64_C(0));
|
QCOMPARE(process.bytesAvailable(), Q_INT64_C(0));
|
||||||
@ -2220,6 +2282,8 @@ void tst_QProcess::setWorkingDirectory()
|
|||||||
process.start(QFileInfo("testSetWorkingDirectory/testSetWorkingDirectory").absoluteFilePath());
|
process.start(QFileInfo("testSetWorkingDirectory/testSetWorkingDirectory").absoluteFilePath());
|
||||||
|
|
||||||
QVERIFY2(process.waitForFinished(), process.errorString().toLocal8Bit());
|
QVERIFY2(process.waitForFinished(), process.errorString().toLocal8Bit());
|
||||||
|
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||||
|
QCOMPARE(process.exitCode(), 0);
|
||||||
|
|
||||||
QByteArray workingDir = process.readAllStandardOutput();
|
QByteArray workingDir = process.readAllStandardOutput();
|
||||||
QCOMPARE(QDir("test").canonicalPath(), QDir(workingDir.constData()).canonicalPath());
|
QCOMPARE(QDir("test").canonicalPath(), QDir(workingDir.constData()).canonicalPath());
|
||||||
@ -2254,8 +2318,11 @@ void tst_QProcess::startFinishStartFinish()
|
|||||||
QCOMPARE(QString::fromLatin1(process.readLine().trimmed()),
|
QCOMPARE(QString::fromLatin1(process.readLine().trimmed()),
|
||||||
QString("0 -this is a number"));
|
QString("0 -this is a number"));
|
||||||
#endif
|
#endif
|
||||||
if (process.state() != QProcess::NotRunning)
|
if (process.state() != QProcess::NotRunning) {
|
||||||
QVERIFY(process.waitForFinished(10000));
|
QVERIFY(process.waitForFinished(10000));
|
||||||
|
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||||
|
QCOMPARE(process.exitCode(), 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2308,6 +2375,8 @@ void tst_QProcess::onlyOneStartedSignal()
|
|||||||
|
|
||||||
process.start("testProcessNormal/testProcessNormal");
|
process.start("testProcessNormal/testProcessNormal");
|
||||||
QVERIFY(process.waitForFinished(5000));
|
QVERIFY(process.waitForFinished(5000));
|
||||||
|
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||||
|
QCOMPARE(process.exitCode(), 0);
|
||||||
QCOMPARE(spyStarted.count(), 1);
|
QCOMPARE(spyStarted.count(), 1);
|
||||||
QCOMPARE(spyFinished.count(), 1);
|
QCOMPARE(spyFinished.count(), 1);
|
||||||
}
|
}
|
||||||
@ -2342,6 +2411,8 @@ void tst_QProcess::finishProcessBeforeReadingDone()
|
|||||||
QRegExp(QStringLiteral("[\r\n]")), QString::SkipEmptyParts);
|
QRegExp(QStringLiteral("[\r\n]")), QString::SkipEmptyParts);
|
||||||
QVERIFY(!lines.isEmpty());
|
QVERIFY(!lines.isEmpty());
|
||||||
QCOMPARE(lines.last(), QStringLiteral("10239 -this is a number"));
|
QCOMPARE(lines.last(), QStringLiteral("10239 -this is a number"));
|
||||||
|
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||||
|
QCOMPARE(process.exitCode(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -2358,14 +2429,17 @@ void tst_QProcess::startStopStartStop()
|
|||||||
QProcess process;
|
QProcess process;
|
||||||
process.start("testProcessNormal/testProcessNormal");
|
process.start("testProcessNormal/testProcessNormal");
|
||||||
QVERIFY(process.waitForFinished());
|
QVERIFY(process.waitForFinished());
|
||||||
|
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||||
QCOMPARE(process.exitCode(), 0);
|
QCOMPARE(process.exitCode(), 0);
|
||||||
|
|
||||||
process.start("testExitCodes/testExitCodes", QStringList() << "1");
|
process.start("testExitCodes/testExitCodes", QStringList() << "1");
|
||||||
QVERIFY(process.waitForFinished());
|
QVERIFY(process.waitForFinished());
|
||||||
|
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||||
QCOMPARE(process.exitCode(), 1);
|
QCOMPARE(process.exitCode(), 1);
|
||||||
|
|
||||||
process.start("testProcessNormal/testProcessNormal");
|
process.start("testProcessNormal/testProcessNormal");
|
||||||
QVERIFY(process.waitForFinished());
|
QVERIFY(process.waitForFinished());
|
||||||
|
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||||
QCOMPARE(process.exitCode(), 0);
|
QCOMPARE(process.exitCode(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2437,6 +2511,7 @@ void tst_QProcess::startStopStartStopBuffers()
|
|||||||
process.write("line3\n");
|
process.write("line3\n");
|
||||||
process.closeWriteChannel();
|
process.closeWriteChannel();
|
||||||
QVERIFY(process.waitForFinished());
|
QVERIFY(process.waitForFinished());
|
||||||
|
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||||
QCOMPARE(process.exitCode(), 0);
|
QCOMPARE(process.exitCode(), 0);
|
||||||
|
|
||||||
if (channelMode2 == QProcess::MergedChannels) {
|
if (channelMode2 == QProcess::MergedChannels) {
|
||||||
|
Loading…
Reference in New Issue
Block a user