tests/tools: only run qdbus{cpp2xml,xml2cpp} tests if D-Bus is available

Strictly speaking, we don't need the *bus*, only libdbus-1, but some
machines in our CI appear to be misconfigured somehow. I don't
understand how they can both have and not have this library in the same
run.

Pick-to: 6.5 6.6
Change-Id: I80612a7d275c41f1baf0fffd177a66a04951948c
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
This commit is contained in:
Thiago Macieira 2023-08-11 11:10:48 -07:00
parent 14d1108d35
commit 7a1ffacca0
2 changed files with 26 additions and 24 deletions

View File

@ -4,6 +4,29 @@
# Order by dependency [*], then alphabetic. [*] If bugs in part A of
# our source would break tests of part B, then test A before B.
set(run_dbus_tests OFF)
if (QT_FEATURE_dbus)
set(run_dbus_tests ON)
if(NOT CMAKE_CROSSCOMPILING AND TARGET Qt::DBus)
execute_process(COMMAND dbus-send --session --type=signal / local.AutotestCheck.Hello
TIMEOUT 5
RESULT_VARIABLE dbus_session_test
OUTPUT_QUIET ERROR_QUIET)
if(NOT "${dbus_session_test}" STREQUAL "0")
set(run_dbus_tests OFF)
if(QT_FEATURE_dbus_linked)
message(WARNING
" QtDBus is enabled but session bus is not available for testing.\n"
" Please check the installation. Skipping QtDBus tests.")
else()
message(WARNING
" QtDBus is enabled with runtime support, but session bus is not available.\n"
" Skipping QtDBus tests.")
endif()
endif()
endif()
endif()
if(UIKIT)
# For now, only build CMake auto tests when QT_BUILD_MINIMAL_STATIC_TEST
# is a requested (which is basically what CI will build).
@ -57,29 +80,8 @@ if (TARGET Qt::Concurrent)
add_subdirectory(concurrent)
endif()
if (QT_FEATURE_dbus)
set(run_dbus_tests ON)
if(NOT CMAKE_CROSSCOMPILING AND TARGET Qt::DBus)
execute_process(COMMAND dbus-send --session --type=signal / local.AutotestCheck.Hello
TIMEOUT 5
RESULT_VARIABLE dbus_session_test
OUTPUT_QUIET ERROR_QUIET)
if(NOT "${dbus_session_test}" STREQUAL "0")
set(run_dbus_tests OFF)
if(QT_FEATURE_dbus_linked)
message(WARNING
" QtDBus is enabled but session bus is not available for testing.\n"
" Please check the installation. Skipping QtDBus tests.")
else()
message(WARNING
" QtDBus is enabled with runtime support, but session bus is not available.\n"
" Skipping QtDBus tests.")
endif()
endif()
endif()
if(run_dbus_tests)
add_subdirectory(dbus)
endif()
if(run_dbus_tests)
add_subdirectory(dbus)
endif()
if (TARGET Qt::Gui)

View File

@ -15,7 +15,7 @@ endif()
if(TARGET Qt::Widgets AND NOT ANDROID AND NOT IOS)
add_subdirectory(uic)
endif()
if(TARGET Qt::DBus)
if(run_dbus_tests)
add_subdirectory(qdbuscpp2xml)
add_subdirectory(qdbusxml2cpp)
endif()