#include "test-runner.h"
#include "wayland-util.h"
+extern int leak_check_enabled;
+
TEST(empty)
{
}
{
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. */
{
struct wl_array array;
+ assert(leak_check_enabled);
+
wl_array_init(&array);
/* call into library that calls malloc */
{
int fd[2];
+ assert(leak_check_enabled);
+
/* leak 2 file descriptors */
if (pipe(fd) < 0)
exit(EXIT_SUCCESS); /* failed to fail */
static void* (*sys_realloc)(void*, size_t);
static void* (*sys_calloc)(size_t, size_t);
+int leak_check_enabled;
+
extern const struct test __start_test_section, __stop_test_section;
__attribute__ ((visibility("default"))) void *
cur_fds = count_open_fds();
t->run();
- if (!getenv("NO_ASSERT_LEAK_CHECK")) {
+ if (leak_check_enabled) {
assert(cur_alloc == num_alloc && "memory leak detected in test.");
assert(cur_fds == count_open_fds() && "fd leak detected");
}
sys_malloc = dlsym(RTLD_NEXT, "malloc");
sys_free = dlsym(RTLD_NEXT, "free");
+ leak_check_enabled = !getenv("NO_ASSERT_LEAK_CHECK");
+
if (argc == 2) {
t = find_test(argv[1]);
if (t == NULL) {