[PATCH] osmo-pcu[master]: bitcomp test: use expected rc instead of 'verify' flag

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/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Sun Mar 26 22:25:08 UTC 2017


Review at  https://gerrit.osmocom.org/2170

bitcomp test: use expected rc instead of 'verify' flag

The 'verify' flag is useless, we always want to verify everything.  Replace
'verify' with 'expect_rc', expecting a specific decoding result per test set.

When an error code was returned, cut short the loop and skip printing expected
vs. decoded bits.

This uncovers the fact that the first test marked as "invalid inputs" does not
seem to be invalid after all, or at least does not produce an error to be
returned. For now, only uncover this fact, the fix shall be submitted later.

Change-Id: Icf815a8f1acb0e275463408450171df046879847
---
M tests/bitcomp/BitcompTest.cpp
M tests/bitcomp/BitcompTest.err
2 files changed, 51 insertions(+), 41 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/70/2170/1

diff --git a/tests/bitcomp/BitcompTest.cpp b/tests/bitcomp/BitcompTest.cpp
index c5fde2e..4ec6f29 100644
--- a/tests/bitcomp/BitcompTest.cpp
+++ b/tests/bitcomp/BitcompTest.cpp
@@ -29,7 +29,7 @@
 	uint8_t crbb_data[MAX_CRBB_LEN]; /* compressed data */
 	uint8_t ucmp_data[MAX_URBB_LEN]; /* uncompressed data */
 	int ucmp_len;
-	int verify;
+	int expect_rc;
 } test[] = {
 		{ .crbb_len = 67, .cc = 1,
 			.crbb_data = {
@@ -40,7 +40,8 @@
 			0xff, 0xf8, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xfe,
 			0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xc0
 			},
-			.ucmp_len = 194, .verify = 1
+			.ucmp_len = 194,
+			.expect_rc = 0,
 		},
 		{ .crbb_len = 40, .cc = 1,
 			.crbb_data = {
@@ -51,12 +52,14 @@
 			0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8,
 			0x00, 0x00, 0x00, 0x00, 0x00
 			},
-			.ucmp_len = 182, .verify = 1
+			.ucmp_len = 182,
+			.expect_rc = 0,
 		},
 		{ .crbb_len = 8, .cc = 1,
 			.crbb_data = {0x02},
 			.ucmp_data = {0xff, 0xff, 0xff, 0xf8},
-			.ucmp_len = 29, .verify = 1
+			.ucmp_len = 29,
+			.expect_rc = 0,
 		},
 		{ .crbb_len = 103, .cc = 1,
 			.crbb_data = {
@@ -69,13 +72,15 @@
 			0x0f, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x7f, 0xff,
 			0xff, 0xff, 0x80, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff
 			},
-			.ucmp_len = 288, .verify = 1
+			.ucmp_len = 288,
+			.expect_rc = 0,
 		},
 		/* Test vector from libosmocore test */
 		{ .crbb_len = 35, .cc = 0,
 			.crbb_data = {0xde, 0x88, 0x75, 0x65, 0x80},
 			.ucmp_data = {0x37, 0x47, 0x81, 0xf0},
-			.ucmp_len = 28, .verify = 1
+			.ucmp_len = 28,
+			.expect_rc = 0,
 		},
 		{ .crbb_len = 18, .cc = 1,
 			.crbb_data = {0xdd, 0x41, 0x00},
@@ -83,23 +88,28 @@
 			0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
 			0xff, 0x00, 0x00
 			},
-			.ucmp_len = 90, .verify = 1
+			.ucmp_len = 90,
+			.expect_rc = 0,
 		},
-		/*Invalid inputs*/
+		/* TODO: previously marked as "Invalid inputs" but succeeds */
 		{ .crbb_len = 18, .cc = 1,
 			.crbb_data = {0x1E, 0x70, 0xc0},
-			.ucmp_data = {0x0},
-			.ucmp_len = 0, .verify = 0
+			.ucmp_data = {0xb0, 0x00, 0x00},
+			.ucmp_len = 19,
+			.expect_rc = 0,
 		},
+		/* Invalid inputs */
 		{ .crbb_len = 14, .cc = 1,
 			.crbb_data = {0x00, 0x1E, 0x7c},
 			.ucmp_data = {0x0},
-			.ucmp_len = 0, .verify = 0
+			.ucmp_len = 0,
+			.expect_rc = -1,
 		},
 		{ .crbb_len = 24, .cc = 0,
 			.crbb_data = {0x00, 0x00, 0x00},
 			.ucmp_data = {0x0},
-			.ucmp_len = 0, .verify = 0
+			.ucmp_len = 0,
+			.expect_rc = -1,
 		}
 	};
 
@@ -158,28 +168,29 @@
 		     test[itr].crbb_len);
 		rc = egprs_compress::decompress_crbb(test[itr].crbb_len,
 			test[itr].cc, test[itr].crbb_data, &dest);
+		_LOG("rc = %d\n", rc);
+		OSMO_ASSERT(test[itr].expect_rc == rc);
 		if (rc < 0) {
-			_LOG("\nFailed to decode CRBB: length %d, data %s",
+			_LOG("Failed to decode CRBB: length %d, data %s\n",
 			     test[itr].crbb_len,
 			     osmo_hexdump(test[itr].crbb_data,
 					  CEIL_DIV_8(test[itr].crbb_len)));
+			continue;
 		}
-		if (test[itr].verify) {
-			if (!result_matches(dest, test[itr].ucmp_data,
-					    test[itr].ucmp_len)) {
-				_LOG("\nTree based decoding: Error\n"
-				     "expected data = %s\n"
-				     "expected len = %d\n",
-				     osmo_hexdump(test[itr].ucmp_data,
-						  CEIL_DIV_8(test[itr].ucmp_len)),
-				     test[itr].ucmp_len);
-				_LOG("decoded data = %s\n"
-				     "decoded len = %d\n",
-				     osmo_hexdump(dest.data,
-						  CEIL_DIV_8(dest.cur_bit)),
-				     dest.cur_bit);
-				OSMO_ASSERT(0);
-			}
+		if (!result_matches(dest, test[itr].ucmp_data,
+				    test[itr].ucmp_len)) {
+			_LOG("\nTree based decoding: Error\n"
+			     "expected data = %s\n"
+			     "expected len = %d\n",
+			     osmo_hexdump(test[itr].ucmp_data,
+					  CEIL_DIV_8(test[itr].ucmp_len)),
+			     test[itr].ucmp_len);
+			_LOG("decoded data = %s\n"
+			     "decoded len = %d\n",
+			     osmo_hexdump(dest.data,
+					  CEIL_DIV_8(dest.cur_bit)),
+			     dest.cur_bit);
+			OSMO_ASSERT(0);
 		}
 		_LOG("\nexpected data = %s\n"
 		     "expected len = %d\n",
diff --git a/tests/bitcomp/BitcompTest.err b/tests/bitcomp/BitcompTest.err
index 1d6fb00..2eabd78 100644
--- a/tests/bitcomp/BitcompTest.err
+++ b/tests/bitcomp/BitcompTest.err
@@ -10,6 +10,7 @@
 Run_length = 31
 Run_length = 19
 Run_length = 32
+rc = 0
 
 expected data = ff ff ff f8 00 00 01 ff ff ff f8 00 00 00 ff ff ff fe 00 00 3f ff ff ff c0 
 expected len = 194
@@ -24,6 +25,7 @@
 Run_length = 40
 Run_length = 51
 Run_length = 41
+rc = 0
 
 expected data = ff ff ff ff ff ff c0 00 00 00 00 3f ff ff ff ff ff f8 00 00 00 00 00 
 expected len = 182
@@ -35,6 +37,7 @@
 uncompressed data = 02 
 len = 8
 Run_length = 29
+rc = 0
 
 expected data = ff ff ff f8 
 expected len = 29
@@ -56,6 +59,7 @@
 Run_length = 32
 Run_length = 22
 Run_length = 33
+rc = 0
 
 expected data = ff ff ff f8 00 00 ff ff ff f8 00 00 7f ff ff fe 00 00 0f ff ff ff e0 00 00 7f ff ff ff 80 00 01 ff ff ff ff 
 expected len = 288
@@ -76,6 +80,7 @@
 Run_length = 4
 Run_length = 6
 Run_length = 5
+rc = 0
 
 expected data = 37 47 81 f0 
 expected len = 28
@@ -89,6 +94,7 @@
 Run_length = 64
 Run_length = 16
 Run_length = 10
+rc = 0
 
 expected data = ff ff ff ff ff ff ff ff ff ff 00 00 
 expected len = 90
@@ -103,9 +109,10 @@
 Run_length = 1
 Run_length = 2
 Run_length = 15
+rc = 0
 
-expected data = 
-expected len = 0
+expected data = b0 00 00 
+expected len = 19
 decoded data = b0 00 00 
 decoded len = 19
 
@@ -113,20 +120,12 @@
 Tree based decoding:
 uncompressed data = 00 1e 
 len = 14
-
+rc = -1
 Failed to decode CRBB: length 14, data 00 1e 
-expected data = 
-expected len = 0
-decoded data = 
-decoded len = 0
 
 Test:9
 Tree based decoding:
 uncompressed data = 00 00 00 
 len = 24
-
+rc = -1
 Failed to decode CRBB: length 24, data 00 00 00 
-expected data = 
-expected len = 0
-decoded data = 
-decoded len = 0

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icf815a8f1acb0e275463408450171df046879847
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list