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 <james.r.harris@intel.com>
Change-Id: If2fbad0bcc3bc92b50b50f21d7e893e0ba05e325

Reviewed-on: https://review.gerrithub.io/433083
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Jim Harris 2018-10-30 16:01:40 -07:00 committed by Darek Stojaczyk
parent 08d36a55f9
commit 8c50e8c106

View File

@ -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;
}