summaryrefslogtreecommitdiffstats
path: root/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2015-01-01 19:56:06 -0200
committerThiago Macieira <thiago.macieira@intel.com>2015-01-06 17:36:58 +0100
commitaa83bacb14dac06eb7226c8c688f37eeecec15d4 (patch)
tree223ea192ba0b4eb268c352b67e3589907a567411 /tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp
parent01fc82e3574614762d2ce061dd45ce4995c79e7f (diff)
Autotest: fix a race condition in verifying a peer D-Bus connected
On the unit test side, everything is sequential: we first ask for the connection, verify that it is connected, then ask the remote side via the session bus if it is connected. Unfortunately, the remote site may handle things in a different order: it may handle the incoming function call to "isConnected" before doing accept(2) on the listening socket. So, instead, make the local side block until the connection is received on the other side. On the remote, we don't block, instead we use the feature of delayed replies. Change-Id: Ie386938b8b39dd94a9d7e5913668125fb4a3c7da Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp')
-rw-r--r--tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp b/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp
index 4c6f3c5eee..b7ecdef16e 100644
--- a/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp
+++ b/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp
@@ -514,10 +514,9 @@ void tst_QDBusAbstractAdaptor::initTestCase()
QDBusConnection peercon = QDBusConnection::connectToPeer(address, "peer");
QVERIFY(peercon.isConnected());
- QDBusMessage req2 = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "isConnected");
+ QDBusMessage req2 = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "waitForConnected");
QDBusMessage rpl2 = QDBusConnection::sessionBus().call(req2);
- QVERIFY(rpl2.type() == QDBusMessage::ReplyMessage);
- QVERIFY(rpl2.arguments().at(0).toBool());
+ QVERIFY2(rpl2.type() == QDBusMessage::ReplyMessage, rpl2.errorMessage().toLatin1());
}
void tst_QDBusAbstractAdaptor::cleanupTestCase()