Running unit tests without X

Nicolás Alvarez nicolas.alvarez at
Thu Nov 18 23:21:15 UTC 2010

(I wrote this long ago, but it seems it never reached the mailing list)

Running kdevplatform tests on a user account without X makes every
test fail except one or two. So X seems pretty much required. I tried
Xvfb, which was mentioned in this list before.

So I started Xvfb, set DISPLAY appropriately, and ran the tests.
shell-documentoperationtest hanged in a pretty strange way...

ctest prints:
      Start  7: sublime-aggregatemodeltest
 7/17 Test  #7: sublime-aggregatemodeltest .......   Passed    0.05 sec
      Start  8: sublime-toolviewtoolbartest
 8/17 Test  #8: sublime-toolviewtoolbartest ......   Passed    0.12 sec
      Start  9: shell-documentoperationtest

And it gets stuck there. The test process *isn't running anymore*, it
finished and passed. But the test completion isn't announced on
console, and the next test doesn't run. 'ps f' shows the ctest process
has no child processes. Killing Xvfb gets ctest un-hanged and it
instantly moves on to the next test!

Further testing showed that killing kded4 and kdeinit4 is enough to
get it unstuck (killing X was making the daemons quit).

The shell test is the first one to make the KDE daemons start. When
the test program quits, the daemons stay running. I suspect ctest
noticed the test program spawned other processes and started watching
them too (assuming they were all part of the test), so it's now
waiting for the daemons to quit. After I kill the KDE daemons,
shell-sessioncontrollertest gets ctest stuck in the same way.

After a lot more experimenting, I found the way to get the tests to
run properly:
- Start Xvfb.
- Set and export the DISPLAY env var appropriately.
- Launch the DBus daemon with "export `dbus-launch`".
- Run kdeinit4.
- Now run 'make test'.

With the above procedure, the only tests that fail are those that also
fail in my normal user account with a complete KDE environment
running, both for kdevplatform and kdevelop.

I hope that helps anyone who wants to run tests X-less-ly :)

(note: it's possible some broken tests got fixed and some working
tests got broken since I wrote this message)


More information about the KDevelop-devel mailing list