summaryrefslogtreecommitdiffstats
path: root/tests/gsm0808/gsm0808_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/gsm0808/gsm0808_test.c')
-rw-r--r--tests/gsm0808/gsm0808_test.c196
1 files changed, 196 insertions, 0 deletions
diff --git a/tests/gsm0808/gsm0808_test.c b/tests/gsm0808/gsm0808_test.c
index ae138be8..29cecb2e 100644
--- a/tests/gsm0808/gsm0808_test.c
+++ b/tests/gsm0808/gsm0808_test.c
@@ -1444,6 +1444,200 @@ static void test_gsm0808_enc_dec_cell_id_global()
msgb_free(msg);
}
+static void test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(struct gsm48_multi_rate_conf *cfg)
+{
+ uint16_t s15_s0;
+
+ printf("Input:\n");
+ printf(" m4_75= %u smod= %u\n", cfg->m4_75, cfg->smod);
+ printf(" m5_15= %u spare= %u\n", cfg->m5_15, cfg->spare);
+ printf(" m5_90= %u icmi= %u\n", cfg->m5_90, cfg->icmi);
+ printf(" m6_70= %u nscb= %u\n", cfg->m6_70, cfg->nscb);
+ printf(" m7_40= %u ver= %u\n", cfg->m7_40, cfg->ver);
+ printf(" m7_95= %u\n", cfg->m7_95);
+ printf(" m10_2= %u\n", cfg->m10_2);
+ printf(" m12_2= %u\n", cfg->m12_2);
+
+ s15_s0 = gsm0808_sc_cfg_from_gsm48_mr_cfg(cfg, true);
+ printf("Result (fr):\n");
+ printf(" S15-S0 = %04x = 0b" OSMO_BIN_SPEC OSMO_BIN_SPEC "\n", s15_s0,
+ OSMO_BIN_PRINT(s15_s0 >> 8), OSMO_BIN_PRINT(s15_s0));
+
+ s15_s0 = gsm0808_sc_cfg_from_gsm48_mr_cfg(cfg, false);
+ printf("Result (hr):\n");
+ printf(" S15-S0 = %04x = 0b" OSMO_BIN_SPEC OSMO_BIN_SPEC "\n", s15_s0,
+ OSMO_BIN_PRINT(s15_s0 >> 8), OSMO_BIN_PRINT(s15_s0));
+
+ printf("\n");
+}
+
+static void test_gsm0808_sc_cfg_from_gsm48_mr_cfg(void)
+{
+ struct gsm48_multi_rate_conf cfg;
+
+ printf("Testing gsm0808_sc_cfg_from_gsm48_mr_cfg():\n");
+
+ cfg.m4_75 = 0;
+ cfg.m5_15 = 0;
+ cfg.m5_90 = 0;
+ cfg.m6_70 = 0;
+ cfg.m7_40 = 0;
+ cfg.m7_95 = 0;
+ cfg.m10_2 = 0;
+ cfg.m12_2 = 0;
+ test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg);
+
+ cfg.m4_75 = 1;
+ cfg.m5_15 = 0;
+ cfg.m5_90 = 0;
+ cfg.m6_70 = 0;
+ cfg.m7_40 = 0;
+ cfg.m7_95 = 0;
+ cfg.m10_2 = 0;
+ cfg.m12_2 = 0;
+ test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg);
+
+ cfg.m4_75 = 0;
+ cfg.m5_15 = 1;
+ cfg.m5_90 = 0;
+ cfg.m6_70 = 0;
+ cfg.m7_40 = 0;
+ cfg.m7_95 = 0;
+ cfg.m10_2 = 0;
+ cfg.m12_2 = 0;
+ test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg);
+
+ cfg.m4_75 = 0;
+ cfg.m5_15 = 0;
+ cfg.m5_90 = 1;
+ cfg.m6_70 = 0;
+ cfg.m7_40 = 0;
+ cfg.m7_95 = 0;
+ cfg.m10_2 = 0;
+ cfg.m12_2 = 0;
+ test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg);
+
+ cfg.m4_75 = 0;
+ cfg.m5_15 = 0;
+ cfg.m5_90 = 0;
+ cfg.m6_70 = 1;
+ cfg.m7_40 = 0;
+ cfg.m7_95 = 0;
+ cfg.m10_2 = 0;
+ cfg.m12_2 = 0;
+ test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg);
+
+ cfg.m4_75 = 0;
+ cfg.m5_15 = 0;
+ cfg.m5_90 = 0;
+ cfg.m6_70 = 0;
+ cfg.m7_40 = 1;
+ cfg.m7_95 = 0;
+ cfg.m10_2 = 0;
+ cfg.m12_2 = 0;
+ test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg);
+
+ cfg.m4_75 = 0;
+ cfg.m5_15 = 0;
+ cfg.m5_90 = 0;
+ cfg.m6_70 = 0;
+ cfg.m7_40 = 0;
+ cfg.m7_95 = 1;
+ cfg.m10_2 = 0;
+ cfg.m12_2 = 0;
+ test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg);
+
+ cfg.m4_75 = 0;
+ cfg.m5_15 = 0;
+ cfg.m5_90 = 0;
+ cfg.m6_70 = 0;
+ cfg.m7_40 = 0;
+ cfg.m7_95 = 0;
+ cfg.m10_2 = 1;
+ cfg.m12_2 = 0;
+ test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg);
+
+ cfg.m4_75 = 0;
+ cfg.m5_15 = 0;
+ cfg.m5_90 = 0;
+ cfg.m6_70 = 0;
+ cfg.m7_40 = 0;
+ cfg.m7_95 = 0;
+ cfg.m10_2 = 0;
+ cfg.m12_2 = 1;
+ test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg);
+
+ cfg.m4_75 = 1;
+ cfg.m5_15 = 1;
+ cfg.m5_90 = 1;
+ cfg.m6_70 = 1;
+ cfg.m7_40 = 0;
+ cfg.m7_95 = 0;
+ cfg.m10_2 = 0;
+ cfg.m12_2 = 0;
+ test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg);
+
+ cfg.m4_75 = 0;
+ cfg.m5_15 = 0;
+ cfg.m5_90 = 0;
+ cfg.m6_70 = 0;
+ cfg.m7_40 = 1;
+ cfg.m7_95 = 1;
+ cfg.m10_2 = 1;
+ cfg.m12_2 = 1;
+ test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg);
+
+ cfg.m4_75 = 0;
+ cfg.m5_15 = 0;
+ cfg.m5_90 = 1;
+ cfg.m6_70 = 1;
+ cfg.m7_40 = 0;
+ cfg.m7_95 = 0;
+ cfg.m10_2 = 1;
+ cfg.m12_2 = 1;
+ test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg);
+
+ cfg.m4_75 = 1;
+ cfg.m5_15 = 1;
+ cfg.m5_90 = 0;
+ cfg.m6_70 = 0;
+ cfg.m7_40 = 1;
+ cfg.m7_95 = 1;
+ cfg.m10_2 = 0;
+ cfg.m12_2 = 0;
+ test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg);
+
+ cfg.m4_75 = 0;
+ cfg.m5_15 = 1;
+ cfg.m5_90 = 0;
+ cfg.m6_70 = 1;
+ cfg.m7_40 = 0;
+ cfg.m7_95 = 1;
+ cfg.m10_2 = 0;
+ cfg.m12_2 = 1;
+ test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg);
+
+ cfg.m4_75 = 1;
+ cfg.m5_15 = 0;
+ cfg.m5_90 = 1;
+ cfg.m6_70 = 0;
+ cfg.m7_40 = 1;
+ cfg.m7_95 = 0;
+ cfg.m10_2 = 1;
+ cfg.m12_2 = 0;
+ test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg);
+
+ cfg.m4_75 = 1;
+ cfg.m5_15 = 1;
+ cfg.m5_90 = 1;
+ cfg.m6_70 = 1;
+ cfg.m7_40 = 1;
+ cfg.m7_95 = 1;
+ cfg.m10_2 = 1;
+ cfg.m12_2 = 1;
+ test_gsm0808_sc_cfg_from_gsm48_mr_cfg_single(&cfg);
+}
+
int main(int argc, char **argv)
{
printf("Testing generation of GSM0808 messages\n");
@@ -1495,6 +1689,8 @@ int main(int argc, char **argv)
test_gsm0808_enc_dec_cell_id_lac_and_ci();
test_gsm0808_enc_dec_cell_id_global();
+ test_gsm0808_sc_cfg_from_gsm48_mr_cfg();
+
printf("Done\n");
return EXIT_SUCCESS;
}