summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Holland <dominik.holland@qt.io>2024-02-20 16:07:09 +0100
committerDominik Holland <dominik.holland@qt.io>2024-02-20 17:55:52 +0100
commitb488ddf54c2bf5d90c418cfbc9b2f13809a61a83 (patch)
treeabc869ac73b3bb817e5793fcf009d03e5fd65493
parent9f10ab61b13017714b4562cf812ca9e0626de656 (diff)
tst_backends: Try to shutdown the server process before killing it
Otherwise the code-coverage data is not written correctly. Pick-to: 6.7 Change-Id: Ia5efe74e4e55db79ffac682c007acd4d06e8cc9d Reviewed-by: Robert Griebl <robert.griebl@qt.io>
-rw-r--r--tests/auto/core/ifcodegen/backends/server_qtro/serverMain.cpp2
-rw-r--r--tests/auto/core/ifcodegen/backends/test/CMakeLists.txt6
-rw-r--r--tests/auto/core/ifcodegen/backends/test/simulation.qml2
-rw-r--r--tests/auto/core/ifcodegen/backends/test/tst_backends.cpp10
4 files changed, 18 insertions, 2 deletions
diff --git a/tests/auto/core/ifcodegen/backends/server_qtro/serverMain.cpp b/tests/auto/core/ifcodegen/backends/server_qtro/serverMain.cpp
index 16f74212..898a0a13 100644
--- a/tests/auto/core/ifcodegen/backends/server_qtro/serverMain.cpp
+++ b/tests/auto/core/ifcodegen/backends/server_qtro/serverMain.cpp
@@ -123,6 +123,8 @@ void serverMain(QIfRemoteObjectsConfig &config)
contactsModelService->update(0, updatedContact);
} else if (cmd == u"remove"_s) {
contactsModelService->remove(0);
+ } else if (cmd == u"quit"_s) {
+ qApp->quit();
}
});
}
diff --git a/tests/auto/core/ifcodegen/backends/test/CMakeLists.txt b/tests/auto/core/ifcodegen/backends/test/CMakeLists.txt
index ea6b4bdc..14bbf422 100644
--- a/tests/auto/core/ifcodegen/backends/test/CMakeLists.txt
+++ b/tests/auto/core/ifcodegen/backends/test/CMakeLists.txt
@@ -14,5 +14,11 @@ qt_internal_add_test(tst_backends
TESTDATA simulation.qml minimal_simulation_data.json server.conf
)
+add_custom_target(tst_backends_extra_files
+ SOURCES
+ simulation.qml
+ minimal_simulation_data.json
+)
+
set_target_properties(tst_backends PROPERTIES RUNTIME_OUTPUT_DIRECTORY ../)
diff --git a/tests/auto/core/ifcodegen/backends/test/simulation.qml b/tests/auto/core/ifcodegen/backends/test/simulation.qml
index 5a3deb99..946733b8 100644
--- a/tests/auto/core/ifcodegen/backends/test/simulation.qml
+++ b/tests/auto/core/ifcodegen/backends/test/simulation.qml
@@ -157,6 +157,8 @@ QtObject {
echo.contactList.update(0, Echomodule.contact("Mr B.", 30, true, undefined))
} else if (cmd === "remove") {
echo.contactList.remove(0)
+ } else if (cmd === "quit") {
+ Qt.quit()
}
}
}
diff --git a/tests/auto/core/ifcodegen/backends/test/tst_backends.cpp b/tests/auto/core/ifcodegen/backends/test/tst_backends.cpp
index f65262ac..486680be 100644
--- a/tests/auto/core/ifcodegen/backends/test/tst_backends.cpp
+++ b/tests/auto/core/ifcodegen/backends/test/tst_backends.cpp
@@ -127,8 +127,14 @@ void BackendsTest::cleanup()
{
if (m_serverProcess->state() == QProcess::Running) {
qInfo() << "Stopping Server Process";
- m_serverProcess->kill();
- QVERIFY(m_serverProcess->waitForFinished());
+
+ sendCmd("quit");
+ m_serverProcess->waitForFinished(500);
+
+ if (m_serverProcess->state() == QProcess::Running) {
+ m_serverProcess->kill();
+ QVERIFY(m_serverProcess->waitForFinished());
+ }
}
delete m_localSocket;
m_localSocket = nullptr;