aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2015-08-21 18:07:47 +0200
committerJacob Erlbeck <jerlbeck@sysmocom.de>2015-08-21 19:02:18 +0200
commit257b630216f0dc702013ecc51ac680b5296ae898 (patch)
treed5bdd36e3fd70855074623d7d0f3532920a75c01 /tests
parente91bd3babd5c04a154f296607b401a5050dcba31 (diff)
llc: Add move_and_merge method to llc_queue
This methods takes all LLC frames from the old LLC queue and moves them into the current. If both queues are ordered chronologically (recv_time), the resulting queue is also ordered. Sponsored-by: On-Waves ehf
Diffstat (limited to 'tests')
-rw-r--r--tests/llc/LlcTest.cpp51
-rw-r--r--tests/llc/LlcTest.err5
-rw-r--r--tests/llc/LlcTest.ok2
3 files changed, 58 insertions, 0 deletions
diff --git a/tests/llc/LlcTest.cpp b/tests/llc/LlcTest.cpp
index a2e3c5e9..e972cf4e 100644
--- a/tests/llc/LlcTest.cpp
+++ b/tests/llc/LlcTest.cpp
@@ -165,6 +165,56 @@ static void test_llc_meta()
printf("=== end %s ===\n", __func__);
}
+static void test_llc_merge()
+{
+ gprs_llc_queue queue1;
+ gprs_llc_queue queue2;
+ gprs_llc_queue::MetaInfo info = {0};
+
+ printf("=== start %s ===\n", __func__);
+
+ queue1.init();
+ queue2.init();
+
+ info.recv_time.tv_sec += 1;
+ enqueue_data(&queue1, "*A*", &info);
+
+ info.recv_time.tv_sec += 1;
+ enqueue_data(&queue1, "*B*", &info);
+
+ info.recv_time.tv_sec += 1;
+ enqueue_data(&queue2, "*C*", &info);
+
+ info.recv_time.tv_sec += 1;
+ enqueue_data(&queue1, "*D*", &info);
+
+ info.recv_time.tv_sec += 1;
+ enqueue_data(&queue2, "*E*", &info);
+
+ OSMO_ASSERT(queue1.size() == 3);
+ OSMO_ASSERT(queue1.octets() == 9);
+ OSMO_ASSERT(queue2.size() == 2);
+ OSMO_ASSERT(queue2.octets() == 6);
+
+ queue2.move_and_merge(&queue1);
+
+ OSMO_ASSERT(queue1.size() == 0);
+ OSMO_ASSERT(queue1.octets() == 0);
+ OSMO_ASSERT(queue2.size() == 5);
+ OSMO_ASSERT(queue2.octets() == 15);
+
+ dequeue_and_check(&queue2, "*A*");
+ dequeue_and_check(&queue2, "*B*");
+ dequeue_and_check(&queue2, "*C*");
+ dequeue_and_check(&queue2, "*D*");
+ dequeue_and_check(&queue2, "*E*");
+
+ OSMO_ASSERT(queue2.size() == 0);
+ OSMO_ASSERT(queue2.octets() == 0);
+
+ printf("=== end %s ===\n", __func__);
+}
+
static const struct log_info_cat default_categories[] = {
{"DPCU", "", "GPRS Packet Control Unit (PCU)", LOGL_INFO, 1},
};
@@ -200,6 +250,7 @@ int main(int argc, char **argv)
test_llc_queue();
test_llc_meta();
+ test_llc_merge();
if (getenv("TALLOC_REPORT_FULL"))
talloc_report_full(tall_pcu_ctx, stderr);
diff --git a/tests/llc/LlcTest.err b/tests/llc/LlcTest.err
index b28fe1df..f2c5cab8 100644
--- a/tests/llc/LlcTest.err
+++ b/tests/llc/LlcTest.err
@@ -2,3 +2,8 @@ dequeued msg, length 11 (expected 11), data 4c 4c 43 20 6d 65 73 73 61 67 65
dequeued msg, length 17 (expected 17), data 6f 74 68 65 72 20 4c 4c 43 20 6d 65 73 73 61 67 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 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
+dequeued msg, length 3 (expected 3), data 2a 44 2a
+dequeued msg, length 3 (expected 3), data 2a 45 2a
diff --git a/tests/llc/LlcTest.ok b/tests/llc/LlcTest.ok
index 8a5f2354..311f37cd 100644
--- a/tests/llc/LlcTest.ok
+++ b/tests/llc/LlcTest.ok
@@ -2,3 +2,5 @@
=== end test_llc_queue ===
=== start test_llc_meta ===
=== end test_llc_meta ===
+=== start test_llc_merge ===
+=== end test_llc_merge ===