diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 6f06ba591f80a40c9168ad3d0de9bd8ce10d2fa7..9cab3c9e42dfbc9e0498a7017839d0aea82c8c0f 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -32,8 +32,11 @@ cross_compile:                              SUBDIRS -= tools
 
 # Disable the QtDBus tests if we can't connect to the session bus
 qtHaveModule(dbus) {
-    !system("dbus-send --session --type=signal / local.AutotestCheck.Hello"): {
-        warning("QtDBus is enabled but session bus is not available. Please check the installation.")
+    !system("dbus-send --session --type=signal / local.AutotestCheck.Hello >/dev/null 2>&1") {
+        contains(QT_CONFIG, dbus-linked): \
+            error("QtDBus is enabled but session bus is not available. Please check the installation.")
+        else: \
+            warning("QtDBus is enabled with runtime support, but session bus is not available. Skipping QtDBus tests.")
         SUBDIRS -= dbus
     }
 } else {