test/common: Added spdk_ring_count mock
Change-Id: Iefb4c76f2db5416d185556fa8c84a36291e72d3e Signed-off-by: Wojciech Malikowski <wojciech.malikowski@intel.com> Reviewed-on: https://review.gerrithub.io/c/443237 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Konrad Sztyber <konrad.sztyber@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
68b49203a7
commit
eccf549159
@ -293,6 +293,7 @@ struct spdk_ring_ele {
|
||||
struct spdk_ring {
|
||||
TAILQ_HEAD(, spdk_ring_ele) elements;
|
||||
pthread_mutex_t lock;
|
||||
size_t count;
|
||||
};
|
||||
|
||||
DEFINE_RETURN_MOCK(spdk_ring_create, struct spdk_ring *);
|
||||
@ -353,6 +354,7 @@ spdk_ring_enqueue(struct spdk_ring *ring, void **objs, size_t count)
|
||||
|
||||
ele->ele = objs[i];
|
||||
TAILQ_INSERT_TAIL(&ring->elements, ele, link);
|
||||
ring->count++;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&ring->lock);
|
||||
@ -376,6 +378,7 @@ spdk_ring_dequeue(struct spdk_ring *ring, void **objs, size_t count)
|
||||
|
||||
TAILQ_FOREACH_SAFE(ele, &ring->elements, link, tmp) {
|
||||
TAILQ_REMOVE(&ring->elements, ele, link);
|
||||
ring->count--;
|
||||
objs[i] = ele->ele;
|
||||
free(ele);
|
||||
i++;
|
||||
@ -389,6 +392,15 @@ spdk_ring_dequeue(struct spdk_ring *ring, void **objs, size_t count)
|
||||
|
||||
}
|
||||
|
||||
|
||||
DEFINE_RETURN_MOCK(spdk_ring_count, size_t);
|
||||
size_t
|
||||
spdk_ring_count(struct spdk_ring *ring)
|
||||
{
|
||||
HANDLE_RETURN_MOCK(spdk_ring_count);
|
||||
return ring->count;
|
||||
}
|
||||
|
||||
DEFINE_RETURN_MOCK(spdk_get_ticks, uint64_t);
|
||||
uint64_t
|
||||
spdk_get_ticks(void)
|
||||
|
Loading…
Reference in New Issue
Block a user