RFC: Autotests for the drm platform
In order to do testing for the drm platform there are effectively three options:
- manual testing. The obvious downsides are that it takes time and effort and requires having fitting hardware of all kinds, the obvious upside is that it's the real thing with the real drivers and their quirks... This will of course never go away completely
- spin up a VM with VKMS and run autotests in there. The upside is that no emulation is needed, a real session can be run, with real IOCTLs and everything. In theory the sort of autotests that would be written for it could also run directly on real systems, making "manual testing" a little less manual. The downsides are that VKMS is still very limiting itself, in terms of configuration, multi-gpu and special setups, and that a VM has to be spun up for the test, which may make it rather slow.
- write a MockDrm layer that simulates the drm API and run the tests with this layer
The MockDrm layer has some nice upsides vs the VM approach, which is why I chose it:
- testing very specific scenarios and unique setups is possible, fast and easy. Specifically that would be VR headsets, tiling displays (!1174), display device constraints (!844 (merged)) and multi-gpu
- checking for correct drm resource cleanup is very easy
- testing can be done in little steps, which should make finding bugs easier
- the layer contains very specific and easy to read error / debug prints, should also make finding bugs easier
But it also has the downsides that
- the MockDrm layer itself is rather big. With that size and complexity, bugs in the test system may not be avoidable, making the results unreliable
- a lot of things have to be simulated or changed with ugly
#ifdef KWIN_UNIT_TESTs. For some tests full KWin would have to run, with a local socket for the simulated GPU and simulated udev... The current implementation simply doesn't do all that, which limits what we can test (although not by too much tbh).
This is largely still WIP; before this can get used I'd like to make it work for / add a test for legacy drivers (because those are most likely to have regressions) and clean it up a little. It has however already helped find small issues like a crashing debug operator, a
DrmConnector memory leak and sub-ideal handling of the cursor in