[autotests] Fix race condition in ShellClient::testUnresponsiveWindow
Summary: The test executable "kill" freezes itself after 1ms, supposedly after showing a window. However showing a window is not syncronous on wayland, it's illegal to map a buffer before getting a configure event from the server. This patch removes any potential for a race by having the server tell our test executable when to freeze. Test Plan: Test still passed Reviewers: #kwin Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D19406
This commit is contained in:
parent
6ddf50a77b
commit
768e5fb7f4
2 changed files with 13 additions and 6 deletions
|
@ -3,6 +3,7 @@ KWin - the KDE window manager
|
||||||
This file is part of the KDE project.
|
This file is part of the KDE project.
|
||||||
|
|
||||||
Copyright (C) 2016 Martin Gräßlin <mgraesslin@kde.org>
|
Copyright (C) 2016 Martin Gräßlin <mgraesslin@kde.org>
|
||||||
|
Copyright (C) 2019 David Edmundson <davidedmundson@kde.org>
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -23,6 +24,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
qputenv("QT_QPA_PLATFORM", QByteArrayLiteral("wayland"));
|
qputenv("QT_QPA_PLATFORM", QByteArrayLiteral("wayland"));
|
||||||
|
@ -31,14 +34,13 @@ int main(int argc, char *argv[])
|
||||||
w.setGeometry(QRect(0, 0, 100, 200));
|
w.setGeometry(QRect(0, 0, 100, 200));
|
||||||
w.show();
|
w.show();
|
||||||
|
|
||||||
//after showing the window block the main thread
|
auto freezeHandler = [](int) {
|
||||||
//1 as we want it to come after the singleshots in qApp construction
|
|
||||||
QTimer::singleShot(1, []() {
|
|
||||||
//block
|
|
||||||
while(true) {
|
while(true) {
|
||||||
sleep(100000);
|
sleep(10000);
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
|
signal(SIGUSR1, freezeHandler);
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ KWin - the KDE window manager
|
||||||
This file is part of the KDE project.
|
This file is part of the KDE project.
|
||||||
|
|
||||||
Copyright (C) 2016 Martin Gräßlin <mgraesslin@kde.org>
|
Copyright (C) 2016 Martin Gräßlin <mgraesslin@kde.org>
|
||||||
|
Copyright (C) 2019 David Edmundson <davidedmundson@kde.org>
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -48,6 +49,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
using namespace KWin;
|
using namespace KWin;
|
||||||
using namespace KWayland::Client;
|
using namespace KWayland::Client;
|
||||||
|
@ -1133,7 +1135,10 @@ void TestShellClient::testUnresponsiveWindow()
|
||||||
if (shellClientAddedSpy.isEmpty()) {
|
if (shellClientAddedSpy.isEmpty()) {
|
||||||
QVERIFY(shellClientAddedSpy.wait());
|
QVERIFY(shellClientAddedSpy.wait());
|
||||||
}
|
}
|
||||||
|
::kill(process->processId(), SIGUSR1); // send a signal to freeze the process
|
||||||
|
|
||||||
killClient = shellClientAddedSpy.first().first().value<AbstractClient*>();
|
killClient = shellClientAddedSpy.first().first().value<AbstractClient*>();
|
||||||
|
QVERIFY(killClient);
|
||||||
QSignalSpy unresponsiveSpy(killClient, &AbstractClient::unresponsiveChanged);
|
QSignalSpy unresponsiveSpy(killClient, &AbstractClient::unresponsiveChanged);
|
||||||
QSignalSpy killedSpy(process.data(), static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished));
|
QSignalSpy killedSpy(process.data(), static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished));
|
||||||
QSignalSpy deletedSpy(killClient, &QObject::destroyed);
|
QSignalSpy deletedSpy(killClient, &QObject::destroyed);
|
||||||
|
|
Loading…
Reference in a new issue