<div dir="ltr"><div>Thanks! I'll look at that :)<br><br></div>Marek Ch<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 29 November 2013 15:36, Pekka Paalanen <span dir="ltr"><<a href="mailto:ppaalanen@gmail.com" target="_blank">ppaalanen@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Fri, 29 Nov 2013 14:52:30 +0100<br>
Marek Ch <<a href="mailto:mchqwerty@gmail.com">mchqwerty@gmail.com</a>> wrote:<br>
<br>
><br>
> Hi!<br>
><br>
> I was looking into wayland's code and I saw static wl_buffer_*<br>
> functions and I thought: These would use a test.. But how to do it<br>
> when they are static? I can take the code and copy it into test<br>
> manually, but that is not good. The code can change..<br>
><br>
> I solved it by writting simple scanner that is invoked, just like<br>
> the wayland-scanner, when compiling the code. It searches for<br>
> definitions marked by WL_EXPORT_TEST and if it finds one, it<br>
> copies it into tests-private.c (.h, respectively).<br>
> Test can then be linked together with this file, so it is<br>
> guaranteed, that the test will use the code from current HEAD.<br>
><br>
> The adventage is that in order to test static function there's<br>
> no need to delete the static keyword and thus make it public.<br>
> The disadvantage is that if the to-be-tested function uses<br>
> any other static function, it must be exported too.<br>
><br>
> To sum it up: this is more like experiment but since it worked<br>
> for me, I'd like to ask you for your comments.<br>
><br>
> P.S.<br>
> The first patch included is not important for the scanner but<br>
> I wrote the code having it applied so I attached it too<br>
> (it's a patch a sent to devel-list some time ago).<br>
> The third patch is simple example test of wl_buffer_put.<br>
<br>
</div></div>Hi,<br>
<br>
instead of writing a C language parser to copy stuff around, how about<br>
doing what was done with Weston matrix code? See:<br>
<br>
<a href="http://cgit.freedesktop.org/wayland/weston/tree/tests/Makefile.am" target="_blank">http://cgit.freedesktop.org/wayland/weston/tree/tests/Makefile.am</a><br>
<a href="http://cgit.freedesktop.org/wayland/weston/tree/shared/matrix.c" target="_blank">http://cgit.freedesktop.org/wayland/weston/tree/shared/matrix.c</a><br>
<a href="http://cgit.freedesktop.org/wayland/weston/tree/tests/matrix-test.c" target="_blank">http://cgit.freedesktop.org/wayland/weston/tree/tests/matrix-test.c</a><br>
<br>
and note UNIT_TEST and MATRIX_TEST_EXPORT that give the test code<br>
access to otherwise static functions.<br>
<br>
<br>
Thanks,<br>
pq<br>
</blockquote></div><br></div>