AM_CFLAGS = $(GCC_CFLAGS)
LDADD = $(top_builddir)/src/libwayland-util.la \
$(top_builddir)/src/libwayland-server.la \
- -lrt $(FFI_LIBS)
+ -lrt -ldl $(FFI_LIBS)
l = wl_map_insert_new(&map, WL_MAP_SERVER_SIDE, &d);
assert(l == WL_SERVER_ID_START + 1);
assert(wl_map_lookup(&map, l) == &d);
+
+ wl_map_release(&map);
}
* OF THIS SOFTWARE.
*/
+#define _GNU_SOURCE
+
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <string.h>
#include <assert.h>
+#include <dlfcn.h>
#include "test-runner.h"
+static int num_alloc;
+static void* (*sys_malloc)(size_t);
+static void (*sys_free)(void*);
+
extern const struct test __start_test_section, __stop_test_section;
+void* malloc(size_t size)
+{
+ num_alloc++;
+ return sys_malloc(size);
+}
+
+void free(void* mem)
+{
+ if (mem != NULL)
+ num_alloc--;
+ sys_free(mem);
+}
+
static const struct test *
find_test(const char *name)
{
static void
run_test(const struct test *t)
{
+ int cur_alloc = num_alloc;
+
t->run();
+ assert(("memory leak detected in test.", cur_alloc == num_alloc));
exit(EXIT_SUCCESS);
}
int total, pass;
siginfo_t info;
+ /* Load system malloc and free */
+ sys_malloc = dlsym(RTLD_NEXT, "malloc");
+ sys_free = dlsym(RTLD_NEXT, "free");
+
if (argc == 2) {
t = find_test(argv[1]);
if (t == NULL) {