From b488ddf54c2bf5d90c418cfbc9b2f13809a61a83 Mon Sep 17 00:00:00 2001 From: Dominik Holland Date: Tue, 20 Feb 2024 16:07:09 +0100 Subject: 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 --- tests/auto/core/ifcodegen/backends/server_qtro/serverMain.cpp | 2 ++ tests/auto/core/ifcodegen/backends/test/CMakeLists.txt | 6 ++++++ tests/auto/core/ifcodegen/backends/test/simulation.qml | 2 ++ tests/auto/core/ifcodegen/backends/test/tst_backends.cpp | 10 ++++++++-- 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; -- cgit v1.2.3