[PATCH] libosmocore[master]: tests/conv: separate both test codes and vectors

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Vadim Yanitskiy gerrit-no-reply at lists.osmocom.org
Sun Jan 8 15:48:05 UTC 2017


Review at  https://gerrit.osmocom.org/1542

tests/conv: separate both test codes and vectors

Before adding new test vectors, it would be better to separate
non GSM related convolutional code definitions and existing
test vectors from the test logic.

This change introduces the following new files:

 - conv_codes.c - the codes, which aren't preset in libosmocore;
 - conv_test_vectors.c - contains the test vectors array;
 - conv_test.h - header file, which makes separated codes and
     vectors accessible from the 'conv_test.c'.

Change-Id: Iffee60ad19d38bcfdce2e5f47a4e886f6f74e271
---
M tests/Makefile.am
A tests/conv/conv_codes.c
M tests/conv/conv_test.c
A tests/conv/conv_test.h
A tests/conv/conv_test_vectors.c
5 files changed, 262 insertions(+), 221 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/42/1542/1

diff --git a/tests/Makefile.am b/tests/Makefile.am
index b9eb8f2..b9be650 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -54,7 +54,7 @@
 bits_bitcomp_test_SOURCES = bits/bitcomp_test.c
 bits_bitcomp_test_LDADD = $(top_builddir)/src/libosmocore.la
 
-conv_conv_test_SOURCES = conv/conv_test.c
+conv_conv_test_SOURCES = conv/conv_test.c conv/conv_codes.c conv/conv_test_vectors.c
 conv_conv_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libgsmint.la
 
 gsm0808_gsm0808_test_SOURCES = gsm0808/gsm0808_test.c
@@ -178,6 +178,8 @@
 	     oap/oap_test.ok fsm/fsm_test.ok fsm/fsm_test.err		\
 	     write_queue/wqueue_test.ok
 
+EXTRA_DIST += conv/conv_test.h
+
 DISTCLEANFILES = atconfig atlocal
 
 TESTSUITE = $(srcdir)/testsuite
diff --git a/tests/conv/conv_codes.c b/tests/conv/conv_codes.c
new file mode 100644
index 0000000..8bcf05f
--- /dev/null
+++ b/tests/conv/conv_codes.c
@@ -0,0 +1,141 @@
+#include <osmocom/core/conv.h>
+#include <osmocom/gsm/gsm0503.h>
+
+#include "conv_test.h"
+
+static const uint8_t xcch_state[][2] = {
+	{  0,  1 }, {  2,  3 }, {  4,  5 }, {  6,  7 },
+	{  8,  9 }, { 10, 11 }, { 12, 13 }, { 14, 15 },
+	{  0,  1 }, {  2,  3 }, {  4,  5 }, {  6,  7 },
+	{  8,  9 }, { 10, 11 }, { 12, 13 }, { 14, 15 },
+};
+
+static const uint8_t xcch_output[][2] = {
+	{  0,  3 }, {  1,  2 }, {  0,  3 }, {  1,  2 },
+	{  3,  0 }, {  2,  1 }, {  3,  0 }, {  2,  1 },
+	{  3,  0 }, {  2,  1 }, {  3,  0 }, {  2,  1 },
+	{  0,  3 }, {  1,  2 }, {  0,  3 }, {  1,  2 },
+};
+
+/**
+ * Random code
+ * Non recursive code, direct truncation, non-punctured
+ */
+const struct osmo_conv_code conv_trunc = {
+	.N = 2,
+	.K = 5,
+	.len = 224,
+	.term = CONV_TERM_TRUNCATION,
+	.next_output = xcch_output,
+	.next_state  = xcch_state,
+};
+
+/**
+ * GMR-1 TCH3 Speech
+ * Non recursive code, tail-biting, punctured
+ */
+static const uint8_t conv_gmr1_tch3_speech_next_output[][2] = {
+	{  0,  3 }, {  1,  2 }, {  3,  0 }, {  2,  1 },
+	{  3,  0 }, {  2,  1 }, {  0,  3 }, {  1,  2 },
+	{  0,  3 }, {  1,  2 }, {  3,  0 }, {  2,  1 },
+	{  3,  0 }, {  2,  1 }, {  0,  3 }, {  1,  2 },
+	{  2,  1 }, {  3,  0 }, {  1,  2 }, {  0,  3 },
+	{  1,  2 }, {  0,  3 }, {  2,  1 }, {  3,  0 },
+	{  2,  1 }, {  3,  0 }, {  1,  2 }, {  0,  3 },
+	{  1,  2 }, {  0,  3 }, {  2,  1 }, {  3,  0 },
+	{  3,  0 }, {  2,  1 }, {  0,  3 }, {  1,  2 },
+	{  0,  3 }, {  1,  2 }, {  3,  0 }, {  2,  1 },
+	{  3,  0 }, {  2,  1 }, {  0,  3 }, {  1,  2 },
+	{  0,  3 }, {  1,  2 }, {  3,  0 }, {  2,  1 },
+	{  1,  2 }, {  0,  3 }, {  2,  1 }, {  3,  0 },
+	{  2,  1 }, {  3,  0 }, {  1,  2 }, {  0,  3 },
+	{  1,  2 }, {  0,  3 }, {  2,  1 }, {  3,  0 },
+	{  2,  1 }, {  3,  0 }, {  1,  2 }, {  0,  3 },
+};
+
+static const uint8_t conv_gmr1_tch3_speech_next_state[][2] = {
+	{  0,  1 }, {  2,  3 }, {  4,  5 }, {  6,  7 },
+	{  8,  9 }, { 10, 11 }, { 12, 13 }, { 14, 15 },
+	{ 16, 17 }, { 18, 19 }, { 20, 21 }, { 22, 23 },
+	{ 24, 25 }, { 26, 27 }, { 28, 29 }, { 30, 31 },
+	{ 32, 33 }, { 34, 35 }, { 36, 37 }, { 38, 39 },
+	{ 40, 41 }, { 42, 43 }, { 44, 45 }, { 46, 47 },
+	{ 48, 49 }, { 50, 51 }, { 52, 53 }, { 54, 55 },
+	{ 56, 57 }, { 58, 59 }, { 60, 61 }, { 62, 63 },
+	{  0,  1 }, {  2,  3 }, {  4,  5 }, {  6,  7 },
+	{  8,  9 }, { 10, 11 }, { 12, 13 }, { 14, 15 },
+	{ 16, 17 }, { 18, 19 }, { 20, 21 }, { 22, 23 },
+	{ 24, 25 }, { 26, 27 }, { 28, 29 }, { 30, 31 },
+	{ 32, 33 }, { 34, 35 }, { 36, 37 }, { 38, 39 },
+	{ 40, 41 }, { 42, 43 }, { 44, 45 }, { 46, 47 },
+	{ 48, 49 }, { 50, 51 }, { 52, 53 }, { 54, 55 },
+	{ 56, 57 }, { 58, 59 }, { 60, 61 }, { 62, 63 },
+};
+
+static const int conv_gmr1_tch3_speech_puncture[] = {
+	 3,  7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47,
+	51, 55, 59, 63, 67, 71, 75, 79, 83, 87, 91, 95,
+	-1,
+};
+
+const struct osmo_conv_code conv_gmr1_tch3_speech = {
+	.N = 2,
+	.K = 7,
+	.len = 48,
+	.term = CONV_TERM_TAIL_BITING,
+	.next_output = conv_gmr1_tch3_speech_next_output,
+	.next_state  = conv_gmr1_tch3_speech_next_state,
+	.puncture = conv_gmr1_tch3_speech_puncture,
+};
+
+
+/**
+ * WiMax FCH
+ * Non recursive code, tail-biting, non-punctured
+ */
+static const uint8_t conv_wimax_fch_next_output[][2] = {
+	{  0,  3 }, {  2,  1 }, {  3,  0 }, {  1,  2 },
+	{  3,  0 }, {  1,  2 }, {  0,  3 }, {  2,  1 },
+	{  0,  3 }, {  2,  1 }, {  3,  0 }, {  1,  2 },
+	{  3,  0 }, {  1,  2 }, {  0,  3 }, {  2,  1 },
+	{  1,  2 }, {  3,  0 }, {  2,  1 }, {  0,  3 },
+	{  2,  1 }, {  0,  3 }, {  1,  2 }, {  3,  0 },
+	{  1,  2 }, {  3,  0 }, {  2,  1 }, {  0,  3 },
+	{  2,  1 }, {  0,  3 }, {  1,  2 }, {  3,  0 },
+	{  3,  0 }, {  1,  2 }, {  0,  3 }, {  2,  1 },
+	{  0,  3 }, {  2,  1 }, {  3,  0 }, {  1,  2 },
+	{  3,  0 }, {  1,  2 }, {  0,  3 }, {  2,  1 },
+	{  0,  3 }, {  2,  1 }, {  3,  0 }, {  1,  2 },
+	{  2,  1 }, {  0,  3 }, {  1,  2 }, {  3,  0 },
+	{  1,  2 }, {  3,  0 }, {  2,  1 }, {  0,  3 },
+	{  2,  1 }, {  0,  3 }, {  1,  2 }, {  3,  0 },
+	{  1,  2 }, {  3,  0 }, {  2,  1 }, {  0,  3 },
+};
+
+static const uint8_t conv_wimax_fch_next_state[][2] = {
+	{  0,  1 }, {  2,  3 }, {  4,  5 }, {  6,  7 },
+	{  8,  9 }, { 10, 11 }, { 12, 13 }, { 14, 15 },
+	{ 16, 17 }, { 18, 19 }, { 20, 21 }, { 22, 23 },
+	{ 24, 25 }, { 26, 27 }, { 28, 29 }, { 30, 31 },
+	{ 32, 33 }, { 34, 35 }, { 36, 37 }, { 38, 39 },
+	{ 40, 41 }, { 42, 43 }, { 44, 45 }, { 46, 47 },
+	{ 48, 49 }, { 50, 51 }, { 52, 53 }, { 54, 55 },
+	{ 56, 57 }, { 58, 59 }, { 60, 61 }, { 62, 63 },
+	{  0,  1 }, {  2,  3 }, {  4,  5 }, {  6,  7 },
+	{  8,  9 }, { 10, 11 }, { 12, 13 }, { 14, 15 },
+	{ 16, 17 }, { 18, 19 }, { 20, 21 }, { 22, 23 },
+	{ 24, 25 }, { 26, 27 }, { 28, 29 }, { 30, 31 },
+	{ 32, 33 }, { 34, 35 }, { 36, 37 }, { 38, 39 },
+	{ 40, 41 }, { 42, 43 }, { 44, 45 }, { 46, 47 },
+	{ 48, 49 }, { 50, 51 }, { 52, 53 }, { 54, 55 },
+	{ 56, 57 }, { 58, 59 }, { 60, 61 }, { 62, 63 },
+};
+
+const struct osmo_conv_code conv_wimax_fch = {
+	.N = 2,
+	.K = 7,
+	.len = 48,
+	.term = CONV_TERM_TAIL_BITING,
+	.next_output = conv_wimax_fch_next_output,
+	.next_state  = conv_wimax_fch_next_state,
+};
diff --git a/tests/conv/conv_test.c b/tests/conv/conv_test.c
index 608f829..55f4c0e 100644
--- a/tests/conv/conv_test.c
+++ b/tests/conv/conv_test.c
@@ -8,135 +8,7 @@
 #include <osmocom/core/utils.h>
 #include <osmocom/gsm/gsm0503.h>
 
-#define MAX_LEN_BITS	512
-#define MAX_LEN_BYTES	(512/8)
-
-
-/* ------------------------------------------------------------------------ */
-/* Test codes                                                               */
-/* ------------------------------------------------------------------------ */
-
-/* GMR-1 TCH3 Speech -> Non recursive code, tail-biting, punctured */
-static const uint8_t conv_gmr1_tch3_speech_next_output[][2] = {
-	{  0,  3 }, {  1,  2 }, {  3,  0 }, {  2,  1 },
-	{  3,  0 }, {  2,  1 }, {  0,  3 }, {  1,  2 },
-	{  0,  3 }, {  1,  2 }, {  3,  0 }, {  2,  1 },
-	{  3,  0 }, {  2,  1 }, {  0,  3 }, {  1,  2 },
-	{  2,  1 }, {  3,  0 }, {  1,  2 }, {  0,  3 },
-	{  1,  2 }, {  0,  3 }, {  2,  1 }, {  3,  0 },
-	{  2,  1 }, {  3,  0 }, {  1,  2 }, {  0,  3 },
-	{  1,  2 }, {  0,  3 }, {  2,  1 }, {  3,  0 },
-	{  3,  0 }, {  2,  1 }, {  0,  3 }, {  1,  2 },
-	{  0,  3 }, {  1,  2 }, {  3,  0 }, {  2,  1 },
-	{  3,  0 }, {  2,  1 }, {  0,  3 }, {  1,  2 },
-	{  0,  3 }, {  1,  2 }, {  3,  0 }, {  2,  1 },
-	{  1,  2 }, {  0,  3 }, {  2,  1 }, {  3,  0 },
-	{  2,  1 }, {  3,  0 }, {  1,  2 }, {  0,  3 },
-	{  1,  2 }, {  0,  3 }, {  2,  1 }, {  3,  0 },
-	{  2,  1 }, {  3,  0 }, {  1,  2 }, {  0,  3 },
-};
-
-static const uint8_t conv_gmr1_tch3_speech_next_state[][2] = {
-	{  0,  1 }, {  2,  3 }, {  4,  5 }, {  6,  7 },
-	{  8,  9 }, { 10, 11 }, { 12, 13 }, { 14, 15 },
-	{ 16, 17 }, { 18, 19 }, { 20, 21 }, { 22, 23 },
-	{ 24, 25 }, { 26, 27 }, { 28, 29 }, { 30, 31 },
-	{ 32, 33 }, { 34, 35 }, { 36, 37 }, { 38, 39 },
-	{ 40, 41 }, { 42, 43 }, { 44, 45 }, { 46, 47 },
-	{ 48, 49 }, { 50, 51 }, { 52, 53 }, { 54, 55 },
-	{ 56, 57 }, { 58, 59 }, { 60, 61 }, { 62, 63 },
-	{  0,  1 }, {  2,  3 }, {  4,  5 }, {  6,  7 },
-	{  8,  9 }, { 10, 11 }, { 12, 13 }, { 14, 15 },
-	{ 16, 17 }, { 18, 19 }, { 20, 21 }, { 22, 23 },
-	{ 24, 25 }, { 26, 27 }, { 28, 29 }, { 30, 31 },
-	{ 32, 33 }, { 34, 35 }, { 36, 37 }, { 38, 39 },
-	{ 40, 41 }, { 42, 43 }, { 44, 45 }, { 46, 47 },
-	{ 48, 49 }, { 50, 51 }, { 52, 53 }, { 54, 55 },
-	{ 56, 57 }, { 58, 59 }, { 60, 61 }, { 62, 63 },
-};
-
-static const int conv_gmr1_tch3_speech_puncture[] = {
-	 3,  7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47,
-	51, 55, 59, 63, 67, 71, 75, 79, 83, 87, 91, 95,
-	-1, /* end */
-};
-
-static const struct osmo_conv_code conv_gmr1_tch3_speech = {
-	.N = 2,
-	.K = 7,
-	.len = 48,
-	.term = CONV_TERM_TAIL_BITING,
-	.next_output = conv_gmr1_tch3_speech_next_output,
-	.next_state  = conv_gmr1_tch3_speech_next_state,
-	.puncture = conv_gmr1_tch3_speech_puncture,
-};
-
-
-/* WiMax FCH -> Non recursive code, tail-biting, non-punctured */
-static const uint8_t conv_wimax_fch_next_output[][2] = {
-	{  0,  3 }, {  2,  1 }, {  3,  0 }, {  1,  2 },
-	{  3,  0 }, {  1,  2 }, {  0,  3 }, {  2,  1 },
-	{  0,  3 }, {  2,  1 }, {  3,  0 }, {  1,  2 },
-	{  3,  0 }, {  1,  2 }, {  0,  3 }, {  2,  1 },
-	{  1,  2 }, {  3,  0 }, {  2,  1 }, {  0,  3 },
-	{  2,  1 }, {  0,  3 }, {  1,  2 }, {  3,  0 },
-	{  1,  2 }, {  3,  0 }, {  2,  1 }, {  0,  3 },
-	{  2,  1 }, {  0,  3 }, {  1,  2 }, {  3,  0 },
-	{  3,  0 }, {  1,  2 }, {  0,  3 }, {  2,  1 },
-	{  0,  3 }, {  2,  1 }, {  3,  0 }, {  1,  2 },
-	{  3,  0 }, {  1,  2 }, {  0,  3 }, {  2,  1 },
-	{  0,  3 }, {  2,  1 }, {  3,  0 }, {  1,  2 },
-	{  2,  1 }, {  0,  3 }, {  1,  2 }, {  3,  0 },
-	{  1,  2 }, {  3,  0 }, {  2,  1 }, {  0,  3 },
-	{  2,  1 }, {  0,  3 }, {  1,  2 }, {  3,  0 },
-	{  1,  2 }, {  3,  0 }, {  2,  1 }, {  0,  3 },
-};
-
-static const uint8_t conv_wimax_fch_next_state[][2] = {
-	{  0,  1 }, {  2,  3 }, {  4,  5 }, {  6,  7 },
-	{  8,  9 }, { 10, 11 }, { 12, 13 }, { 14, 15 },
-	{ 16, 17 }, { 18, 19 }, { 20, 21 }, { 22, 23 },
-	{ 24, 25 }, { 26, 27 }, { 28, 29 }, { 30, 31 },
-	{ 32, 33 }, { 34, 35 }, { 36, 37 }, { 38, 39 },
-	{ 40, 41 }, { 42, 43 }, { 44, 45 }, { 46, 47 },
-	{ 48, 49 }, { 50, 51 }, { 52, 53 }, { 54, 55 },
-	{ 56, 57 }, { 58, 59 }, { 60, 61 }, { 62, 63 },
-	{  0,  1 }, {  2,  3 }, {  4,  5 }, {  6,  7 },
-	{  8,  9 }, { 10, 11 }, { 12, 13 }, { 14, 15 },
-	{ 16, 17 }, { 18, 19 }, { 20, 21 }, { 22, 23 },
-	{ 24, 25 }, { 26, 27 }, { 28, 29 }, { 30, 31 },
-	{ 32, 33 }, { 34, 35 }, { 36, 37 }, { 38, 39 },
-	{ 40, 41 }, { 42, 43 }, { 44, 45 }, { 46, 47 },
-	{ 48, 49 }, { 50, 51 }, { 52, 53 }, { 54, 55 },
-	{ 56, 57 }, { 58, 59 }, { 60, 61 }, { 62, 63 },
-};
-
-static const struct osmo_conv_code conv_wimax_fch = {
-	.N = 2,
-	.K = 7,
-	.len = 48,
-	.term = CONV_TERM_TAIL_BITING,
-	.next_output = conv_wimax_fch_next_output,
-	.next_state  = conv_wimax_fch_next_state,
-};
-
-/* ------------------------------------------------------------------------ */
-/* Test vectors                                                             */
-/* ------------------------------------------------------------------------ */
-
-struct conv_test_vector {
-	const char *name;
-	const struct osmo_conv_code *code;
-	int in_len;
-	int out_len;
-	int has_vec;
-	pbit_t vec_in[MAX_LEN_BYTES];
-	pbit_t vec_out[MAX_LEN_BYTES];
-};
-
-/* ------------------------------------------------------------------------ */
-/* Main                                                                     */
-/* ------------------------------------------------------------------------ */
+#include "conv_test.h"
 
 static void
 fill_random(ubit_t *b, int n)
@@ -151,94 +23,7 @@
 	const struct conv_test_vector *tst;
 	ubit_t *bu0, *bu1;
 	sbit_t *bs;
-
-/* Random code -> Non recursive code, direct truncation, non-punctured */
-	const struct osmo_conv_code conv_trunc = {
-		.N = 2,
-		.K = 5,
-		.len = 224,
-		.term = CONV_TERM_TRUNCATION,
-		.next_output = gsm0503_xcch.next_output,
-		.next_state  = gsm0503_xcch.next_state,
-	};
-
-	const struct conv_test_vector tests[] = {
-		{
-			.name = "GSM xCCH (non-recursive, flushed, not punctured)",
-			.code = &gsm0503_xcch,
-			.in_len  = 224,
-			.out_len = 456,
-			.has_vec = 1,
-			.vec_in  = { 0xf3, 0x1d, 0xb4, 0x0c, 0x4d, 0x1d, 0x9d, 0xae,
-						 0xc0, 0x0a, 0x42, 0x57, 0x13, 0x60, 0x80, 0x96,
-						 0xef, 0x23, 0x7e, 0x4c, 0x1d, 0x96, 0x24, 0x19,
-						 0x17, 0xf2, 0x44, 0x99 },
-			.vec_out = { 0xe9, 0x4d, 0x70, 0xab, 0xa2, 0x87, 0xf0, 0xe7,
-						 0x04, 0x14, 0x7c, 0xab, 0xaf, 0x6b, 0xa1, 0x16,
-						 0xeb, 0x30, 0x00, 0xde, 0xc8, 0xfd, 0x0b, 0x85,
-						 0x80, 0x41, 0x4a, 0xcc, 0xd3, 0xc0, 0xd0, 0xb6,
-						 0x26, 0xe5, 0x4e, 0x32, 0x49, 0x69, 0x38, 0x17,
-						 0x33, 0xab, 0xaf, 0xb6, 0xc1, 0x08, 0xf3, 0x9f,
-						 0x8c, 0x75, 0x6a, 0x4e, 0x08, 0xc4, 0x20, 0x5f,
-						 0x8f },
-		},
-		{
-			.name = "GSM TCH/AFS 7.95 (recursive, flushed, punctured)",
-			.code = &gsm0503_tch_afs_7_95,
-			.in_len  = 165,
-			.out_len = 448,
-			.has_vec = 1,
-			.vec_in  = { 0x87, 0x66, 0xc3, 0x58, 0x09, 0xd4, 0x06, 0x59,
-						 0x10, 0xbf, 0x6b, 0x7f, 0xc8, 0xed, 0x72, 0xaa,
-						 0xc1, 0x3d, 0xf3, 0x1e, 0xb0 },
-			.vec_out = { 0x92, 0xbc, 0xde, 0xa0, 0xde, 0xbe, 0x01, 0x2f,
-						 0xbe, 0xe4, 0x61, 0x32, 0x4d, 0x4f, 0xdc, 0x41,
-						 0x43, 0x0d, 0x15, 0xe0, 0x23, 0xdd, 0x18, 0x91,
-						 0xe5, 0x36, 0x2d, 0xb7, 0xd9, 0x78, 0xb8, 0xb1,
-						 0xb7, 0xcb, 0x2f, 0xc0, 0x52, 0x8f, 0xe2, 0x8c,
-						 0x6f, 0xa6, 0x79, 0x88, 0xed, 0x0c, 0x2e, 0x9e,
-						 0xa1, 0x5f, 0x45, 0x4a, 0xfb, 0xe6, 0x5a, 0x9c },
-		},
-		{
-			.name = "GMR-1 TCH3 Speech (non-recursive, tail-biting, punctured)",
-			.code = &conv_gmr1_tch3_speech,
-			.in_len  = 48,
-			.out_len = 72,
-			.has_vec = 1,
-		.vec_in  = { 0x4d, 0xcb, 0xfc, 0x72, 0xf4, 0x8c },
-			.vec_out = { 0xc0, 0x86, 0x63, 0x4b, 0x8b, 0xd4, 0x6a, 0x76, 0xb2 },
-		},
-		{
-			.name = "WiMax FCH (non-recursive, tail-biting, not punctured)",
-			.code = &conv_wimax_fch,
-			.in_len  = 48,
-			.out_len = 96,
-			.has_vec = 1,
-			.vec_in  = { 0xfc, 0xa0, 0xa0, 0xfc, 0xa0, 0xa0 },
-			.vec_out = { 0x19, 0x42, 0x8a, 0xed, 0x21, 0xed, 0x19, 0x42,
-						 0x8a, 0xed, 0x21, 0xed },
-		},
-		{
-			.name = "??? (non-recursive, direct truncation, not punctured)",
-			.code = &conv_trunc,
-			.in_len  = 224,
-			.out_len = 448,
-			.has_vec = 1,
-			.vec_in  = { 0xe5, 0xe0, 0x85, 0x7e, 0xf7, 0x08, 0x19, 0x5a,
-						 0xb9, 0xad, 0x82, 0x37, 0x98, 0x8b, 0x26, 0xb9,
-						 0x81, 0x26, 0x9c, 0x75, 0xaf, 0xf3, 0xcb, 0x07,
-						 0xac, 0x63, 0xe2, 0x9c,
-			},
-			.vec_out = { 0xea, 0x3b, 0x55, 0x0c, 0xd3, 0xf7, 0x85, 0x69,
-						 0xe5, 0x79, 0x83, 0xd3, 0xc3, 0x9f, 0xb8, 0x61,
-						 0x21, 0x63, 0x51, 0x18, 0xac, 0xcd, 0x32, 0x49,
-						 0x53, 0x5c, 0x13, 0x1d, 0xbe, 0x05, 0x11, 0x63,
-						 0x5c, 0xc3, 0x42, 0x05, 0x1c, 0x68, 0x0a, 0xb4,
-						 0x61, 0x15, 0xaa, 0x4d, 0x94, 0xed, 0xb3, 0x3a,
-						 0x5d, 0x1b, 0x09, 0xc2, 0x99, 0x01, 0xec, 0x68 },
-		},
-		{ /* end */ },
-	};
+	int i;
 
 	srandom(time(NULL));
 
@@ -246,9 +31,10 @@
 	bu1 = malloc(sizeof(ubit_t) * MAX_LEN_BITS);
 	bs  = malloc(sizeof(sbit_t) * MAX_LEN_BITS);
 
-	for (tst=tests; tst->name; tst++)
+	for (i = 0; i < TEST_VEC_COUNT; i++)
 	{
-		int i,l;
+		int j, l;
+		tst = &tests[i];
 
 		/* Test name */
 		printf("[+] Testing: %s\n", tst->name);
@@ -323,7 +109,7 @@
 		/* Check random vector */
 		printf("[.] Random vector checks:\n");
 
-		for (i=0; i<3; i++) {
+		for (j = 0; j < 3; j++) {
 			printf("[..] Encoding / Decoding cycle : ");
 
 			fill_random(bu0, tst->in_len);
diff --git a/tests/conv/conv_test.h b/tests/conv/conv_test.h
new file mode 100644
index 0000000..41e8686
--- /dev/null
+++ b/tests/conv/conv_test.h
@@ -0,0 +1,24 @@
+#pragma once
+
+#include <osmocom/core/conv.h>
+
+#define TEST_VEC_COUNT	5
+#define MAX_LEN_BITS	512
+#define MAX_LEN_BYTES	(512 / 8)
+
+struct conv_test_vector {
+	const char *name;
+	const struct osmo_conv_code *code;
+	int in_len;
+	int out_len;
+	int has_vec;
+	pbit_t vec_in[MAX_LEN_BYTES];
+	pbit_t vec_out[MAX_LEN_BYTES];
+};
+
+const struct conv_test_vector tests[TEST_VEC_COUNT];
+
+/* Non GSM specific codes */
+const struct osmo_conv_code conv_gmr1_tch3_speech;
+const struct osmo_conv_code conv_wimax_fch;
+const struct osmo_conv_code conv_trunc;
diff --git a/tests/conv/conv_test_vectors.c b/tests/conv/conv_test_vectors.c
new file mode 100644
index 0000000..8b245d3
--- /dev/null
+++ b/tests/conv/conv_test_vectors.c
@@ -0,0 +1,88 @@
+#include <osmocom/core/conv.h>
+#include <osmocom/gsm/gsm0503.h>
+
+#include "conv_test.h"
+
+/**
+ * NOTE: Don't forget to increase the TEST_VEC_COUNT
+ * after adding new vectors!
+ */
+const struct conv_test_vector tests[TEST_VEC_COUNT] = {
+	/* GSM specific test vectors */
+	{
+		.name = "GSM xCCH (non-recursive, flushed, not punctured)",
+		.code = &gsm0503_xcch,
+		.in_len  = 224,
+		.out_len = 456,
+		.has_vec = 1,
+		.vec_in  = { 0xf3, 0x1d, 0xb4, 0x0c, 0x4d, 0x1d, 0x9d, 0xae,
+					 0xc0, 0x0a, 0x42, 0x57, 0x13, 0x60, 0x80, 0x96,
+					 0xef, 0x23, 0x7e, 0x4c, 0x1d, 0x96, 0x24, 0x19,
+					 0x17, 0xf2, 0x44, 0x99 },
+		.vec_out = { 0xe9, 0x4d, 0x70, 0xab, 0xa2, 0x87, 0xf0, 0xe7,
+					 0x04, 0x14, 0x7c, 0xab, 0xaf, 0x6b, 0xa1, 0x16,
+					 0xeb, 0x30, 0x00, 0xde, 0xc8, 0xfd, 0x0b, 0x85,
+					 0x80, 0x41, 0x4a, 0xcc, 0xd3, 0xc0, 0xd0, 0xb6,
+					 0x26, 0xe5, 0x4e, 0x32, 0x49, 0x69, 0x38, 0x17,
+					 0x33, 0xab, 0xaf, 0xb6, 0xc1, 0x08, 0xf3, 0x9f,
+					 0x8c, 0x75, 0x6a, 0x4e, 0x08, 0xc4, 0x20, 0x5f,
+					 0x8f },
+	},
+	{
+		.name = "GSM TCH/AFS 7.95 (recursive, flushed, punctured)",
+		.code = &gsm0503_tch_afs_7_95,
+		.in_len  = 165,
+		.out_len = 448,
+		.has_vec = 1,
+		.vec_in  = { 0x87, 0x66, 0xc3, 0x58, 0x09, 0xd4, 0x06, 0x59,
+					 0x10, 0xbf, 0x6b, 0x7f, 0xc8, 0xed, 0x72, 0xaa,
+					 0xc1, 0x3d, 0xf3, 0x1e, 0xb0 },
+		.vec_out = { 0x92, 0xbc, 0xde, 0xa0, 0xde, 0xbe, 0x01, 0x2f,
+					 0xbe, 0xe4, 0x61, 0x32, 0x4d, 0x4f, 0xdc, 0x41,
+					 0x43, 0x0d, 0x15, 0xe0, 0x23, 0xdd, 0x18, 0x91,
+					 0xe5, 0x36, 0x2d, 0xb7, 0xd9, 0x78, 0xb8, 0xb1,
+					 0xb7, 0xcb, 0x2f, 0xc0, 0x52, 0x8f, 0xe2, 0x8c,
+					 0x6f, 0xa6, 0x79, 0x88, 0xed, 0x0c, 0x2e, 0x9e,
+					 0xa1, 0x5f, 0x45, 0x4a, 0xfb, 0xe6, 0x5a, 0x9c },
+	},
+
+	/* Other test vectors */
+	{
+		.name = "GMR-1 TCH3 Speech (non-recursive, tail-biting, punctured)",
+		.code = &conv_gmr1_tch3_speech,
+		.in_len  = 48,
+		.out_len = 72,
+		.has_vec = 1,
+		.vec_in  = { 0x4d, 0xcb, 0xfc, 0x72, 0xf4, 0x8c },
+		.vec_out = { 0xc0, 0x86, 0x63, 0x4b, 0x8b, 0xd4, 0x6a, 0x76, 0xb2 },
+	},
+	{
+		.name = "WiMax FCH (non-recursive, tail-biting, not punctured)",
+		.code = &conv_wimax_fch,
+		.in_len  = 48,
+		.out_len = 96,
+		.has_vec = 1,
+		.vec_in  = { 0xfc, 0xa0, 0xa0, 0xfc, 0xa0, 0xa0 },
+		.vec_out = { 0x19, 0x42, 0x8a, 0xed, 0x21, 0xed, 0x19, 0x42,
+					 0x8a, 0xed, 0x21, 0xed },
+	},
+	{
+		.name = "??? (non-recursive, direct truncation, not punctured)",
+		.code = &conv_trunc,
+		.in_len  = 224,
+		.out_len = 448,
+		.has_vec = 1,
+		.vec_in  = { 0xe5, 0xe0, 0x85, 0x7e, 0xf7, 0x08, 0x19, 0x5a,
+					 0xb9, 0xad, 0x82, 0x37, 0x98, 0x8b, 0x26, 0xb9,
+					 0x81, 0x26, 0x9c, 0x75, 0xaf, 0xf3, 0xcb, 0x07,
+					 0xac, 0x63, 0xe2, 0x9c,
+		},
+		.vec_out = { 0xea, 0x3b, 0x55, 0x0c, 0xd3, 0xf7, 0x85, 0x69,
+					 0xe5, 0x79, 0x83, 0xd3, 0xc3, 0x9f, 0xb8, 0x61,
+					 0x21, 0x63, 0x51, 0x18, 0xac, 0xcd, 0x32, 0x49,
+					 0x53, 0x5c, 0x13, 0x1d, 0xbe, 0x05, 0x11, 0x63,
+					 0x5c, 0xc3, 0x42, 0x05, 0x1c, 0x68, 0x0a, 0xb4,
+					 0x61, 0x15, 0xaa, 0x4d, 0x94, 0xed, 0xb3, 0x3a,
+					 0x5d, 0x1b, 0x09, 0xc2, 0x99, 0x01, 0xec, 0x68 },
+	},
+};

-- 
To view, visit https://gerrit.osmocom.org/1542
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iffee60ad19d38bcfdce2e5f47a4e886f6f74e271
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>



More information about the gerrit-log mailing list