tests/llc: Add test_llc_codel

Related: OS#5508
Change-Id: I9c87b65496a6fe0187a1bc9f3419e2d7269e66f0
changes/43/27643/3
Pau Espin 8 months ago committed by pespin
parent 2f94b77d8e
commit 0bdad9f388
  1. 71
      tests/llc/LlcTest.cpp
  2. 9
      tests/llc/LlcTest.err
  3. 2
      tests/llc/LlcTest.ok

@ -224,6 +224,76 @@ static void test_llc_meta_pdu_life_expire()
TALLOC_FREE(the_pcu);
}
/* Test codel entering in action */
static void test_llc_codel()
{
clk_mono_override_time->tv_sec = 1000;
clk_mono_override_time->tv_nsec = 0;
the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
the_pcu->vty.llc_codel_interval_msec = LLC_CODEL_USE_DEFAULT;
/* DEFAULT should be resolved to GPRS_CODEL_SLOW_INTERVAL_MS 4000 */
#define GPRS_CODEL_SLOW_INTERVAL_MS 4000
struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0);
struct GprsMs *ms = bts_alloc_ms(bts, 0, 0);
gprs_llc_queue *queue = ms_llc_queue(ms);
unsigned int i;
for (i = 0; i < ARRAY_SIZE(queue->pq); i++) {
gprs_codel_set_maxpacket(&queue->pq[i].codel_state, 8);
}
MetaInfo info1 = {0};
printf("=== start %s ===\n", __func__);
for (i = 0; i < 10; i++) {
char buf[256];
snprintf(buf, sizeof(buf), "LLC message %u", i);
info1.recv_time.tv_sec = clk_mono_override_time->tv_sec;
info1.recv_time.tv_nsec = clk_mono_override_time->tv_nsec;
info1.expire_time.tv_sec = clk_mono_override_time->tv_sec + 500;
info1.expire_time.tv_nsec = clk_mono_override_time->tv_nsec;
clk_mono_override_time->tv_sec += 1;
enqueue_data(queue, buf, &info1.expire_time);
}
OSMO_ASSERT(llc_queue_size(queue) == 10);
OSMO_ASSERT(llc_queue_octets(queue) != 0);
dequeue_and_check(queue, "LLC message 0", NULL);
OSMO_ASSERT(queue->pq[LLC_QUEUE_PRIO_OTHER].codel_state.first_above_time.tv_sec ==
clk_mono_override_time->tv_sec + GPRS_CODEL_SLOW_INTERVAL_MS/1000);
dequeue_and_check(queue, "LLC message 1", NULL);
clk_mono_override_time->tv_sec += 7;
dequeue_and_check(queue, "LLC message 2", NULL); /*recently == 0*/
OSMO_ASSERT(queue->pq[LLC_QUEUE_PRIO_OTHER].codel_state.dropping == 0);
OSMO_ASSERT(queue->pq[LLC_QUEUE_PRIO_OTHER].codel_state.count == 0);
clk_mono_override_time->tv_sec += GPRS_CODEL_SLOW_INTERVAL_MS/1000 + 1;
dequeue_and_check(queue, "LLC message 4", NULL); /* recently = 1, message 3 is dropped here */
OSMO_ASSERT(queue->pq[LLC_QUEUE_PRIO_OTHER].codel_state.dropping == 1);
OSMO_ASSERT(queue->pq[LLC_QUEUE_PRIO_OTHER].codel_state.count == 1);
dequeue_and_check(queue, "LLC message 5", NULL);
OSMO_ASSERT(queue->pq[LLC_QUEUE_PRIO_OTHER].codel_state.dropping == 1);
OSMO_ASSERT(queue->pq[LLC_QUEUE_PRIO_OTHER].codel_state.count == 1);
dequeue_and_check(queue, "LLC message 6", NULL);
OSMO_ASSERT(queue->pq[LLC_QUEUE_PRIO_OTHER].codel_state.dropping == 1);
dequeue_and_check(queue, "LLC message 7", NULL);
OSMO_ASSERT(queue->pq[LLC_QUEUE_PRIO_OTHER].codel_state.dropping == 1);
dequeue_and_check(queue, "LLC message 8", NULL);
OSMO_ASSERT(queue->pq[LLC_QUEUE_PRIO_OTHER].codel_state.dropping == 1);
dequeue_and_check(queue, "LLC message 9", NULL);
OSMO_ASSERT(queue->pq[LLC_QUEUE_PRIO_OTHER].codel_state.dropping == 0);
OSMO_ASSERT(llc_queue_size(queue) == 0);
OSMO_ASSERT(llc_queue_octets(queue) == 0);
llc_queue_clear(queue, NULL);
printf("=== end %s ===\n", __func__);
TALLOC_FREE(the_pcu);
}
static void test_llc_merge()
{
gprs_llc_queue *queue1 = prepare_queue();
@ -299,6 +369,7 @@ int main(int argc, char **argv)
test_llc_queue();
test_llc_meta();
test_llc_meta_pdu_life_expire();
test_llc_codel();
test_llc_merge();
if (getenv("TALLOC_REPORT_FULL"))

@ -3,6 +3,15 @@ dequeued msg, length 17 (expected 17), data 6f 74 68 65 72 20 4c 4c 43 20 6d 65
dequeued msg, length 13 (expected 13), data 4c 4c 43 20 6d 65 73 73 61 67 65 20 31
dequeued msg, length 13 (expected 13), data 4c 4c 43 20 6d 65 73 73 61 67 65 20 32
dequeued msg, length 13 (expected 13), data 4c 4c 43 20 6d 65 73 73 61 67 65 20 32
dequeued msg, length 13 (expected 13), data 4c 4c 43 20 6d 65 73 73 61 67 65 20 30
dequeued msg, length 13 (expected 13), data 4c 4c 43 20 6d 65 73 73 61 67 65 20 31
dequeued msg, length 13 (expected 13), data 4c 4c 43 20 6d 65 73 73 61 67 65 20 32
dequeued msg, length 13 (expected 13), data 4c 4c 43 20 6d 65 73 73 61 67 65 20 34
dequeued msg, length 13 (expected 13), data 4c 4c 43 20 6d 65 73 73 61 67 65 20 35
dequeued msg, length 13 (expected 13), data 4c 4c 43 20 6d 65 73 73 61 67 65 20 36
dequeued msg, length 13 (expected 13), data 4c 4c 43 20 6d 65 73 73 61 67 65 20 37
dequeued msg, length 13 (expected 13), data 4c 4c 43 20 6d 65 73 73 61 67 65 20 38
dequeued msg, length 13 (expected 13), data 4c 4c 43 20 6d 65 73 73 61 67 65 20 39
dequeued msg, length 3 (expected 3), data 2a 41 2a
dequeued msg, length 3 (expected 3), data 2a 42 2a
dequeued msg, length 3 (expected 3), data 2a 43 2a

@ -4,5 +4,7 @@
=== end test_llc_meta ===
=== start test_llc_meta_pdu_life_expire ===
=== end test_llc_meta_pdu_life_expire ===
=== start test_llc_codel ===
=== end test_llc_codel ===
=== start test_llc_merge ===
=== end test_llc_merge ===

Loading…
Cancel
Save