From eccf549159ca06b8e38c8784fdf4fbc06c1fe868 Mon Sep 17 00:00:00 2001 From: Wojciech Malikowski Date: Fri, 1 Feb 2019 10:02:43 -0500 Subject: [PATCH] test/common: Added spdk_ring_count mock Change-Id: Iefb4c76f2db5416d185556fa8c84a36291e72d3e Signed-off-by: Wojciech Malikowski Reviewed-on: https://review.gerrithub.io/c/443237 Tested-by: SPDK CI Jenkins Reviewed-by: Konrad Sztyber Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- test/common/lib/test_env.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/common/lib/test_env.c b/test/common/lib/test_env.c index bed0383edd..fdb697f488 100644 --- a/test/common/lib/test_env.c +++ b/test/common/lib/test_env.c @@ -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)