summaryrefslogtreecommitdiffstats
path: root/tests/gsm0408/gsm0408_test.c
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-02-20 22:19:56 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2018-02-28 19:26:43 +0100
commit4566f4e79d48ccff881035b89f393ad8737e9b25 (patch)
treecb186a54fcc42958e3ebde8180c2c13bea9c3436 /tests/gsm0408/gsm0408_test.c
parentdbb25132d737ca7d483f1195057c851836e9afdd (diff)
gsm0408_test: test new gsm48_{decode,generate}_lai2() functions
Change-Id: I4c8492b8055803d2857f1ef30aede088778b085b
Diffstat (limited to 'tests/gsm0408/gsm0408_test.c')
-rw-r--r--tests/gsm0408/gsm0408_test.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c
index 9e552ab9..479b3710 100644
--- a/tests/gsm0408/gsm0408_test.c
+++ b/tests/gsm0408/gsm0408_test.c
@@ -187,6 +187,39 @@ static inline void check_lai(const struct gprs_ra_id *raid)
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 @@ static void test_lai_encode_decode(void)
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]);
}
}