[PATCH wayland 3/3] tests: Test proxy versions
Derek Foreman
derekf at osg.samsung.com
Thu Jan 14 14:13:53 PST 2016
On 14/01/16 02:34 AM, Pekka Paalanen wrote:
> Oh wait!
>
> One more thing...
>
> On Thu, 14 Jan 2016 10:28:32 +0200
> Pekka Paalanen <ppaalanen at gmail.com> wrote:
>
>> On Tue, 12 Jan 2016 16:28:47 -0600
>> Derek Foreman <derekf at osg.samsung.com> wrote:
>>
>>> Add a test that confirms that proxy versions are always 0 for display
>>> and correct otherwise.
>>>
>>> Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
>>> ---
>>> tests/display-test.c | 41 +++++++++++++++++++++++++++++++++++++++++
>>> 1 file changed, 41 insertions(+)
>>>
>>> diff --git a/tests/display-test.c b/tests/display-test.c
>>> index 161a402..7a0aa91 100644
>>> --- a/tests/display-test.c
>>> +++ b/tests/display-test.c
>>> @@ -609,3 +609,43 @@ TEST(threading_read_after_error_tst)
>>>
>>> display_destroy(d);
>>> }
>>> +
>>> +static int expected_version;
>>> +
>>> +static void
>>> +seat_version_main(void)
>>> +{
>>> + struct client *c = client_connect();
>>> + struct wl_seat *seat = client_get_seat(c);
>>> + int ver;
>>> +
>>> + /* display proxy should always be version 0 */
>>> + ver = wl_proxy_get_version((struct wl_proxy *) c->wl_display);
>>> + assert(ver == 0);
>>> +
>>> + ver = wl_proxy_get_version((struct wl_proxy *) seat);
>>> + assert(ver == expected_version);
>>> +
>>> + wl_proxy_destroy((struct wl_proxy *) seat);
>>> + client_disconnect_nocheck(c);
>>> +}
>>> +
>>> +TEST(versions)
>>> +{
>>> + struct display *d = display_create();
>>> + struct wl_global *global;
>>> + int i;
>>> +
>>> + for (i = 0; i < 5; i++) {
>
> This causes the tests to use versions 0..4 when I think the intention
> was to use 1..5. It works, but we always start versioning from 1, so
> should fix that here.
Pffft, it's not invalid if the library doesn't stop you. ;)
>
> Thanks,
> pq
>
>>> + expected_version = i;
>>> + global = wl_global_create(d->wl_display, &wl_seat_interface,
>>> + expected_version, d, bind_seat);
>>> +
>>> + client_create(d, seat_version_main);
>>> + display_run(d);
>>> +
>>> + wl_global_destroy(global);
>>> + }
>>> +
>>> + display_destroy(d);
>>> +}
>>
>> Hi Derek,
>>
>> yup, this is half of the minimal testing I was craving for. This test
>> is checking that the version bound in wl_registry.bind gets recorded
>> correctly.
>>
>> Reviewed-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
>>
>> It would also be nicer to have the global always at version 5 and then
>> bind it with versions 1..5, but I can see that would be more work
>> because of client_get_seat().
client_get_seat() isn't so bad, it's that registry_listener... Not too
hard to make it bind expected_version (if non zero), if you'll let me be
lazy just one more time. ;)
>> The static variable is also a lazy man's solution, but it's ok for now.
>> client_create() could be extended to take a void *testdata.
>>
>> The other half would be to create e.g. wl_pointer or something from the
>> wl_seat and check that the version gets inherited properly.
That's pretty trivial too.
>> Yet another future work item would be to add a test that explicitly
>> uses the unversioned libwayland-client ABI to mimic "a software
>> component built with old protocol headers" and check the wl_pointer
>> version comes back as zero.
Right - that's the hardest of the bunch, I think? To do this in a
not-completely-contrived fashion I'd have to check in an old generated
header file to build against? :/
>> Anyway, I think this is enough to get wl_proxy_get_version() landed now.
>>
>> Checking that the inheritance works would be the next most important
>> test to add in this story.
I think that's important enough to do now. I'll send a new revision
shortly.
>> Thanks,
>> pq
>
>
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>
More information about the wayland-devel
mailing list