test: add mock and new function to test_env.c
Need to mock spdk_mempool_get() to test code path when it fails. Also added spdk_mempool_get_bulk() to test env. Change-Id: I7f64230c9841215a404149e9a48ad4bf8a63822c Signed-off-by: Paul Luse <paul.e.luse@intel.com> Reviewed-on: https://review.gerrithub.io/420110 Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
6397392ede
commit
911c042df8
@ -203,12 +203,17 @@ spdk_mempool_free(struct spdk_mempool *_mp)
|
||||
free(mp);
|
||||
}
|
||||
|
||||
bool ut_spdk_mempool_get = false;
|
||||
void *
|
||||
spdk_mempool_get(struct spdk_mempool *_mp)
|
||||
{
|
||||
struct test_mempool *mp = (struct test_mempool *)_mp;
|
||||
void *buf;
|
||||
|
||||
if (ut_spdk_mempool_get) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (mp && mp->count == 0) {
|
||||
return NULL;
|
||||
}
|
||||
@ -223,6 +228,18 @@ spdk_mempool_get(struct spdk_mempool *_mp)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
spdk_mempool_get_bulk(struct spdk_mempool *mp, void **ele_arr, size_t count)
|
||||
{
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
ele_arr[i] = spdk_mempool_get(mp);
|
||||
if (ele_arr[i] == NULL) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
spdk_mempool_put(struct spdk_mempool *_mp, void *ele)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user