mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2026-03-19 05:34:02 -04:00
tests: ensure sanity leak check tests pass when leak checks are disabled.
This finalizes Robert Bradfords patch to allow NO_ASSERT_LEAK_CHECK environment variable to disable leak checks in unit tests. Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
This commit is contained in:
parent
c95c2dffb0
commit
91931bcabb
2 changed files with 13 additions and 1 deletions
|
|
@ -29,6 +29,8 @@
|
|||
#include "test-runner.h"
|
||||
#include "wayland-util.h"
|
||||
|
||||
extern int leak_check_enabled;
|
||||
|
||||
TEST(empty)
|
||||
{
|
||||
}
|
||||
|
|
@ -68,6 +70,8 @@ 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. */
|
||||
|
|
@ -78,6 +82,8 @@ FAIL_TEST(sanity_malloc_indirect)
|
|||
{
|
||||
struct wl_array array;
|
||||
|
||||
assert(leak_check_enabled);
|
||||
|
||||
wl_array_init(&array);
|
||||
|
||||
/* call into library that calls malloc */
|
||||
|
|
@ -90,6 +96,8 @@ FAIL_TEST(sanity_fd_leak)
|
|||
{
|
||||
int fd[2];
|
||||
|
||||
assert(leak_check_enabled);
|
||||
|
||||
/* leak 2 file descriptors */
|
||||
if (pipe(fd) < 0)
|
||||
exit(EXIT_SUCCESS); /* failed to fail */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue