From af75109ba5c81e29792f61753b05abae2db5d52b Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Thu, 12 Sep 2024 09:36:23 +0200 Subject: [PATCH] Process: Add a test which creates process reaper in non-main thread Change-Id: I17ef75f42cd855b47f385dfbb3bac955eb7e0998 Reviewed-by: Marcus Tillmanns --- tests/auto/utils/process/tst_process.cpp | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/auto/utils/process/tst_process.cpp b/tests/auto/utils/process/tst_process.cpp index a1e92edfe28..d6e283e4f9a 100644 --- a/tests/auto/utils/process/tst_process.cpp +++ b/tests/auto/utils/process/tst_process.cpp @@ -5,6 +5,7 @@ #include +#include #include #include #include @@ -98,6 +99,9 @@ class tst_Process : public QObject private slots: void initTestCase(); + // Keep me as a first test to ensure that all singletons are working OK + // when being instantiated from the non-main thread. + void processReaperCreatedInNonMainThread(); void testEnv() { if (HostOsInfo::isWindowsHost()) @@ -250,6 +254,27 @@ Q_DECLARE_METATYPE(ProcessArgs::SplitError) Q_DECLARE_METATYPE(OsType) Q_DECLARE_METATYPE(ProcessResult) +static bool deleteRunningProcess() +{ + SubProcessConfig subConfig(ProcessTestApp::SimpleTest::envVar(), {}); + Process process; + subConfig.setupSubProcess(&process); + process.start(); + process.waitForStarted(); + return process.isRunning(); +} + +void tst_Process::processReaperCreatedInNonMainThread() +{ + Singleton::deleteAll(); + + auto future = Utils::asyncRun(deleteRunningProcess); + future.waitForFinished(); + QVERIFY(future.result()); + + Singleton::deleteAll(); +} + void tst_Process::multiRead_data() { QTest::addColumn("processChannel");