提交 7861bb0d authored 作者: Shane Bryldt's avatar Shane Bryldt

FS-10167: Added test to identify issue with ks_pool_realloc

上级 e26e8732
......@@ -9,6 +9,11 @@ testpools_SOURCES = testpools.c tap.c
testpools_CFLAGS = $(AM_CFLAGS)
testpools_LDADD = $(TEST_LDADD)
check_PROGRAMS += testrealloc
testrealloc_SOURCES = testrealloc.c tap.c
testrealloc_CFLAGS = $(AM_CFLAGS)
testrealloc_LDADD = $(TEST_LDADD)
check_PROGRAMS += testacl
testacl_SOURCES = testacl.c tap.c
testacl_CFLAGS = $(AM_CFLAGS)
......
#include "ks.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "tap.h"
int main(int argc, char **argv)
{
ks_pool_t *pool;
uint32_t *buf = NULL;
intptr_t ptr = 0;
ks_init();
plan(3);
ks_pool_open(&pool);
buf = (uint32_t *)ks_pool_resize(pool, buf, sizeof(uint32_t) * 1);
ok(buf != NULL);
ptr = (intptr_t)buf;
buf = (uint32_t *)ks_pool_resize(pool, buf, sizeof(uint32_t) * 2);
ok(buf != NULL);
ok((intptr_t)buf == ptr);
buf = (uint32_t *)ks_pool_resize(pool, buf, sizeof(uint32_t) * 1);
ok(buf != NULL);
ok((intptr_t)buf == ptr);
buf = (uint32_t *)ks_pool_resize(pool, buf, sizeof(uint32_t) * 2);
ok(buf != NULL);
ok((intptr_t)buf == ptr);
ks_pool_free(pool, &buf);
ks_pool_close(&pool);
ks_shutdown();
done_testing();
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论