Introduce a test server
ClosedPublic

Authored by graesslin on May 31 2016, 1:57 PM.

Details

Reviewers
sebas
bshah
Group Reviewers
Plasma
Summary

The idea of shipping a test server is to have something like Xvfb for
Wayland. To be able to run a test application with a fake Wayland server.

To make this super easy the test server binary is installed into libexec
directory and provides a cmake function to run a test application with
the test server.

The test server takes full control over the process. It's a guiless
application and starts the passed test application once it is fully
set up. The environment is setup to have the test application connect
to the fake server (WAYLAND_SOCKET env variable and QT_QPA_PLATFORM).

When the started application finishes the test server goes down and
exits with the exit value of the test application. This allows a good
integration with ctest.

The test server is a virtual server which supports the following
interfaces:

  • Shm
  • Compositor
  • Shell
  • Seat
  • DataDeviceManager
  • Idle
  • SubCompositor
  • Output (1280x1024 at 60 Hz with 96 dpi)
  • FakeInput

This is sufficient to bring up a QtWayland based application and
allows some basic interactions from a test application (e.g. fake
input).

So far the server fakes a repaint every 16 msec, but does not yet
pass events to the test applications.

To integrate this into an application for testing use:

find_package(KF5Wayland CONFIG)
add_executable(myTest myTest.cpp)
target_link_libraries(myTest Qt5::Gui Qt5::Test)
kwaylandtest(myTest)

When now running ctest in the build directory the test server gets
started and will start the myTest binary and report the passed/failed
in the expected and normal way.

This way a test case can easily be run against both X11 and Wayland.

Diff Detail

Repository
R127 KWayland
Branch
test-server
Lint
No Linters Available
Unit
No Unit Test Coverage
graesslin updated this revision to Diff 4094.May 31 2016, 1:57 PM
graesslin retitled this revision from to Introduce a test server.
graesslin updated this object.
graesslin edited the test plan for this revision. (Show Details)
graesslin added a reviewer: Plasma.
Restricted Application added a project: Plasma. · View Herald TranscriptMay 31 2016, 1:57 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
bshah added a subscriber: bshah.May 31 2016, 2:11 PM
bshah added inline comments.
src/tools/testserver/main.cpp
31–34

It might be possible that one want to use executable with command line option... lets not restrict it to 1? and have >= 1?

graesslin added inline comments.May 31 2016, 2:34 PM
src/tools/testserver/main.cpp
31–34

right, but then more needs to be changed. All positional arguments need to be passed to the application.

sebas accepted this revision.Jun 1 2016, 12:30 AM
sebas added a reviewer: sebas.
sebas added a subscriber: sebas.

Aside from @bshah 's request, it looks good to me.

src/tools/testserver/main.cpp
31–34

That sounds useful when we want to allow more fancy stuff (different configs?) in the future.

This revision is now accepted and ready to land.Jun 1 2016, 12:30 AM
bshah requested changes to this revision.Jun 1 2016, 3:00 AM
bshah added a reviewer: bshah.

While looking at cmake, I realized one issue.. and to verify this I tried to build it and it didn't even build.. :\

KF5WaylandConfig.cmake.in
10

I've gut feeling this will not work on CI, I am 80% sure about this but can't verify because I can't build this at all.

It works for you and me because in your local setup all repos are installed in same prefix, so CMAKE_INSTALL_FULL_LIBEXECDIR is same for all repos, while on CI each repo gets its own prefix, So on CI, when you will be using this CMAKE_INSTALL_FULL_LIBEXEC_DIR will resolve to repo using (e.g. kwayland-integration) this function and not to install prefix of kwayland.

Change this line to,

@CMAKE_INSTALL_FULL_LIBEXECDIR@/org-kde-kf5-kwayland-testserver ${CMAKE_CURRENT_BINARY_DIR}/${testBinaryName}

instead.

src/tools/testserver/testserver.cpp
141

Actually this doesn't build for me.

/home/bshah/kdesrc/source/kwayland/src/tools/testserver/testserver.cpp:140:47: error: no viable conversion from 'const QHash<int, int>::const_iterator' to 'QHash<int, int>::iterator'
                        m_touchIdMapper.erase(it);
                                              ^~
/usr/include/qt/QtCore/qhash.h:296:11: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'const QHash<int, int>::const_iterator' to 'const QHash<int, int>::iterator &' for 1st argument
    class iterator
          ^
/usr/include/qt/QtCore/qhash.h:296:11: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'const QHash<int, int>::const_iterator' to 'QHash<int, int>::iterator &&' for 1st argument
    class iterator
          ^
/usr/include/qt/QtCore/qhash.h:453:29: note: passing argument to parameter 'it' here
    iterator erase(iterator it);
                            ^
1 error generated.

(Using Qt 5.6)

This revision now requires changes to proceed.Jun 1 2016, 3:00 AM
graesslin marked 5 inline comments as done.Jun 1 2016, 6:16 AM
graesslin updated this revision to Diff 4120.Jun 1 2016, 6:17 AM
graesslin edited edge metadata.
  • Fixed the build error (accidentially introduced a Qt 5.7 functionality)
  • Fixed the CMake path generation
  • Pass arguments around. For this I removed QCommandLineParser as it doesn't really make sense.
bshah accepted this revision.Jun 1 2016, 6:26 AM
bshah edited edge metadata.

Looks good.

This revision is now accepted and ready to land.Jun 1 2016, 6:26 AM
sebas added a comment.Jun 1 2016, 2:14 PM

Changes look good.

graesslin closed this revision.Jun 2 2016, 6:15 AM

pushed with 37f7cb99535d8fdcfc16ad99c045bddb67798b45 - seems to not have been picked up as I added a changelog entry.