Commit 2f77d60b authored by Jens Korinth's avatar Jens Korinth
Browse files

Add tool for testing single memory allocation

parent 9ff3e1eb
......@@ -20,6 +20,10 @@ add_executable(platform-stress-ioctl platform_stress_ioctl.c ${TAPASCO_PLATFORM_
set_target_properties(platform-stress-ioctl PROPERTIES LINK_SEARCH_START_STATIC 1 LINK_SEARCH_END_STATIC 1)
target_link_libraries(platform-stress-ioctl m platform atomic pthread)
add_executable(platform-alloc platform_alloc.c ${TAPASCO_PLATFORM_LIB})
set_target_properties(platform-alloc PROPERTIES LINK_SEARCH_START_STATIC 1 LINK_SEARCH_END_STATIC 1)
target_link_libraries(platform-alloc m platform atomic pthread)
add_executable(platform-slots platform_slots.c ${TAPASCO_PLATFORM_LIB})
target_link_libraries(platform-slots pthread platform)
......
#include <stdio.h>
#include <platform.h>
int main(int argc, char *argv[])
{
platform_res_t res;
platform_ctx_t *ctx;
platform_devctx_t *devctx;
platform_mem_addr_t addr;
size_t sz = argc > 1 ? strtoul(argv[1], NULL, 0) : 1024;
platform_init(&ctx);
platform_devctx_init(ctx, 0, PLATFORM_SHARED_ACCESS, &devctx);
if ((res = platform_alloc(devctx, sz, &addr, 0)) != PLATFORM_SUCCESS) {
fprintf(stderr, "platform error during allocation: %s", platform_strerror(res));
} else {
if ((res = platform_dealloc(devctx, addr, 0)) != PLATFORM_SUCCESS) {
fprintf(stderr, "platform error during free: %s", platform_strerror(res));
}
}
return res != PLATFORM_SUCCESS;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment