[RFC wayland] tests: Test wl_message_count_arrays

Yong Bakos junk at humanoriented.com
Tue Nov 1 17:49:14 UTC 2016


On Nov 1, 2016, at 10:35 AM, Giulio Camuffo <giuliocamuffo at gmail.com> wrote:
> 
> Hi,
> 
> I think i would put more messages in the array, just two seems like
> it's not really testing much. Besides that it looks good.
> 
> 
> Cheers,
> Giulio

Thanks Giulio, I'll add some more. My main concern (hence the RFC)
is about ABI compatibility. I /think/ removing static is ok here,
but I am not 100% confident.

yong


> 2016-10-27 17:58 GMT+02:00 Yong Bakos <junk at humanoriented.com>:
>> From: Yong Bakos <ybakos at humanoriented.com>
>> 
>> message-test.c did not cover wl_message_count_arrays, so add one test that
>> specifically tests this method. Note that this exposes wl_message_count_arrays
>> in a private header (wayland-private.h), and removes the `static` modifier of
>> the implementation.
>> 
>> Signed-off-by: Yong Bakos <ybakos at humanoriented.com>
>> ---
>> src/connection.c      |  2 +-
>> src/wayland-private.h |  3 +++
>> tests/message-test.c  | 17 +++++++++++++++++
>> 3 files changed, 21 insertions(+), 1 deletion(-)
>> 
>> diff --git a/src/connection.c b/src/connection.c
>> index c3293a9..5c3d187 100644
>> --- a/src/connection.c
>> +++ b/src/connection.c
>> @@ -392,7 +392,7 @@ wl_connection_queue(struct wl_connection *connection,
>>        return wl_buffer_put(&connection->out, data, count);
>> }
>> 
>> -static int
>> +int
>> wl_message_count_arrays(const struct wl_message *message)
>> {
>>        int i, arrays;
>> diff --git a/src/wayland-private.h b/src/wayland-private.h
>> index ef58ccf..676b181 100644
>> --- a/src/wayland-private.h
>> +++ b/src/wayland-private.h
>> @@ -163,6 +163,9 @@ int
>> arg_count_for_signature(const char *signature);
>> 
>> int
>> +wl_message_count_arrays(const struct wl_message *message);
>> +
>> +int
>> wl_message_get_since(const struct wl_message *message);
>> 
>> void
>> diff --git a/tests/message-test.c b/tests/message-test.c
>> index cb08f90..2f29875 100644
>> --- a/tests/message-test.c
>> +++ b/tests/message-test.c
>> @@ -51,3 +51,20 @@ TEST(message_version)
>>                       messages[i].expected_version);
>>        }
>> }
>> +
>> +TEST(message_count_arrays)
>> +{
>> +       unsigned int i;
>> +       const struct {
>> +               const struct wl_message *message;
>> +               int expected_array_count;
>> +       } messages[] = {
>> +               { &wl_pointer_interface.events[WL_POINTER_ENTER], 0 },
>> +               { &wl_keyboard_interface.events[WL_KEYBOARD_ENTER], 1 },
>> +       };
>> +
>> +       for (i = 0; i < ARRAY_LENGTH(messages); ++i) {
>> +               assert(wl_message_count_arrays(messages[i].message) ==
>> +                      messages[i].expected_array_count);
>> +       }
>> +}
>> --
>> 2.7.2
>> 
>> _______________________________________________
>> wayland-devel mailing list
>> wayland-devel at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/wayland-devel



More information about the wayland-devel mailing list