Commit Graph

15 Commits

Author SHA1 Message Date
Alexandros Frantzis
e09010f470 tests: Support tests that check for client failure
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>
2023-02-28 11:22:04 +00:00
Alexandros Frantzis
d4d3228853 tests: Capture the test client log
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>
2023-02-28 11:22:04 +00:00
Derek Foreman
bf98c1a8f2 tests: Destroy custom global object
Destroy our custom global object at end of run so we no longer "leak"
it.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2021-08-27 09:56:17 -05:00
Manuel Stoeckl
e449232f37 tests: Fix race condition in send overflow test
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>
2020-01-15 13:18:56 +00:00
Manuel Stoeckl
a89a5349af tests: Test that send overflow doesn't abort
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>
2019-09-10 07:59:50 -04:00
Daniel Stone
01095a9ce4 tests: Remove memory leak checking infrastructure
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>
2018-08-29 09:59:04 +01:00
Yong Bakos
2b1c1b2d66 (multiple): Include stdint.h
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>
2016-07-25 18:39:32 -07:00
Jonas Ådahl
046012a6cf 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>
2016-01-16 16:37:37 +08:00
Jonas Ådahl
7efe8fbd89 tests: Synchronize client termination in idle callback
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>
2016-01-16 16:37:36 +08:00
Bryce Harrington
773babedfc tests: Update boilerplate from MIT X11 license to MIT Expat license
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-06-12 15:31:24 -07:00
Bryce Harrington
70d3c0fe8a tests: Typo in a comment
(Spotted by Silvan)

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
2015-04-15 15:07:54 -07:00
Bryce Harrington
439b0a3863 Spelling fixes (cosmetic)
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>
2015-03-19 16:56:17 +02:00
Marek Chalupa
9ef0277571 test-compositor: extend leak checks into clients
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.]
2015-01-28 17:17:06 +00:00
Marek Chalupa
e118c11178 tests: fix memory leak
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>
2014-12-01 12:34:23 +02:00
Marek Chalupa
85d08e8bd6 tests: add test-compositor
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>
2014-08-22 12:34:33 +03:00