summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2021-02-18 09:22:09 -0800
committerThiago Macieira <thiago.macieira@intel.com>2021-02-18 12:34:17 -0800
commit31bb141aed52549fae52f2156ac66bd2647cad16 (patch)
tree5662493d18c0dfe4cff34a5ab9d329b92d4208fc /tests/auto/corelib/io/qprocess/tst_qprocess.cpp
parente274d56effc13e4ba7c5fcec783c3227551551c6 (diff)
QProcess::startDetached/Unix: move up the chdir() and remove qWarning
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>
Diffstat (limited to 'tests/auto/corelib/io/qprocess/tst_qprocess.cpp')
-rw-r--r--tests/auto/corelib/io/qprocess/tst_qprocess.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
index 82a2cb1254..e68fccf4be 100644
--- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
@@ -118,6 +118,7 @@ private slots:
void discardUnwantedOutput();
void setWorkingDirectory();
void setNonExistentWorkingDirectory();
+ void detachedSetNonExistentWorkingDirectory();
void exitStatus_data();
void exitStatus();
@@ -2266,6 +2267,20 @@ void tst_QProcess::setNonExistentWorkingDirectory()
#endif
}
+void tst_QProcess::detachedSetNonExistentWorkingDirectory()
+{
+ QProcess process;
+ process.setWorkingDirectory("this/directory/should/not/exist/for/sure");
+
+ // use absolute path because on Windows, the executable is relative to the parent's CWD
+ // while on Unix with fork it's relative to the child's (with posix_spawn, it could be either).
+ process.setProgram(QFileInfo("testSetWorkingDirectory/testSetWorkingDirectory").absoluteFilePath());
+
+ qint64 pid = -1;
+ QVERIFY(!process.startDetached(&pid));
+ QCOMPARE(pid, -1);
+}
+
void tst_QProcess::startFinishStartFinish()
{
QProcess process;