test/common: spdk_mempool mock configurable element size

Change-Id: Ia93b4d7ea3ce77b8c45d34eedb5201ca5ea34688
Signed-off-by: Wojciech Malikowski <wojciech.malikowski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/443248
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Wojciech Malikowski 2019-02-04 09:23:22 -05:00 committed by Jim Harris
parent 5c97ac1636
commit a4968634f1

View File

@ -37,6 +37,7 @@
#include "spdk/env.h"
#include "spdk/queue.h"
#include "spdk/util.h"
DEFINE_STUB(spdk_process_is_primary, bool, (void), true)
DEFINE_STUB(spdk_memzone_lookup, void *, (const char *name), NULL)
@ -187,6 +188,7 @@ spdk_memzone_free(const char *name)
struct test_mempool {
size_t count;
size_t ele_size;
};
DEFINE_RETURN_MOCK(spdk_mempool_create, struct spdk_mempool *);
@ -204,6 +206,7 @@ spdk_mempool_create(const char *name, size_t count,
}
mp->count = count;
mp->ele_size = ele_size;
return (struct spdk_mempool *)mp;
}
@ -221,6 +224,7 @@ void *
spdk_mempool_get(struct spdk_mempool *_mp)
{
struct test_mempool *mp = (struct test_mempool *)_mp;
size_t ele_size = 0x10000;
void *buf;
HANDLE_RETURN_MOCK(spdk_mempool_get);
@ -229,7 +233,11 @@ spdk_mempool_get(struct spdk_mempool *_mp)
return NULL;
}
if (posix_memalign(&buf, 64, 0x10000)) {
if (mp) {
ele_size = mp->ele_size;
}
if (posix_memalign(&buf, 64, spdk_align32pow2(ele_size))) {
return NULL;
} else {
if (mp) {