]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-10167: Added testmmap to isolate page allocation issues under windows, vs project...
authorShane Bryldt <astaelan@gmail.com>
Mon, 27 Mar 2017 14:11:23 +0000 (09:11 -0500)
committerShane Bryldt <astaelan@gmail.com>
Mon, 27 Mar 2017 14:11:23 +0000 (09:11 -0500)
libs/libks/test/Makefile.am
libs/libks/test/testmmap.c [new file with mode: 0644]

index 17bd30d05e8fb6541f37a0304c508f47b95e9fbc..933b8db8b6300fdf63a2e2745cc34c32d407b7dd 100644 (file)
@@ -9,6 +9,11 @@ testpools_SOURCES = testpools.c tap.c
 testpools_CFLAGS = $(AM_CFLAGS)
 testpools_LDADD = $(TEST_LDADD)
 
+check_PROGRAMS += testmmap
+testmmap_SOURCES = testmmap.c tap.c
+testmmap_CFLAGS = $(AM_CFLAGS)
+testmmap_LDADD = $(TEST_LDADD)
+
 check_PROGRAMS += testacl
 testacl_SOURCES = testacl.c tap.c
 testacl_CFLAGS = $(AM_CFLAGS)
diff --git a/libs/libks/test/testmmap.c b/libs/libks/test/testmmap.c
new file mode 100644 (file)
index 0000000..d2da12f
--- /dev/null
@@ -0,0 +1,39 @@
+#include "ks.h"
+#include "tap.h"
+
+static ks_pool_t *pool = NULL;
+
+#define LOOP_COUNT 1000000
+
+ks_status_t test1()
+{
+       int i;
+       void *mem, *last_mem = NULL;
+
+       for (i = 0; i < LOOP_COUNT; i++) {
+               if (last_mem) {
+                       ks_pool_free(pool, &last_mem);
+               }
+               mem = ks_pool_alloc(pool, 1024);
+               last_mem = mem;
+       }
+
+       return KS_STATUS_SUCCESS;
+}
+
+int main(int argc, char **argv)
+{
+       ks_init();
+
+       ok(ks_pool_open(&pool) == KS_STATUS_SUCCESS);
+
+       ok(test1() == KS_STATUS_SUCCESS);
+
+       ok(ks_pool_close(&pool) == KS_STATUS_SUCCESS);
+
+       ks_shutdown();
+
+       done_testing();
+
+       return 0;
+}