diff options
author | James McDonnell <jmcdonnell@qnx.com> | 2016-03-18 12:53:12 -0400 |
---|---|---|
committer | James McDonnell <jmcdonnell@qnx.com> | 2016-03-22 15:20:06 +0000 |
commit | 005a8bfbf0022f03dafafcf2b5c438ccf0675a49 (patch) | |
tree | 653114a219805930e4852ae8cb2c8894e85f8ccc /tests | |
parent | 663263c124339db432cd5596b87462343096dd83 (diff) |
Remove QPROCESS_USE_SPAWN and all that it surrounds
The spawn code was only used to make QProcess work on QNX 6.5.0. Fork
works on QNX 6.6.0. The QNX spawn implementation has a flaw that causes
a deadlock in certain situations. When a working directory is specified
for the process, the QNX spawn implementation stops all threads except
the one doing the spawn so that it can temporarily change the process'
working directory. This can lead to a deadlock if the thread does
anything that conficts with something being done in a stopped thread.
QNX 6.5.0 is no longer supported in Qt 5.6.0 so we can just switch QNX
to the fork implementation and get rid of the spawn implementation.
Made a QNX specific adjustment to the hardExit test. There's a bug
in the OS that the test can run into because it does something that
normal applications wouldn't.
Task-number: QTBUG-47250
Change-Id: Ib32567d2c15ce651815858000035ac5aa6f35224
Reviewed-by: Dan Cape <dcape@qnx.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/io/qprocess/tst_qprocess.cpp | 38 |
1 files changed, 10 insertions, 28 deletions
diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index 46bf1a19e8..7e1d5487ba 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -45,8 +45,6 @@ #include <QtNetwork/QHostInfo> #include <stdlib.h> -# include <private/qprocess_p.h> // only so we get QPROCESS_USE_SPAWN - typedef void (QProcess::*QProcessFinishedSignal1)(int); typedef void (QProcess::*QProcessFinishedSignal2)(int, QProcess::ExitStatus); typedef void (QProcess::*QProcessErrorSignal)(QProcess::ProcessError); @@ -325,9 +323,6 @@ void tst_QProcess::startDetached() { QVERIFY(QProcess::startDetached("testProcessNormal/testProcessNormal", QStringList() << "arg1" << "arg2")); -#ifdef QPROCESS_USE_SPAWN - QEXPECT_FAIL("", "QProcess cannot detect failure to start when using posix_spawn()", Continue); -#endif QCOMPARE(QProcess::startDetached("nonexistingexe"), false); } @@ -707,9 +702,6 @@ void tst_QProcess::waitForFinished() QCOMPARE(output.count("\n"), 10*1024); process.start("blurdybloop"); -#if defined(QPROCESS_USE_SPAWN) && !defined(Q_OS_QNX) - QEXPECT_FAIL("", "QProcess cannot detect failure to start when using posix_spawn()", Abort); -#endif QVERIFY(!process.waitForFinished()); QCOMPARE(process.error(), QProcess::FailedToStart); } @@ -922,6 +914,16 @@ void tst_QProcess::hardExit() #endif QVERIFY2(proc.waitForStarted(), qPrintable(proc.errorString())); + +#if defined(Q_OS_QNX) + // QNX may lose the kill if it's delivered while the forked process + // is doing the exec that morphs it into testProcessEcho. It's very + // unlikely that a normal application would do such a thing. Make + // sure the test doesn't accidentally try to do it. + proc.write("A"); + QVERIFY(proc.waitForReadyRead(5000)); +#endif + proc.kill(); QVERIFY(proc.waitForFinished(5000)); @@ -1503,11 +1505,6 @@ void tst_QProcess::nativeArguments() void tst_QProcess::exitCodeTest() { for (int i = 0; i < 255; ++i) { -#ifdef QPROCESS_USE_SPAWN - // POSIX reserves exit code 127 when using posix_spawn - if (i == 127) - continue; -#endif QProcess process; process.start("testExitCodes/testExitCodes " + QString::number(i)); QVERIFY(process.waitForFinished(5000)); @@ -1518,9 +1515,6 @@ void tst_QProcess::exitCodeTest() void tst_QProcess::failToStart() { -#if defined(QPROCESS_USE_SPAWN) && !defined(Q_OS_QNX) - QSKIP("QProcess cannot detect failure to start when using posix_spawn()"); -#endif qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError"); qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus"); qRegisterMetaType<QProcess::ProcessState>("QProcess::ProcessState"); @@ -1591,9 +1585,6 @@ void tst_QProcess::failToStart() void tst_QProcess::failToStartWithWait() { -#if defined(QPROCESS_USE_SPAWN) && !defined(Q_OS_QNX) - QSKIP("QProcess cannot detect failure to start when using posix_spawn()"); -#endif qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError"); qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus"); @@ -1623,9 +1614,6 @@ void tst_QProcess::failToStartWithWait() void tst_QProcess::failToStartWithEventLoop() { -#if defined(QPROCESS_USE_SPAWN) && !defined(Q_OS_QNX) - QSKIP("QProcess cannot detect failure to start when using posix_spawn()"); -#endif qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError"); qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus"); @@ -1912,9 +1900,6 @@ void tst_QProcess::waitForReadyReadForNonexistantProcess() QVERIFY(!process.waitForReadyRead()); // used to crash process.start("doesntexist"); QVERIFY(!process.waitForReadyRead()); -#if defined(QPROCESS_USE_SPAWN) && !defined(Q_OS_QNX) - QEXPECT_FAIL("", "QProcess cannot detect failure to start when using posix_spawn()", Abort); -#endif QCOMPARE(errorSpy.count(), 1); QCOMPARE(errorSpy.at(0).at(0).toInt(), 0); QCOMPARE(errorSpy2.count(), 1); @@ -2282,9 +2267,6 @@ void tst_QProcess::setNonExistentWorkingDirectory() // while on Unix with fork it's relative to the child's (with posix_spawn, it could be either). process.start(QFileInfo("testSetWorkingDirectory/testSetWorkingDirectory").absoluteFilePath()); QVERIFY(!process.waitForFinished()); -#ifdef QPROCESS_USE_SPAWN - QEXPECT_FAIL("", "QProcess cannot detect failure to start when using posix_spawn()", Continue); -#endif QCOMPARE(int(process.error()), int(QProcess::FailedToStart)); } #endif |