aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHolger Freyther <zecke@selfish.org>2008-12-28 21:55:40 +0000
committerHolger Freyther <zecke@selfish.org>2008-12-28 21:55:40 +0000
commitaa0fb362c0d44d43320e15529e84920bf2d38771 (patch)
tree6bd2da63d9813a8971d9fa020d9331048dc91c4a /tests
parent6e6143e2921317eac68fe2b47ca59aef6c1ee3bb (diff)
Add stubs to test gsm0408 functionality including LAI
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am2
-rw-r--r--tests/gsm0408/Makefile.am4
-rw-r--r--tests/gsm0408/gsm0408_test.c80
3 files changed, 85 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ccfedceae..fbfc827a7 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1 +1 @@
-SUBDIRS = debug timer sms
+SUBDIRS = debug timer sms gsm0408
diff --git a/tests/gsm0408/Makefile.am b/tests/gsm0408/Makefile.am
new file mode 100644
index 000000000..59a9599ef
--- /dev/null
+++ b/tests/gsm0408/Makefile.am
@@ -0,0 +1,4 @@
+INCLUDES = $(all_includes) -I$(top_srcdir)/include
+noinst_PROGRAMS = gsm0408_test
+
+gsm0408_test_SOURCES = gsm0408_test.c $(top_srcdir)/src/gsm_04_08.c $(top_srcdir)/src/debug.c
diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c
new file mode 100644
index 000000000..870574112
--- /dev/null
+++ b/tests/gsm0408/gsm0408_test.c
@@ -0,0 +1,80 @@
+/* simple test for the gsm0408 formatting functions */
+/*
+ * (C) 2008 by Holger Hans Peter Freyther <zecke@selfish.org>
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <openbsc/gsm_04_08.h>
+
+#define COMPARE(result, op, value) \
+ if (!((result) op (value))) {\
+ fprintf(stderr, "Compare failed. Was %x should be %x in %s:%d\n",result, value, __FILE__, __LINE__); \
+ exit(-1); \
+ }
+
+
+/*
+ * Test Location Area Identifier formatting. Table 10.5.3 of 04.08
+ */
+static void test_location_area_identifier(void)
+{
+ struct gsm48_loc_area_id lai48;
+
+ printf("Testing test location area identifier\n");
+
+ /*
+ * Test the default/test setup. Coming from
+ * bsc_hack.c dumps
+ */
+ gsm0408_generate_lai(&lai48, 1, 1, 1);
+ COMPARE(lai48.digits[0], ==, 0x00);
+ COMPARE(lai48.digits[1], ==, 0xF1);
+ COMPARE(lai48.digits[2], ==, 0x10);
+ COMPARE(lai48.lac, ==, htons(0x0001));
+
+ gsm0408_generate_lai(&lai48, 602, 1, 15);
+ COMPARE(lai48.digits[0], ==, 0x06);
+ COMPARE(lai48.digits[1], ==, 0xF2);
+ COMPARE(lai48.digits[2], ==, 0x10);
+ COMPARE(lai48.lac, ==, htons(0x000f));
+}
+
+int main(int argc, char** argv)
+{
+ test_location_area_identifier();
+}
+
+
+
+/*
+ * Stubs to compile and link
+ */
+void rsl_data_request(void) {}
+void gsm0411_rcv_sms(void) {}
+void schedule_timer(void) {}
+void subscr_get_by_tmsi(void) {}
+void subscr_update(void) {}
+void db_subscriber_assoc_imei(void) {}
+void db_subscriber_alloc_tmsi(void) {}
+void db_create_subscriber(void) {}
+void rsl_chan_release(void) {}
+void msgb_alloc(void) {}