summaryrefslogtreecommitdiffstats
path: root/tests/auto/dbus/qdbusmarshall
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2015-05-19 11:56:24 -0700
committerThiago Macieira <thiago.macieira@intel.com>2015-05-26 07:20:35 +0000
commitbd1f5b268a1095ec6a4856cef46bc8550a8a8af8 (patch)
tree92b5070846667a1a0e163590e71c35913e241c6c /tests/auto/dbus/qdbusmarshall
parent75af24a2d121ab56c5b60524bf1d7f2af1613025 (diff)
Make sure we don't call dbus_connection_can_send_type on too old libdbus
This function was introduced alongside the support for Unix file descriptors, so it's a good indicator of whether Unix FDs are supported. Ever since dbus_minimal_p.h, however, DBUS_TYPE_UNIX_FD may be defined even if the system libs don't support it. In order to fix this issue, I had to fix what was apparently a merge conflict resolution mistake and remove the #ifdef around the test. Doing the latter is a good idea due to moc being unable to find <dbus/dbus.h>. This was tested with both linked and dynamically-loaded libdbus-1. Task-number: QTBUG-46199 Change-Id: I66a35ce5f88941f29aa6ffff13dfb4b5438613a3 Reviewed-by: Jani Vähäkangas <jani.vahakangas@theqtcompany.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'tests/auto/dbus/qdbusmarshall')
-rw-r--r--tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp33
1 files changed, 24 insertions, 9 deletions
diff --git a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp
index 76e740dc5f..16314a5dc5 100644
--- a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp
+++ b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp
@@ -39,10 +39,7 @@
#include <QtDBus/private/qdbusutil_p.h>
#include <QtDBus/private/qdbusconnection_p.h>
-
-#define QT_LINKED_LIBDBUS
-#include <QtDBus/private/qdbusutil_p.h>
-#include <QtDBus/private/qdbusconnection_p.h>
+#include <QtDBus/private/qdbus_symbols_p.h>
static const char serviceName[] = "org.qtproject.autotests.qpong";
static const char objectPath[] = "/org/qtproject/qpong";
@@ -85,10 +82,8 @@ private slots:
void sendCallErrors_data();
void sendCallErrors();
-#ifdef DBUS_TYPE_UNIX_FD
void receiveUnknownType_data();
void receiveUnknownType();
-#endif
void demarshallPrimitives_data();
void demarshallPrimitives();
@@ -1017,7 +1012,6 @@ void tst_QDBusMarshall::sendCallErrors()
QCOMPARE(reply.errorMessage(), errorMsg);
}
-#ifdef DBUS_TYPE_UNIX_FD
// If DBUS_TYPE_UNIX_FD is not defined, it means the current system's D-Bus library is too old for this test
void tst_QDBusMarshall::receiveUnknownType_data()
{
@@ -1075,6 +1069,27 @@ public:
}
};
+// mostly the same as qdbusintegrator.cpp:connectionCapabilies
+static bool canSendUnixFd(DBusConnection *connection)
+{
+ typedef dbus_bool_t (*can_send_type_t)(DBusConnection *, int);
+ static can_send_type_t can_send_type = 0;
+
+#if defined(QT_LINKED_LIBDBUS)
+# if DBUS_VERSION-0 >= 0x010400
+ can_send_type = dbus_connection_can_send_type;
+# endif
+#else
+ // run-time check if the next functions are available
+ can_send_type = (can_send_type_t)qdbus_resolve_conditionally("dbus_connection_can_send_type");
+#endif
+
+#ifndef DBUS_TYPE_UNIX_FD
+# define DBUS_TYPE_UNIX_FD int('h')
+#endif
+ return can_send_type && can_send_type(connection, DBUS_TYPE_UNIX_FD);
+}
+
void tst_QDBusMarshall::receiveUnknownType()
{
QDBusConnection con = QDBusConnection::sessionBus();
@@ -1088,7 +1103,8 @@ void tst_QDBusMarshall::receiveUnknownType()
QVERIFY2(rawcon.data(), error.name);
// check if this bus supports passing file descriptors
- if (!q_dbus_connection_can_send_type(rawcon.data(), DBUS_TYPE_UNIX_FD))
+
+ if (!canSendUnixFd(rawcon.data()))
QSKIP("Your session bus does not allow sending Unix file descriptors");
// make sure this QDBusConnection won't handle Unix file descriptors
@@ -1184,7 +1200,6 @@ void tst_QDBusMarshall::receiveUnknownType()
QCOMPARE(spy.list.at(0).arguments().at(0).userType(), receivedTypeId);
}
}
-#endif
void tst_QDBusMarshall::demarshallPrimitives_data()
{