[RFC/PATCH 0/2] The beginnings of an in-server unit test suite.
Peter Hutterer
peter.hutterer at who-t.net
Sun Apr 19 17:55:47 PDT 2009
These are the humble beginnings on an in-server unit testing suite.
Currently, testing in-server changes is annoying if it's not easily
triggerable by client requests. This patch reduces this problem by providing a
test/ directory with (in the future) a number of test suites that verify
server-internal state.
I do not claim this is or will be a complete suite. There are many parts in
the server that rely on state and setting this state up correctly for a test
to run may be difficult.
The principle is quite simple:
The final Xorg binary is linked against a bunch of static libraries. So we
create a test binary that links against the same libraries and thus has
access to the same functions as Xorg has.
Then we run our test cases by running "make check", or the test binaries
directly if needed.
This could potentially be connected to a git commit hook.
There's a bit of automake abuse included since one of the crucial libraries
includes main() and an objcopy strips this out. This could be avoided by
modifying the server source to have main() separate, so that only Xorg links
it, not the test suite.
Things I'd like to hear comments on:
- Is this something we want in the server?
- Can we make the automake hurt less (Dan? Alan? anyone?)
- Provide override functionality - ideally, a test case could specify which
functions it overrides with dummies to test more complicated functionality
without relying on server state.
e.g. if foo() calls bar(), a test suite for foo() could override with a
special bar() that only provides the vital parts to not break foo() itself.
- Is anyone interested in taking this on? I'm quite busy already, so I
wouldn't mind if someone with more (== any) experience in writing test
suites wants to take over.
Cheers
Peter
Many thanks to Benjamin Close, for telling me most of the automake trickery
involved.
More information about the xorg-devel
mailing list