aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/it_q/it_q_test.c43
-rw-r--r--tests/it_q/it_q_test.ok5
2 files changed, 48 insertions, 0 deletions
diff --git a/tests/it_q/it_q_test.c b/tests/it_q/it_q_test.c
index 28e32d89..9545183a 100644
--- a/tests/it_q/it_q_test.c
+++ b/tests/it_q/it_q_test.c
@@ -68,6 +68,48 @@ static void tc_queue_length(void)
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 @@ int main(int argc, char **argv)
{
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 7f102c61..91ba0cec 100644
--- a/tests/it_q/it_q_test.ok
+++ b/tests/it_q/it_q_test.ok
@@ -9,6 +9,11 @@ allocating q1
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