mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-29 05:40:16 -04:00
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>
This commit is contained in:
parent
cb9a2557e1
commit
01095a9ce4
4 changed files with 20 additions and 143 deletions
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
#include "test-compositor.h"
|
||||
|
||||
extern int leak_check_enabled;
|
||||
extern int fd_leak_check_enabled;
|
||||
|
||||
TEST(empty)
|
||||
{
|
||||
|
|
@ -83,71 +83,11 @@ FAIL_TEST(sanity_assert)
|
|||
assert(0);
|
||||
}
|
||||
|
||||
FAIL_TEST(sanity_malloc_direct)
|
||||
{
|
||||
void *p;
|
||||
|
||||
assert(leak_check_enabled);
|
||||
|
||||
p = malloc(10); /* memory leak */
|
||||
assert(p); /* assert that we got memory, also prevents
|
||||
* the malloc from getting optimized away. */
|
||||
free(NULL); /* NULL must not be counted */
|
||||
test_disable_coredumps();
|
||||
}
|
||||
|
||||
TEST(disable_leak_checks)
|
||||
{
|
||||
volatile void *mem;
|
||||
assert(leak_check_enabled);
|
||||
/* normally this should be on the beginning of the test.
|
||||
* Here we need to be sure, that the leak checks are
|
||||
* turned on */
|
||||
DISABLE_LEAK_CHECKS;
|
||||
|
||||
mem = malloc(16);
|
||||
assert(mem);
|
||||
}
|
||||
|
||||
FAIL_TEST(sanity_malloc_indirect)
|
||||
{
|
||||
struct wl_array array;
|
||||
|
||||
assert(leak_check_enabled);
|
||||
|
||||
wl_array_init(&array);
|
||||
|
||||
/* call into library that calls malloc */
|
||||
wl_array_add(&array, 14);
|
||||
|
||||
/* not freeing array, must leak */
|
||||
|
||||
test_disable_coredumps();
|
||||
}
|
||||
|
||||
FAIL_TEST(tc_client_memory_leaks)
|
||||
{
|
||||
struct display *d = display_create();
|
||||
client_create_noarg(d, sanity_malloc_direct);
|
||||
display_run(d);
|
||||
test_disable_coredumps();
|
||||
display_destroy(d);
|
||||
}
|
||||
|
||||
FAIL_TEST(tc_client_memory_leaks2)
|
||||
{
|
||||
struct display *d = display_create();
|
||||
client_create_noarg(d, sanity_malloc_indirect);
|
||||
display_run(d);
|
||||
test_disable_coredumps();
|
||||
display_destroy(d);
|
||||
}
|
||||
|
||||
FAIL_TEST(sanity_fd_leak)
|
||||
{
|
||||
int fd[2];
|
||||
|
||||
assert(leak_check_enabled);
|
||||
assert(fd_leak_check_enabled);
|
||||
|
||||
/* leak 2 file descriptors */
|
||||
if (pipe(fd) < 0)
|
||||
|
|
@ -185,7 +125,7 @@ sanity_fd_no_leak(void)
|
|||
{
|
||||
int fd[2];
|
||||
|
||||
assert(leak_check_enabled);
|
||||
assert(fd_leak_check_enabled);
|
||||
|
||||
/* leak 2 file descriptors */
|
||||
if (pipe(fd) < 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue