Autotest: Be nicer when asking the sub-processes to exit

Instead of killing them outright (and note that terminate() doesn't work
on Windows), ask them nicely to exit on their own. This way, if we run
them in valgrind, valgrind gets a chance to print the leak check output
and summary.

Change-Id: Ib6cc8d4560ff0bf255f94980eb220e97592c00f0
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com>
This commit is contained in:
Thiago Macieira 2015-01-01 18:21:35 -02:00
parent 5fefec9136
commit 6d3558b449
8 changed files with 32 additions and 17 deletions

View File

@ -133,6 +133,11 @@ public slots:
valueSpy.clear();
}
void quit()
{
qApp->quit();
}
signals:
Q_SCRIPTABLE void syncReceived(const QString &sequence);

View File

@ -521,8 +521,10 @@ void tst_QDBusAbstractAdaptor::initTestCase()
void tst_QDBusAbstractAdaptor::cleanupTestCase()
{
QDBusMessage msg = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "quit");
QDBusConnection::sessionBus().call(msg);
proc.waitForFinished(200);
proc.close();
proc.kill();
}
void tst_QDBusAbstractAdaptor::methodCalls_data()

View File

@ -87,6 +87,11 @@ public slots:
emit targetObj.complexSignal(reg);
}
void quit()
{
qApp->quit();
}
private slots:
void handleConnection(const QDBusConnection& con)
{

View File

@ -252,19 +252,10 @@ void tst_QDBusAbstractInterface::initTestCase()
void tst_QDBusAbstractInterface::cleanupTestCase()
{
// Kill peer, resetting the object exported by a separate process
#ifdef Q_OS_WIN
proc.kill(); // non-GUI processes don't respond to QProcess::terminate()
#else
proc.terminate();
#endif
QVERIFY(proc.waitForFinished() || proc.state() == QProcess::NotRunning);
// Wait until the service is certainly not registered
QDBusConnection con = QDBusConnection::sessionBus();
if (con.isConnected()) {
QTRY_VERIFY(!con.interface()->isServiceRegistered(serviceName));
}
QDBusMessage msg = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "quit");
QDBusConnection::sessionBus().call(msg);
proc.waitForFinished(200);
proc.close();
}
void tst_QDBusAbstractInterface::init()

View File

@ -112,6 +112,10 @@ public slots:
return obj.m_complexProp;
}
void quit()
{
qApp->quit();
}
private slots:
void handleConnection(const QDBusConnection& con)

View File

@ -297,8 +297,10 @@ void tst_QDBusInterface::initTestCase()
void tst_QDBusInterface::cleanupTestCase()
{
QDBusMessage msg = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "quit");
QDBusConnection::sessionBus().call(msg);
proc.waitForFinished(200);
proc.close();
proc.kill();
}
void tst_QDBusInterface::notConnected()

View File

@ -49,6 +49,11 @@ public slots:
if (!QDBusConnection::sessionBus().send(msg.createReply(msg.arguments())))
exit(1);
}
void quit()
{
qApp->quit();
}
};
int main(int argc, char *argv[])

View File

@ -143,9 +143,10 @@ void tst_QDBusMarshall::initTestCase()
void tst_QDBusMarshall::cleanupTestCase()
{
proc.close();
proc.terminate();
QDBusMessage msg = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "quit");
QDBusConnection::sessionBus().call(msg);
proc.waitForFinished(200);
proc.close();
}
int tst_QDBusMarshall::fileDescriptorForTest()