diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2014-12-11 17:50:01 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2014-12-20 07:37:17 +0100 |
commit | d55db285fc4ae0a978591213c294f53ab879cd40 (patch) | |
tree | 5cb6a91c8a219284035851ecaaaf0243cb1a9ea3 /tests/auto/dbus/qdbusmarshall | |
parent | 36314ae75f2f13b6c93252dc2c93592bc0624296 (diff) |
Autotest: Fix a race condition in launching the QtDBus sub-processes
Wait for the subprocess to print "ready" before assuming that it is
ready to receive calls. waitForStarted() will return as soon as the
child is running, but it may not have registered on D-Bus yet.
This also solves the synchronization problem more elegantly than how
tst_qdbusmarshall.cpp was trying to do it.
Change-Id: I548dfba2677cc5a34ba50f4310c4d5baa98093b2
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'tests/auto/dbus/qdbusmarshall')
-rw-r--r-- | tests/auto/dbus/qdbusmarshall/qpong/qpong.cpp | 1 | ||||
-rw-r--r-- | tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp | 16 |
2 files changed, 3 insertions, 14 deletions
diff --git a/tests/auto/dbus/qdbusmarshall/qpong/qpong.cpp b/tests/auto/dbus/qdbusmarshall/qpong/qpong.cpp index 5476dd7f8e..bb8aab3d21 100644 --- a/tests/auto/dbus/qdbusmarshall/qpong/qpong.cpp +++ b/tests/auto/dbus/qdbusmarshall/qpong/qpong.cpp @@ -66,6 +66,7 @@ int main(int argc, char *argv[]) con.registerObject(objectPath, &pong, QDBusConnection::ExportAllSlots); printf("ready.\n"); + fflush(stdout); return app.exec(); } diff --git a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp index 0d9fba3e1f..4d12522a68 100644 --- a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp +++ b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp @@ -137,20 +137,8 @@ void tst_QDBusMarshall::initTestCase() # define EXE "" #endif proc.start(QFINDTESTDATA("qpong/qpong" EXE)); - if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(serviceName)) { - QVERIFY2(proc.waitForStarted(), qPrintable(proc.errorString())); - - QVERIFY(con.isConnected()); - con.connect("org.freedesktop.DBus", QString(), "org.freedesktop.DBus", "NameOwnerChanged", - QStringList() << serviceName << QString(""), QString(), - &QTestEventLoop::instance(), SLOT(exitLoop())); - QTestEventLoop::instance().enterLoop(2); - QVERIFY(!QTestEventLoop::instance().timeout()); - QVERIFY(QDBusConnection::sessionBus().interface()->isServiceRegistered(serviceName)); - con.disconnect("org.freedesktop.DBus", QString(), "org.freedesktop.DBus", "NameOwnerChanged", - QStringList() << serviceName << QString(""), QString(), - &QTestEventLoop::instance(), SLOT(exitLoop())); - } + QVERIFY2(proc.waitForStarted(), qPrintable(proc.errorString())); + QVERIFY(proc.waitForReadyRead()); } void tst_QDBusMarshall::cleanupTestCase() |