From: Shane Bryldt Date: Mon, 27 Mar 2017 14:11:23 +0000 (-0500) Subject: FS-10167: Added testmmap to isolate page allocation issues under windows, vs project... X-Git-Tag: v1.8.0~675 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f6b8329827226ba72f52b15ed67fc6f54cc6c539;p=thirdparty%2Ffreeswitch.git FS-10167: Added testmmap to isolate page allocation issues under windows, vs project coming soon --- diff --git a/libs/libks/test/Makefile.am b/libs/libks/test/Makefile.am index 17bd30d05e..933b8db8b6 100644 --- a/libs/libks/test/Makefile.am +++ b/libs/libks/test/Makefile.am @@ -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 index 0000000000..d2da12ff29 --- /dev/null +++ b/libs/libks/test/testmmap.c @@ -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; +}