diff options
| author | Jonas Ådahl <jadahl@gmail.com> | 2015-12-28 11:25:00 +0800 |
|---|---|---|
| committer | Jonas Ådahl <jadahl@gmail.com> | 2016-01-16 16:37:37 +0800 |
| commit | 046012a6cf1a50e1de2c73cf5a29098453b0171f (patch) | |
| tree | c7e710b0f72ee5861a7aaa91c83da06308991015 /tests/test-compositor.c | |
| parent | tests: Synchronize client termination in idle callback (diff) | |
| download | wayland-046012a6cf1a50e1de2c73cf5a29098453b0171f.tar wayland-046012a6cf1a50e1de2c73cf5a29098453b0171f.tar.gz wayland-046012a6cf1a50e1de2c73cf5a29098453b0171f.tar.bz2 wayland-046012a6cf1a50e1de2c73cf5a29098453b0171f.tar.lz wayland-046012a6cf1a50e1de2c73cf5a29098453b0171f.tar.xz wayland-046012a6cf1a50e1de2c73cf5a29098453b0171f.tar.zst wayland-046012a6cf1a50e1de2c73cf5a29098453b0171f.zip | |
tests: Pass argument to client main
Change the API to pass an "void *" argument to the client main
function, allowing the caller to call the same main function with
different input.
A helper (client_create_noarg) is added for when no argument is passed,
and the existing test cases are changed to use this function instead.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Diffstat (limited to 'tests/test-compositor.c')
| -rw-r--r-- | tests/test-compositor.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/tests/test-compositor.c b/tests/test-compositor.c index 965074b..b01e8af 100644 --- a/tests/test-compositor.c +++ b/tests/test-compositor.c @@ -151,7 +151,8 @@ client_destroyed(struct wl_listener *listener, void *data) } static void -run_client(void (*client_main)(void), int wayland_sock, int client_pipe) +run_client(void (*client_main)(void *data), void *data, + int wayland_sock, int client_pipe) { char s[8]; int cur_alloc, cur_fds; @@ -170,7 +171,7 @@ run_client(void (*client_main)(void), int wayland_sock, int client_pipe) cur_alloc = get_current_alloc_num(); cur_fds = count_open_fds(); - client_main(); + client_main(data); /* Clients using wl_display_connect() will end up closing the socket * passed in through the WAYLAND_SOCKET environment variable. When @@ -185,7 +186,8 @@ run_client(void (*client_main)(void), int wayland_sock, int client_pipe) static struct client_info * display_create_client(struct display *d, - void (*client_main)(void), + void (*client_main)(void *data), + void *data, const char *name) { int pipe_cli[2]; @@ -205,7 +207,7 @@ display_create_client(struct display *d, close(sock_wayl[1]); close(pipe_cli[1]); - run_client(client_main, sock_wayl[0], pipe_cli[0]); + run_client(client_main, data, sock_wayl[0], pipe_cli[0]); close(sock_wayl[0]); close(pipe_cli[0]); @@ -246,11 +248,14 @@ display_create_client(struct display *d, } struct client_info * -client_create_with_name(struct display *d, void (*client_main)(void), +client_create_with_name(struct display *d, + void (*client_main)(void *data), void *data, const char *name) { int can_continue = 1; - struct client_info *cl = display_create_client(d, client_main, name); + struct client_info *cl = display_create_client(d, + client_main, data, + name); /* let the show begin! */ assert(write(cl->pipe, &can_continue, sizeof(int)) == sizeof(int)); |
