coding: test FACCH/[FH] bitstealing in test_csd()
In test_csd() we encode three data frames filled-in with three specific
patterns and then try decoding them. Additionally execute the same set
of tests, but with FACCH/[FH] bitstealing (pattern 0x2b).
As can be seen from the test output, we have problems decoding FACCH:
* FACCH/F: decoding fails (n_errors=0 / n_bits_total=0),
* FACCH/H: decoding with errors (n_errors=2 / n_bits_total=456).
A patch fixing the problem follows.
Change-Id: Idc6decec3b84981d2aab4e27caab9ad65180f945
Related: OS#1572
diff --git a/tests/coding/coding_test.c b/tests/coding/coding_test.c
index e8dbe83..e53c8ad 100644
--- a/tests/coding/coding_test.c
+++ b/tests/coding/coding_test.c
@@ -540,6 +540,7 @@
unsigned int num_bits;
int (*enc_fn)(ubit_t *out, const ubit_t *in);
int (*dec_fn)(ubit_t *out, const sbit_t *in, int *ne, int *nb);
+ bool half_rate;
};
static const struct csd_test_case csd_tests[] = {
@@ -560,12 +561,14 @@
.num_bits = 4 * 60,
.enc_fn = &gsm0503_tch_hr48_encode,
.dec_fn = &gsm0503_tch_hr48_decode,
+ .half_rate = true,
},
{
.name = "TCH/H2.4",
.num_bits = 2 * 72,
.enc_fn = &gsm0503_tch_hr24_encode,
.dec_fn = &gsm0503_tch_hr24_decode,
+ .half_rate = true,
},
{
.name = "TCH/F14.4",
@@ -575,7 +578,7 @@
},
};
-static void test_csd(const struct csd_test_case *tc)
+static void test_csd(const struct csd_test_case *tc, bool facch)
{
const uint8_t patterns[] = { 0x00, 0xaa, 0xff };
ubit_t bursts_u[116 * (22 + 8)] = { 0 };
@@ -590,9 +593,17 @@
rc = tc->enc_fn(&bursts_u[i * 4 * 116], &data[0]);
CHECK_RC_OR_RET(rc == 0, "encoding");
- }
- /* TODO: test FACCH stealing */
+ /* Test FACCH bitstealing */
+ if (facch && i == 1) {
+ memset(&data, GSM_MACBLOCK_PADDING, GSM_MACBLOCK_LEN);
+ if (tc->half_rate)
+ rc = gsm0503_tch_hr_facch_encode(&bursts_u[116 * 4], &data[0]);
+ else
+ rc = gsm0503_tch_fr_facch_encode(&bursts_u[116 * 4], &data[0]);
+ CHECK_RC_OR_RET(rc == 0, "encoding FACCH");
+ }
+ }
/* Prepare soft-bits */
osmo_ubit2sbit(&bursts_s[0], &bursts_u[0], sizeof(bursts_s));
@@ -618,6 +629,27 @@
printf("\n");
}
+ /* Test FACCH bitstealing if requested */
+ if (facch) {
+ int n_errors = 0, n_bits_total = 0;
+
+ if (tc->half_rate) {
+ rc = gsm0503_tch_hr_facch_decode(&data[0], &bursts_s[116 * 4],
+ &n_errors, &n_bits_total);
+ } else {
+ rc = gsm0503_tch_fr_facch_decode(&data[0], &bursts_s[116 * 4],
+ &n_errors, &n_bits_total);
+ }
+#if 0
+ /* FIXME: there's something wrong with CSD mapping */
+ CHECK_RC_OR_RET(rc == GSM_MACBLOCK_LEN, "decoding FACCH");
+#endif
+
+ printf("%s(%s): FACCH/%c (pattern 0x2b): n_errors=%d / n_bits_total=%d\n",
+ __func__, tc->name, tc->half_rate ? 'H' : 'F', n_errors, n_bits_total);
+ printf("%s\n", osmo_hexdump(&data[0], GSM_MACBLOCK_LEN));
+ }
+
printf("\n");
}
@@ -688,9 +720,12 @@
for (i = 0; i < ARRAY_SIZE(test_l2); i++)
test_facch(test_l2[i], true);
- printf("\nTesting CSD functions:\n");
+ printf("\nTesting CSD functions (no FACCH):\n");
for (i = 0; i < ARRAY_SIZE(csd_tests); i++)
- test_csd(&csd_tests[i]);
+ test_csd(&csd_tests[i], false);
+ printf("\nTesting CSD functions (with FACCH):\n");
+ for (i = 0; i < ARRAY_SIZE(csd_tests); i++)
+ test_csd(&csd_tests[i], true);
printf("Success\n");
diff --git a/tests/coding/coding_test.ok b/tests/coding/coding_test.ok
index 3985513..c9c6bb7 100644
--- a/tests/coding/coding_test.ok
+++ b/tests/coding/coding_test.ok
@@ -402,7 +402,7 @@
test_facch(FACCH/H): decoded (BER=0/456): 01 02 03 00 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17
-Testing CSD functions:
+Testing CSD functions (no FACCH):
test_csd(TCH/F9.6): block #0 (pattern 0x00): n_errors=0 / n_bits_total=456
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
@@ -477,4 +477,90 @@
11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111111
11111111 11111111 11111111 11111111 11
+
+Testing CSD functions (with FACCH):
+test_csd(TCH/F9.6): block #0 (pattern 0x00): n_errors=34 / n_bits_total=456
+00000000 00000000 00000000 00000000 00010010 01100000 00000000 00000000
+00000000 00010011 01111000 00000000 00000000 00000000 00100100 10000000
+00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
+00000000 00000000 00000000 00000000 00000000 00000000
+test_csd(TCH/F9.6): block #1 (pattern 0xaa): n_errors=34 / n_bits_total=456
+01010101 01010101 01010101 01010101 01010101 01010101 01010101 01010101
+01010101 01010101 01010101 01010101 01010101 01010101 00101011 01010101
+01010101 01010101 01010101 01010101 01010101 01010101 01010101 01010101
+01010101 01010101 01010101 01010101 01010101 01010101
+test_csd(TCH/F9.6): block #2 (pattern 0xff): n_errors=6 / n_bits_total=456
+11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111111
+11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111111
+11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111111
+11111111 11111111 11111111 11111111 11111111 11111111
+test_csd(TCH/F9.6): FACCH/F (pattern 0x2b): n_errors=0 / n_bits_total=0
+01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+
+test_csd(TCH/F4.8): block #0 (pattern 0x00): n_errors=38 / n_bits_total=456
+00000000 00000000 01010000 00000000 00000000 00000000 00000000 00000000
+00000000 00000000 00000000 00000000 00000000 00000000 00000000
+test_csd(TCH/F4.8): block #1 (pattern 0xaa): n_errors=37 / n_bits_total=456
+01010101 01010101 01010101 01010101 01010101 01010101 01010101 01010101
+01010101 01010101 01010101 01010101 01010101 01010101 01010101
+test_csd(TCH/F4.8): block #2 (pattern 0xff): n_errors=1 / n_bits_total=456
+11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111111
+11111111 11111111 11111111 11111111 11111111 11111111 11111111
+test_csd(TCH/F4.8): FACCH/F (pattern 0x2b): n_errors=0 / n_bits_total=0
+01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+
+test_csd(TCH/H4.8): block #0 (pattern 0x00): n_errors=35 / n_bits_total=456
+00000000 00000000 00000000 00000000 00111000 10000000 00000000 00000000
+00000001 00000000 00000000 00000000 00000000 00000000 00011000 10000000
+00000000 00000000 00000000 00000000 00000000 00001000 00000000 00000000
+00000000 00000000 00000000 00000000 00000000 00000000
+test_csd(TCH/H4.8): block #1 (pattern 0xaa): n_errors=38 / n_bits_total=456
+01010101 01010101 01010101 01010101 01010101 01010101 01010101 01010101
+01010101 01010101 01010101 01010101 01010101 01010101 00101011 01010101
+01010101 01010101 01010101 00111010 01010101 01010101 01010101 01010101
+01010101 01010101 01010101 01010101 01010101 01010101
+test_csd(TCH/H4.8): block #2 (pattern 0xff): n_errors=1 / n_bits_total=456
+11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111111
+11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111111
+11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111111
+11111111 11111111 11111111 11111111 11111111 11111111
+test_csd(TCH/H4.8): FACCH/H (pattern 0x2b): n_errors=2 / n_bits_total=456
+2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b
+
+test_csd(TCH/H2.4): block #0 (pattern 0x00): n_errors=38 / n_bits_total=456
+00000000 00000000 00000101 00000000 00000000 00000000 00000000 00000000
+00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
+00000000 00000000
+test_csd(TCH/H2.4): block #1 (pattern 0xaa): n_errors=32 / n_bits_total=456
+01010101 01010101 01010101 01010101 01010101 01010101 01010101 01010101
+01010101 01010101 01010101 01010101 01010101 01010101 01010101 01010101
+01010101 01010101
+test_csd(TCH/H2.4): block #2 (pattern 0xff): n_errors=0 / n_bits_total=456
+11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111111
+11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111111
+11111111 11111111
+test_csd(TCH/H2.4): FACCH/H (pattern 0x2b): n_errors=2 / n_bits_total=456
+2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b
+
+test_csd(TCH/F14.4): block #0 (pattern 0x00): n_errors=27 / n_bits_total=456
+00000000 00000000 00000000 00000000 00000000 00111100 01000000 00000000
+00000000 00000000 00000000 00111000 10011000 00000000 10000000 00000000
+00000000 00000000 00001111 10001101 01110000 00000000 00000000 00000000
+00000000 00000000 00001001 11000000 00000000 00000000 00000000 00000000
+00000000 00000010 00100010 01000000 00
+test_csd(TCH/F14.4): block #1 (pattern 0xaa): n_errors=35 / n_bits_total=456
+01010101 01010100 10110111 01010101 01010101 00011000 10010001 11000110
+11011100 11011101 11000110 01010101 01010101 01010101 10100100 10010001
+11000110 00001010 01010101 01010101 11101101 11010101 01010100 01010101
+01010101 01010101 00101001 00100101 01010101 01010101 01010101 01010101
+01010101 01010101 01010101 01010101 01
+test_csd(TCH/F14.4): block #2 (pattern 0xff): n_errors=3 / n_bits_total=456
+11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111111
+11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111111
+11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111111
+11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111111
+11111111 11111111 11111111 11111111 11
+test_csd(TCH/F14.4): FACCH/F (pattern 0x2b): n_errors=0 / n_bits_total=0
+01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+
Success