[MERGED] libosmocore[master]: gsm0408_test: test new gsm48_{decode, generate}_lai2() functions

Harald Welte gerrit-no-reply at lists.osmocom.org
Wed Feb 28 23:18:56 UTC 2018


Harald Welte has submitted this change and it was merged.

Change subject: gsm0408_test: test new gsm48_{decode,generate}_lai2() functions
......................................................................


gsm0408_test: test new gsm48_{decode,generate}_lai2() functions

Change-Id: I4c8492b8055803d2857f1ef30aede088778b085b
---
M tests/gsm0408/gsm0408_test.c
M tests/gsm0408/gsm0408_test.ok
2 files changed, 50 insertions(+), 0 deletions(-)

Approvals:
  Neels Hofmeyr: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c
index 9e552ab..479b371 100644
--- a/tests/gsm0408/gsm0408_test.c
+++ b/tests/gsm0408/gsm0408_test.c
@@ -187,6 +187,39 @@
 		printf("  FAIL\n");
 }
 
+static inline void dump_lai(const struct osmo_location_area_id *lai)
+{
+	printf("%s%s\n", osmo_lai_name(lai), lai->plmn.mnc_3_digits ? " (3-digit MNC)" : "");
+}
+
+static inline void check_lai2(const struct gprs_ra_id *raid)
+{
+	struct gsm48_loc_area_id lai = {};
+	struct osmo_location_area_id decoded = {};
+	struct osmo_location_area_id laid = {
+		.plmn = {
+			.mcc = raid->mcc,
+			.mnc = raid->mnc,
+			.mnc_3_digits = raid->mnc_3_digits,
+		},
+		.lac = raid->lac,
+	};
+
+	printf("- gsm48_generate_lai2() from "); dump_lai(&laid);
+
+	gsm48_generate_lai2(&lai, &laid);
+	printf("  Encoded %s\n", osmo_hexdump((unsigned char*)&lai, sizeof(lai)));
+	gsm48_decode_lai2(&lai, &decoded);
+	printf("  gsm48_decode_lai2() gives  "); dump_lai(&decoded);
+	if (decoded.plmn.mcc == laid.plmn.mcc
+	    && decoded.plmn.mnc == laid.plmn.mnc
+	    && decoded.lac == laid.lac
+	    && decoded.plmn.mnc_3_digits == (laid.plmn.mnc_3_digits || laid.plmn.mnc > 99))
+		printf("  passed\n");
+	else
+		printf("  FAIL\n");
+}
+
 static struct gprs_ra_id test_ra_cap_items[] = {
 	{
 		.mcc = 77,
@@ -228,6 +261,7 @@
 
 	for (i = 0; i < ARRAY_SIZE(test_ra_cap_items); i++) {
 		check_lai(&test_ra_cap_items[i]);
+		check_lai2(&test_ra_cap_items[i]);
 	}
 }
 
diff --git a/tests/gsm0408/gsm0408_test.ok b/tests/gsm0408/gsm0408_test.ok
index cc56763..a0e2c23 100644
--- a/tests/gsm0408/gsm0408_test.ok
+++ b/tests/gsm0408/gsm0408_test.ok
@@ -26,15 +26,31 @@
   Encoded 70 17 21 02 9a 
   gsm48_decode_lai() gives  077-121-666-0
   passed
+- gsm48_generate_lai2() from 077-121-666
+  Encoded 70 17 21 02 9a 
+  gsm48_decode_lai2() gives  077-121-666 (3-digit MNC)
+  passed
 - gsm48_generate_lai() from 084-98-11-0
   Encoded 80 f4 89 00 0b 
   gsm48_decode_lai() gives  084-98-11-0
+  passed
+- gsm48_generate_lai2() from 084-98-11
+  Encoded 80 f4 89 00 0b 
+  gsm48_decode_lai2() gives  084-98-11
   passed
 - gsm48_generate_lai() from 000-00-0-0
   Encoded 00 f0 00 00 00 
   gsm48_decode_lai() gives  000-00-0-0
   passed
+- gsm48_generate_lai2() from 000-00-0
+  Encoded 00 f0 00 00 00 
+  gsm48_decode_lai2() gives  000-00-0
+  passed
 - gsm48_generate_lai() from 999-999-65535-0
   Encoded 99 99 99 ff ff 
   gsm48_decode_lai() gives  999-999-65535-0
   passed
+- gsm48_generate_lai2() from 999-999-65535
+  Encoded 99 99 99 ff ff 
+  gsm48_decode_lai2() gives  999-999-65535 (3-digit MNC)
+  passed

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I4c8492b8055803d2857f1ef30aede088778b085b
Gerrit-PatchSet: 7
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>


More information about the gerrit-log mailing list