[PATCH] osmo-pcu[master]: Add test case for decompression of compressed bitmap

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

pravin gerrit-no-reply at lists.osmocom.org
Tue Jul 12 12:19:01 UTC 2016


Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/417

to look at the new patch set (#2).

Add test case for decompression of compressed bitmap

Test case is added to validate decompressed result of the bitmap
present in EPDAN.
Test is done for multiple bitmaps of varying length.

Change-Id: I0f26ec3d9eeace4ea8396ad5786a988fb58cf445
---
M tests/tbf/TbfTest.cpp
1 file changed, 105 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/17/417/2

diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp
index e1be844..d9de271 100644
--- a/tests/tbf/TbfTest.cpp
+++ b/tests/tbf/TbfTest.cpp
@@ -26,10 +26,11 @@
 #include "pcu_utils.h"
 #include "gprs_bssgp_pcu.h"
 #include "pcu_l1_if.h"
-
+#include "egprs_rlc_compression.h"
+#include "decoding.h"
 extern "C" {
 #include "pcu_vty.h"
-
+#include <osmocom/core/bitcomp.h>
 #include <osmocom/core/application.h>
 #include <osmocom/core/msgb.h>
 #include <osmocom/core/talloc.h>
@@ -38,9 +39,31 @@
 }
 
 #include <errno.h>
-
+#define NUMBER_OF_TEST_CASE 4
+#define NEW 1
+#define DELTA 1000
+#define MASK(n) (0xFF << (8-n))
 void *tall_pcu_ctx;
 int16_t spoof_mnc = 0, spoof_mcc = 0;
+struct test_data {
+	int8_t crbb_len;
+	uint8_t cc ;
+	uint8_t data[23];
+	uint8_t exp_data[40];
+	int exp_len;
+}test[4] = { { (int8_t)67, (uint8_t)1,{0x02, 0x0c, 0xa0, 0x30, 0xcb, 0x1a, 0x0c, 0xe3, 0x6c},
+		{0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0xf8, 0x00,
+		0x00, 0x00, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff,
+		0xdb}, (int)194},
+		{(int8_t)40, (uint8_t)1, {0x53,0x06,0xc5,0x40,0x6d}, {0xff, 0xff, 0xff, 0xff, 0xff,
+		0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00,
+		0x00, 0x00, 0x00, 0x03}, (int)182},
+		{ (int8_t)8, (uint8_t)1, {0x02}, {0xff, 0xff, 0xff, 0xf8}, (int)29},
+		{ (int8_t)103,(uint8_t)1, {0x02, 0x0c, 0xe0, 0x41, 0xa0, 0x0c, 0x36, 0x0d, 0x03,
+		0x71, 0xb0, 0x6e, 0x24}, {0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0xff, 0xff, 0xff,
+		0xf8, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff,
+		0xe0, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0x80, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff} ,
+		(int)288} };
 
 static void check_tbf(gprs_rlcmac_tbf *tbf)
 {
@@ -51,19 +74,84 @@
 		OSMO_ASSERT(tbf->T != 0);
 }
 
-/*
-static unsigned inc_fn(fn)
+/* To verify the result with expected result */
+int check_result(bitvec bits, uint8_t *exp_data, int exp_len)
 {
-	unsigned next_fn;
-
-	next_fn = fn + 4;
-	if ((block_nr % 3) == 2)
-		next_fn ++;
-	next_fn = next_fn % 2715648;
-
-	return next_fn;
+	if (bits.cur_bit != exp_len)
+		return 0;
+	size_t n = (exp_len / 8);
+	int rem = (exp_len % 8);
+	if (memcmp (exp_data, bits.data, n) == 0) {
+		if (rem == 0)
+			return 1;
+		if ((bits.data[n] & MASK(rem)) == ((*(exp_data + n)) & MASK(rem)))
+			return 1;
+		else
+			return 0;
+	} else {
+		return 0;
+	}
 }
-*/
+
+/*  To check time taken to decode crbb by Tree based method
+ *  and to verify the result with expected result */
+void test_EPDAN_time_tree(int test_run, int verify)
+{
+	long long int min_tree[NUMBER_OF_TEST_CASE] = {0}, max_tree[NUMBER_OF_TEST_CASE] = {0};
+	long long int sum[NUMBER_OF_TEST_CASE] = {0}, avg[NUMBER_OF_TEST_CASE] = {0};
+	float avg_tree[NUMBER_OF_TEST_CASE] = {0};
+	bitvec bits;
+	struct bitvec data1;
+	int loop = 0, itr = 0;
+	while (loop++ < test_run) {
+		int init_flag = 1, first[NUMBER_OF_TEST_CASE] = {0}, last[NUMBER_OF_TEST_CASE] = {0};
+		int count[NUMBER_OF_TEST_CASE] = {0}, itr = 0;
+		for (itr ; itr < NUMBER_OF_TEST_CASE ; itr++) {
+			data1.data_len = ((test[itr].crbb_len + 7)/8);
+			data1.cur_bit = test[itr].crbb_len;
+			struct timeval t0, t1;
+			data1.data = test[itr].data;
+			uint8_t bits_data[RLC_EGPRS_MAX_WS/8];
+			bits.data = bits_data;
+			bits.data_len = sizeof(bits_data);
+			bits.cur_bit = 0;
+			gettimeofday(&t0, 0);
+			Decoding::decompress_crbb(test[itr].crbb_len, test[itr].cc, test[itr].data, &bits);
+			gettimeofday(&t1, 0);
+			long long elapsed = (t1.tv_sec-t0.tv_sec)*1000000LL + t1.tv_usec-t0.tv_usec;
+			if (init_flag)
+				init_flag = 0;
+			if (verify) {
+				if (check_result(bits, test[itr].exp_data, test[itr].exp_len) == 0) {
+					LOGP (DRLCMACDL, LOGL_DEBUG, "Tree based decoding :Error\n");
+					OSMO_ASSERT(0) ;
+				}
+			}
+			if (loop == 1) {
+				first[itr] = elapsed;
+				min_tree[itr] = elapsed;
+				max_tree[itr] = elapsed;
+				sum[itr] = elapsed;
+				avg[itr] = elapsed;
+				avg_tree[itr] = elapsed;
+			} else {
+				if (loop == test_run-1)
+					last[itr] = elapsed;
+				if (elapsed > (avg[itr]+DELTA))
+					count[itr]++;
+				sum[itr] = sum[itr] + elapsed;
+				avg[itr] = sum[itr] / loop;
+				if (min_tree[itr] > elapsed)
+					min_tree[itr] = elapsed;
+				if (max_tree[itr] < elapsed)
+					max_tree[itr] = elapsed;
+				avg_tree[itr] = avg_tree[itr] + elapsed;
+			}
+		}
+	}
+	for (int i = 0 ; i < NUMBER_OF_TEST_CASE ; i++)
+		avg_tree[i] = avg_tree[i]/test_run;
+}
 
 static void test_tbf_base()
 {
@@ -1337,7 +1425,8 @@
 
 	vty_init(&pcu_vty_info);
 	pcu_vty_init(&debug_log_info);
-
+	/*initialization_of_tree*/
+	egprs_compress::instance()->decode_tree_init();
 	test_tbf_base();
 	test_tbf_tlli_update();
 	test_tbf_final_ack(TEST_MODE_STANDARD);
@@ -1356,7 +1445,7 @@
 	test_tbf_ws();
 	test_tbf_egprs_two_phase();
 	test_tbf_egprs_dl();
-
+	test_EPDAN_time_tree(1000, 1);
 	if (getenv("TALLOC_REPORT_FULL"))
 		talloc_report_full(tall_pcu_ctx, stderr);
 	return EXIT_SUCCESS;

-- 
To view, visit https://gerrit.osmocom.org/417
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I0f26ec3d9eeace4ea8396ad5786a988fb58cf445
Gerrit-PatchSet: 2
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: pravin <pravin.manoharan at radisys.com>
Gerrit-Reviewer: Holger Freyther <holger at freyther.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: pravin <pravin.manoharan at radisys.com>



More information about the gerrit-log mailing list