tests: add tests for leak check in clients
Sanity tests for leak checks in clients of test compositor and also check if the test-compositor itself is not leaking anything. Signed-off-by: Marek Chalupa <mchqwerty@gmail.com> Reviewed-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
parent
9ef0277571
commit
d1855797d3
|
@ -80,6 +80,23 @@ TEST(display_destroy_listener)
|
|||
assert(b.done);
|
||||
}
|
||||
|
||||
/* Fake 'client' which does not use wl_display_connect, and thus leaves the
|
||||
* file descriptor passed through WAYLAND_SOCKET intact. This should not
|
||||
* trigger an assertion in the leak check. */
|
||||
static void
|
||||
empty_client(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TEST(tc_leaks_tests)
|
||||
{
|
||||
struct display *d = display_create();
|
||||
client_create(d, empty_client);
|
||||
display_run(d);
|
||||
display_destroy(d);
|
||||
}
|
||||
|
||||
static void
|
||||
registry_handle_globals(void *data, struct wl_registry *registry,
|
||||
uint32_t id, const char *intf, uint32_t ver)
|
||||
|
|
|
@ -95,6 +95,22 @@ FAIL_TEST(sanity_malloc_indirect)
|
|||
/* not freeing array, must leak */
|
||||
}
|
||||
|
||||
FAIL_TEST(tc_client_memory_leaks)
|
||||
{
|
||||
struct display *d = display_create();
|
||||
client_create(d, sanity_malloc_direct);
|
||||
display_run(d);
|
||||
display_destroy(d);
|
||||
}
|
||||
|
||||
FAIL_TEST(tc_client_memory_leaks2)
|
||||
{
|
||||
struct display *d = display_create();
|
||||
client_create(d, sanity_malloc_indirect);
|
||||
display_run(d);
|
||||
display_destroy(d);
|
||||
}
|
||||
|
||||
FAIL_TEST(sanity_fd_leak)
|
||||
{
|
||||
int fd[2];
|
||||
|
@ -129,6 +145,65 @@ TEST(sanity_fd_exec)
|
|||
exec_fd_leak_check(nr_fds + 2);
|
||||
}
|
||||
|
||||
static void
|
||||
sanity_fd_no_leak(void)
|
||||
{
|
||||
int fd[2];
|
||||
|
||||
assert(leak_check_enabled);
|
||||
|
||||
/* leak 2 file descriptors */
|
||||
if (pipe(fd) < 0)
|
||||
exit(EXIT_SUCCESS); /* failed to fail */
|
||||
|
||||
close(fd[0]);
|
||||
close(fd[1]);
|
||||
}
|
||||
|
||||
static void
|
||||
sanity_client_no_leak(void)
|
||||
{
|
||||
struct wl_display *display = wl_display_connect(NULL);
|
||||
assert(display);
|
||||
|
||||
wl_display_disconnect(display);
|
||||
}
|
||||
|
||||
TEST(tc_client_no_fd_leaks)
|
||||
{
|
||||
struct display *d = display_create();
|
||||
|
||||
/* Client which does not consume the WAYLAND_DISPLAY socket. */
|
||||
client_create(d, sanity_fd_no_leak);
|
||||
display_run(d);
|
||||
|
||||
/* Client which does consume the WAYLAND_DISPLAY socket. */
|
||||
client_create(d, sanity_client_no_leak);
|
||||
display_run(d);
|
||||
|
||||
display_destroy(d);
|
||||
}
|
||||
|
||||
FAIL_TEST(tc_client_fd_leaks)
|
||||
{
|
||||
struct display *d = display_create();
|
||||
|
||||
client_create(d, sanity_fd_leak);
|
||||
display_run(d);
|
||||
|
||||
display_destroy(d);
|
||||
}
|
||||
|
||||
FAIL_TEST(tc_client_fd_leaks_exec)
|
||||
{
|
||||
struct display *d = display_create();
|
||||
|
||||
client_create(d, sanity_fd_leak);
|
||||
display_run(d);
|
||||
|
||||
display_destroy(d);
|
||||
}
|
||||
|
||||
FAIL_TEST(timeout_tst)
|
||||
{
|
||||
test_set_timeout(1);
|
||||
|
|
Loading…
Reference in New Issue
Block a user