fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/35293?usp=email )
Change subject: tests/it_q: add tc_enqueue/dequeue testcase ...................................................................... tests/it_q: add tc_enqueue/dequeue testcase This patch is adding a simple testcase, which does the following: * enqueue up to the limit (12 items), * dequeue up to the limit (12 items). Everything works as expected, unless you attempt to dequeue from an empty queue: the test binary segfaults. The problem is explained and fixed in a subsequent patch. Change-Id: Ie0edbf00e656fbe231952bdbccfd37d143e8b2b1 Related: CID#336557 --- M tests/it_q/it_q_test.c M tests/it_q/it_q_test.ok 2 files changed, 67 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/93/35293/1 diff --git a/tests/it_q/it_q_test.c b/tests/it_q/it_q_test.c index 28e32d8..9545183 100644 --- a/tests/it_q/it_q_test.c +++ b/tests/it_q/it_q_test.c @@ -68,6 +68,48 @@ osmo_it_q_destroy(q1); } +static void tc_enqueue_dequeue(void) +{ + const unsigned int qlen = 12; + struct it_q_test1 *item; + struct osmo_it_q *q1; + int rc; + + ENTER_TC; + + printf("allocating q1\n"); + q1 = osmo_it_q_alloc(OTC_GLOBAL, "q1", 12, NULL, NULL); + OSMO_ASSERT(q1); + +#if 0 + printf("try dequeueing from an empty queue\n"); + osmo_it_q_dequeue(q1, &item, list); + OSMO_ASSERT(item == NULL); +#endif + + printf("adding queue entries up to the limit\n"); + for (unsigned int i = 0; i < qlen; i++) { + item = talloc_zero(OTC_GLOBAL, struct it_q_test1); + rc = osmo_it_q_enqueue(q1, item, list); + OSMO_ASSERT(rc == 0); + } + + printf("removing queue entries up to the limit\n"); + for (unsigned int i = 0; i < qlen; i++) { + osmo_it_q_dequeue(q1, &item, list); + OSMO_ASSERT(item != NULL); + talloc_free(item); + } + +#if 0 + printf("try dequeueing from an empty queue\n"); + osmo_it_q_dequeue(q1, &item, list); + OSMO_ASSERT(item == NULL); +#endif + + osmo_it_q_destroy(q1); +} + static int g_read_cb_count; static void q_read_cb(struct osmo_it_q *q, struct llist_head *item) @@ -115,6 +157,7 @@ { tc_alloc(); tc_queue_length(); + tc_enqueue_dequeue(); tc_eventfd(); return 0; } diff --git a/tests/it_q/it_q_test.ok b/tests/it_q/it_q_test.ok index 7f102c6..91ba0ce 100644 --- a/tests/it_q/it_q_test.ok +++ b/tests/it_q/it_q_test.ok @@ -9,6 +9,11 @@ adding queue entries up to the limit attempting to add more than the limit +== Entering test case tc_enqueue_dequeue +allocating q1 +adding queue entries up to the limit +removing queue entries up to the limit + == Entering test case tc_eventfd allocating q1 adding 30 queue entries up to the limit -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35293?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: Ie0edbf00e656fbe231952bdbccfd37d143e8b2b1 Gerrit-Change-Number: 35293 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanits...@sysmocom.de> Gerrit-MessageType: newchange