summaryrefslogtreecommitdiff
path: root/cesar/mac/common/test/pb
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/mac/common/test/pb')
-rw-r--r--cesar/mac/common/test/pb/Makefile13
-rw-r--r--cesar/mac/common/test/pb/src/test_pb.c74
2 files changed, 87 insertions, 0 deletions
diff --git a/cesar/mac/common/test/pb/Makefile b/cesar/mac/common/test/pb/Makefile
new file mode 100644
index 0000000000..35e3504cc4
--- /dev/null
+++ b/cesar/mac/common/test/pb/Makefile
@@ -0,0 +1,13 @@
+BASE = ../../../..
+
+TARGET = sparc
+
+HOST_PROGRAMS = test_pb
+test_pb_SOURCES = test_pb.c
+test_pb_MODULES = mac/common lib
+
+TARGET_PROGRAMS = test_pb_target
+test_pb_target_SOURCES = test_pb.c
+test_pb_target_MODULES = mac/common lib
+
+include $(BASE)/common/make/top.mk
diff --git a/cesar/mac/common/test/pb/src/test_pb.c b/cesar/mac/common/test/pb/src/test_pb.c
new file mode 100644
index 0000000000..44b7b45531
--- /dev/null
+++ b/cesar/mac/common/test/pb/src/test_pb.c
@@ -0,0 +1,74 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file src/test_pb.c
+ * \brief Test the PB descriptor.
+ * \ingroup test
+ */
+#include "common/std.h"
+
+#include "mac/common/pb.h"
+
+#include "lib/test.h"
+
+void
+pb_basic_test_case (test_t t)
+{
+ pb_t pb;
+ pb_header_t h;
+ /* Fill using the bit-fields, read using the word. */
+ test_begin (t, "fields to words")
+ {
+ h.ssn = 0x4242;
+ h.mfbo = 0x12;
+ h.vpbf = true;
+ h.mmqf = false;
+ h.mfbf = true;
+ h.opsf = false;
+ h.rsvd = 0;
+ pb.header = h;
+ test_fail_unless (sizeof (h) == 4);
+ test_fail_unless (pb.phy_pb.pb_tx.header == 0x0a124242);
+ } test_end;
+ /* Fill using phy struct, read using MAC struct (this is not a real life
+ * test!). */
+ test_begin (t, "phy to mac")
+ {
+ pb.phy_pb.pb_tx.blk.next = (blk_t *) &pb;
+ pb.phy_pb.pb_tx.blk.data = NULL;
+ test_fail_unless (pb.next == &pb);
+ test_fail_unless (pb.data == NULL);
+ pb.phy_pb.pb_rx.pb_measurement.ber = 0x5aa5;
+ pb.phy_pb.pb_rx.pb_measurement.halfit = 0x12;
+ pb.phy_pb.pb_rx.pb_measurement.crc_error = true;
+ test_fail_unless ((pb.expiration_ntb & 0x3fffff) == 0x325aa5);
+ pb.phy_pb.chandata.size = 0x12;
+ pb.phy_pb.chandata.last = true;
+ pb.phy_pb.chandata.type = 6;
+ pb.phy_pb.chandata.address = 0x123;
+ test_fail_unless ((pb.phy_pb.pb_tx.header & 0xfff01fff) ==
+ 0x12300d12);
+ } test_end;
+}
+
+void
+pb_test_suite (test_t t)
+{
+ test_suite_begin (t, "pb");
+ pb_basic_test_case (t);
+}
+
+int
+main (int argc, char **argv)
+{
+ test_t t;
+ test_init (t, argc, argv);
+ pb_test_suite (t);
+ test_result (t);
+ return test_nb_failed (t) == 0 ? 0 : 1;
+}