aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test-compositor.c
Commit message (Collapse)AuthorAgeFilesLines
* tests: Avoid calling function with wrong typeDemi Marie Obenour2024-11-301-1/+1
| | | | | | | | | 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>
* compat: prefer waitpid() over waitid()Sébastien Marie2024-02-211-13/+10
| | | | | | while both are defined by POSIX, waitpid() is more common than waitid(). Signed-off-by: Sebastien Marie <semarie@online.fr>
* tests: Support tests that check for client failureAlexandros Frantzis2023-02-281-3/+19
| | | | | | | | 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-2/+39
| | | | | | | 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>
* tests: Destroy custom global objectDerek Foreman2021-08-271-4/+5
| | | | | | | 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-1/+6
| | | | | | | | | | | | | 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-4/+22
| | | | | | | | | | 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>
* tests: Remove memory leak checking infrastructureDaniel Stone2018-08-291-3/+2
| | | | | | | | | | | | | There are far better ways to detect memory leaks, such as either valgrind or ASan. Having Meson makes it really easy to use these tools in our tests, and we can do that in CI as well. Having these local wrappers actually completely broke ASan usage, so remove them in favour of using the more powerful options. Signed-off-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
* (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-6/+11
| | | | | | | | | | | | 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: Synchronize client termination in idle callbackJonas Ådahl2016-01-161-6/+21
| | | | | | | | | | | We currently wait for clients in the wl_client destroy signal, which is called before the client is destructed and the socket is closed. If test clients rely on being closed due to the socket being closed we'd dead lock. Avoid this by synchronizing in an idle task that is called after the client is fully destroyed. 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: Typo in a commentBryce Harrington2015-04-151-1/+1
| | | | | | (Spotted by Silvan) Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
* Spelling fixes (cosmetic)Bryce Harrington2015-03-191-2/+2
| | | | | | | | | | | | | | | | A few typos in comments and protocol docs, no code changes. ./src/wayland-util.h:281: recieved ==> received ./src/wayland-client.c:115: occured ==> occurred ./src/wayland-client.c:156: occured ==> occurred ./tests/test-compositor.c:76: parallely ==> parallelly ./tests/test-compositor.c:474: recieve ==> receive ./protocol/wayland.xml:1767: layed ==> laid ./protocol/wayland.xml:2112: dependant ==> dependent ./doc/publican/sources/Client.xml:25: recieved ==> received Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Bill Spitzak <spitzak@gmail.com>
* test-compositor: extend leak checks into clientsMarek Chalupa2015-01-281-0/+15
| | | | | | | | | | | | | | | | | | | Run leak checks also on clients of test-compositor. Checking leaks in memory is the same as in normal TEST. Checking file descriptor leaks is slightly more complex, as we pass an open file descriptor in the WAYLAND_SOCKET environment variable, which will be consumed by a client calling wl_display_connect(), but otherwise remain unused. We manage this accounting by checking if the environment variable has been unset by wl_display_connect() as it consumes the socket. Signed-off-by: Marek Chalupa <mchqwerty@gmail.com> Reviewed-by: Daniel Stone <daniels@collabora.com> [daniels: squashed counter-proposal patch to simplify fd leak checking, plus Bill's counter-counter-proposal, and reworded log.]
* tests: fix memory leakMarek Chalupa2014-12-011-0/+1
| | | | | | | We didn't free the struct client that we got from client_connect() Signed-off-by: Marek Chalupa <mchqwerty@gmail.com> Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* tests: add test-compositorMarek Chalupa2014-08-221-0/+472
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>