[PATCH/RFC] Scanner for tests

Marek Ch mchqwerty at gmail.com
Fri Nov 29 06:40:03 PST 2013


Thanks! I'll look at that :)

Marek Ch


On 29 November 2013 15:36, Pekka Paalanen <ppaalanen at gmail.com> wrote:

> On Fri, 29 Nov 2013 14:52:30 +0100
> Marek Ch <mchqwerty at gmail.com> wrote:
>
> >
> > Hi!
> >
> > 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.
> >
> > P.S.
> > 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.
>
> Hi,
>
> instead of writing a C language parser to copy stuff around, how about
> doing what was done with Weston matrix code? See:
>
> http://cgit.freedesktop.org/wayland/weston/tree/tests/Makefile.am
> http://cgit.freedesktop.org/wayland/weston/tree/shared/matrix.c
> http://cgit.freedesktop.org/wayland/weston/tree/tests/matrix-test.c
>
> and note UNIT_TEST and MATRIX_TEST_EXPORT that give the test code
> access to otherwise static functions.
>
>
> Thanks,
> pq
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20131129/1478d8ee/attachment-0001.html>


More information about the wayland-devel mailing list