From 8c50e8c106328d6f9e28f2b372bc2b890eda4741 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Tue, 30 Oct 2018 16:01:40 -0700 Subject: [PATCH] test: handle align=0 in test_env spdk_malloc DPDK treats align=0 as effectively align=8. But the test_env spdk_malloc uses posix_memalign and passes the align as-is. posix_memalign requires a non-zero align parameter however. So change the test_env implementation to match DPDK. This fixes libreduce unit tests, since it does some allocations with default alignment. Signed-off-by: Jim Harris Change-Id: If2fbad0bcc3bc92b50b50f21d7e893e0ba05e325 Reviewed-on: https://review.gerrithub.io/433083 Chandler-Test-Pool: SPDK Automated Test System Tested-by: SPDK CI Jenkins Reviewed-by: Darek Stojaczyk Reviewed-by: Changpeng Liu Reviewed-by: Shuhei Matsumoto --- test/common/lib/test_env.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/common/lib/test_env.c b/test/common/lib/test_env.c index abb56a6d0..4e9fbce50 100644 --- a/test/common/lib/test_env.c +++ b/test/common/lib/test_env.c @@ -72,6 +72,11 @@ spdk_malloc(size_t size, size_t align, uint64_t *phys_addr, int socket_id, uint3 HANDLE_RETURN_MOCK(spdk_malloc); void *buf = NULL; + + if (align == 0) { + align = 8; + } + if (posix_memalign(&buf, align, size)) { return NULL; }