[MERGED] libosmocore[master]: gsm0408_test: also test gsm48_generate_lai() and gsm48_decod...

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

Harald Welte gerrit-no-reply at lists.osmocom.org
Thu Feb 22 07:49:07 UTC 2018


Harald Welte has submitted this change and it was merged.

Change subject: gsm0408_test: also test gsm48_generate_lai() and gsm48_decode_lai()
......................................................................


gsm0408_test: also test gsm48_generate_lai() and gsm48_decode_lai()

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

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c
index ad45507..a0e740a 100644
--- a/tests/gsm0408/gsm0408_test.c
+++ b/tests/gsm0408/gsm0408_test.c
@@ -159,6 +159,33 @@
 		printf("passed\n");
 }
 
+static inline void check_lai(const struct gprs_ra_id *raid)
+{
+	int rc;
+	struct gsm48_loc_area_id lai = {};
+	struct gprs_ra_id decoded = {};
+	struct gprs_ra_id _laid = *raid;
+	struct gprs_ra_id *laid = &_laid;
+	laid->rac = 0;
+
+	printf("- gsm48_generate_lai() from "); dump_ra(laid);
+
+	gsm48_generate_lai(&lai, laid->mcc, laid->mnc, laid->lac);
+	printf("  Encoded %s\n", osmo_hexdump((unsigned char*)&lai, sizeof(lai)));
+	rc = gsm48_decode_lai(&lai, &decoded.mcc, &decoded.mnc, &decoded.lac);
+	if (rc) {
+		printf("  gsm48_decode_lai() returned %d --> FAIL\n", rc);
+		return;
+	}
+	printf("  gsm48_decode_lai() gives  "); dump_ra(&decoded);
+	if (decoded.mcc == laid->mcc
+	    && decoded.mnc == laid->mnc
+	    && decoded.lac == laid->lac)
+		printf("  passed\n");
+	else
+		printf("  FAIL\n");
+}
+
 static struct gprs_ra_id test_ra_cap_items[] = {
 	{
 		.mcc = 77,
@@ -192,6 +219,15 @@
 
 	for (i = 0; i < ARRAY_SIZE(test_ra_cap_items); i++)
 		check_ra(&test_ra_cap_items[i]);
+}
+
+static void test_lai_encode_decode(void)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(test_ra_cap_items); i++) {
+		check_lai(&test_ra_cap_items[i]);
+	}
 }
 
 static void test_mid_from_tmsi(void)
@@ -229,6 +265,7 @@
 	test_mid_from_tmsi();
 	test_mid_from_imsi();
 	test_ra_cap();
+	test_lai_encode_decode();
 
 	return EXIT_SUCCESS;
 }
diff --git a/tests/gsm0408/gsm0408_test.ok b/tests/gsm0408/gsm0408_test.ok
index dc19eea..7612c12 100644
--- a/tests/gsm0408/gsm0408_test.ok
+++ b/tests/gsm0408/gsm0408_test.ok
@@ -22,3 +22,19 @@
 MCC+MNC in BCD: 99 99 99 
 999-999-65535-255
 RA test...passed
+- gsm48_generate_lai() from 077-121-666-0
+  Encoded 70 17 21 02 9a 
+  gsm48_decode_lai() gives  077-121-666-0
+  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_lai() from 000-00-0-0
+  Encoded 00 f0 00 00 00 
+  gsm48_decode_lai() gives  000-00-0-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

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Idd6cee090464bc92b654332904a9a08edf16e5c9
Gerrit-PatchSet: 1
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



More information about the gerrit-log mailing list