aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test-compositor.h
Commit message (Collapse)AuthorAgeFilesLines
* tests: Avoid calling function with wrong typeDemi Marie Obenour2024-11-301-1/+13
| | | | | | | | | Calling a function with the wrong type is immediate undefined behavior, even if the ABI says it should be harmless. UBSAN picks it up immediately, and any decent control-flow integrity mechanism will as well. Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
* tests: Support tests that check for client failureAlexandros Frantzis2023-02-281-0/+2
| | | | | | | | Add the display_destroy_expect_signal() function to check that test clients exit due to a particular signal. This is useful for checking that clients fail in an expected way. Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
* tests: Capture the test client logAlexandros Frantzis2023-02-281-0/+4
| | | | | | | Capture the test client log to a temporary fd, so that is accessible by both the test server process and the test client process. Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
* display-test: Fix a race condition in test suiteFergus Dall2022-02-051-1/+2
| | | | | | | | | | | | | | | | | | Several tests in this suite use setting and checking client.display_stopped (in test-compositor.h) to synchronise between threads. This is a data race because display_stopped is a non-atomic int. Fix this by making it an atomic_bool instead. We don't need to change the access code because reads and writes are sequentially consistent by default. This can be reproduced (with both clang and gcc) by running ``` meson -Db_sanitize=thread build cd build ninja meson test ``` Signed-off-by: Fergus Dall <sidereal@google.com>
* tests: Destroy custom global objectDerek Foreman2021-08-271-0/+1
| | | | | | | Destroy our custom global object at end of run so we no longer "leak" it. Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
* tests: Fix race condition in send overflow testManuel Stoeckl2020-01-151-2/+11
| | | | | | | | | | | | | This change ensures that the compositor process is not able to respond to any of the noop requests sent by the client process, by using the test compositor's `stop_display` mechanism to coordinate when the compositor should stop processing messages. (Before this change, it was possible that one of the calls of wl_event_loop_dispatch in the compositor process could respond to all the client's noop requests before returning.) Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
* tests: Test that send overflow doesn't abortManuel Stoeckl2019-09-101-0/+1
| | | | | | | | | | The new display test runs a client that makes a very large number of trivial requests. After responding to initial setup requests, the server is paused, letting the trivial requests fill up the Unix socket buffer, making further writes to the socket fail. The test then checks that the client sets an appropriate error code, and does not abort or crash. Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
* (multiple): Include stdint.hYong Bakos2016-07-251-0/+1
| | | | | | | | | | Some headers and source files have been using types such as uint32_t without explicitly including stdint.h. Explicitly include stdint.h where appropriate. Signed-off-by: Yong Bakos <ybakos@humanoriented.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
* tests: Pass argument to client mainJonas Ådahl2016-01-161-4/+7
| | | | | | | | | | | | 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>
* tests: Update boilerplate from MIT X11 license to MIT Expat licenseBryce Harrington2015-06-121-16/+19
| | | | | Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* tests: add test-compositorMarek Chalupa2014-08-221-0/+97
This patch introduces a set of functions that can create a display and clients for tests. On server side the user can use functions: display_create() display_destroy() create_client() display_run() display_resume() and on client side the user can use: client_connect() client_disconnect() stop_display() The stop_display() and display_resume() are functions that serve as a barrier and also allow the display to take some action after the display_run() was called, because after the display is stopped, it can run arbitrary code until it calls display_resume(). client_connect() function connects to wayland display and creates a proxy to test_compositor global object, so it can ask for stopping the display later using stop_display(). An example: void client_main() { /* or client can use wl_display_connect(NULL) * and do all the stuff manually */ struct client *c = client_connect(); /* do some stuff, ... */ /* stop the display so that it can * do some other stuff */ stop_display(c, 1); /* ... */ client_disconnect(c); } TEST(dummy_tst) { struct display *d = display_create(); /* set up the display */ wl_global_create(d->wl_display, ...); /* ... */ create_client(d, client_main); display_run(); /* if we are here, the display has been stopped * and we can do some code, i. e. create another global or so */ wl_global_create(d->wl_display, ...); /* ... */ display_resume(d); /* resume display and clients */ display_destroy(d); } v2: added/changed message in few asserts that were not clear fixed codying style issues and typo client_create_with_name: fixed a condition in an assert get_socket_name: use also pid check_error: fix errno -> err [Pekka Paalanen: added test-compositor.h to SOURCES, added WL_HIDE_DEPRECATED to get rid of deprecated defs and lots of warnings, fixed one unchecked return value from write().] Signed-off-by: Marek Chalupa <mchqwerty@gmail.com> Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>