X server testing

Peter Hutterer peter.hutterer at who-t.net
Thu Jun 11 21:06:40 PDT 2009


Over the last days, I've been busy writing tests for the new XI2 stuff.
So far this resulted in 15 patches fixing up random issues from broken swap
code to buffer overflows.

The current set of patches is visible here, have a look at the last 7.
http://cgit.freedesktop.org/~whot/xserver/log/?h=xi2-protocol-tests

Since it was so useful to me, here's a bit of a rundown of how it works:

GNU ld supports a -wrap option, so you can override any function in the
server with your own one. So a function foo() in the server is replaced with
__real_foo() and anything that calls foo() now calls __wrap_foo().
In the simplest case, this would be something like this:

int __wrap_foo(int a)
{
        printf("foo called with %d.", a);
        return __real_foo(a);
}

In the XI2 tests, I override WriteToClient (which sends replies to the
clients) and then throw requests with various values at ProcXIRequestName().
In __wrap_WriteToClient, I can then check for validity for and compare it to
the data passed in.

The advantages for me are:
- testing from 0 to <max value of field> is simple
- testing swapping code is a matter of a few lines.
- no server or client setup are required.

I encourage you to have a look at the patches (which will be merged when I
have the complete set for all requests) and start thinking about how to
apply this method of testing to your parts of the code. There's plenty of
stuff in the server that could deal with some tests, especially considering
how long it takes to develop a simple test and how long it takes to triage
bugs...

Cheers,
  Peter


More information about the xorg-devel mailing list