aboutsummaryrefslogtreecommitdiffstats
path: root/tests/prbs/prbs_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/prbs/prbs_test.c')
-rw-r--r--tests/prbs/prbs_test.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/prbs/prbs_test.c b/tests/prbs/prbs_test.c
new file mode 100644
index 00000000..f478635b
--- /dev/null
+++ b/tests/prbs/prbs_test.c
@@ -0,0 +1,47 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <osmocom/core/prbs.h>
+
+static void dump_bits(const ubit_t *bits, unsigned int num_bits)
+{
+ unsigned int i;
+
+ for (i = 0; i < num_bits; i++) {
+ if (bits[i])
+ fputc('1', stdout);
+ else
+ fputc('0', stdout);
+ }
+ fputc('\n',stdout);
+}
+
+static void test_prbs(const struct osmo_prbs *prbs)
+{
+ struct osmo_prbs_state st;
+ unsigned int i;
+
+ printf("Testing PRBS sequence generation '%s'\n", prbs->name);
+ osmo_prbs_state_init(&st, prbs);
+
+ /* 2 lines */
+ for (i = 0; i < 2; i++) {
+ unsigned int seq_len = (1 << prbs->len)-1;
+ ubit_t bits[seq_len];
+ memset(bits, 0, sizeof(bits));
+ osmo_prbs_get_ubits(bits, sizeof(bits), &st);
+ dump_bits(bits, sizeof(bits));
+ }
+
+ printf("\n");
+}
+
+int main(int argc, char **argv)
+{
+ test_prbs(&osmo_prbs7);
+ test_prbs(&osmo_prbs9);
+ test_prbs(&osmo_prbs11);
+ test_prbs(&osmo_prbs15);
+
+ exit(0);
+}