[PATCH/RFC] Scanner for tests

Marek Ch mchqwerty at gmail.com
Fri Nov 29 05:52:30 PST 2013


I was looking into wayland's code and I saw static wl_buffer_*
functions and I thought: These would use a test.. But how to do it
when they are static? I can take the code and copy it into test
manually, but that is not good. The code can change..

I solved it by writting simple scanner that is invoked, just like
the wayland-scanner, when compiling the code. It searches for
definitions marked by WL_EXPORT_TEST and if it finds one, it
copies it into tests-private.c (.h, respectively).
Test can then be linked together with this file, so it is
guaranteed, that the test will use the code from current HEAD.

The adventage is that in order to test static function there's
no need to delete the static keyword and thus make it public.
The disadvantage is that if the to-be-tested function uses
any other static function, it must be exported too.

To sum it up: this is more like experiment but since it worked
for me, I'd like to ask you for your comments.

The first patch included is not important for the scanner but
I wrote the code having it applied so I attached it too
(it's a patch a sent to devel-list some time ago).
The third patch is simple example test of wl_buffer_put.

Marek Ch

More information about the wayland-devel mailing list