summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QProcess: fix startCommand() with whitespace-only stringsThiago Macieira2024-04-191-0/+20
| | | | | | | | | | | | | | We'd end up trying to takeFirst() from an empty QStringList. [ChangeLog][QtCore][QProcess] Fixed a bug that would cause startCommand() to crash if passed a string that was empty or contained only whitespace characters. Fixes: QTBUG-124512 Pick-to: 6.5 6.6 6.7 Change-Id: I455fe22ef4ad4b2f9b01fffd17c7689095c39272 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QProcess/Unix: fix close() on invalid file descriptorThiago Macieira2024-03-121-5/+20
| | | | | | | | | | | | | | | | Commit 90bc0ad41f9937f9cba801b3166635f6f55e0678 ("QProcess/Unix: add failChildProcessModifier()") added this line that set childStartedPipe so that the failChildProcess() callback had something to write to. But we left it set on exit from QProcessPrivate::startDetached(), which caused the QProcess destructor to try and close it. Noticed when debugging the issue for QTBUG-123083. Pick-to: 6.7 6.7.0 Task-number: QTBUG-123083 Change-Id: I6818d78a57394e37857bfffd17bbc41c8400270f Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Change license for tests filesLucie Gérard2024-02-041-1/+1
| | | | | | | | | | | | According to QUIP-18 [1], all tests file should be LicenseRef-Qt-Commercial OR GPL-3.0-only [1]: https://contribute.qt-project.org/quips/18 Pick-to: 6.7 Task-number: QTBUG-121787 Change-Id: I9657df5d660820e56c96d511ea49d321c54682e8 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
* QProcess: align treatment of early start errorsThiago Macieira2024-01-221-3/+87
| | | | | | | | | | | | | | | | There are a couple of possible runtime errors that could happen before the state was changed to QProcess::Starting. This aligns the Unix code with Windows, which has the state transition at the top, and with the documentation which says we will enter QProcess::Starting state. Complements commit 956b2495285251e4840ec32885ffa2cfbb7bd79c, repeating what it did for Unix (removing the overwriting of the error message that openChannel() sets) on Windows. We also need to ensure cleanup() is always called. Pick-to: 6.6 6.7 Change-Id: I76ffba14ece04f24b43efffd17aafdd47f908bf1 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* QProcess: use enum types in tests instead of plain intAhmad Samir2024-01-221-28/+27
| | | | | | Pick-to: 6.7 Change-Id: Ibba85d28c2a5329f9224ffdc893f2dab8e672ee9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_QProcess::startStopStartStopBuffers: depend less on OS configurationThiago Macieira2023-10-181-8/+13
| | | | | | | | | | | | | | | | | The comment in this function made it clear that it really depended on the size of the pipe buffer in the OS. I don't see a way to make a pipe default to a different size on Linux -- it always defaults to PIPE_DEF_BUFFERS (16) and that value is only increased as a result of fcntl(F_SETPIPE_SZ), which we don't do. But we can be defensive and simply write until the OS can't take any more data. Drive-by update the comment on Windows to be clear that bytesToWrite() does work, but only while the child process is still running. Pick-to: 6.6 Task-number: QTBUG-80953 Change-Id: I9d43e5b91eb142d6945cfffd17866d22a4127e5e Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QProcess: remove a XFAIL for QNXGiuseppe D'Angelo2023-09-081-4/+0
| | | | | | | | | | | 91dcc76fc1 might have fixed the underlying issue, so we no longer need the XFAIL codepath at all. Fixes: QTBUG-114720 Change-Id: I67ccbed67a0536b679c50c26eb0b3e51c93dceeb Pick-to: 6.6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QProcess/Unix: add a simple way to reset the UID and GID for the childThiago Macieira2023-07-081-0/+6
| | | | | | | | | | | | | | | This is done as one of the last steps inside QProcess itself, so the child modifier and all other tasks still run with the parent process' permissions. On Linux, setting the UID to non-zero will also automatically clear the effective capabilities(7) set. This feature is only useful for setuid or setgid applications, so this commit updates the QCoreApplication::setSetuidAllowed() documentation to mention the QProcess flag. Change-Id: I3e3bfef633af4130a03afffd175e940c0668d244 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QProcess/Unix: add a few, basic session & terminal management flagsThiago Macieira2023-07-081-0/+44
| | | | | | | | | | | | Doing setsid() and disconnecting from the controlling terminal are, in addition to resetting the standard file descriptors to /dev/null, a common task that daemons do. These options allow a QProcess to force a child to be a daemon. QProcess ensures that the operations are done in the correct order. Change-Id: I3e3bfef633af4130a03afffd175e9451d2716d7a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QProcess on QNX: only expect failure if there is oneVolker Hilsheimer2023-07-091-2/+4
| | | | | | | | | | | The QProcessunixProcessParameters sometimes fails in CI with an XPASS. Unclear under what conditions QNX behaves correctly, so accept that it is unpredictable and only expect a failure when a failure is imminent. Amends f9c87cfd44bcf4b90cb45354252ef19f647b0469. Change-Id: Icf70861343747e6323c7953a2462b7bbc46549b3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QProcess/Unix: block all Unix signals between vfork() and exec()Thiago Macieira2023-06-281-2/+78
| | | | | | | | | | | | | | | | | | | This is similar to and extends the prevention of thread cancellation introduced by commit ba05af82d3d8b7cbc6e22f93cbf1e3d1575afefe. This prevents the situation in which a signal gets delivered (usually because of a crash) and the parent process' handler is run, doing things it shouldn't between vfork() and execve(). Most C libraries (all that I've investigated) unblock SIGABRT on abort(), so this doesn't affect them. Likewise, on most OSes, crashes ignore the signal block and terminate the application -- Darwin appears to be an exception, but vfork() is not enabled there. Both situations are tested by terminateInChildProcessModifier(). Task-number: QTBUG-113822 Change-Id: Ib5ce7a497e034ebabb2cfffd17628ca33969b7af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QProcess/Unix: fix setting SIGPIPE to SIG_IGN where SIG_DFL was intendedThiago Macieira2023-06-211-0/+4
| | | | | | | | | | | And take the opportunity to clarify what the QtVforkSafe namespace is doing. Amends commit e71c226d6f188abd811b28d3cb7529343f52d61f. Pick-to: 6.6 Change-Id: I443cf0c8a76243eead33fffd1767f3fa390a7cdd Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QProcess/Unix: capture the child process modifier exception's what()Thiago Macieira2023-06-091-1/+9
| | | | | | Change-Id: I5f7f427ded124479baa6fffd175ffb017b6cd13c Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QProcess/Unix: add failChildProcessModifier()Thiago Macieira2023-06-091-15/+112
| | | | | | | | | | | | | | | QProcess detects other types of failures from inside the modifier as successful starts, because the childStartedPipe gets closed without an error condition getting written. The new method allows a reporting as a proper failure-to-start. Added tests for both cases. [ChangeLog][QtCore][QProcess] Added failChildProcessModifier(). Change-Id: Icfe44ecf285a480fafe4fffd174da2b10306d3c2 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QProcess/Unix: update the close-file-descriptors feature with a minimumThiago Macieira2023-06-091-3/+48
| | | | | | | | | | | | | | | | | | | | So that one can pass a few extra file descriptors to the child while still closing all the rest. strace -f of this test showed on Linux: [pid 117952] dup3(4, 0, 0) = 0 [pid 117952] dup3(9, 1, 0) = 1 [pid 117952] dup3(11, 2, 0) = 2 [pid 117952] close(12) = 0 [pid 117952] dup2(100, 3) = 3 [pid 117952] close_range(4, 2147483647, 0) = 0 [pid 117952] execve("testUnixProcessParameters/testUnixProcessParameters", ["testUnixProcessParameters/testUn"..., "file-descriptors2", "3", "100"], 0x561793dc87d0 /* 120 vars */ <unfinished ...> Pick-to: 6.6 Change-Id: I3e3bfef633af4130a03afffd175e984bf50b558d Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QProcess/Unix: reset the signal block if ResetSignalHandlers requestedThiago Macieira2023-06-091-0/+9
| | | | | | | | | | | This amends commit f9c87cfd44bcf4b90cb45354252ef19f647b0469 to reset the signal block mask too, not just the signal handlers. For this, SIGPIPE is not treated specially. Pick-to: 6.6 Change-Id: Ib5ce7a497e034ebabb2cfffd17627289614bf315 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* tst_QProcess: put the tests in the right orderThiago Macieira2023-06-031-75/+73
| | | | | | | | | They were in the right order before rebasing multiple times. kdiff3 is currently broken, so I don't know what happened. Change-Id: Ib5ce7a497e034ebabb2cfffd17626fcf46c541fd Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QProcess/Linux: add a flag to re-enable the vfork()-like semanticsThiago Macieira2023-05-221-2/+16
| | | | | | | | | | | | | | | | | | Commit 29b2fe40dc778ec73da7e5643fcfd8979d8ecebc disabled it by reverting commit d6bf71123d3ef073f25610345cb5dc920e4fb783. We now add the promised flag to opt-in. The flag is added to all Unix systems, but it really only applies to Linux right now. No ChangeLog because the whole UnixProcessParameters structure is new and has its own changelog. Task-number: QTBUG-104493 Task-number: QTBUG-111243 Task-number: QTBUG-111964 Change-Id: Icfe44ecf285a480fafe4fffd174d4effd3382495 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QProcess/Unix: add setUnixProcessParameters()Thiago Macieira2023-05-221-0/+107
| | | | | | | | | | | | | | | This commit adds those three flags that are either frequent enough or difficult to do: close all file descriptors above stderr and reset the signal handlers. Setting SIGPIPE to be ignored isn't critical, but is required when the ResetSignalHandlers flag is used, as this is run after the user child process modifier. [ChangeLog][QtCore][QProcess] Added setUnixProcessParameters() function that can be used to modify certain settings of the child process, without the need to provide a callback using setChildProcessModifier(). Change-Id: Icfe44ecf285a480fafe4fffd174d0d1d63840403 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QProcess/Unix: enable setChildProcessModifier for startDetachedThiago Macieira2023-05-151-8/+21
| | | | | | | | | | | | | | Do this by making the actual child-execution code common between startProcess() and startDetached(). It does mean we've moved the chdir() operation from the child to the grandchild process, though. [ChangeLog][QtCore][QProcess] The modifier function set with setChildProcessModifier() will now also be executed when the process is started with startDetached(). Change-Id: Icfe44ecf285a480fafe4fffd174d9aa57dd7dfff Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QProcess/Unix: improve the error message if the child modifier throwsThiago Macieira2023-05-151-2/+2
| | | | | | | | Functionality added for 6.5, but after translatable string freeze. Change-Id: Icfe44ecf285a480fafe4fffd174d984c5349e0cb Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QProcess/Unix: protect against stack unwinding in the child process stubThiago Macieira2023-05-151-0/+29
| | | | | | | | | | | | | | | | | | | | | | There are two types of stack unwinding that can happen on Unix systems: C++ exceptions and PThread cancellations (on some systems, like Linux, PThread cancellations can be caught in catch(...) statements). We call a variety of PThread cancellation functions from inside the child stub, like close(). To avoid problems, we disable PThread cancellations completely before fork() or vfork(). The C++ exception case is simpler, because we can be sure of catching them with the catch (...) statement and simply transform them into an error message. This is also testable, which the PThread cancellation isn't. The error message isn't ideal because we're string-frozen. I'll improve it for 6.6. Pick-to: 6.5 Change-Id: Icfe44ecf285a480fafe4fffd174d97a475c93ff1 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* tst_QProcess: move setChildProcessModifier test to a Q_OS_UNIX sectionThiago Macieira2023-05-151-39/+38
| | | | | | | | | | There's no need to say it's getting skipped on Windows. moc *can* parse the #ifdefs these days. Pick-to: 6.5 Change-Id: Icfe44ecf285a480fafe4fffd174d95c709ff6a74 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* Corelib: s/Q_OS_MAC/Q_OS_DARWIN/wg except for doc and definitionEdward Welbourne2023-03-201-1/+1
| | | | | | | | | | I got tired of being told off by the inanity 'bot for faithfully reflecting existing #if-ery in new #if-ery. Retain only the documentation and definition of the deprecated define. Change-Id: I47f47b76bd239a360f27ae5afe593dfad8746538 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QThread: add sleep(std::chrono::nanoseconds) overloadAhmad Samir2023-03-131-1/+1
| | | | | | | | | | | | | | All the other overloads are implemented using the new one. Windows change relies on the pre-check in the code review making sure it compiles. [ChangeLog][QtCore][QThread] Added sleep(std::chrono::nanoseconds) overload. Task-number: QTBUG-110059 Change-Id: I9a4f4bf09041788ec9275093b6b8d0386521e286 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Skip QProcess tests when run under ASanVille Voutilainen2022-12-161-0/+3
| | | | | | | | | | These tests exhibit weird crashes when run under ASan, but sometimes they fail sometimes they don't. Pending more insight, just skip this test under that configuration. Fixes: QTBUG-109329 Change-Id: I49d940de419f7166aab0da0b8c2b44297c4b6d74 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Port from container::count() and length() to size() - V5Marc Mutz2022-11-031-33/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to handle typedefs and accesses through pointers, too: const std::string o = "object"; auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); }; auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) { auto exprOfDeclaredType = [&](auto decl) { return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o); }; return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes)))); }; auto renameMethod = [&] (ArrayRef<StringRef> classes, StringRef from, StringRef to) { return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)), callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))), changeTo(cat(access(o, cat(to)), "()")), cat("use '", to, "' instead of '", from, "'")); }; renameMethod(<classes>, "count", "size"); renameMethod(<classes>, "length", "size"); except that the on() matcher has been replaced by one that doesn't ignoreParens(). a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'. Added two NOLINTNEXTLINEs in tst_qbitarray and tst_qcontiguouscache, to avoid porting calls that explicitly test count(). Change-Id: Icfb8808c2ff4a30187e9935a51cad26987451c22 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Port from container.count()/length() to size()Marc Mutz2022-10-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* tst_qprocess: remove unused loop counterJohannes Kauffmann2022-09-201-2/+0
| | | | | Change-Id: I1eece5a676cfa02fff27be01f25b07ddd82c40d6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QProcess: skip processesInMultipleThreads test on emulatorsVolker Hilsheimer2022-07-131-0/+5
| | | | | | | | | | The test has timed out when run on ARM in qemu. We start more threads than the ideal count, which is likely too much for the emulator when not running the native architecture. Pick-to: 6.4 Change-Id: I42e11945070646551e77c10618df762a4bffc8ba Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use SPDX license identifiersLucie Gérard2022-05-161-28/+3
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Ensure that readAllStandardError() doesn't crash on assertJarek Kobus2022-04-091-0/+10
| | | | | | | | | | | Ensure that it's safe to call readAllStandardError() when process channel mode is set to MergedChannels. Pick-to: 6.3 6.3.0 Task-number: QTBUG-102177 Task-number: QTCREATORBUG-27196 Change-Id: I01073255d9347dee4654d602802a12d341372b73 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QProcess/Unix: ensure we don't accidentally execute something from CWDThiago Macieira2022-02-091-1/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unless "." (or the empty string) is in $PATH, we're not supposed to find executables in the current directory. This is how the Unix shells behave and we match their behavior. It's also the behavior Qt had prior to 5.9 (commit 28666d167aa8e602c0bea25ebc4d51b55005db13). On Windows, searching the current directory is the norm, so we keep that behavior. This commit does not add an explicit check for an empty return from QStandardPaths::findExecutable(). Instead, we allow that empty string to go all the way to execve(2), which will fail with ENOENT. We could catch it early, before fork(2), but why add code for the error case? See https://kde.org/info/security/advisory-20220131-1.txt [ChangeLog][Important Behavior Changes] When passed a simple program name with no slashes, QProcess on Unix systems will now only search the current directory if "." is one of the entries in the PATH environment variable. This bug fix restores the behavior QProcess had before Qt 5.9. If launching an executable in the directory set by setWorkingDirectory() or inherited from the parent is intended, pass a program name starting with "./". For more information and best practices about finding an executable, see QProcess' documentation. Pick-to: 5.15 6.2 6.3 Change-Id: I54f205f6b7314351b078fffd16cf7013c97ee9fb Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QNX: Cannot handle threads in given timePasi Petäjäjärvi2021-12-121-0/+4
| | | | | | | | Large amount of threads is unstable and do not finish in given time Pick-to: 6.2 Change-Id: I0ce4c8cd278d6611c9e9da7326048279ccc458fd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Revert "QProcess: do not emit aboutToClose() twice"Alex Trotsenko2021-09-241-2/+0
| | | | | | | | | | This reverts commit efb90f6e7ed3e8d4f7b6c0fb96012cb3a9a9d037. Reason for revert: behavior change for signal listeners Change-Id: Ibe3c5d496cd61a9fccab17a10cc9fda8334fc9d4 Reviewed-by: Björn Schäpers <qt-codereview@hazardy.de> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QProcess: do not emit aboutToClose() twiceAlex Trotsenko2021-09-191-0/+2
| | | | | | | | | This signal is emitted by the QIODevice itself, so we don't have to emit it from QProcess::close(). Pick-to: 6.1 6.2 Change-Id: I9165b3eebadc17a66cc834d5ef54441d13f23d7d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use a scope-guard to take care of process deletion in a testEdward Welbourne2021-08-171-6/+5
| | | | | | | | | | Doing the deletion at the end of the block only works if the test passes. Drive-by: remove spurious braces from single-line bodies of single-line controls. The QTest macros are done properly. Pick-to: 6.2 6.1 5.15 Change-Id: I83002547dba49ab9792f4db44d73151b1c036900 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* tst_QProcess: increase wait time and remove ill-advised QCOMPAREThiago Macieira2021-05-031-2/+1
| | | | | | | The QCOMPARE made dead code of a more verbose QVERIFY2 below Change-Id: I26b8286f61534f88b649fffd166b67d8603280a7 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QWindowsPipe{Reader|Writer}: restructure signalsAlex Trotsenko2021-04-151-1/+3
| | | | | | | | | | | | | | | | | | | For QProcess, there is no point in suppressing recursive QWPR::readyRead() emission, as the former manages this logic itself. On top of that, the non-recursive nature of QWPR::readyRead() indirectly disallowed reading from the channels inside QProcess::waitForReadyRead(), if that is called from a slot connected to QProcess::readyRead(). QWPW had two signals, one allowing recursion and one not. This commit allows recursion of QWPR::readyRead() and QWPW::bytesWritten(), and moves recursion suppression to the higher- level classes. This makes the code more uniform and efficient, at the cost of a few duplicated lines. Change-Id: Ib20017fff4d92403d0bf2335f1622de4aa1ddcef Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QProcess/Unix: remove outdated notices about use of posix_spawn() on QNXThiago Macieira2021-02-211-3/+0
| | | | | | | | | We haven't used the spawn functionality on QNX since Qt 5.7 (commit 005a8bfbf0022f03dafafcf2b5c438ccf0675a49) because that's when we dropped support for QNX 6.5.0. Change-Id: Ic90d8429a0eb4837971dfffd1664f9712bdce2d8 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QProcess::startDetached/Unix: report which function failedThiago Macieira2021-02-211-0/+4
| | | | | | | | Like QProcess::start(). Pick-to: 6.1 Change-Id: Ic90d8429a0eb4837971dfffd1664ef1293a6523d Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QProcess::startDetached: set the error condition on failure to startThiago Macieira2021-02-211-0/+2
| | | | | | | | | | | | And set *pid to -1. [ChangeLog][QtCore][QProcess] If a startDetached() fails to start the target application, the QProcess object should now have a proper error string in errorString(). Pick-to: 6.1 Change-Id: Ic90d8429a0eb4837971dfffd1664e825ffcb923e Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QProcess::startDetached/Unix: move up the chdir() and remove qWarningThiago Macieira2021-02-181-0/+15
| | | | | | | | | | That qWarning cannot be in the child process (we don't know if a user logger is fork-no-exec-safe) and the failure to chdir() should be reported as a failure in QProcess::startDetached() instead. Change-Id: Ic90d8429a0eb4837971dfffd1664e7577c81610b Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: David Llewellyn-Jones <david.llewellyn-jones@jolla.com>
* tst_qprocess: enable test again for cross-compilationsSamuli Piippo2021-02-161-3/+0
| | | | | | | | | | | | All test cases pass with QEMU. Fixes: QTBUG-85287 Fixes: QTBUG-67760 Pick-to: 6.1 Change-Id: I188d70c05f6d858e17f1099d3c02862ea9b2a2ab Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Move QEMU emulation detector to QTestSamuli Piippo2021-02-131-3/+2
| | | | | | | | | The emulation detection has been usable only on qtbase tests, move it to QTest so that it can be used in other modules as well. Pick-to: 6.1 Change-Id: I4b2321b7856414d7b1cfd5e6b1405a633c6bb878 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QProcess: allow pipelining for detached processesAlex Trotsenko2020-12-311-1/+5
| | | | | | | | [ChangeLog][QtCore][QProcess] Added support for setStandardOutputProcess() with startDetached(). Change-Id: I61278cdb7084127f583c8c017688da392017b44c Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QProcess: allow merged channels forwarding for detached processesAlex Trotsenko2020-12-311-0/+4
| | | | | | | | [ChangeLog][QtCore][QProcess] Added support for QProcess::MergedChannels mode with startDetached(). Change-Id: I953ad2063322015332269522a297f8e2842e438c Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* Replace QtTest headers with QTestDavid Skoland2020-12-221-1/+4
| | | | | | | | | | | Complete search and replace of QtTest and QtTest/QtTest with QTest, as QtTest includes the whole module. Replace all such instances with correct header includes. See Jira task for more discussion. Fixes: QTBUG-88831 Change-Id: I981cfae18a1cabcabcabee376016b086d9d01f44 Pick-to: 6.0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* tst_QProcess: fix compilation on WindowsAlex Trotsenko2020-11-221-0/+2
| | | | | | | | | | Suppress warning: ..\tst_qprocess.cpp:272:13: warning: 'void childProcessModifier(int)' defined but not used ... Change-Id: Idf601df78be256cfbee0ca80252d1c364c712c8e Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* Properly deprecate QProcess::pidVolker Hilsheimer2020-10-011-1/+1
| | | | | | | | | | | Address an old ### Qt 5 comment. The method has been documented as deprecated and replaced by QProcess::processId since at least Qt 5.9, so we can first properly flag it as such for 5.15.2, and remove it from Qt 6 in a follow-up commit. Change-Id: Ic4e3351740617083b16723db8eef7a341bccfbf6 Pick-to: 5.15 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>