[PATCH/RFC] Scanner for tests

Marek Ch mchqwerty at gmail.com
Tue Dec 3 02:40:19 PST 2013


I would propose WL_PRIVATE, because it's logical to me to store the
declarations
into wayland-private.h (it has been already used - or even created - for
this purpose).
Moreover it states that the function is private (static) in the terms of
Wayland.

Also, the UNIT_TEST define (or it's renamed alternative) have to be defined
in both
src/Makefile.am and tests/Makefile.am. Wouldn't it be better to handle this
define
via configure.ac in this case?

Thanks,
Marek Ch


On 2 December 2013 22:18, Bryce W. Harrington <b.harrington at samsung.com>wrote:

> On Fri, Nov 29, 2013 at 04:36:56PM +0200, Pekka Paalanen 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.
>
> I agree this looks like a better approach.  I wonder if the define could
> be named differently to more clearly indicate that the function is
> normally static?  So maybe like WL_STATIC_TESTABLE or some such?
>
> Bryce
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20131203/99564e2d/attachment-0001.html>


More information about the wayland-devel mailing list