From: Anthony Minessale Date: Fri, 4 Sep 2015 20:06:52 +0000 (-0500) Subject: add test X-Git-Tag: v1.6.0~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6bb3e866299fbb00bb80d1c213d43f510c23d931;p=thirdparty%2Ffreeswitch.git add test --- diff --git a/libs/libks/test/testpools b/libs/libks/test/testpools new file mode 100755 index 0000000000..7b08d632e5 Binary files /dev/null and b/libs/libks/test/testpools differ diff --git a/libs/libks/test/testpools.c b/libs/libks/test/testpools.c new file mode 100644 index 0000000000..48580a0525 --- /dev/null +++ b/libs/libks/test/testpools.c @@ -0,0 +1,47 @@ +#include +#include +#include "mpool.h" +#include + +int main(int argc, char **argv) +{ + mpool_t *pool; + int err = 0; + char *str = NULL; + int x = 0; + int bytes = 1024; + + if (argc > 1) { + int tmp = atoi(argv[1]); + + if (tmp > 0) { + bytes = tmp; + } else { + fprintf(stderr, "INVALID\n"); + exit(255); + } + } + + pool = mpool_open(MPOOL_FLAG_ANONYMOUS, 0, NULL, &err); + + if (!pool || err != MPOOL_ERROR_NONE) { + fprintf(stderr, "ERR: %d [%s]\n", err, mpool_strerror(err)); + exit(255); + } + + str = mpool_alloc(pool, bytes, &err); + memset(str+x, '.', bytes -1); + *(str+(bytes-1)) = '\0'; + + printf("%s\n", str); + + //mpool_clear(pool); + err = mpool_close(pool); + + if (err != MPOOL_ERROR_NONE) { + fprintf(stderr, "ERR: [%s]\n", mpool_strerror(err)); + exit(255); + } + + exit(0); +}