diff options
author | Max <msuraev@sysmocom.de> | 2017-08-30 19:17:50 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2017-09-01 07:57:40 +0000 |
commit | 99377c2daab6e428194c92103a3a7c2d8a8b5551 (patch) | |
tree | 8d983e95575eee9928ed31b5a3e60ebe0b1427fc | |
parent | 272bd4fa6611bfb4f7a9fc9a46184709f984f3c1 (diff) |
libosmogsm: add Routing Area Identifier test
Ensure that gsm48_parse_ra() and gsm48_construct_ra() behave properly.
Change-Id: I27117fe728407dd10886459e89ba4ff9d5e53e6b
-rw-r--r-- | tests/gsm0408/gsm0408_test.c | 49 | ||||
-rw-r--r-- | tests/gsm0408/gsm0408_test.ok | 8 |
2 files changed, 57 insertions, 0 deletions
diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c index f922a4fd..3f3a5c7e 100644 --- a/tests/gsm0408/gsm0408_test.c +++ b/tests/gsm0408/gsm0408_test.c @@ -130,6 +130,54 @@ static int test_bearer_cap() 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 @@ int main(int argc, char **argv) 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 4a6d78b9..f0abfd5c 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 |