[MERGED] libosmocore[master]: libosmogsm: add Routing Area Identifier test

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
Fri Sep 1 07:57:41 UTC 2017


Harald Welte has submitted this change and it was merged.

Change subject: libosmogsm: add Routing Area Identifier test
......................................................................


libosmogsm: add Routing Area Identifier test

Ensure that gsm48_parse_ra() and gsm48_construct_ra() behave properly.

Change-Id: I27117fe728407dd10886459e89ba4ff9d5e53e6b
---
M tests/gsm0408/gsm0408_test.c
M tests/gsm0408/gsm0408_test.ok
2 files changed, 57 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 f922a4f..3f3a5c7 100644
--- a/tests/gsm0408/gsm0408_test.c
+++ b/tests/gsm0408/gsm0408_test.c
@@ -130,6 +130,54 @@
 	return 0;
 }
 
+static inline void dump_ra(const struct gprs_ra_id *raid)
+{
+	printf("RA: MNC=%u, MCC=%u, LAC=%u, RAC=%u\n", raid->mnc, raid->mcc, raid->lac, raid->rac);
+}
+
+static inline void check_ra(const struct gprs_ra_id *raid)
+{
+	uint8_t buf[6];
+	int res;
+	struct gprs_ra_id raid0 = {
+		.mnc = 0,
+		.mcc = 0,
+		.lac = 0,
+		.rac = 0,
+	};
+
+	res = gsm48_construct_ra(buf, raid);
+	printf("Constructed RA: %d - %s\n", res, res != sizeof(buf) ? "FAIL" : "OK");
+
+	gsm48_parse_ra(&raid0, buf);
+	dump_ra(raid);
+	dump_ra(&raid0);
+	printf("RA test...");
+	if (raid->mnc != raid0.mnc || raid->mcc != raid0.mcc || raid->lac != raid0.lac || raid->rac != raid0.rac)
+		printf("FAIL\n");
+	else
+		printf("passed\n");
+}
+
+static void test_ra_cap(void)
+{
+	struct gprs_ra_id raid1 = {
+		.mnc = 121,
+		.mcc = 77,
+		.lac = 666,
+		.rac = 5,
+	};
+	struct gprs_ra_id raid2 = {
+		.mnc = 98,
+		.mcc = 84,
+		.lac = 11,
+		.rac = 89,
+	};
+
+	check_ra(&raid1);
+	check_ra(&raid2);
+}
+
 static void test_mid_from_tmsi(void)
 {
 	static const uint8_t res[] = { 0x17, 0x05, 0xf4, 0xaa, 0xbb, 0xcc, 0xdd };
@@ -152,6 +200,7 @@
 	msgb_talloc_ctx_init(NULL, 0);
 	test_bearer_cap();
 	test_mid_from_tmsi();
+	test_ra_cap();
 
 	return EXIT_SUCCESS;
 }
diff --git a/tests/gsm0408/gsm0408_test.ok b/tests/gsm0408/gsm0408_test.ok
index 4a6d78b..f0abfd5 100644
--- a/tests/gsm0408/gsm0408_test.ok
+++ b/tests/gsm0408/gsm0408_test.ok
@@ -1,3 +1,11 @@
 Test `CSD 9600/V.110/transparent' passed
 Test `Speech, all codecs' passed
 Simple TMSI encoding test....passed
+Constructed RA: 6 - OK
+RA: MNC=121, MCC=77, LAC=666, RAC=5
+RA: MNC=121, MCC=77, LAC=666, RAC=5
+RA test...passed
+Constructed RA: 6 - OK
+RA: MNC=98, MCC=84, LAC=11, RAC=89
+RA: MNC=98, MCC=84, LAC=11, RAC=89
+RA test...passed

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I27117fe728407dd10886459e89ba4ff9d5e53e6b
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list