• Home
  • Raw
  • Download

Lines Matching +full:test +full:- +full:cl

40 #include "test-runner.h"
41 #include "test-compositor.h"
43 int client_log_fd = -1;
45 /* --- Protocol --- */
59 "test", 1,
87 * for each test, otherwise the test can fail on wl_display_add_socket. */
95 snprintf(retval, sizeof retval, "wayland-test-%d-%ld%ld", in get_socket_name()
108 d = ci->display; in handle_client_destroy()
110 assert(waitid(P_PID, ci->pid, &status, WEXITED) != -1); in handle_client_destroy()
116 ci->name, status.si_status); in handle_client_destroy()
117 ci->kill_code = status.si_status; in handle_client_destroy()
122 ci->name, status.si_status); in handle_client_destroy()
124 ci->exit_code = status.si_status; in handle_client_destroy()
128 ++d->clients_terminated_no; in handle_client_destroy()
129 if (d->clients_no == d->clients_terminated_no) { in handle_client_destroy()
130 wl_display_terminate(d->wl_display); in handle_client_destroy()
134 * at the end of the test we check the exit codes of all in handle_client_destroy()
135 * clients. In the case that the test would go through in handle_client_destroy()
153 d = ci->display; in client_destroyed()
154 loop = wl_display_get_event_loop(d->wl_display); in client_destroyed()
157 ci->wl_client = NULL; in client_destroyed()
204 cur_fds--; in run_client()
212 char logname[] = "/tmp/wayland-tests-log-XXXXXX"; in create_log_fd()
231 struct client_info *cl; in display_create_client() local
242 assert(pid != -1 && "Fork failed"); in display_create_client()
260 cl = calloc(1, sizeof(struct client_info)); in display_create_client()
261 assert(cl && "Out of memory"); in display_create_client()
263 wl_list_insert(&d->clients, &cl->link); in display_create_client()
265 cl->display = d; in display_create_client()
266 cl->name = name; in display_create_client()
267 cl->pid = pid; in display_create_client()
268 cl->pipe = pipe_cli[1]; in display_create_client()
269 cl->log_fd = log_fd; in display_create_client()
270 cl->destroy_listener.notify = &client_destroyed; in display_create_client()
272 cl->wl_client = wl_client_create(d->wl_display, sock_wayl[1]); in display_create_client()
273 if (!cl->wl_client) { in display_create_client()
277 ret = write(cl->pipe, &can_continue, sizeof(int)); in display_create_client()
282 wl_client_add_destroy_listener(cl->wl_client, in display_create_client()
283 &cl->destroy_listener); in display_create_client()
285 ++d->clients_no; in display_create_client()
287 return cl; in display_create_client()
296 struct client_info *cl = display_create_client(d, in client_create_with_name() local
301 assert(write(cl->pipe, &can_continue, sizeof(int)) == sizeof(int)); in client_create_with_name()
303 return cl; in client_create_with_name()
319 assert(d->wfr_num < num in handle_stop_display()
320 && "test error: Too many clients sent stop_display request"); in handle_stop_display()
322 ++d->wfr_num; in handle_stop_display()
330 wfr->resource = resource; in handle_stop_display()
331 wl_list_insert(&d->waiting_for_resume, &wfr->link); in handle_stop_display()
333 if (d->wfr_num == num) in handle_stop_display()
334 wl_display_terminate(d->wl_display); in handle_stop_display()
374 d->wl_display = wl_display_create(); in display_create()
375 assert(d->wl_display && "Creating display failed"); in display_create()
379 stat = wl_display_add_socket(d->wl_display, socket_name); in display_create()
382 wl_list_init(&d->clients); in display_create()
383 d->clients_no = d->clients_terminated_no = 0; in display_create()
385 wl_list_init(&d->waiting_for_resume); in display_create()
386 d->wfr_num = 0; in display_create()
388 d->test_global = wl_global_create(d->wl_display, in display_create()
391 assert(d->test_global && "Creating test global failed"); in display_create()
399 assert(d->wfr_num == 0 in display_run()
400 && "test error: Have waiting clients. Use display_resume."); in display_run()
401 wl_display_run(d->wl_display); in display_run()
409 assert(d->wfr_num > 0 && "test error: No clients waiting."); in display_post_resume_events()
411 wl_list_for_each_safe(wfr, next, &d->waiting_for_resume, link) { in display_post_resume_events()
412 wl_resource_post_event(wfr->resource, DISPLAY_RESUMED); in display_post_resume_events()
413 wl_list_remove(&wfr->link); in display_post_resume_events()
417 assert(wl_list_empty(&d->waiting_for_resume)); in display_post_resume_events()
418 d->wfr_num = 0; in display_post_resume_events()
425 wl_display_run(d->wl_display); in display_resume()
433 struct client_info *cl, *next; in display_destroy_expect_signal() local
436 assert(d->wfr_num == 0 in display_destroy_expect_signal()
437 && "test error: Didn't you forget to call display_resume?"); in display_destroy_expect_signal()
439 wl_list_for_each_safe(cl, next, &d->clients, link) { in display_destroy_expect_signal()
440 assert(cl->wl_client == NULL); in display_destroy_expect_signal()
442 if (signum != 0 && cl->kill_code != signum) { in display_destroy_expect_signal()
447 cl->name, signum, cl->kill_code); in display_destroy_expect_signal()
450 (cl->kill_code != 0 || cl->exit_code != 0)) { in display_destroy_expect_signal()
452 fprintf(stderr, "Client '%s' failed\n", cl->name); in display_destroy_expect_signal()
455 close(cl->pipe); in display_destroy_expect_signal()
456 close(cl->log_fd); in display_destroy_expect_signal()
457 free(cl); in display_destroy_expect_signal()
460 wl_global_destroy(d->test_global); in display_destroy_expect_signal()
461 wl_display_destroy(d->wl_display); in display_destroy_expect_signal()
477 * --- Client helper functions ---
484 c->display_stopped = 0; in handle_display_resumed()
497 if (strcmp(intf, "test") != 0) in registry_handle_globals()
500 c->tc = wl_registry_bind(registry, id, &test_compositor_interface, ver); in registry_handle_globals()
501 assert(c->tc && "Failed binding to registry"); in registry_handle_globals()
503 wl_proxy_add_listener((struct wl_proxy *) c->tc, in registry_handle_globals()
519 c->wl_display = wl_display_connect(NULL); in client_connect()
520 assert(c->wl_display && "Failed connecting to display"); in client_connect()
524 reg = wl_display_get_registry(c->wl_display); in client_connect()
527 wl_display_roundtrip(c->wl_display); in client_connect()
528 assert(c->tc); in client_connect()
547 " (object %u)\n", ec, intf->name, id); in check_error()
560 check_error(c->wl_display); in client_disconnect()
562 wl_proxy_destroy((struct wl_proxy *) c->tc); in client_disconnect()
563 wl_display_disconnect(c->wl_display); in client_disconnect()
574 c->display_stopped = 1; in stop_display()
575 wl_proxy_marshal((struct wl_proxy *) c->tc, STOP_DISPLAY, num); in stop_display()
577 while (c->display_stopped && n >= 0) { in stop_display()
578 n = wl_display_dispatch(c->wl_display); in stop_display()
587 wl_proxy_marshal((struct wl_proxy *) c->tc, TEST_NOOP); in noop_request()