Changed qprocess unittest to work from installation directory.

- All subprograms installed as part of test instead of separate installs
  using installTestHelperApp() from testcase.prf
- Removed use of app_bundle for subprograms

Change-Id: I0a3de021800d36bd48479f63588b09fc7e60f32f
Reviewed-by: Kurt Korbatits  <kurt.korbatits@nokia.com>
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
This commit is contained in:
Kurt Korbatits 2012-01-12 13:07:12 +10:00 committed by Qt by Nokia
parent 2087db0b20
commit f1da37e989
25 changed files with 44 additions and 233 deletions

View File

@ -3,7 +3,3 @@ CONFIG += console
CONFIG -= app_bundle
QT = core
DESTDIR = ./
# This app is testdata for tst_qprocess
target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -0,0 +1,17 @@
SUBPROGRAMS = \
testProcessCrash \
testProcessEcho \
testProcessEcho2 \
testProcessEcho3 \
testProcessEnvironment \
testProcessLoopback \
testProcessNormal \
testProcessOutput \
testProcessDeadWhileReading \
testProcessEOF \
testExitCodes \
testGuiProcess \
testDetached \
fileWriterProcess \
testSetWorkingDirectory \
testSoftExit

View File

@ -1,27 +1,14 @@
TEMPLATE = subdirs
SUBDIRS = \
testProcessCrash \
testProcessEcho \
testProcessEcho2 \
testProcessEcho3 \
testProcessEnvironment \
testProcessLoopback \
testProcessNormal \
testProcessOutput \
testProcessDeadWhileReading \
testProcessEOF \
testProcessSpacesArgs/nospace.pro \
testExitCodes \
testSpaceInName \
testGuiProcess \
testDetached \
fileWriterProcess \
testSetWorkingDirectory \
testProcessSpacesArgs/onespace.pro \
testProcessSpacesArgs/twospaces.pro \
testSoftExit
include(qprocess.pri)
SUBDIRS = $$SUBPROGRAMS
# Add special cases
SUBDIRS += testProcessSpacesArgs/nospace.pro \
testProcessSpacesArgs/onespace.pro \
testProcessSpacesArgs/twospaces.pro \
testSpaceInName
win32:!wince*:SUBDIRS+=testProcessEchoGui
test.depends += $$SUBDIRS
SUBDIRS += test

View File

@ -5,4 +5,12 @@ SOURCES = ../tst_qprocess.cpp
TARGET = ../tst_qprocess
TESTDATA += ../testBatFiles/*
win32:TESTDATA += ../testBatFiles/*
include(../qprocess.pri)
load(testcase) # for target.path and installTestHelperApp()
for(file, SUBPROGRAMS): installTestHelperApp("../$${file}/$${file}",$${file},$${file})
installTestHelperApp("../testProcessSpacesArgs/nospace",testProcessSpacesArgs,nospace)
installTestHelperApp("../testProcessSpacesArgs/one space",testProcessSpacesArgs,"one space")
installTestHelperApp("../testProcessSpacesArgs/two space s",testProcessSpacesArgs,"two space s")
installTestHelperApp("../test Space In Name/testSpaceInName","test Space In Name",testSpaceInName)

View File

@ -4,7 +4,3 @@ CONFIG += console
CONFIG -= app_bundle
INSTALLS =
DESTDIR = ./
# This app is testdata for tst_qprocess
target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -3,7 +3,3 @@ CONFIG -= qt app_bundle
CONFIG += console
DESTDIR = ./
# This app is testdata for tst_qprocess
target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -1,8 +1,5 @@
SOURCES += main.cpp
QT += widgets
CONFIG += console
CONFIG -= app_bundle
DESTDIR = ./
# This app is testdata for tst_qprocess
target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -3,7 +3,3 @@ CONFIG += console
CONFIG -= qt app_bundle
DESTDIR = ./
# This app is testdata for tst_qprocess
target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -1,9 +1,5 @@
SOURCES = main.cpp
CONFIG -= qt
CONFIG -= qt app_bundle
CONFIG += console
DESTDIR = ./
# This app is testdata for tst_qprocess
target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -4,7 +4,3 @@ CONFIG += console
win32:!win32-g++*:!equals(TEMPLATE_PREFIX, "vc"):QMAKE_CXXFLAGS += /GS-
DESTDIR = ./
# This app is testdata for tst_qprocess
target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -1,8 +1,4 @@
SOURCES = main.cpp
CONFIG -= qt
CONFIG -= qt app_bundle
CONFIG += console
DESTDIR = ./
# This app is testdata for tst_qprocess
target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -1,8 +1,4 @@
SOURCES = main.cpp
CONFIG -= qt
CONFIG -= qt app_bundle
CONFIG += console
DESTDIR = ./
# This app is testdata for tst_qprocess
target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -1,8 +1,4 @@
SOURCES = main.cpp
CONFIG -= qt
CONFIG -= qt app_bundle
CONFIG += console
DESTDIR = ./
# This app is testdata for tst_qprocess
target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -3,9 +3,5 @@ win32 {
!win32-borland:LIBS += -lUser32
}
CONFIG -= qt
CONFIG -= qt app_bundle
DESTDIR = ./
# This app is testdata for tst_qprocess
target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -6,7 +6,3 @@ DESTDIR = ./
mac {
CONFIG -= app_bundle
}
# This app is testdata for tst_qprocess
target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -1,8 +1,4 @@
SOURCES = main.cpp
CONFIG -= qt
CONFIG -= qt app_bundle
CONFIG += console
DESTDIR = ./
# This app is testdata for tst_qprocess
target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -3,7 +3,3 @@ CONFIG += console
CONFIG -= qt app_bundle
DESTDIR = ./
# This app is testdata for tst_qprocess
target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -1,8 +1,4 @@
SOURCES = main.cpp
CONFIG -= qt
CONFIG -= qt app_bundle
CONFIG += console
DESTDIR = ./
# This app is testdata for tst_qprocess
target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -2,7 +2,3 @@ SOURCES = main.cpp
CONFIG -= qt app_bundle
CONFIG += console
DESTDIR = ./
# This app is testdata for tst_qproces
target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/testProcessSpacesArgs
INSTALLS += target

View File

@ -4,7 +4,3 @@ CONFIG += console
DESTDIR = ./
TARGET = "one space"
# This app is testdata for tst_qprocess
target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/testProcessSpacesArgs
INSTALLS += target

View File

@ -4,7 +4,3 @@ CONFIG += console
DESTDIR = ./
TARGET = "two space s"
# This app is testdata for tst_qprocess
target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/testProcessSpacesArgs
INSTALLS += target

View File

@ -1,7 +1,4 @@
SOURCES = main.cpp
CONFIG += console
CONFIG -= app_bundle
DESTDIR = ./
# This app is testdata for tst_qprocess
target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -9,7 +9,3 @@ unix {
CONFIG -= qt app_bundle
CONFIG += console
DESTDIR = ./
# This app is testdata for tst_qprocess
target.path = $$[QT_INSTALL_TESTS]/tst_qprocess/$$TARGET
INSTALLS += target

View File

@ -6,7 +6,3 @@ DESTDIR = "../test Space In Name"
mac {
CONFIG -= app_bundle
}
# This app is testdata for tst_qprocess
target.path = "$$[QT_INSTALL_TESTS]/tst_qprocess/test Space In Name"
INSTALLS += target

View File

@ -400,11 +400,7 @@ void tst_QProcess::echoTest()
process = new QProcess;
connect(process, SIGNAL(readyRead()), this, SLOT(exitLoopSlot()));
#ifdef Q_OS_MAC
process->start("testProcessEcho/testProcessEcho.app");
#else
process->start("testProcessEcho/testProcessEcho");
#endif
QVERIFY(process->waitForStarted(5000));
process->write(input);
@ -456,11 +452,7 @@ void tst_QProcess::echoTest2()
process = new QProcess;
connect(process, SIGNAL(readyRead()), this, SLOT(exitLoopSlot()));
#ifdef Q_OS_MAC
process->start("testProcessEcho2/testProcessEcho2.app");
#else
process->start("testProcessEcho2/testProcessEcho2");
#endif
QVERIFY(process->waitForStarted(5000));
QVERIFY(!process->waitForReadyRead(250));
QCOMPARE(process->error(), QProcess::Timedout);
@ -508,11 +500,7 @@ void tst_QProcess::echoTest_performance()
#endif
QProcess process;
#ifdef Q_OS_MAC
process.start("testProcessLoopback/testProcessLoopback.app");
#else
process.start("testProcessLoopback/testProcessLoopback");
#endif
QByteArray array;
array.resize(1024 * 1024);
@ -663,11 +651,7 @@ void tst_QProcess::loopBackTest()
#endif
process = new QProcess;
#ifdef Q_OS_MAC
process->start("testProcessEcho/testProcessEcho.app");
#else
process->start("testProcessEcho/testProcessEcho");
#endif
QVERIFY(process->waitForStarted(5000));
for (int i = 0; i < 100; ++i) {
@ -693,11 +677,7 @@ void tst_QProcess::readTimeoutAndThenCrash()
#endif
process = new QProcess;
#ifdef Q_OS_MAC
process->start("testProcessEcho/testProcessEcho.app");
#else
process->start("testProcessEcho/testProcessEcho");
#endif
if (process->state() != QProcess::Starting)
QCOMPARE(process->state(), QProcess::Running);
@ -727,11 +707,7 @@ void tst_QProcess::waitForFinished()
{
QProcess process;
#ifdef Q_OS_MAC
process.start("testProcessOutput/testProcessOutput.app");
#else
process.start("testProcessOutput/testProcessOutput");
#endif
#if !defined(Q_OS_WINCE)
QVERIFY(process.waitForFinished(5000));
@ -759,11 +735,7 @@ void tst_QProcess::deadWhileReading()
QProcess process;
#ifdef Q_OS_MAC
process.start("testProcessDeadWhileReading/testProcessDeadWhileReading.app");
#else
process.start("testProcessDeadWhileReading/testProcessDeadWhileReading");
#endif
QString output;
@ -789,11 +761,7 @@ void tst_QProcess::restartProcessDeadlock()
process = &proc;
connect(process, SIGNAL(finished(int)), this, SLOT(restartProcess()));
#ifdef Q_OS_MAC
process->start("testProcessEcho/testProcessEcho.app");
#else
process->start("testProcessEcho/testProcessEcho");
#endif
QCOMPARE(process->write("", 1), qlonglong(1));
QVERIFY(process->waitForFinished(5000));
@ -806,11 +774,7 @@ void tst_QProcess::restartProcessDeadlock()
void tst_QProcess::restartProcess()
{
#ifdef Q_OS_MAC
process->start("testProcessEcho/testProcessEcho.app");
#else
process->start("testProcessEcho/testProcessEcho");
#endif
}
//-----------------------------------------------------------------------------
@ -854,11 +818,7 @@ void tst_QProcess::closeReadChannel()
QProcess::ProcessChannel channel2 = QProcess::StandardError;
QProcess proc;
#ifdef Q_OS_MAC
proc.start("testProcessEcho2/testProcessEcho2.app");
#else
proc.start("testProcessEcho2/testProcessEcho2");
#endif
QVERIFY(proc.waitForStarted(5000));
proc.closeReadChannel(i&1 ? channel2 : channel1);
proc.setReadChannel(i&1 ? channel2 : channel1);
@ -889,11 +849,7 @@ void tst_QProcess::openModes()
QProcess proc;
QVERIFY(!proc.isOpen());
QVERIFY(proc.openMode() == QProcess::NotOpen);
#ifdef Q_OS_MAC
proc.start("testProcessEcho3/testProcessEcho3.app");
#else
proc.start("testProcessEcho3/testProcessEcho3");
#endif
QVERIFY(proc.waitForStarted(5000));
QVERIFY(proc.isOpen());
QVERIFY(proc.openMode() == QProcess::ReadWrite);
@ -941,11 +897,7 @@ void tst_QProcess::emitReadyReadOnlyWhenNewDataArrives()
QSignalSpy spy(&proc, SIGNAL(readyRead()));
QVERIFY(spy.isValid());
#ifdef Q_OS_MAC
proc.start("testProcessEcho/testProcessEcho.app");
#else
proc.start("testProcessEcho/testProcessEcho");
#endif
QCOMPARE(spy.count(), 0);
@ -974,9 +926,7 @@ void tst_QProcess::hardExit()
{
QProcess proc;
#if defined(Q_OS_MAC)
proc.start("testProcessEcho/testProcessEcho.app");
#elif defined(Q_OS_WINCE)
#if defined(Q_OS_WINCE)
proc.start("testSoftExit/testSoftExit");
#else
proc.start("testProcessEcho/testProcessEcho");
@ -1084,16 +1034,8 @@ void tst_QProcess::softExitInSlots_data()
{
QTest::addColumn<QString>("appName");
#ifdef Q_OS_MAC
QTest::newRow("gui app") << "testGuiProcess/testGuiProcess.app";
#else
QTest::newRow("gui app") << "testGuiProcess/testGuiProcess";
#endif
#ifdef Q_OS_MAC
QTest::newRow("console app") << "testProcessEcho2/testProcessEcho2.app";
#else
QTest::newRow("console app") << "testProcessEcho2/testProcessEcho2";
#endif
}
//-----------------------------------------------------------------------------
@ -1126,11 +1068,7 @@ void tst_QProcess::mergedChannels()
process.setReadChannelMode(QProcess::MergedChannels);
QCOMPARE(process.readChannelMode(), QProcess::MergedChannels);
#ifdef Q_OS_MAC
process.start("testProcessEcho2/testProcessEcho2.app");
#else
process.start("testProcessEcho2/testProcessEcho2");
#endif
QVERIFY(process.waitForStarted(5000));
@ -1156,11 +1094,7 @@ void tst_QProcess::forwardedChannels()
process.setReadChannelMode(QProcess::ForwardedChannels);
QCOMPARE(process.readChannelMode(), QProcess::ForwardedChannels);
#ifdef Q_OS_MAC
process.start("testProcessEcho2/testProcessEcho2.app");
#else
process.start("testProcessEcho2/testProcessEcho2");
#endif
QVERIFY(process.waitForStarted(5000));
QCOMPARE(process.write("forwarded\n"), qlonglong(10));
@ -1181,11 +1115,7 @@ void tst_QProcess::atEnd()
QProcess process;
#ifdef Q_OS_MAC
process.start("testProcessEcho/testProcessEcho.app");
#else
process.start("testProcessEcho/testProcessEcho");
#endif
process.write("abcdefgh\n");
while (process.bytesAvailable() < 8)
@ -1219,11 +1149,7 @@ protected:
connect(&process, SIGNAL(finished(int)), this, SLOT(catchExitCode(int)),
Qt::DirectConnection);
#ifdef Q_OS_MAC
process.start("testProcessEcho/testProcessEcho.app");
#else
process.start("testProcessEcho/testProcessEcho");
#endif
#if !defined(Q_OS_WINCE)
QCOMPARE(process.write("abc\0", 4), qint64(4));
@ -1284,11 +1210,7 @@ void tst_QProcess::waitForFinishedWithTimeout()
process = new QProcess(this);
#ifdef Q_OS_MAC
process->start("testProcessEcho/testProcessEcho.app");
#else
process->start("testProcessEcho/testProcessEcho");
#endif
QVERIFY(process->waitForStarted(5000));
QVERIFY(!process->waitForFinished(1));
@ -1313,11 +1235,7 @@ void tst_QProcess::waitForReadyReadInAReadyReadSlot()
connect(process, SIGNAL(finished(int)), this, SLOT(exitLoopSlot()));
bytesAvailable = 0;
#ifdef Q_OS_MAC
process->start("testProcessEcho/testProcessEcho.app");
#else
process->start("testProcessEcho/testProcessEcho");
#endif
QVERIFY(process->waitForStarted(5000));
QSignalSpy spy(process, SIGNAL(readyRead()));
@ -1359,11 +1277,7 @@ void tst_QProcess::waitForBytesWrittenInABytesWrittenSlot()
connect(process, SIGNAL(bytesWritten(qint64)), this, SLOT(waitForBytesWrittenInABytesWrittenSlotSlot()));
bytesAvailable = 0;
#ifdef Q_OS_MAC
process->start("testProcessEcho/testProcessEcho.app");
#else
process->start("testProcessEcho/testProcessEcho");
#endif
QVERIFY(process->waitForStarted(5000));
qRegisterMetaType<qint64>("qint64");
@ -1712,11 +1626,7 @@ void tst_QProcess::removeFileWhileProcessIsRunning()
QVERIFY(file.open(QFile::WriteOnly));
QProcess process;
#ifdef Q_OS_MAC
process.start("testProcessEcho/testProcessEcho.app");
#else
process.start("testProcessEcho/testProcessEcho");
#endif
QVERIFY(process.waitForStarted(5000));
@ -1900,11 +1810,7 @@ void tst_QProcess::atEnd2()
QProcess process;
#ifdef Q_OS_MAC
process.start("testProcessEcho/testProcessEcho.app");
#else
process.start("testProcessEcho/testProcessEcho");
#endif
process.write("Foo\nBar\nBaz\nBodukon\nHadukan\nTorwukan\nend\n");
process.putChar('\0');
QVERIFY(process.waitForFinished());
@ -1956,11 +1862,7 @@ void tst_QProcess::setStandardInputFile()
file.close();
process.setStandardInputFile("data");
#ifdef Q_OS_MAC
process.start("testProcessEcho/testProcessEcho.app");
#else
process.start("testProcessEcho/testProcessEcho");
#endif
QPROCESS_VERIFY(process, waitForFinished());
QByteArray all = process.readAll();
@ -2027,11 +1929,7 @@ void tst_QProcess::setStandardOutputFile()
else
process.setStandardErrorFile("data", mode);
#ifdef Q_OS_MAC
process.start("testProcessEcho2/testProcessEcho2.app");
#else
process.start("testProcessEcho2/testProcessEcho2");
#endif
process.write(testdata, sizeof testdata);
QPROCESS_VERIFY(process,waitForFinished());
@ -2075,13 +1973,8 @@ void tst_QProcess::setStandardOutputProcess()
source.setReadChannelMode(merged ? QProcess::MergedChannels : QProcess::SeparateChannels);
source.setStandardOutputProcess(&sink);
#ifdef Q_OS_MAC
source.start("testProcessEcho2/testProcessEcho2.app");
sink.start("testProcessEcho2/testProcessEcho2.app");
#else
source.start("testProcessEcho2/testProcessEcho2");
sink.start("testProcessEcho2/testProcessEcho2");
#endif
QByteArray data("Hello, World");
source.write(data);
@ -2179,11 +2072,7 @@ void tst_QProcess::switchReadChannels()
QProcess process;
#ifdef Q_OS_MAC
process.start("testProcessEcho2/testProcessEcho2.app");
#else
process.start("testProcessEcho2/testProcessEcho2");
#endif
process.write(data);
process.closeWriteChannel();
QVERIFY(process.waitForFinished(5000));
@ -2212,11 +2101,7 @@ void tst_QProcess::setWorkingDirectory()
#endif
process = new QProcess;
process->setWorkingDirectory("test");
#ifdef Q_OS_MAC
process->start("testSetWorkingDirectory/testSetWorkingDirectory.app");
#else
process->start("testSetWorkingDirectory/testSetWorkingDirectory");
#endif
#ifndef Q_OS_WIN
QSKIP("setWorkingDirectory will chdir before starting the process on unices");
#endif
@ -2237,11 +2122,7 @@ void tst_QProcess::startFinishStartFinish()
for (int i = 0; i < 3; ++i) {
QCOMPARE(process.state(), QProcess::NotRunning);
#ifdef Q_OS_MAC
process.start("testProcessOutput/testProcessOutput.app");
#else
process.start("testProcessOutput/testProcessOutput");
#endif
#if !defined(Q_OS_WINCE)
QVERIFY(process.waitForReadyRead(10000));
QCOMPARE(QString::fromLatin1(process.readLine().trimmed()),