summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/gsm0408/gsm0408_test.c34
-rw-r--r--tests/gsm0408/gsm0408_test.ok16
2 files changed, 50 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]);
}
}
diff --git a/tests/gsm0408/gsm0408_test.ok b/tests/gsm0408/gsm0408_test.ok
index cc567636..a0e2c234 100644
--- a/tests/gsm0408/gsm0408_test.ok
+++ b/tests/gsm0408/gsm0408_test.ok
@@ -26,15 +26,31 @@ RA test...passed
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