aboutsummaryrefslogtreecommitdiffstats
path: root/tests/amr/amr_test.c
diff options
context:
space:
mode:
authorneels <nhofmeyr@sysmocom.de>2020-05-14 23:22:54 +0000
committerneels <nhofmeyr@sysmocom.de>2020-05-14 23:22:54 +0000
commit8b77ad940a68e98f789d810bc30bdc2c6af01cbc (patch)
tree75970c959ab43fd5ac917a531c0c28ffe69084e1 /tests/amr/amr_test.c
parent002a51e2180cf19bf5e11e16d78271998d0b3f5c (diff)
Revert "amr: Fix OA<->BWE conversion."
This reverts commit 002a51e2180cf19bf5e11e16d78271998d0b3f5c. Reason for revert: amr_test fails with sanitizer build: Sample No.: 6 bw-efficient: a7bfc03fc03fc03fc03fc03fc03fc03fc03fc03fc03fc03fc03fc03fc03fc03f 1010011110111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111 ../../../src/libosmo-netif/src/amr.c:63:24: runtime error: index 15 out of bounds for type 'size_t [9]' ../../../src/libosmo-netif/src/amr.c:63:24: runtime error: load of address 0x7f69498e56b8 with insufficient space for an object of type 'size_t' 0x7f69498e56b8: note: pointer points here 00 00 00 00 00 00 00 00 00 00 00 00 5f 00 00 00 00 00 00 00 67 00 00 00 00 00 00 00 76 00 00 00 ^ ================================================================= ==489935==ERROR: AddressSanitizer: global-buffer-overflow on address 0x7f69498e56b8 at pc 0x7f69498abec7 bp 0x7ffeafb35330 sp 0x7ffeafb35328 READ of size 8 at 0x7f69498e56b8 thread T0 #0 0x7f69498abec6 in osmo_amr_bytes ../../../src/libosmo-netif/src/amr.c:63 #1 0x7f69498ac661 in osmo_amr_bwe_to_oa ../../../src/libosmo-netif/src/amr.c:193 #2 0x5648b11afb96 in osmo_amr_bwe_to_oa_test ../../../src/libosmo-netif/tests/amr/amr_test.c:134 #3 0x5648b11af31d in main ../../../src/libosmo-netif/tests/amr/amr_test.c:235 #4 0x7f6948d5de0a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x26e0a) #5 0x5648b11af3d9 in _start (/n/s/dev/make/libosmo-netif/tests/amr/amr_test+0x43d9) 0x7f69498e56b8 is located 8 bytes to the left of global variable 'amr_ft_to_bits' defined in '../../../src/libosmo-netif/src/amr.c:32:15' (0x7f69498e56c0) of size 72 0x7f69498e56b8 is located 48 bytes to the right of global variable 'amr_ft_to_bytes' defined in '../../../src/libosmo-netif/src/amr.c:44:15' (0x7f69498e5640) of size 72 SUMMARY: AddressSanitizer: global-buffer-overflow ../../../src/libosmo-netif/src/amr.c:63 in osmo_amr_bytes Change-Id: I8232521c513722435e71dc90bdbfee10f8f83496
Diffstat (limited to 'tests/amr/amr_test.c')
-rw-r--r--tests/amr/amr_test.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/tests/amr/amr_test.c b/tests/amr/amr_test.c
index af10289..fff686c 100644
--- a/tests/amr/amr_test.c
+++ b/tests/amr/amr_test.c
@@ -44,9 +44,6 @@ char *oa_amr_samples[] = {
"100c4e9ba850e30d5d53d04de41e7c",
"100c6c18e7b7fff53aeb055e7d1c54",
"100c1fb967f7f1fdf547bf2e61c060",
- "0004f89d67f1160935bde1996840",
- "0004633cc7f0630439ffe0000000",
- "0004eb81fc0758973b9edc782552",
"a038ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00fc", /* test pattern */
"END",
};
@@ -90,6 +87,7 @@ void osmo_amr_oa_to_bwe_test(void)
return;
printf("\n");
printf("Sample No.: %i\n", i);
+ len = strlen(oa_amr_samples[i]);
len = osmo_hexparse(oa_amr_samples[i], buf, sizeof(buf));
OSMO_ASSERT(len > 0);
@@ -104,6 +102,11 @@ void osmo_amr_oa_to_bwe_test(void)
dump_bits(buf, rc);
printf("\n");
printf(" rc: %i\n", rc);
+
+ if (rc > 0) {
+ OSMO_ASSERT(rc == len - 1);
+ OSMO_ASSERT(buf[len - 1] == 0x00);
+ }
i++;
}
}
@@ -123,6 +126,7 @@ void osmo_amr_bwe_to_oa_test(void)
return;
printf("\n");
printf("Sample No.: %i\n", i);
+ len = strlen(bwe_amr_samples[i]);
len = osmo_hexparse(bwe_amr_samples[i], buf, sizeof(buf));
OSMO_ASSERT(len > 0);
@@ -138,6 +142,7 @@ void osmo_amr_bwe_to_oa_test(void)
printf("\n");
printf(" rc: %i\n", rc);
+ OSMO_ASSERT(rc == len + 1);
i++;
}
}
@@ -146,8 +151,6 @@ void osmo_amr_oa_to_bwe_and_inverse_test(void)
{
uint8_t buf[256];
uint8_t buf_chk[256];
- struct amr_hdr *oa_hd = (struct amr_hdr *)buf;
- unsigned int ft;
unsigned int i = 0;
int len;
@@ -160,21 +163,16 @@ void osmo_amr_oa_to_bwe_and_inverse_test(void)
while (1) {
if (strcmp(oa_amr_samples[i], "END") == 0)
return;
- printf("Sample No.: %i...", i);
+ printf("Sample No.: %i...\n", i);
+ len = strlen(oa_amr_samples[i]);
len = osmo_hexparse(oa_amr_samples[i], buf, sizeof(buf));
OSMO_ASSERT(len > 0);
- ft = oa_hd->ft;
- OSMO_ASSERT(osmo_amr_bytes(ft) + 2 == len);
- printf(" AMR mode: %d, OA: %d bytes,", ft, len);
memcpy(buf_chk, buf, sizeof(buf));
rc = osmo_amr_oa_to_bwe(buf, len);
OSMO_ASSERT(rc > 0);
- printf(" BE: %d bytes,", rc);
rc = osmo_amr_bwe_to_oa(buf, rc, sizeof(buf));
- printf(" OA: %d bytes\n", rc);
- OSMO_ASSERT(len == rc);
OSMO_ASSERT(memcmp(buf, buf_chk, len) == 0);
i++;
}