test: add ability to mock spdk_dma_malloc()
Used in crypto unit tests. Change-Id: I7d7e31e9030c238cb539b9fcf0936e588c1a4211 Signed-off-by: Paul Luse <paul.e.luse@intel.com> Reviewed-on: https://review.gerrithub.io/418320 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
0e9f9bead9
commit
58d8a4564b
@ -89,17 +89,24 @@ spdk_memzone_reserve_aligned(const char *name, size_t len, int socket_id,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ut_spdk_dma_malloc = (int)MOCK_PASS_THRU;
|
||||||
|
void *ut_p_spdk_dma_malloc = &ut_spdk_dma_malloc;
|
||||||
void *
|
void *
|
||||||
spdk_dma_malloc(size_t size, size_t align, uint64_t *phys_addr)
|
spdk_dma_malloc(size_t size, size_t align, uint64_t *phys_addr)
|
||||||
{
|
{
|
||||||
void *buf = NULL;
|
if (ut_p_spdk_dma_malloc &&
|
||||||
if (posix_memalign(&buf, align, size)) {
|
ut_spdk_dma_malloc == (int)MOCK_PASS_THRU) {
|
||||||
return NULL;
|
void *buf = NULL;
|
||||||
|
if (posix_memalign(&buf, align, size)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (phys_addr) {
|
||||||
|
*phys_addr = (uint64_t)buf;
|
||||||
|
}
|
||||||
|
return buf;
|
||||||
|
} else {
|
||||||
|
return ut_p_spdk_dma_malloc;
|
||||||
}
|
}
|
||||||
if (phys_addr) {
|
|
||||||
*phys_addr = (uint64_t)buf;
|
|
||||||
}
|
|
||||||
return buf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ut_spdk_dma_zmalloc = (int)MOCK_PASS_THRU;
|
int ut_spdk_dma_zmalloc = (int)MOCK_PASS_THRU;
|
||||||
|
Loading…
Reference in New Issue
Block a user