queue-test.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846
  1. /*
  2. * Copyright © 2012 Jonas Ådahl
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining
  5. * a copy of this software and associated documentation files (the
  6. * "Software"), to deal in the Software without restriction, including
  7. * without limitation the rights to use, copy, modify, merge, publish,
  8. * distribute, sublicense, and/or sell copies of the Software, and to
  9. * permit persons to whom the Software is furnished to do so, subject to
  10. * the following conditions:
  11. *
  12. * The above copyright notice and this permission notice (including the
  13. * next paragraph) shall be included in all copies or substantial
  14. * portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  17. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  18. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  19. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  20. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  21. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  22. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  23. * SOFTWARE.
  24. */
  25. #include <stdlib.h>
  26. #include <stdint.h>
  27. #include <stdio.h>
  28. #include <stdbool.h>
  29. #include <string.h>
  30. #include <unistd.h>
  31. #include <sys/mman.h>
  32. #include <sys/types.h>
  33. #include <sys/wait.h>
  34. #include <assert.h>
  35. #include <signal.h>
  36. #include "wayland-client.h"
  37. #include "wayland-server.h"
  38. #include "test-runner.h"
  39. #include "test-compositor.h"
  40. #include "../src/timespec-util.h"
  41. #define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
  42. static void
  43. registry_handle_global(void *data, struct wl_registry *registry,
  44. uint32_t id, const char *interface, uint32_t version)
  45. {
  46. int *pcounter = data;
  47. (*pcounter)++;
  48. assert(*pcounter == 1);
  49. wl_registry_destroy(registry);
  50. }
  51. static const struct wl_registry_listener registry_listener = {
  52. registry_handle_global,
  53. NULL
  54. };
  55. /* Test that destroying a proxy object doesn't result in any more
  56. * callback being invoked, even though were many queued. */
  57. static void
  58. client_test_proxy_destroy(void)
  59. {
  60. struct wl_display *display;
  61. struct wl_registry *registry;
  62. int counter = 0;
  63. display = wl_display_connect(NULL);
  64. assert(display);
  65. registry = wl_display_get_registry(display);
  66. assert(registry != NULL);
  67. wl_registry_add_listener(registry, &registry_listener,
  68. &counter);
  69. assert(wl_display_roundtrip(display) != -1);
  70. assert(counter == 1);
  71. /* don't destroy the registry, we have already destroyed them
  72. * in the global handler */
  73. wl_display_disconnect(display);
  74. }
  75. struct multiple_queues_state {
  76. struct wl_display *display;
  77. struct wl_callback* callback2;
  78. bool done;
  79. };
  80. static void
  81. sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
  82. {
  83. struct multiple_queues_state *state = data;
  84. state->done = true;
  85. wl_callback_destroy(callback);
  86. wl_display_dispatch_pending(state->display);
  87. wl_callback_destroy(state->callback2);
  88. }
  89. static const struct wl_callback_listener sync_listener = {
  90. sync_callback
  91. };
  92. /* Test that when receiving the first of two synchronization
  93. * callback events, destroying the second one doesn't cause any
  94. * errors even if the delete_id event is handled out of order. */
  95. static void
  96. client_test_multiple_queues(void)
  97. {
  98. struct wl_event_queue *queue;
  99. struct wl_callback *callback1;
  100. struct multiple_queues_state state;
  101. int ret = 0;
  102. state.display = wl_display_connect(NULL);
  103. assert(state.display);
  104. queue = wl_display_create_queue(state.display);
  105. assert(queue);
  106. state.done = false;
  107. callback1 = wl_display_sync(state.display);
  108. assert(callback1 != NULL);
  109. wl_callback_add_listener(callback1, &sync_listener, &state);
  110. wl_proxy_set_queue((struct wl_proxy *) callback1, queue);
  111. state.callback2 = wl_display_sync(state.display);
  112. assert(state.callback2 != NULL);
  113. wl_callback_add_listener(state.callback2, &sync_listener, NULL);
  114. wl_proxy_set_queue((struct wl_proxy *) state.callback2, queue);
  115. wl_display_flush(state.display);
  116. while (!state.done && !ret)
  117. ret = wl_display_dispatch_queue(state.display, queue);
  118. wl_event_queue_destroy(queue);
  119. wl_display_disconnect(state.display);
  120. exit(ret == -1 ? -1 : 0);
  121. }
  122. static void
  123. sync_callback_roundtrip(void *data, struct wl_callback *callback, uint32_t serial)
  124. {
  125. bool *done = data;
  126. *done = true;
  127. }
  128. static const struct wl_callback_listener sync_listener_roundtrip = {
  129. sync_callback_roundtrip
  130. };
  131. /* Test that doing a roundtrip on a queue only the events on that
  132. * queue get dispatched. */
  133. static void
  134. client_test_queue_roundtrip(void)
  135. {
  136. struct wl_event_queue *queue;
  137. struct wl_callback *callback1;
  138. struct wl_callback *callback2;
  139. struct wl_display *display;
  140. bool done1 = false;
  141. bool done2 = false;
  142. display = wl_display_connect(NULL);
  143. assert(display);
  144. queue = wl_display_create_queue(display);
  145. assert(queue);
  146. /* arm a callback on the default queue */
  147. callback1 = wl_display_sync(display);
  148. assert(callback1 != NULL);
  149. wl_callback_add_listener(callback1, &sync_listener_roundtrip, &done1);
  150. /* arm a callback on the other queue */
  151. callback2 = wl_display_sync(display);
  152. assert(callback2 != NULL);
  153. wl_callback_add_listener(callback2, &sync_listener_roundtrip, &done2);
  154. wl_proxy_set_queue((struct wl_proxy *) callback2, queue);
  155. /* roundtrip on default queue must not dispatch the other queue. */
  156. wl_display_roundtrip(display);
  157. assert(done1 == true);
  158. assert(done2 == false);
  159. /* re-arm the sync callback on the default queue, so we see that
  160. * wl_display_roundtrip_queue() does not dispatch the default queue. */
  161. wl_callback_destroy(callback1);
  162. done1 = false;
  163. callback1 = wl_display_sync(display);
  164. assert(callback1 != NULL);
  165. wl_callback_add_listener(callback1, &sync_listener_roundtrip, &done1);
  166. wl_display_roundtrip_queue(display, queue);
  167. assert(done1 == false);
  168. assert(done2 == true);
  169. wl_callback_destroy(callback1);
  170. wl_callback_destroy(callback2);
  171. wl_event_queue_destroy(queue);
  172. wl_display_disconnect(display);
  173. }
  174. static void
  175. client_test_queue_proxy_wrapper(void)
  176. {
  177. struct wl_event_queue *queue;
  178. struct wl_display *display;
  179. struct wl_display *display_wrapper;
  180. struct wl_callback *callback;
  181. bool done = false;
  182. /*
  183. * For an illustration of what usage would normally fail without using
  184. * proxy wrappers, see the `client_test_queue_set_queue_race' test case.
  185. */
  186. display = wl_display_connect(NULL);
  187. assert(display);
  188. /* Pretend we are in a separate thread where a thread-local queue is
  189. * used. */
  190. queue = wl_display_create_queue(display);
  191. assert(queue);
  192. display_wrapper = wl_proxy_create_wrapper(display);
  193. assert(display_wrapper);
  194. wl_proxy_set_queue((struct wl_proxy *) display_wrapper, queue);
  195. callback = wl_display_sync(display_wrapper);
  196. wl_proxy_wrapper_destroy(display_wrapper);
  197. assert(callback != NULL);
  198. /* Pretend we are now another thread and dispatch the dispatch the main
  199. * queue while also knowing our callback is read and queued. */
  200. wl_display_roundtrip(display);
  201. /* Make sure that the pretend-to-be main thread didn't dispatch our
  202. * callback, behind our back. */
  203. wl_callback_add_listener(callback, &sync_listener_roundtrip, &done);
  204. wl_display_flush(display);
  205. assert(!done);
  206. /* Make sure that we eventually end up dispatching our callback. */
  207. while (!done)
  208. assert(wl_display_dispatch_queue(display, queue) != -1);
  209. wl_callback_destroy(callback);
  210. wl_event_queue_destroy(queue);
  211. wl_display_disconnect(display);
  212. }
  213. static void
  214. client_test_queue_set_queue_race(void)
  215. {
  216. struct wl_event_queue *queue;
  217. struct wl_display *display;
  218. struct wl_callback *callback;
  219. bool done = false;
  220. /*
  221. * This test illustrates the multi threading scenario which would fail
  222. * without doing what is done in the `client_test_queue_proxy_wrapper'
  223. * test.
  224. */
  225. display = wl_display_connect(NULL);
  226. assert(display);
  227. /* Pretend we are in a separate thread where a thread-local queue is
  228. * used. */
  229. queue = wl_display_create_queue(display);
  230. assert(queue);
  231. callback = wl_display_sync(display);
  232. assert(callback != NULL);
  233. /* Pretend we are now another thread and dispatch the dispatch the main
  234. * queue while also knowing our callback is read, queued on the wrong
  235. * queue, and dispatched. */
  236. wl_display_roundtrip(display);
  237. /* Pretend we are back in the separate thread, and continue with setting
  238. * up our callback. */
  239. wl_callback_add_listener(callback, &sync_listener_roundtrip, &done);
  240. wl_proxy_set_queue((struct wl_proxy *) callback, queue);
  241. /* Roundtrip our separate thread queue to make sure any events are
  242. * dispatched. */
  243. wl_display_roundtrip_queue(display, queue);
  244. /* Verify that the callback has indeed been dropped. */
  245. assert(!done);
  246. wl_callback_destroy(callback);
  247. wl_event_queue_destroy(queue);
  248. wl_display_disconnect(display);
  249. }
  250. static char *
  251. maybe_map_file(int fd, size_t *len)
  252. {
  253. char *data;
  254. *len = lseek(fd, 0, SEEK_END);
  255. data = mmap(0, *len, PROT_READ, MAP_PRIVATE, fd, 0);
  256. return data;
  257. }
  258. static char *
  259. map_file(int fd, size_t *len)
  260. {
  261. char *data;
  262. data = maybe_map_file(fd, len);
  263. assert(data != MAP_FAILED && "Failed to mmap file");
  264. return data;
  265. }
  266. static char *
  267. last_line_of(char *s)
  268. {
  269. char *last = s;
  270. char *nl;
  271. /* Walk forward over the newlines, remembering the start of each line
  272. * that has content, so that a trailing newline is ignored. */
  273. while ((nl = strchr(last, '\n')) != NULL && nl[1] != '\0')
  274. last = nl + 1;
  275. return last;
  276. }
  277. static void
  278. client_test_queue_destroy_with_attached_proxies(void)
  279. {
  280. struct wl_event_queue *queue;
  281. struct wl_display *display;
  282. struct wl_display *display_wrapper;
  283. struct wl_callback *callback;
  284. char *log;
  285. size_t log_len;
  286. char callback_name[24];
  287. int ret;
  288. display = wl_display_connect(NULL);
  289. assert(display);
  290. /* Pretend we are in a separate thread where a thread-local queue is
  291. * used. */
  292. queue = wl_display_create_queue(display);
  293. assert(queue);
  294. /* Create a sync dispatching events on the thread-local queue. */
  295. display_wrapper = wl_proxy_create_wrapper(display);
  296. assert(display_wrapper);
  297. wl_proxy_set_queue((struct wl_proxy *) display_wrapper, queue);
  298. callback = wl_display_sync(display_wrapper);
  299. wl_proxy_wrapper_destroy(display_wrapper);
  300. assert(callback != NULL);
  301. /* Destroy the queue before the attached object. */
  302. wl_event_queue_destroy(queue);
  303. /* Check that the log contains some information about the attached
  304. * wl_callback proxy. */
  305. log = map_file(client_log_fd, &log_len);
  306. ret = snprintf(callback_name, sizeof(callback_name), "wl_callback#%u",
  307. wl_proxy_get_id((struct wl_proxy *) callback));
  308. assert(ret > 0 && ret < (int)sizeof(callback_name) &&
  309. "callback name creation failed (possibly truncated)");
  310. assert(strstr(last_line_of(log), callback_name));
  311. munmap(log, log_len);
  312. wl_callback_destroy(callback);
  313. wl_display_disconnect(display);
  314. }
  315. static void
  316. client_test_queue_proxy_event_to_destroyed_queue(void)
  317. {
  318. struct wl_event_queue *queue;
  319. struct wl_display *display;
  320. struct wl_display *display_wrapper;
  321. struct wl_callback *callback;
  322. display = wl_display_connect(NULL);
  323. assert(display);
  324. /* Pretend we are in a separate thread where a thread-local queue is
  325. * used. */
  326. queue = wl_display_create_queue(display);
  327. assert(queue);
  328. /* Create a sync dispatching events on the thread-local queue. */
  329. display_wrapper = wl_proxy_create_wrapper(display);
  330. assert(display_wrapper);
  331. wl_proxy_set_queue((struct wl_proxy *) display_wrapper, queue);
  332. callback = wl_display_sync(display_wrapper);
  333. wl_proxy_wrapper_destroy(display_wrapper);
  334. assert(callback != NULL);
  335. wl_display_flush(display);
  336. /* Destroy the queue before the attached object. */
  337. wl_event_queue_destroy(queue);
  338. /* During this roundtrip we should receive the done event on 'callback',
  339. * try to queue it to the destroyed queue, and abort. */
  340. wl_display_roundtrip(display);
  341. wl_callback_destroy(callback);
  342. wl_display_disconnect(display);
  343. }
  344. static void
  345. client_test_queue_destroy_default_with_attached_proxies(void)
  346. {
  347. struct wl_display *display;
  348. struct wl_callback *callback;
  349. char *log;
  350. size_t log_len;
  351. char callback_name[24];
  352. int ret;
  353. display = wl_display_connect(NULL);
  354. assert(display);
  355. /* Create a sync dispatching events on the default queue. */
  356. callback = wl_display_sync(display);
  357. assert(callback != NULL);
  358. /* Destroy the default queue (by disconnecting) before the attached
  359. * object. */
  360. wl_display_disconnect(display);
  361. /* Check that the log does not contain any warning about the attached
  362. * wl_callback proxy. */
  363. log = maybe_map_file(client_log_fd, &log_len);
  364. ret = snprintf(callback_name, sizeof(callback_name), "wl_callback#%u",
  365. wl_proxy_get_id((struct wl_proxy *) callback));
  366. assert(ret > 0 && ret < (int)sizeof(callback_name) &&
  367. "callback name creation failed (possibly truncated)");
  368. assert(log == MAP_FAILED || strstr(log, callback_name) == NULL);
  369. if (log != MAP_FAILED)
  370. munmap(log, log_len);
  371. /* HACK: Directly free the memory of the wl_callback proxy to appease
  372. * ASan. We would normally use wl_callback_destroy(), but since we have
  373. * destroyed the associated wl_display, using this function would lead
  374. * to memory errors. */
  375. free(callback);
  376. }
  377. static void
  378. check_queue_name(struct wl_proxy *proxy, const char *name)
  379. {
  380. struct wl_event_queue *queue;
  381. const char *queue_name;
  382. queue = wl_proxy_get_queue(proxy);
  383. queue_name = wl_event_queue_get_name(queue);
  384. if (!name)
  385. assert(!queue_name);
  386. else
  387. assert(strcmp(queue_name, name) == 0);
  388. }
  389. static struct wl_callback *
  390. roundtrip_named_queue_nonblock(struct wl_display *display,
  391. struct wl_event_queue *queue,
  392. const char *name)
  393. {
  394. struct wl_callback *callback;
  395. struct wl_display *wrapped_display = NULL;
  396. if (queue) {
  397. wrapped_display = wl_proxy_create_wrapper(display);
  398. assert(wrapped_display);
  399. wl_proxy_set_queue((struct wl_proxy *) wrapped_display, queue);
  400. check_queue_name((struct wl_proxy *) wrapped_display, name);
  401. callback = wl_display_sync(wrapped_display);
  402. } else
  403. callback = wl_display_sync(display);
  404. check_queue_name((struct wl_proxy *) callback, name);
  405. if (wrapped_display)
  406. wl_proxy_wrapper_destroy(wrapped_display);
  407. assert(callback != NULL);
  408. return callback;
  409. }
  410. static void
  411. client_test_queue_names(void)
  412. {
  413. struct wl_event_queue *queue1, *queue2, *queue3;
  414. struct wl_display *display;
  415. struct wl_callback *callback1, *callback2, *callback3, *callback4;
  416. struct wl_event_queue *default_queue;
  417. char *log;
  418. size_t log_len;
  419. const char *default_queue_name;
  420. display = wl_display_connect(NULL);
  421. assert(display);
  422. default_queue = wl_proxy_get_queue((struct wl_proxy *) display);
  423. default_queue_name = wl_event_queue_get_name(default_queue);
  424. assert(strcmp(default_queue_name, "Default Queue") == 0);
  425. /* Create some event queues both with and without names. */
  426. queue1 = wl_display_create_queue_with_name(display, "First");
  427. assert(queue1);
  428. queue2 = wl_display_create_queue_with_name(display, "Second");
  429. assert(queue2);
  430. queue3 = wl_display_create_queue(display);
  431. assert(queue3);
  432. /* Create some requests and ensure their queues have the expected
  433. * names.
  434. */
  435. callback1 = roundtrip_named_queue_nonblock(display, queue1, "First");
  436. callback2 = roundtrip_named_queue_nonblock(display, queue2, "Second");
  437. callback3 = roundtrip_named_queue_nonblock(display, queue3, NULL);
  438. callback4 = roundtrip_named_queue_nonblock(display, NULL, "Default Queue");
  439. /* Destroy one queue with proxies still attached so we can verify
  440. * that the queue name is in the log message. */
  441. wl_event_queue_destroy(queue2);
  442. log = map_file(client_log_fd, &log_len);
  443. assert(strstr(log, "Second"));
  444. /* There's no reason for the First queue name to be present. */
  445. assert(!strstr(log, "First"));
  446. munmap(log, log_len);
  447. wl_callback_destroy(callback1);
  448. wl_callback_destroy(callback2);
  449. wl_callback_destroy(callback3);
  450. wl_callback_destroy(callback4);
  451. wl_event_queue_destroy(queue1);
  452. wl_event_queue_destroy(queue3);
  453. wl_display_disconnect(display);
  454. }
  455. static void
  456. dispatch_timeout_sync_callback(void *data, struct wl_callback *callback,
  457. uint32_t serial)
  458. {
  459. bool *done = data;
  460. *done = true;
  461. wl_callback_destroy(callback);
  462. }
  463. static const struct wl_callback_listener dispatch_timeout_sync_listener = {
  464. dispatch_timeout_sync_callback
  465. };
  466. static void
  467. client_test_queue_dispatch_simple(void)
  468. {
  469. struct wl_display *display;
  470. struct timespec timeout;
  471. struct wl_callback *callback;
  472. bool done = false;
  473. int ret = 0;
  474. display = wl_display_connect(NULL);
  475. assert(display);
  476. callback = wl_display_sync(display);
  477. assert(callback != NULL);
  478. wl_callback_add_listener(callback, &dispatch_timeout_sync_listener, &done);
  479. timespec_from_msec(&timeout, 1000);
  480. while (!done) {
  481. ret = wl_display_dispatch_timeout(display, &timeout);
  482. assert(ret > 0);
  483. }
  484. wl_display_disconnect(display);
  485. exit(0);
  486. }
  487. static void
  488. client_test_queue_dispatch_timeout(void)
  489. {
  490. struct wl_display *display;
  491. struct timespec timeout;
  492. int ret = 0;
  493. display = wl_display_connect(NULL);
  494. assert(display);
  495. timespec_from_msec(&timeout, 100);
  496. ret = wl_display_dispatch_timeout(display, &timeout);
  497. assert(ret == 0);
  498. wl_display_disconnect(display);
  499. exit(0);
  500. }
  501. /* Try to use a proxy with a destroyed queue as a factory for
  502. * another proxy (either normal or wrapper). This should succeed
  503. * although the new proxy may not be useful until a queue is attached.
  504. * The following code is safe to perform in the context of the test, since
  505. * we are not flushing the display write buffer, neither explicitly
  506. * (wl_display_flush()) nor implicitly (we don't place enough data to
  507. * fill the display buffer and cause an auto-flush). */
  508. static void
  509. client_test_queue_destroy_then_use_proxy_as_factory(void)
  510. {
  511. struct wl_display *display;
  512. struct wl_event_queue *queue;
  513. struct wl_registry *registry, *registry_wrapper;
  514. struct wl_proxy *proxy;
  515. display = wl_display_connect(NULL);
  516. assert(display);
  517. /* Create registry with a queue that's immediately destroyed. */
  518. queue = wl_display_create_queue(display);
  519. assert(queue);
  520. registry = wl_display_get_registry(display);
  521. assert(registry);
  522. wl_proxy_set_queue((struct wl_proxy *) registry, queue);
  523. wl_event_queue_destroy(queue);
  524. /* Scenario 1: Create a proxy using the registry (never flushed,
  525. * so details don't matter). */
  526. proxy = wl_registry_bind(registry, 1000, &wl_output_interface, 1);
  527. assert(proxy);
  528. /* Scenario 2: Create a wrapper proxy using the registry. */
  529. registry_wrapper = wl_proxy_create_wrapper(registry);
  530. assert(registry_wrapper);
  531. wl_proxy_wrapper_destroy((struct wl_proxy *) registry_wrapper);
  532. wl_proxy_destroy(proxy);
  533. wl_registry_destroy(registry);
  534. wl_display_disconnect(display);
  535. exit(0);
  536. }
  537. static void
  538. dummy_bind(struct wl_client *client,
  539. void *data, uint32_t version, uint32_t id)
  540. {
  541. }
  542. TEST(queue_proxy_destroy)
  543. {
  544. struct display *d;
  545. const struct wl_interface *dummy_interfaces[] = {
  546. &wl_seat_interface,
  547. &wl_pointer_interface,
  548. &wl_keyboard_interface,
  549. &wl_surface_interface
  550. };
  551. unsigned int i;
  552. d = display_create();
  553. for (i = 0; i < ARRAY_LENGTH(dummy_interfaces); i++)
  554. wl_global_create(d->wl_display, dummy_interfaces[i],
  555. dummy_interfaces[i]->version,
  556. NULL, dummy_bind);
  557. test_set_timeout(2);
  558. client_create_noarg(d, client_test_proxy_destroy);
  559. display_run(d);
  560. display_destroy(d);
  561. }
  562. TEST(queue_multiple_queues)
  563. {
  564. struct display *d = display_create();
  565. test_set_timeout(2);
  566. client_create_noarg(d, client_test_multiple_queues);
  567. display_run(d);
  568. display_destroy(d);
  569. }
  570. TEST(queue_roundtrip)
  571. {
  572. struct display *d = display_create();
  573. test_set_timeout(2);
  574. client_create_noarg(d, client_test_queue_roundtrip);
  575. display_run(d);
  576. display_destroy(d);
  577. }
  578. TEST(queue_set_queue_proxy_wrapper)
  579. {
  580. struct display *d = display_create();
  581. test_set_timeout(2);
  582. client_create_noarg(d, client_test_queue_proxy_wrapper);
  583. display_run(d);
  584. display_destroy(d);
  585. }
  586. TEST(queue_set_queue_race)
  587. {
  588. struct display *d = display_create();
  589. test_set_timeout(2);
  590. client_create_noarg(d, client_test_queue_set_queue_race);
  591. display_run(d);
  592. display_destroy(d);
  593. }
  594. TEST(queue_destroy_with_attached_proxies)
  595. {
  596. struct display *d = display_create();
  597. test_set_timeout(2);
  598. client_create_noarg(d, client_test_queue_destroy_with_attached_proxies);
  599. display_run(d);
  600. display_destroy(d);
  601. }
  602. TEST(queue_proxy_event_to_destroyed_queue)
  603. {
  604. struct display *d = display_create();
  605. struct client_info *ci;
  606. char *client_log;
  607. size_t client_log_len;
  608. test_set_timeout(2);
  609. ci = client_create_noarg(d, client_test_queue_proxy_event_to_destroyed_queue);
  610. display_run(d);
  611. /* Check that the final line in the log mentions the expected reason
  612. * for the abort. */
  613. client_log = map_file(ci->log_fd, &client_log_len);
  614. assert(!strcmp(last_line_of(client_log),
  615. "Tried to add event to destroyed queue\n"));
  616. munmap(client_log, client_log_len);
  617. /* Check that the client aborted. */
  618. display_destroy_expect_signal(d, SIGABRT);
  619. }
  620. TEST(queue_destroy_default_with_attached_proxies)
  621. {
  622. struct display *d = display_create();
  623. test_set_timeout(2);
  624. client_create_noarg(d, client_test_queue_destroy_default_with_attached_proxies);
  625. display_run(d);
  626. display_destroy(d);
  627. }
  628. TEST(queue_names)
  629. {
  630. struct display *d = display_create();
  631. test_set_timeout(2);
  632. client_create_noarg(d, client_test_queue_names);
  633. display_run(d);
  634. display_destroy(d);
  635. }
  636. TEST(queue_dispatch_simple)
  637. {
  638. struct display *d = display_create();
  639. test_set_timeout(2);
  640. client_create_noarg(d, client_test_queue_dispatch_simple);
  641. display_run(d);
  642. display_destroy(d);
  643. }
  644. TEST(queue_dispatch_timeout)
  645. {
  646. struct display *d = display_create();
  647. test_set_timeout(2);
  648. client_create_noarg(d, client_test_queue_dispatch_timeout);
  649. display_run(d);
  650. display_destroy(d);
  651. }
  652. TEST(queue_destroy_then_use_proxy_as_factory)
  653. {
  654. struct display *d = display_create();
  655. test_set_timeout(2);
  656. client_create_noarg(d, client_test_queue_destroy_then_use_proxy_as_factory);
  657. display_run(d);
  658. display_destroy(d);
  659. }