Loading...
tests/gmalloc_test.c /dev/null libmalloc-792.41.1
--- /dev/null
+++ libmalloc/libmalloc-792.41.1/tests/gmalloc_test.c
@@ -0,0 +1,26 @@
+//
+//  gmalloc.c
+//  libmalloc
+//
+//  End-to-end integration tests for GuardMalloc.
+//
+
+#include <darwintest.h>
+
+#include <malloc/malloc.h>
+#include <stdlib.h>
+
+T_GLOBAL_META(
+	T_META_ENVVAR("DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib"),
+	T_META_TAG_VM_PREFERRED,
+	T_META_TAG_NO_ALLOCATOR_OVERRIDE
+);
+
+T_DECL(guard_malloc, "Allocate and free memory with guard malloc enabled")
+{
+	const size_t sz = (unsigned)rand();
+	void *ptr = malloc(sz);
+	T_EXPECT_NOTNULL(ptr, "pointer not NULL");
+	T_EXPECT_GE(malloc_size(ptr), sz, "size is equal or larger");
+	free(ptr);
+}