aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2013-02-15 13:31:10 +0100
committerHarald Welte <laforge@gnumonks.org>2015-09-22 16:41:26 +0200
commit450d32919ada7b037b41d89ea8dd181924ed48e9 (patch)
tree3be00cea59d415e1d102d935a3270e7d90e4f26a
parent78b2080027d398c7242ae6e180b462e32f57a786 (diff)
TRX: Add test code for PDTCH transcoding
-rw-r--r--tests/bursts/Makefile.am7
-rw-r--r--tests/bursts/bursts_test.c88
2 files changed, 94 insertions, 1 deletions
diff --git a/tests/bursts/Makefile.am b/tests/bursts/Makefile.am
index fd6c41f7..09275188 100644
--- a/tests/bursts/Makefile.am
+++ b/tests/bursts/Makefile.am
@@ -4,5 +4,10 @@ LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS)
noinst_PROGRAMS = bursts_test
EXTRA_DIST = bursts_test.ok
-bursts_test_SOURCES = bursts_test.c $(top_builddir)/src/osmo-bts-trx/xcch.c $(top_builddir)/src/osmo-bts-trx/rach.c $(top_builddir)/src/osmo-bts-trx/sch.c $(top_builddir)/src/osmo-bts-trx/tch_fr.c
+bursts_test_SOURCES = bursts_test.c \
+ $(top_builddir)/src/osmo-bts-trx/xcch.c \
+ $(top_builddir)/src/osmo-bts-trx/rach.c \
+ $(top_builddir)/src/osmo-bts-trx/sch.c \
+ $(top_builddir)/src/osmo-bts-trx/tch_fr.c \
+ $(top_builddir)/src/osmo-bts-trx/pxxch.c
bursts_test_LDADD = $(LDADD)
diff --git a/tests/bursts/bursts_test.c b/tests/bursts/bursts_test.c
index 9fc7df04..ad1f6859 100644
--- a/tests/bursts/bursts_test.c
+++ b/tests/bursts/bursts_test.c
@@ -30,6 +30,7 @@
#include "../../src/osmo-bts-trx/rach.h"
#include "../../src/osmo-bts-trx/sch.h"
#include "../../src/osmo-bts-trx/tch_fr.h"
+#include "../../src/osmo-bts-trx/pxxch.h"
#define ASSERT_TRUE(rc) \
@@ -257,6 +258,71 @@ static void test_fr(uint8_t *speech, int len)
printd("\n");
}
+static void test_pdtch(uint8_t *l2, int len)
+{
+ uint8_t result[len];
+ ubit_t bursts_u[116 * 4];
+ sbit_t bursts_s[116 * 4];
+ int rc;
+
+ /* zero the not coded tail bits */
+ switch (len) {
+ case 34:
+ case 54:
+ l2[len - 1] &= 0x7f;
+ result[len - 1] &= 0x7f;
+ break;
+ case 40:
+ l2[len - 1] &= 0x07;
+ result[len - 1] &= 0x07;
+ break;
+ }
+
+ printd("Encoding: %s\n", osmo_hexdump(l2, len));
+
+ /* encode */
+ pdtch_encode(bursts_u, l2, len);
+
+ printd("U-Bits:\n");
+ printd("%s %02x %02x ", osmo_hexdump(bursts_u, 57),
+ bursts_u[57], bursts_u[58]);
+ printd("%s\n", osmo_hexdump(bursts_u + 59, 57));
+ printd("%s %02x %02x ", osmo_hexdump(bursts_u + 116, 57),
+ bursts_u[57 + 116], bursts_u[58 + 116]);
+ printd("%s\n", osmo_hexdump(bursts_u + 59 + 116, 57));
+ printd("%s %02x %02x ", osmo_hexdump(bursts_u + 232, 57),
+ bursts_u[57 + 232], bursts_u[58 + 232]);
+ printd("%s\n", osmo_hexdump(bursts_u + 59 + 232, 57));
+ printd("%s %02x %02x ", osmo_hexdump(bursts_u + 348, 57),
+ bursts_u[57 + 348], bursts_u[58 + 348]);
+ printd("%s\n", osmo_hexdump(bursts_u + 59 + 348, 57));
+ ubits2sbits(bursts_u, bursts_s, 116 * 4);
+ printd("S-Bits:\n");
+ printd("%s %02x %02x ", osmo_hexdump((uint8_t *)bursts_s, 57),
+ (uint8_t)bursts_s[57], (uint8_t)bursts_s[58]);
+ printd("%s\n", osmo_hexdump((uint8_t *)bursts_s + 59, 57));
+ printd("%s %02x %02x ", osmo_hexdump((uint8_t *)bursts_s + 116, 57),
+ (uint8_t)bursts_s[57 + 116], (uint8_t)bursts_s[58 + 116]);
+ printd("%s\n", osmo_hexdump((uint8_t *)bursts_s + 59 + 116, 57));
+ printd("%s %02x %02x ", osmo_hexdump((uint8_t *)bursts_s + 232, 57),
+ (uint8_t)bursts_s[57 + 232], (uint8_t)bursts_s[58 + 232]);
+ printd("%s\n", osmo_hexdump((uint8_t *)bursts_s + 59 + 232, 57));
+ printd("%s %02x %02x ", osmo_hexdump((uint8_t *)bursts_s + 348, 57),
+ (uint8_t)bursts_s[57 + 348], (uint8_t)bursts_s[58 + 348]);
+ printd("%s\n", osmo_hexdump((uint8_t *)bursts_s + 59 + 348, 57));
+
+ /* decode */
+ rc = pdtch_decode(result, bursts_s, NULL);
+
+ ASSERT_TRUE(rc == len);
+
+ printd("Decoded: %s\n", osmo_hexdump(result, len));
+
+ ASSERT_TRUE(!memcmp(l2, result, len));
+
+ printd("\n");
+}
+
uint8_t test_l2[][23] = {
/* dummy frame */
{ 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -272,6 +338,21 @@ uint8_t test_l2[][23] = {
0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 },
};
+uint8_t test_macblock[][54] = {
+ /* random frame */
+ { 0xa3, 0xaf, 0x5f, 0xc6, 0x36, 0x43, 0x44, 0xab,
+ 0xd9, 0x6d, 0x7d, 0x62, 0x24, 0xc9, 0xd2, 0x92,
+ 0xfa, 0x27, 0x5d, 0x71, 0x7a, 0x59, 0xa8, 0x42,
+ 0xa3, 0xaf, 0x5f, 0xc6, 0x36, 0x43, 0x44, 0xab,
+ 0xa3, 0xaf, 0x5f, 0xc6, 0x36, 0x43, 0x44, 0xab,
+ 0xd9, 0x6d, 0x7d, 0x62, 0x24, 0xc9, 0xd2, 0x92,
+ 0xfa, 0x27, 0x5d, 0x71, 0x7a, 0xa8 },
+ /* jolly frame */
+ { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
+ 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 },
+};
+
uint8_t test_speech[33];
int main(int argc, char **argv)
@@ -297,6 +378,13 @@ int main(int argc, char **argv)
for (i = 0; i < sizeof(test_l2) / sizeof(test_l2[0]); i++)
test_fr(test_l2[i], sizeof(test_l2[0]));
+ for (i = 0; i < sizeof(test_macblock) / sizeof(test_macblock[0]); i++) {
+ test_pdtch(test_macblock[i], 23);
+ test_pdtch(test_macblock[i], 34);
+ test_pdtch(test_macblock[i], 40);
+ test_pdtch(test_macblock[i], 54);
+ }
+
printf("Success\n");
return 0;