Commit 768e5fb7 authored by David Edmundson's avatar David Edmundson

[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
parent 6ddf50a7
......@@ -3,6 +3,7 @@ KWin - the KDE window manager
This file is part of the KDE project.
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
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 <unistd.h>
#include <signal.h>
int main(int argc, char *argv[])
{
qputenv("QT_QPA_PLATFORM", QByteArrayLiteral("wayland"));
......@@ -31,14 +34,13 @@ int main(int argc, char *argv[])
w.setGeometry(QRect(0, 0, 100, 200));
w.show();
//after showing the window block the main thread
//1 as we want it to come after the singleshots in qApp construction
QTimer::singleShot(1, []() {
//block
auto freezeHandler = [](int) {
while(true) {
sleep(100000);
sleep(10000);
}
});
};
signal(SIGUSR1, freezeHandler);
return app.exec();
}
......@@ -3,6 +3,7 @@ KWin - the KDE window manager
This file is part of the KDE project.
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
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/socket.h>
#include <unistd.h>
#include <signal.h>
using namespace KWin;
using namespace KWayland::Client;
......@@ -1133,7 +1135,10 @@ void TestShellClient::testUnresponsiveWindow()
if (shellClientAddedSpy.isEmpty()) {
QVERIFY(shellClientAddedSpy.wait());
}
::kill(process->processId(), SIGUSR1); // send a signal to freeze the process
killClient = shellClientAddedSpy.first().first().value<AbstractClient*>();
QVERIFY(killClient);
QSignalSpy unresponsiveSpy(killClient, &AbstractClient::unresponsiveChanged);
QSignalSpy killedSpy(process.data(), static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished));
QSignalSpy deletedSpy(killClient, &QObject::destroyed);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment