summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2011-01-12 11:20:32 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2011-01-12 12:50:09 +0100
commitf3b7effbc169b9bdf91828c1557dcab06aaabb44 (patch)
tree0dd3df9342ce6394f9a989e5962bca34dd91d105 /tests
parentb8962797a5bdbfbf69c294db455654edde8d0e70 (diff)
m2ua: Add parsing and creation of m2ua packages
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am2
-rw-r--r--tests/m2ua/Makefile.am6
-rw-r--r--tests/m2ua/m2ua_test.c54
3 files changed, 61 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index bf7855d..882d1e2 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1 +1 @@
-SUBDIRS = sccp mtp
+SUBDIRS = sccp mtp m2ua
diff --git a/tests/m2ua/Makefile.am b/tests/m2ua/Makefile.am
new file mode 100644
index 0000000..8efb04d
--- /dev/null
+++ b/tests/m2ua/Makefile.am
@@ -0,0 +1,6 @@
+INCLUDES = $(all_includes) -I$(top_srcdir)/include -Wall
+AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS)
+
+noinst_PROGRAMS = m2ua_test
+m2ua_test_SOURCES = m2ua_test.c
+m2ua_test_LDADD = $(LIBOSMOCORE_LIBS) $(top_builddir)/src/libm2ua.a
diff --git a/tests/m2ua/m2ua_test.c b/tests/m2ua/m2ua_test.c
new file mode 100644
index 0000000..cd6f9ad
--- /dev/null
+++ b/tests/m2ua/m2ua_test.c
@@ -0,0 +1,54 @@
+/* (C) 2011 by Holger Hans Peter Freyther <zecke@selfish.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <m2ua/m2ua_msg.h>
+
+#include <osmocore/utils.h>
+#include <osmocore/msgb.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define FAIL(msg) \
+ do { \
+ fprintf(stderr, "FAILURE: %s on line %d\n", msg, __LINE__); \
+ abort(); \
+ } while(0);
+
+static uint8_t asp_up[] = {
+ 0x01, 0x00, 0x03, 0x01, 0x00, 0x00, 0x00, 0x10,
+ 0x00, 0x11, 0x00, 0x08, 0xac, 0x10, 0x01, 0x51,
+};
+
+int main(int argc, char **argv)
+{
+ struct m2ua_msg *m2u = m2ua_from_msg(ARRAY_SIZE(asp_up), asp_up);
+ struct msgb *msg = m2ua_to_msg(m2u);
+
+ if (msg->len != ARRAY_SIZE(asp_up)) {
+ printf("Got %d wanted %d\n", msg->len, ARRAY_SIZE(asp_up));
+ FAIL("Wrong size");
+ }
+
+ if (memcmp(msg->data, asp_up, msg->len) != 0) {
+ printf("Got '%s'\n", hexdump(msg->data, msg->len));
+ FAIL("Wrong memory");
+ }
+
+ return 0;
+}