<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 9 December 2014 at 20:33, Derek Foreman <span dir="ltr"><<a href="mailto:derekf@osg.samsung.com" target="_blank">derekf@osg.samsung.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 05/12/14 07:36 AM, Marek Chalupa wrote:<br>
> We want to use toytoolkit in tests. This patch also<br>
> removes collisions of symbols defined in libtoytoolkit<br>
> with symbols defined in tests (i. e. shm_listener)<br>
<br>
</span>This patch introduces a compiler warning over the definition of<br>
xzalloc() in presentation-test.c.<br>
<br>
It's fixed later in the series, so I'm being pretty pedantic here. :)<br></blockquote><div><br></div><div>Better be pedantic than to let through some errors :)<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Why link all existing tests against toytoolkit instead of just ones that<br>
use toytoolkit functionality?  (I see this patch makes toytoolkit<br>
provide xzalloc to all the tests, is that why?)<br></blockquote><div><br></div><div>Because later I add client_create_toytoolkit() function to weston-test-client-helpers.c.<br>It uses toytoolkit functions and static functions from weston-test-client-helper.c.<br></div><div>Since weston-test-client-helper.c is a part of libtest-client,<br>libtoytoolkit needs to be linked to libtest-client.<br>And as you said, it provides the definition of xzalloc.<br><br></div><div>I think it could be workaround to link it just to some tests, but... I don't think<br>it's worth the work that would be needed to achieve this.<br></div><div><br></div><div>Anyway, I found out that I don't need to add the CLIENT_CFLAGS to every<br></div><div>test if I change the next patch a little bit. It reduces this patch a lot.<br><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
I don't think I see any harm in it, and doing this seems to put us<br>
within reach of having exactly one definition of xzalloc() in the source<br>
tree.  ;)<br>
<div class="HOEnZb"><div class="h5"><br>
> Signed-off-by: Marek Chalupa <<a href="mailto:mchqwerty@gmail.com">mchqwerty@gmail.com</a>><br>
> ---<br>
>  Makefile.am                       | 26 +++++++++++++++-----------<br>
>  tests/weston-test-client-helper.c |  5 +++--<br>
>  tests/weston-test-client-helper.h | 14 ++------------<br>
>  tests/weston-test-runner.h        |  2 ++<br>
>  4 files changed, 22 insertions(+), 25 deletions(-)<br>
><br>
> diff --git a/Makefile.am b/Makefile.am<br>
> index 4f4bb28..47c44dc 100644<br>
> --- a/Makefile.am<br>
> +++ b/Makefile.am<br>
> @@ -1003,51 +1003,55 @@ libtest_client_la_SOURCES =                   \<br>
>  nodist_libtest_client_la_SOURCES =           \<br>
>       protocol/wayland-test-protocol.c        \<br>
>       protocol/wayland-test-client-protocol.h<br>
> -libtest_client_la_CFLAGS = $(AM_CFLAGS) $(TEST_CLIENT_CFLAGS)<br>
> -libtest_client_la_LIBADD = $(TEST_CLIENT_LIBS) <a href="http://libshared.la" target="_blank">libshared.la</a> <a href="http://libtest-runner.la" target="_blank">libtest-runner.la</a><br>
> +libtest_client_la_CFLAGS = $(AM_CFLAGS) $(TEST_CLIENT_CFLAGS) $(CLIENT_CFLAGS)<br>
> +libtest_client_la_LIBADD =                   \<br>
> +     $(TEST_CLIENT_LIBS)                     \<br>
> +     <a href="http://libshared.la" target="_blank">libshared.la</a>                            \<br>
> +     <a href="http://libtest-runner.la" target="_blank">libtest-runner.la</a>                       \<br>
> +     <a href="http://libtoytoolkit.la" target="_blank">libtoytoolkit.la</a><br>
><br>
>  bad_buffer_weston_SOURCES = tests/bad-buffer-test.c<br>
> -bad_buffer_weston_CFLAGS = $(AM_CFLAGS) $(TEST_CLIENT_CFLAGS)<br>
> +bad_buffer_weston_CFLAGS = $(AM_CFLAGS) $(TEST_CLIENT_CFLAGS) $(CLIENT_CFLAGS)<br>
>  bad_buffer_weston_LDADD = <a href="http://libtest-client.la" target="_blank">libtest-client.la</a><br>
><br>
>  keyboard_weston_SOURCES = tests/keyboard-test.c<br>
> -keyboard_weston_CFLAGS = $(AM_CFLAGS) $(TEST_CLIENT_CFLAGS)<br>
> +keyboard_weston_CFLAGS = $(AM_CFLAGS) $(TEST_CLIENT_CFLAGS) $(CLIENT_CFLAGS)<br>
>  keyboard_weston_LDADD = <a href="http://libtest-client.la" target="_blank">libtest-client.la</a><br>
><br>
>  event_weston_SOURCES = tests/event-test.c<br>
> -event_weston_CFLAGS = $(AM_CFLAGS) $(TEST_CLIENT_CFLAGS)<br>
> +event_weston_CFLAGS = $(AM_CFLAGS) $(TEST_CLIENT_CFLAGS) $(CLIENT_CFLAGS)<br>
>  event_weston_LDADD = <a href="http://libtest-client.la" target="_blank">libtest-client.la</a><br>
><br>
>  button_weston_SOURCES = tests/button-test.c<br>
> -button_weston_CFLAGS = $(AM_CFLAGS) $(TEST_CLIENT_CFLAGS)<br>
> +button_weston_CFLAGS = $(AM_CFLAGS) $(TEST_CLIENT_CFLAGS) $(CLIENT_CFLAGS)<br>
>  button_weston_LDADD = <a href="http://libtest-client.la" target="_blank">libtest-client.la</a><br>
><br>
>  text_weston_SOURCES = tests/text-test.c<br>
>  nodist_text_weston_SOURCES =                 \<br>
>       protocol/text-protocol.c                \<br>
>       protocol/text-client-protocol.h<br>
> -text_weston_CFLAGS = $(AM_CFLAGS) $(TEST_CLIENT_CFLAGS)<br>
> +text_weston_CFLAGS = $(AM_CFLAGS) $(TEST_CLIENT_CFLAGS) $(CLIENT_CFLAGS)<br>
>  text_weston_LDADD = <a href="http://libtest-client.la" target="_blank">libtest-client.la</a><br>
><br>
>  subsurface_weston_SOURCES = tests/subsurface-test.c<br>
> -subsurface_weston_CFLAGS = $(AM_CFLAGS) $(TEST_CLIENT_CFLAGS)<br>
> +subsurface_weston_CFLAGS = $(AM_CFLAGS) $(TEST_CLIENT_CFLAGS) $(CLIENT_CFLAGS)<br>
>  subsurface_weston_LDADD = <a href="http://libtest-client.la" target="_blank">libtest-client.la</a><br>
><br>
>  presentation_weston_SOURCES = tests/presentation-test.c<br>
>  nodist_presentation_weston_SOURCES =         \<br>
>       protocol/presentation_timing-protocol.c \<br>
>       protocol/presentation_timing-client-protocol.h<br>
> -presentation_weston_CFLAGS = $(AM_CFLAGS) $(TEST_CLIENT_CFLAGS)<br>
> +presentation_weston_CFLAGS = $(AM_CFLAGS) $(TEST_CLIENT_CFLAGS) $(CLIENT_CFLAGS)<br>
>  presentation_weston_LDADD = <a href="http://libtest-client.la" target="_blank">libtest-client.la</a><br>
><br>
>  roles_weston_SOURCES = tests/roles-test.c<br>
> -roles_weston_CFLAGS = $(AM_CFLAGS) $(TEST_CLIENT_CFLAGS)<br>
> +roles_weston_CFLAGS = $(AM_CFLAGS) $(TEST_CLIENT_CFLAGS) $(CLIENT_CFLAGS)<br>
>  roles_weston_LDADD = <a href="http://libtest-client.la" target="_blank">libtest-client.la</a><br>
><br>
>  if ENABLE_EGL<br>
>  weston_tests += buffer-count.weston<br>
>  buffer_count_weston_SOURCES = tests/buffer-count-test.c<br>
> -buffer_count_weston_CFLAGS = $(GCC_CFLAGS) $(EGL_TESTS_CFLAGS)<br>
> +buffer_count_weston_CFLAGS = $(GCC_CFLAGS) $(EGL_TESTS_CFLAGS) $(CLIENT_CFLAGS)<br>
>  buffer_count_weston_LDADD = <a href="http://libtest-client.la" target="_blank">libtest-client.la</a> $(EGL_TESTS_LIBS)<br>
>  endif<br>
><br>
> diff --git a/tests/weston-test-client-helper.c b/tests/weston-test-client-helper.c<br>
> index e374a96..45c2957 100644<br>
> --- a/tests/weston-test-client-helper.c<br>
> +++ b/tests/weston-test-client-helper.c<br>
> @@ -30,6 +30,7 @@<br>
>  #include <sys/mman.h><br>
><br>
>  #include "../shared/os-compatibility.h"<br>
> +#include "../clients/window.h"<br>
>  #include "weston-test-client-helper.h"<br>
><br>
>  int<br>
> @@ -328,7 +329,7 @@ shm_format(void *data, struct wl_shm *wl_shm, uint32_t format)<br>
>               client->has_argb = 1;<br>
>  }<br>
><br>
> -struct wl_shm_listener shm_listener = {<br>
> +struct wl_shm_listener wl_shm_listener = {<br>
>       shm_format<br>
>  };<br>
><br>
> @@ -466,7 +467,7 @@ handle_global(void *data, struct wl_registry *registry,<br>
>               client->wl_shm =<br>
>                       wl_registry_bind(registry, id,<br>
>                                        &wl_shm_interface, 1);<br>
> -             wl_shm_add_listener(client->wl_shm, &shm_listener, client);<br>
> +             wl_shm_add_listener(client->wl_shm, &wl_shm_listener, client);<br>
>       } else if (strcmp(interface, "wl_output") == 0) {<br>
>               output = xzalloc(sizeof *output);<br>
>               output->wl_output =<br>
> diff --git a/tests/weston-test-client-helper.h b/tests/weston-test-client-helper.h<br>
> index 2cf3d8f..721fc5f 100644<br>
> --- a/tests/weston-test-client-helper.h<br>
> +++ b/tests/weston-test-client-helper.h<br>
> @@ -26,9 +26,10 @@<br>
>  #include "config.h"<br>
><br>
>  #include <assert.h><br>
> -#include "weston-test-runner.h"<br>
>  #include "wayland-test-client-protocol.h"<br>
><br>
> +#include "weston-test-runner.h"<br>
> +<br>
>  struct client {<br>
>       struct wl_display *wl_display;<br>
>       struct wl_registry *wl_registry;<br>
> @@ -101,17 +102,6 @@ struct surface {<br>
>       void *data;<br>
>  };<br>
><br>
> -static inline void *<br>
> -xzalloc(size_t size)<br>
> -{<br>
> -        void *p;<br>
> -<br>
> -        p = calloc(1, size);<br>
> -        assert(p);<br>
> -<br>
> -        return p;<br>
> -}<br>
> -<br>
>  struct client *<br>
>  client_create(int x, int y, int width, int height);<br>
><br>
> diff --git a/tests/weston-test-runner.h b/tests/weston-test-runner.h<br>
> index 193b76d..33de67e 100644<br>
> --- a/tests/weston-test-runner.h<br>
> +++ b/tests/weston-test-runner.h<br>
> @@ -41,7 +41,9 @@ struct weston_test {<br>
>       int must_fail;<br>
>  } __attribute__ ((aligned (32)));<br>
><br>
> +#ifndef ARRAY_LENGTH<br>
>  #define ARRAY_LENGTH(a) ((int) (sizeof (a) / sizeof (a)[0]))<br>
> +#endif<br>
><br>
>  #define TEST_BEGIN(name, arg)                                        \<br>
>       static void name(arg)<br>
><br>
<br></div></div></blockquote><div><br></div><div>Thanks,<br></div><div>Marek <br></div></div><br></div></div>