aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2022-11-22 15:21:45 +0100
committerJarek Kobus <jaroslaw.kobus@qt.io>2022-11-23 12:59:29 +0000
commitdfd06ec1756b1a99ca887d5597c8f26d05d32ddf (patch)
treeef96ef3770c383f6db7c737a2e448377fdcb5f06 /tests
parent3468cd20ca8feeccf023091582d1390947822bd8 (diff)
TaskTree: Fix destruction of running task tree
Delete all storages that were created before. Change-Id: I8cbeb571424086b77fa7b19611c5b3f6cc1f4db1 Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/utils/tasktree/testapp/main.cpp18
-rw-r--r--tests/auto/utils/tasktree/tst_tasktree.cpp23
2 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/utils/tasktree/testapp/main.cpp b/tests/auto/utils/tasktree/testapp/main.cpp
index dc308cca292..218ff783a4d 100644
--- a/tests/auto/utils/tasktree/testapp/main.cpp
+++ b/tests/auto/utils/tasktree/testapp/main.cpp
@@ -2,7 +2,9 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#include <app/app_version.h>
+
#include <QString>
+#include <QThread>
#ifdef Q_OS_WIN
#include <crtdbg.h>
@@ -11,6 +13,7 @@
const char CRASH_OPTION[] = "-crash";
const char RETURN_OPTION[] = "-return";
+const char SLEEP_OPTION[] = "-sleep";
int main(int argc, char **argv)
{
@@ -39,6 +42,21 @@ int main(int argc, char **argv)
// lacking return value
return 1;
}
+ if (arg == SLEEP_OPTION) {
+ if (argc > 2) {
+ const auto secondsString = QString::fromLocal8Bit(argv[2]);
+ bool ok = false;
+ const int secondsVal = secondsString.toInt(&ok);
+ if (ok) {
+ QThread::sleep(secondsVal);
+ return 0;
+ }
+ // not an int return value
+ return 1;
+ }
+ // lacking return value
+ return 1;
+ }
}
// not recognized option
return 1;
diff --git a/tests/auto/utils/tasktree/tst_tasktree.cpp b/tests/auto/utils/tasktree/tst_tasktree.cpp
index 5d467f7cdef..9d98e0532a1 100644
--- a/tests/auto/utils/tasktree/tst_tasktree.cpp
+++ b/tests/auto/utils/tasktree/tst_tasktree.cpp
@@ -38,6 +38,7 @@ private slots:
void processTree();
void storage_data();
void storage();
+ void storageDestructor();
void cleanupTestCase();
@@ -631,6 +632,28 @@ void tst_TaskTree::storage()
QCOMPARE(errorCount, expectedErrorCount);
}
+void tst_TaskTree::storageDestructor()
+{
+ using namespace Tasking;
+
+ QCOMPARE(CustomStorage::instanceCount(), 0);
+ {
+ const auto setupProcess = [this](QtcProcess &process) {
+ process.setCommand(CommandLine(m_testAppPath, {"-sleep", "1"}));
+ };
+ const Group root {
+ Storage(TreeStorage<CustomStorage>()),
+ Process(setupProcess)
+ };
+
+ TaskTree processTree(root);
+ QCOMPARE(CustomStorage::instanceCount(), 0);
+ processTree.start();
+ QCOMPARE(CustomStorage::instanceCount(), 1);
+ }
+ QCOMPARE(CustomStorage::instanceCount(), 0);
+}
+
QTEST_GUILESS_MAIN(tst_TaskTree)
#include "tst_tasktree.moc"