tests/coding_test: Fix test_pdtch() results

When switching the l2 structures passes to test_pdtch() to be constant,
it was noted that output of the test changes. This happens because same
array is tested several times with different length, incrementing each
time. Since the test was modifying the input array directly, it means
each new run of test_pdtch() the array was further modified.
Upon constifying the structures, we copy the array and hence only modify
the required bits each time.

Change-Id: Iffd0ca3669eb8d0d2e80d754fc8acbf72f1bebe8
This commit is contained in:
Pau Espin 2020-04-09 16:16:53 +02:00 committed by laforge
parent ce28d2ebba
commit e7d0d70ce7
2 changed files with 30 additions and 29 deletions

View File

@ -323,7 +323,7 @@ struct test_macblock {
uint8_t l2[54];
};
static struct test_macblock test_macblock[] = {
static const struct test_macblock test_macblock[] = {
/* Random frame */
{ false,
GSM0503_GPRS_BURSTS_NBITS,
@ -385,33 +385,34 @@ GSM RLC/MAC: EGPRS DL DATA BLOCK 1 (BSN 1)
},
};
static void test_pdtch(struct test_macblock *tmb, int len)
static void test_pdtch(const struct test_macblock *tmb, int len)
{
uint8_t result[len];
uint8_t l2[len], result[len];
ubit_t bursts_u[116 * 4];
sbit_t bursts_s[116 * 4];
int n_errors, n_bits_total;
int rc;
/* Zero the not coded tail bits */
memcpy(l2, tmb->l2, len);
switch (len) {
case 34:
case 54:
tmb->l2[len - 1] &= 0x7f;
l2[len - 1] &= 0x7f;
result[len - 1] &= 0x7f;
break;
case 40:
tmb->l2[len - 1] &= 0x07;
l2[len - 1] &= 0x07;
result[len - 1] &= 0x07;
break;
}
/* Encode L2 message */
printf("Encoding: %s\n", osmo_hexdump(tmb->l2, len));
printf("Encoding: %s\n", osmo_hexdump(l2, len));
if (tmb->is_egprs)
rc = gsm0503_pdtch_egprs_encode(bursts_u, tmb->l2, len);
rc = gsm0503_pdtch_egprs_encode(bursts_u, l2, len);
else
rc = gsm0503_pdtch_encode(bursts_u, tmb->l2, len);
rc = gsm0503_pdtch_encode(bursts_u, l2, len);
CHECK_RC_OR_RET(rc == (int)tmb->exp_burst_bits, "encoding");
/* Prepare soft-bits */
@ -435,7 +436,7 @@ static void test_pdtch(struct test_macblock *tmb, int len)
printf("pdtch_decode: n_errors=%d n_bits_total=%d ber=%.2f\n",
n_errors, n_bits_total, (float)n_errors/n_bits_total);
OSMO_ASSERT(!memcmp(tmb->l2, result, len));
OSMO_ASSERT(!memcmp(l2, result, len));
printf("\n");
}

View File

@ -272,32 +272,32 @@ S-Bits:
Decoded: a3 af 5f c6 36 43 44 ab d9 6d 7d 62 24 c9 d2 92 fa 27 5d 71 7a 59 a8 42 a3 af 5f c6 36 43 44 ab a3 2f
pdtch_decode: n_errors=132 n_bits_total=588 ber=0.22
Encoding: a3 af 5f c6 36 43 44 ab d9 6d 7d 62 24 c9 d2 92 fa 27 5d 71 7a 59 a8 42 a3 af 5f c6 36 43 44 ab a3 2f 5f c6 36 43 44 03
Encoding: a3 af 5f c6 36 43 44 ab d9 6d 7d 62 24 c9 d2 92 fa 27 5d 71 7a 59 a8 42 a3 af 5f c6 36 43 44 ab a3 af 5f c6 36 43 44 03
U-Bits:
100010111000001100000000001101001000000000101100111011001 00 00 101110010011001000110010000011100101000011110001101100001
001011110100100101010101111111110011111011111110001101001 01 00 011010010110101000111110001100110011101101111000100101110
110001101010001000010101011111101011000111010110110011110 00 00 101001101100011001101100110110000101000001000001011000110
011100001010000100100101001000110110100111000000101110000 00 01 111100110000011001001100110100111101011010011110100010011
100010111000001100000000001101001000000000101100111011001 00 00 101110011011001000110000000011100101000011110001101100001
001011110100100101010101111111110011111011111110011101001 01 00 011010110110101000110110001100110011101101111000100101100
110001100000001000010101011111101011000111010111110011110 00 00 100001101100011001101100110110000101000001000001011001110
011100001010000100100101001000100110100111010000101110000 00 01 111100110000011001001101110100111101001010011110100110011
S-Bits:
81 7f 7f 7f 81 7f 81 81 81 7f 7f 7f 7f 7f 81 81 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 81 81 7f 81 7f 7f 81 7f 7f 7f 7f 7f 7f 7f 7f 7f 81 7f 81 81 7f 7f 81 81 81 7f 81 81 7f 7f 81 7f 7f 81 7f 81 81 81 7f 7f 81 7f 7f 81 81 7f 7f 81 7f 7f 7f 81 81 7f 7f 81 7f 7f 7f 7f 7f 81 81 81 7f 7f 81 7f 81 7f 7f 7f 7f 81 81 81 81 7f 7f 7f 81 81 7f 81 81 7f 7f 7f 7f 81
7f 7f 81 7f 81 81 81 81 7f 81 7f 7f 81 7f 7f 81 7f 81 7f 81 7f 81 7f 81 81 81 81 81 81 81 81 81 7f 7f 81 81 81 81 81 7f 81 81 81 81 81 81 81 7f 7f 7f 81 81 7f 81 7f 7f 81 81 7f 7f 81 81 7f 81 7f 7f 81 7f 81 81 7f 81 7f 81 7f 7f 7f 81 81 81 81 81 7f 7f 7f 81 81 7f 7f 81 81 7f 7f 81 81 81 7f 81 81 7f 81 81 81 81 7f 7f 7f 81 7f 7f 81 7f 81 81 81 7f
81 81 7f 7f 7f 81 81 7f 81 7f 81 7f 7f 7f 81 7f 7f 7f 7f 81 7f 81 7f 81 7f 81 81 81 81 81 81 7f 81 7f 81 81 7f 7f 7f 81 81 81 7f 81 7f 81 81 7f 81 81 7f 7f 81 81 81 81 7f 7f 7f 81 7f 81 7f 7f 81 81 7f 81 81 7f 7f 7f 81 81 7f 7f 81 81 7f 81 81 7f 7f 81 81 7f 81 81 7f 7f 7f 7f 81 7f 81 7f 7f 7f 7f 7f 81 7f 7f 7f 7f 7f 81 7f 81 81 7f 7f 7f 81 81 7f
7f 81 81 81 7f 7f 7f 7f 81 7f 81 7f 7f 7f 7f 81 7f 7f 81 7f 7f 81 7f 81 7f 7f 81 7f 7f 7f 81 81 7f 81 81 7f 81 7f 7f 81 81 81 7f 7f 7f 7f 7f 7f 81 7f 81 81 81 7f 7f 7f 7f 7f 81 81 81 81 81 7f 7f 81 81 7f 7f 7f 7f 7f 81 81 7f 7f 81 7f 7f 81 81 7f 7f 81 81 7f 81 7f 7f 81 81 81 81 7f 81 7f 81 81 7f 81 7f 7f 81 81 81 81 7f 81 7f 7f 7f 81 7f 7f 81 81
Decoded: a3 af 5f c6 36 43 44 ab d9 6d 7d 62 24 c9 d2 92 fa 27 5d 71 7a 59 a8 42 a3 af 5f c6 36 43 44 ab a3 2f 5f c6 36 43 44 03
81 7f 7f 7f 81 7f 81 81 81 7f 7f 7f 7f 7f 81 81 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 81 81 7f 81 7f 7f 81 7f 7f 7f 7f 7f 7f 7f 7f 7f 81 7f 81 81 7f 7f 81 81 81 7f 81 81 7f 7f 81 7f 7f 81 7f 81 81 81 7f 7f 81 81 7f 81 81 7f 7f 81 7f 7f 7f 81 81 7f 7f 7f 7f 7f 7f 7f 7f 81 81 81 7f 7f 81 7f 81 7f 7f 7f 7f 81 81 81 81 7f 7f 7f 81 81 7f 81 81 7f 7f 7f 7f 81
7f 7f 81 7f 81 81 81 81 7f 81 7f 7f 81 7f 7f 81 7f 81 7f 81 7f 81 7f 81 81 81 81 81 81 81 81 81 7f 7f 81 81 81 81 81 7f 81 81 81 81 81 81 81 7f 7f 81 81 81 7f 81 7f 7f 81 81 7f 7f 81 81 7f 81 7f 81 81 7f 81 81 7f 81 7f 81 7f 7f 7f 81 81 7f 81 81 7f 7f 7f 81 81 7f 7f 81 81 7f 7f 81 81 81 7f 81 81 7f 81 81 81 81 7f 7f 7f 81 7f 7f 81 7f 81 81 7f 7f
81 81 7f 7f 7f 81 81 7f 7f 7f 7f 7f 7f 7f 81 7f 7f 7f 7f 81 7f 81 7f 81 7f 81 81 81 81 81 81 7f 81 7f 81 81 7f 7f 7f 81 81 81 7f 81 7f 81 81 81 81 81 7f 7f 81 81 81 81 7f 7f 7f 81 7f 7f 7f 7f 81 81 7f 81 81 7f 7f 7f 81 81 7f 7f 81 81 7f 81 81 7f 7f 81 81 7f 81 81 7f 7f 7f 7f 81 7f 81 7f 7f 7f 7f 7f 81 7f 7f 7f 7f 7f 81 7f 81 81 7f 7f 81 81 81 7f
7f 81 81 81 7f 7f 7f 7f 81 7f 81 7f 7f 7f 7f 81 7f 7f 81 7f 7f 81 7f 81 7f 7f 81 7f 7f 7f 81 7f 7f 81 81 7f 81 7f 7f 81 81 81 7f 81 7f 7f 7f 7f 81 7f 81 81 81 7f 7f 7f 7f 7f 81 81 81 81 81 7f 7f 81 81 7f 7f 7f 7f 7f 81 81 7f 7f 81 7f 7f 81 81 7f 81 81 81 7f 81 7f 7f 81 81 81 81 7f 81 7f 7f 81 7f 81 7f 7f 81 81 81 81 7f 81 7f 7f 81 81 7f 7f 81 81
Decoded: a3 af 5f c6 36 43 44 ab d9 6d 7d 62 24 c9 d2 92 fa 27 5d 71 7a 59 a8 42 a3 af 5f c6 36 43 44 ab a3 af 5f c6 36 43 44 03
pdtch_decode: n_errors=220 n_bits_total=676 ber=0.33
Encoding: a3 af 5f c6 36 43 44 ab d9 6d 7d 62 24 c9 d2 92 fa 27 5d 71 7a 59 a8 42 a3 af 5f c6 36 43 44 ab a3 2f 5f c6 36 43 44 03 d9 6d 7d 62 24 c9 d2 92 fa 27 5d 71 7a 28
Encoding: a3 af 5f c6 36 43 44 ab d9 6d 7d 62 24 c9 d2 92 fa 27 5d 71 7a 59 a8 42 a3 af 5f c6 36 43 44 ab a3 af 5f c6 36 43 44 ab d9 6d 7d 62 24 c9 d2 92 fa 27 5d 71 7a 28
U-Bits:
100010100101111101110101011001010100000101001001011011000 00 00 001000000000001100000110001011010111110101110101001100010
010101000000101010101011110000010101000100000011010001101 00 01 010111110101110101010111011111100111010011010000111110111
010111100101110011111100101110001010100110000010100000100 00 01 010111101110101111110011110101111101110100011000101111111
011110100110000011110100111111101111111111111010101110000 01 00 001010101010101010101010111010110110000000100000101001011
100010100101111101110101011001010100000101001001011011000 00 00 001010001000001100000111001011010111110101110101001101010
010101000000001010101011110000010101000100000011010001101 00 01 010111010101110101010111011111100111010011010000111110111
010111100101110011111100101111001010100110000011100000100 00 01 010111101110101111110011110101111101110100011000101111111
011110100110000010110100111111111111111111111010101110000 01 00 001010101010101010101011111010110110010000100000101001011
S-Bits:
81 7f 7f 7f 81 7f 81 7f 7f 81 7f 81 81 81 81 81 7f 81 81 81 7f 81 7f 81 7f 81 81 7f 7f 81 7f 81 7f 81 7f 7f 7f 7f 7f 81 7f 81 7f 7f 81 7f 7f 81 7f 81 81 7f 81 81 7f 7f 7f 7f 7f 7f 7f 81 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 81 81 7f 7f 7f 7f 7f 81 81 7f 7f 7f 81 7f 81 81 7f 81 7f 81 81 81 81 81 7f 81 7f 81 81 81 7f 81 7f 81 7f 7f 81 81 7f 7f 7f 81 7f
7f 81 7f 81 7f 81 7f 7f 7f 7f 7f 7f 81 7f 81 7f 81 7f 81 7f 81 7f 81 81 81 81 7f 7f 7f 7f 7f 81 7f 81 7f 81 7f 7f 7f 81 7f 7f 7f 7f 7f 7f 81 81 7f 81 7f 7f 7f 81 81 7f 81 7f 81 7f 81 7f 81 81 81 81 81 7f 81 7f 81 81 81 7f 81 7f 81 7f 81 7f 81 81 81 7f 81 81 81 81 81 81 7f 7f 81 81 81 7f 81 7f 7f 81 81 7f 81 7f 7f 7f 7f 81 81 81 81 81 7f 81 81 81
7f 81 7f 81 81 81 81 7f 7f 81 7f 81 81 81 7f 7f 81 81 81 81 81 81 7f 7f 81 7f 81 81 81 7f 7f 7f 81 7f 81 7f 81 7f 7f 81 81 7f 7f 7f 7f 7f 81 7f 81 7f 7f 7f 7f 7f 81 7f 7f 7f 81 7f 81 7f 81 81 81 81 7f 81 81 81 7f 81 7f 81 81 81 81 81 81 7f 7f 81 81 81 81 7f 81 7f 81 81 81 81 81 7f 81 81 81 7f 81 7f 7f 7f 81 81 7f 7f 7f 81 7f 81 81 81 81 81 81 81
7f 81 81 81 81 7f 81 7f 7f 81 81 7f 7f 7f 7f 7f 81 81 81 81 7f 81 7f 7f 81 81 81 81 81 81 81 7f 81 81 81 81 81 81 81 81 81 81 81 81 81 7f 81 7f 81 7f 81 81 81 7f 7f 7f 7f 81 7f 7f 7f 81 7f 81 7f 81 7f 81 7f 81 7f 81 7f 81 7f 81 7f 81 7f 81 7f 81 7f 81 81 81 7f 81 7f 81 81 7f 81 81 7f 7f 7f 7f 7f 7f 7f 81 7f 7f 7f 7f 7f 81 7f 81 7f 7f 81 7f 81 81
Decoded: a3 af 5f c6 36 43 44 ab d9 6d 7d 62 24 c9 d2 92 fa 27 5d 71 7a 59 a8 42 a3 af 5f c6 36 43 44 ab a3 2f 5f c6 36 43 44 03 d9 6d 7d 62 24 c9 d2 92 fa 27 5d 71 7a 28
81 7f 7f 7f 81 7f 81 7f 7f 81 7f 81 81 81 81 81 7f 81 81 81 7f 81 7f 81 7f 81 81 7f 7f 81 7f 81 7f 81 7f 7f 7f 7f 7f 81 7f 81 7f 7f 81 7f 7f 81 7f 81 81 7f 81 81 7f 7f 7f 7f 7f 7f 7f 81 7f 81 7f 7f 7f 81 7f 7f 7f 7f 7f 81 81 7f 7f 7f 7f 7f 81 81 81 7f 7f 81 7f 81 81 7f 81 7f 81 81 81 81 81 7f 81 7f 81 81 81 7f 81 7f 81 7f 7f 81 81 7f 81 7f 81 7f
7f 81 7f 81 7f 81 7f 7f 7f 7f 7f 7f 7f 7f 81 7f 81 7f 81 7f 81 7f 81 81 81 81 7f 7f 7f 7f 7f 81 7f 81 7f 81 7f 7f 7f 81 7f 7f 7f 7f 7f 7f 81 81 7f 81 7f 7f 7f 81 81 7f 81 7f 81 7f 81 7f 81 81 81 7f 81 7f 81 7f 81 81 81 7f 81 7f 81 7f 81 7f 81 81 81 7f 81 81 81 81 81 81 7f 7f 81 81 81 7f 81 7f 7f 81 81 7f 81 7f 7f 7f 7f 81 81 81 81 81 7f 81 81 81
7f 81 7f 81 81 81 81 7f 7f 81 7f 81 81 81 7f 7f 81 81 81 81 81 81 7f 7f 81 7f 81 81 81 81 7f 7f 81 7f 81 7f 81 7f 7f 81 81 7f 7f 7f 7f 7f 81 81 81 7f 7f 7f 7f 7f 81 7f 7f 7f 81 7f 81 7f 81 81 81 81 7f 81 81 81 7f 81 7f 81 81 81 81 81 81 7f 7f 81 81 81 81 7f 81 7f 81 81 81 81 81 7f 81 81 81 7f 81 7f 7f 7f 81 81 7f 7f 7f 81 7f 81 81 81 81 81 81 81
7f 81 81 81 81 7f 81 7f 7f 81 81 7f 7f 7f 7f 7f 81 7f 81 81 7f 81 7f 7f 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 81 7f 81 7f 81 7f 81 81 81 7f 7f 7f 7f 81 7f 7f 7f 81 7f 81 7f 81 7f 81 7f 81 7f 81 7f 81 7f 81 7f 81 7f 81 7f 81 81 81 81 81 7f 81 7f 81 81 7f 81 81 7f 7f 81 7f 7f 7f 7f 81 7f 7f 7f 7f 7f 81 7f 81 7f 7f 81 7f 81 81
Decoded: a3 af 5f c6 36 43 44 ab d9 6d 7d 62 24 c9 d2 92 fa 27 5d 71 7a 59 a8 42 a3 af 5f c6 36 43 44 ab a3 af 5f c6 36 43 44 ab d9 6d 7d 62 24 c9 d2 92 fa 27 5d 71 7a 28
pdtch_decode: n_errors=0 n_bits_total=444 ber=0.00
Encoding: 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17