[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kwayland] autotests/client: [autotest] Try to make TestWaylandOutputDevice a little bit more robust
From:       Martin_Gräßlin <mgraesslin () kde ! org>
Date:       2016-05-17 11:43:28
Message-ID: E1b2dPM-0000W2-Sv () scm ! kde ! org
[Download RAW message or body]

Git commit a135fcaac13f08b3d217b5c49aee88b6a1e87fc4 by Martin Gräßlin.
Committed on 17/05/2016 at 11:36.
Pushed by graesslin into branch 'master'.

[autotest] Try to make TestWaylandOutputDevice a little bit more robust

> From time to time the test is failing on build.kde.org with an ASAN
heap-use-after-free error. From my investigation this seems to be caused
by the OutputDevice being constructed on the stack and being destroyed
while handling Wayland events, but before all are handled.

The test mostly operates on the changed signal. There is also a done
signal emitted later on. Wayland sends the done after a set of changes
is transmitted. Thus the test is adjusted to wait for done instead of
changed. So we can ensure that all events are handled before the object
gets destroyed.

I have never been able to reproduce the problem locally, so I cannot
guarantee that the issue is solved for good. If it still happens more
investigation will be needed.

M  +16   -27   autotests/client/test_wayland_outputdevice.cpp

http://commits.kde.org/kwayland/a135fcaac13f08b3d217b5c49aee88b6a1e87fc4

diff --git a/autotests/client/test_wayland_outputdevice.cpp \
b/autotests/client/test_wayland_outputdevice.cpp index fe0f9c5..ea7e853 100644
--- a/autotests/client/test_wayland_outputdevice.cpp
+++ b/autotests/client/test_wayland_outputdevice.cpp
@@ -74,6 +74,7 @@ TestWaylandOutputDevice::TestWaylandOutputDevice(QObject *parent)
     , m_display(nullptr)
     , m_serverOutputDevice(nullptr)
     , m_connection(nullptr)
+    , m_queue(nullptr)
     , m_thread(nullptr)
 {
 }
@@ -227,9 +228,11 @@ void TestWaylandOutputDevice::testModeChanges()
     QVERIFY(outputChanged.isValid());
     QSignalSpy modeAddedSpy(&output, &KWayland::Client::OutputDevice::modeAdded);
     QVERIFY(modeAddedSpy.isValid());
+    QSignalSpy doneSpy(&output, &KWayland::Client::OutputDevice::done);
+    QVERIFY(doneSpy.isValid());
     output.setup(registry.bindOutputDevice(announced.first().first().value<quint32>(), \
announced.first().last().value<quint32>()));  \
                wl_display_flush(m_connection->display());
-    QVERIFY(outputChanged.wait());
+    QVERIFY(doneSpy.wait());
     QCOMPARE(modeAddedSpy.count(), 3);
 
     QCOMPARE(modeAddedSpy.at(0).first().value<OutputDevice::Mode>().size, QSize(800, \
600)); @@ -262,10 +265,7 @@ void TestWaylandOutputDevice::testModeChanges()
     QSignalSpy modeChangedSpy(&output, \
&KWayland::Client::OutputDevice::modeChanged);  QVERIFY(modeChangedSpy.isValid());
     m_serverOutputDevice->setCurrentMode(0);
-    QVERIFY(modeChangedSpy.wait());
-    if (modeChangedSpy.size() == 1) {
-        QVERIFY(modeChangedSpy.wait());
-    }
+    QVERIFY(doneSpy.wait());
     QCOMPARE(modeChangedSpy.size(), 2);
     // the one which lost the current flag
     QCOMPARE(modeChangedSpy.first().first().value<OutputDevice::Mode>().size, \
QSize(1024, 768)); @@ -292,10 +292,7 @@ void \
TestWaylandOutputDevice::testModeChanges()  outputChanged.clear();
     modeChangedSpy.clear();
     m_serverOutputDevice->setCurrentMode(2);
-    QVERIFY(modeChangedSpy.wait());
-    if (modeChangedSpy.size() == 1) {
-        QVERIFY(modeChangedSpy.wait());
-    }
+    QVERIFY(doneSpy.wait());
     QCOMPARE(modeChangedSpy.size(), 2);
     // the one which lost the current flag
     QCOMPARE(modeChangedSpy.first().first().value<OutputDevice::Mode>().size, \
QSize(800, 600)); @@ -320,7 +317,7 @@ void TestWaylandOutputDevice::testScaleChange()
     QVERIFY(announced.wait());
 
     KWayland::Client::OutputDevice output;
-    QSignalSpy outputChanged(&output, &KWayland::Client::OutputDevice::changed);
+    QSignalSpy outputChanged(&output, &KWayland::Client::OutputDevice::done);
     QVERIFY(outputChanged.isValid());
     output.setup(registry.bindOutputDevice(announced.first().first().value<quint32>(), \
announced.first().last().value<quint32>()));  \
wl_display_flush(m_connection->display()); @@ -370,22 +367,18 @@ void \
TestWaylandOutputDevice::testSubPixel()  QVERIFY(announced.wait());
 
     KWayland::Client::OutputDevice output;
-    QSignalSpy outputChanged(&output, &KWayland::Client::OutputDevice::changed);
+    QSignalSpy outputChanged(&output, &KWayland::Client::OutputDevice::done);
     QVERIFY(outputChanged.isValid());
     output.setup(registry.bindOutputDevice(announced.first().first().value<quint32>(), \
announced.first().last().value<quint32>()));  \
                wl_display_flush(m_connection->display());
-    if (outputChanged.isEmpty()) {
-        QVERIFY(outputChanged.wait());
-    }
+    QVERIFY(outputChanged.wait());
 
     QTEST(output.subPixel(), "expected");
 
     // change back to unknown
     outputChanged.clear();
     m_serverOutputDevice->setSubPixel(OutputDeviceInterface::SubPixel::Unknown);
-    if (outputChanged.isEmpty()) {
-        QVERIFY(outputChanged.wait());
-    }
+    QVERIFY(outputChanged.wait());
     QCOMPARE(output.subPixel(), OutputDevice::SubPixel::Unknown);
 }
 
@@ -421,21 +414,17 @@ void TestWaylandOutputDevice::testTransform()
     QVERIFY(announced.wait());
 
     KWayland::Client::OutputDevice *output = \
registry.createOutputDevice(announced.first().first().value<quint32>(), \
                announced.first().last().value<quint32>(), &registry);
-    QSignalSpy outputChanged(output, &KWayland::Client::OutputDevice::changed);
+    QSignalSpy outputChanged(output, &KWayland::Client::OutputDevice::done);
     QVERIFY(outputChanged.isValid());
     wl_display_flush(m_connection->display());
-    if (outputChanged.isEmpty()) {
-        QVERIFY(outputChanged.wait());
-    }
+    QVERIFY(outputChanged.wait());
 
     QTEST(output->transform(), "expected");
 
     // change back to normal
     outputChanged.clear();
     m_serverOutputDevice->setTransform(OutputDeviceInterface::Transform::Normal);
-    if (outputChanged.isEmpty()) {
-        QVERIFY(outputChanged.wait());
-    }
+    QVERIFY(outputChanged.wait());
     QCOMPARE(output->transform(), OutputDevice::Transform::Normal);
 }
 
@@ -450,7 +439,7 @@ void TestWaylandOutputDevice::testEnabled()
     QVERIFY(announced.wait());
 
     KWayland::Client::OutputDevice output;
-    QSignalSpy outputChanged(&output, &KWayland::Client::OutputDevice::changed);
+    QSignalSpy outputChanged(&output, &KWayland::Client::OutputDevice::done);
     QVERIFY(outputChanged.isValid());
     output.setup(registry.bindOutputDevice(announced.first().first().value<quint32>(), \
announced.first().last().value<quint32>()));  \
wl_display_flush(m_connection->display()); @@ -463,12 +452,12 @@ void \
TestWaylandOutputDevice::testEnabled()  QVERIFY(enabledChanged.isValid());
 
     m_serverOutputDevice->setEnabled(OutputDeviceInterface::Enablement::Disabled);
-    QVERIFY(enabledChanged.wait(200));
+    QVERIFY(enabledChanged.wait());
     QCOMPARE(output.enabled(), OutputDevice::Enablement::Disabled);
     QCOMPARE(changed.count(), enabledChanged.count());
 
     m_serverOutputDevice->setEnabled(OutputDeviceInterface::Enablement::Enabled);
-    QVERIFY(enabledChanged.wait(200));
+    QVERIFY(enabledChanged.wait());
     QCOMPARE(output.enabled(), OutputDevice::Enablement::Enabled);
     QCOMPARE(changed.count(), enabledChanged.count());
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic