aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/tests
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-03-22 03:25:11 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-03-24 06:16:04 +0100
commit22481bf76d129d3c41d20b96b6587ef085be485b (patch)
tree8c8de852e945dd5422a83bc7e0c37548d2911fe2 /openbsc/tests
parentb973955295b720b8ba7c556d0165750ed9bfb381 (diff)
parent61b4232c6363ff9d78ef73b9dbf47ec16c94d610 (diff)
Merge remote branch 'origin/master' into on-waves/bsc-master
* Move to libosmocore * Move to new debugging architecture * Register the BTS types * Has only been compile tested Conflicts: openbsc/include/openbsc/Makefile.am openbsc/include/openbsc/gsm_data.h openbsc/include/openbsc/ipaccess.h openbsc/include/openbsc/mgcp.h openbsc/include/openbsc/msgb.h openbsc/include/openbsc/tlv.h openbsc/src/Makefile.am openbsc/src/abis_rsl.c openbsc/src/bsc_init.c openbsc/src/bsc_mgcp.c openbsc/src/chan_alloc.c openbsc/src/debug.c openbsc/src/gsm_subscriber_base.c openbsc/src/msgb.c openbsc/src/rest_octets.c openbsc/src/sccp/sccp.c openbsc/src/vty/command.c openbsc/src/vty_interface.c openbsc/tests/Makefile.am
Diffstat (limited to 'openbsc/tests')
-rw-r--r--openbsc/tests/Makefile.am2
-rw-r--r--openbsc/tests/bsc-nat/Makefile.am4
-rw-r--r--openbsc/tests/channel/Makefile.am10
-rw-r--r--openbsc/tests/channel/channel_test.c4
-rw-r--r--openbsc/tests/db/Makefile.am4
-rw-r--r--openbsc/tests/debug/Makefile.am4
-rw-r--r--openbsc/tests/debug/debug_test.c21
-rw-r--r--openbsc/tests/gsm0408/Makefile.am3
-rw-r--r--openbsc/tests/gsm0408/gsm0408_test.c8
-rw-r--r--openbsc/tests/sccp/Makefile.am4
-rw-r--r--openbsc/tests/sccp/sccp_test.c108
-rw-r--r--openbsc/tests/sms/Makefile.am5
-rw-r--r--openbsc/tests/sms/sms_test.c53
-rw-r--r--openbsc/tests/timer/Makefile.am5
-rw-r--r--openbsc/tests/timer/timer_test.c70
15 files changed, 145 insertions, 160 deletions
diff --git a/openbsc/tests/Makefile.am b/openbsc/tests/Makefile.am
index d867ec6bb..b469832fc 100644
--- a/openbsc/tests/Makefile.am
+++ b/openbsc/tests/Makefile.am
@@ -1 +1 @@
-SUBDIRS = debug timer sms gsm0408 db channel sccp bsc-nat
+SUBDIRS = debug gsm0408 db channel sccp bsc-nat
diff --git a/openbsc/tests/bsc-nat/Makefile.am b/openbsc/tests/bsc-nat/Makefile.am
index cc9fb3bae..550f0a820 100644
--- a/openbsc/tests/bsc-nat/Makefile.am
+++ b/openbsc/tests/bsc-nat/Makefile.am
@@ -1,8 +1,8 @@
INCLUDES = $(all_includes) -I$(top_srcdir)/include
-AM_CFLAGS=-Wall -ggdb3
+AM_CFLAGS=-Wall -ggdb3 $(LIBOSMOCORE_CFLAGS)
noinst_PROGRAMS = bsc_nat_test
bsc_nat_test_SOURCES = bsc_nat_test.c $(top_srcdir)/src/nat/bsc_filter.c
-bsc_nat_test_LDADD = $(top_builddir)/src/libbsc.a $(top_builddir)/src/libsccp.a
+bsc_nat_test_LDADD = $(top_builddir)/src/libbsc.a $(top_builddir)/src/libsccp.a $(LIBOSMOCORE_LIBS)
diff --git a/openbsc/tests/channel/Makefile.am b/openbsc/tests/channel/Makefile.am
index 50fadc582..772965953 100644
--- a/openbsc/tests/channel/Makefile.am
+++ b/openbsc/tests/channel/Makefile.am
@@ -1,5 +1,5 @@
INCLUDES = $(all_includes) -I$(top_srcdir)/include
-AM_CFLAGS=-Wall -ggdb3
+AM_CFLAGS=-Wall -ggdb3 $(LIBOSMOCORE_CFLAGS)
noinst_PROGRAMS = channel_test
@@ -8,10 +8,8 @@ channel_test_SOURCES = channel_test.c \
$(top_srcdir)/src/gsm_subscriber_base.c \
$(top_srcdir)/src/gsm_subscriber.c \
$(top_srcdir)/src/debug.c \
- $(top_srcdir)/src/timer.c \
- $(top_srcdir)/src/select.c \
- $(top_srcdir)/src/talloc.c \
$(top_srcdir)/src/gsm_data.c \
- $(top_srcdir)/src/signal.c
-channel_test_LDADD = -ldl -ldbi
+ $(top_srcdir)/src/bts_ipaccess_nanobts.c \
+ $(top_srcdir)/src/bts_siemens_bs11.c
+channel_test_LDADD = -ldl -ldbi $(LIBOSMOCORE_LIBS)
diff --git a/openbsc/tests/channel/channel_test.c b/openbsc/tests/channel/channel_test.c
index ed0f3ad57..4c57a75c6 100644
--- a/openbsc/tests/channel/channel_test.c
+++ b/openbsc/tests/channel/channel_test.c
@@ -23,7 +23,7 @@
#include <assert.h>
-#include <openbsc/select.h>
+#include <osmocore/select.h>
#include <openbsc/gsm_subscriber.h>
#include <openbsc/abis_rsl.h>
@@ -78,3 +78,5 @@ void input_event() {}
void sms_alloc() {}
void _lchan_release() {}
+struct tlv_definition nm_att_tlvdef;
+
diff --git a/openbsc/tests/db/Makefile.am b/openbsc/tests/db/Makefile.am
index 8ce7e3c49..6eb9180ce 100644
--- a/openbsc/tests/db/Makefile.am
+++ b/openbsc/tests/db/Makefile.am
@@ -1,8 +1,8 @@
INCLUDES = $(all_includes) -I$(top_srcdir)/include
-AM_CFLAGS=-Wall -ggdb3
+AM_CFLAGS=-Wall -ggdb3 $(LIBOSMOCORE_CFLAGS)
noinst_PROGRAMS = db_test
db_test_SOURCES = db_test.c
-db_test_LDADD = $(top_builddir)/src/libbsc.a $(top_builddir)/src/libmsc.a $(top_builddir)/src/libbsc.a -ldl -ldbi
+db_test_LDADD = $(top_builddir)/src/libbsc.a $(top_builddir)/src/libmsc.a $(top_builddir)/src/libbsc.a $(LIBOSMOCORE_LIBS) -ldl -ldbi
diff --git a/openbsc/tests/debug/Makefile.am b/openbsc/tests/debug/Makefile.am
index 0cdf46ad5..8423fd178 100644
--- a/openbsc/tests/debug/Makefile.am
+++ b/openbsc/tests/debug/Makefile.am
@@ -1,4 +1,6 @@
INCLUDES = $(all_includes) -I$(top_srcdir)/include
+AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS)
noinst_PROGRAMS = debug_test
-debug_test_SOURCES = debug_test.c $(top_srcdir)/src/debug.c
+debug_test_SOURCES = debug_test.c $(top_srcdir)/src/debug.c
+debug_test_LDADD = $(LIBOSMOCORE_LIBS)
diff --git a/openbsc/tests/debug/debug_test.c b/openbsc/tests/debug/debug_test.c
index 77ac01532..0f0c284ab 100644
--- a/openbsc/tests/debug/debug_test.c
+++ b/openbsc/tests/debug/debug_test.c
@@ -1,6 +1,6 @@
/* simple test for the debug interface */
/*
- * (C) 2008 by Holger Hans Peter Freyther <zecke@selfish.org>
+ * (C) 2008, 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
@@ -24,11 +24,18 @@
int main(int argc, char** argv)
{
- debug_parse_category_mask("DRLL");
- DEBUGP(DCC, "You should not see this\n");
+ struct debug_target *stderr_target;
- debug_parse_category_mask("DRLL:DCC");
- DEBUGP(DRLL, "You should see this\n");
- DEBUGP(DCC, "You should see this\n");
- DEBUGP(DMM, "You should not see this\n");
+ debug_init();
+ stderr_target = debug_target_create_stderr();
+ debug_add_target(stderr_target);
+ debug_set_all_filter(stderr_target, 1);
+
+ debug_parse_category_mask(stderr_target, "DRLL");
+ DEBUGP(DCC, "You should not see this\n");
+
+ debug_parse_category_mask(stderr_target, "DRLL:DCC");
+ DEBUGP(DRLL, "You should see this\n");
+ DEBUGP(DCC, "You should see this\n");
+ DEBUGP(DMM, "You should not see this\n");
}
diff --git a/openbsc/tests/gsm0408/Makefile.am b/openbsc/tests/gsm0408/Makefile.am
index ff8caf999..f98c673ea 100644
--- a/openbsc/tests/gsm0408/Makefile.am
+++ b/openbsc/tests/gsm0408/Makefile.am
@@ -1,5 +1,6 @@
INCLUDES = $(all_includes) -I$(top_srcdir)/include
+AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS)
noinst_PROGRAMS = gsm0408_test
gsm0408_test_SOURCES = gsm0408_test.c
-gsm0408_test_LDADD = $(top_builddir)/src/libbsc.a $(top_builddir)/src/libmsc.a $(top_builddir)/src/libbsc.a -ldbi
+gsm0408_test_LDADD = $(top_builddir)/src/libbsc.a $(top_builddir)/src/libmsc.a $(top_builddir)/src/libbsc.a $(LIBOSMOCORE_LIBS) -ldbi
diff --git a/openbsc/tests/gsm0408/gsm0408_test.c b/openbsc/tests/gsm0408/gsm0408_test.c
index bbf812965..287d4ee99 100644
--- a/openbsc/tests/gsm0408/gsm0408_test.c
+++ b/openbsc/tests/gsm0408/gsm0408_test.c
@@ -23,6 +23,8 @@
#include <stdio.h>
#include <stdlib.h>
+#include <arpa/inet.h>
+
#include <openbsc/gsm_04_08.h>
#include <openbsc/gsm_subscriber.h>
#include <openbsc/debug.h>
@@ -52,13 +54,13 @@ static void test_location_area_identifier(void)
* Test the default/test setup. Coming from
* bsc_hack.c dumps
*/
- gsm0408_generate_lai(&lai48, 1, 1, 1);
+ gsm48_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);
+ gsm48_generate_lai(&lai48, 602, 1, 15);
COMPARE(lai48.digits[0], ==, 0x06);
COMPARE(lai48.digits[1], ==, 0xF2);
COMPARE(lai48.digits[2], ==, 0x10);
@@ -97,6 +99,8 @@ int main(int argc, char** argv)
{
test_location_area_identifier();
test_mi_functionality();
+
+ exit(0);
}
diff --git a/openbsc/tests/sccp/Makefile.am b/openbsc/tests/sccp/Makefile.am
index 5a275fc2b..b35693e82 100644
--- a/openbsc/tests/sccp/Makefile.am
+++ b/openbsc/tests/sccp/Makefile.am
@@ -1,8 +1,8 @@
INCLUDES = $(all_includes) -I$(top_srcdir)/include
-AM_CFLAGS=-Wall -ggdb3
+AM_CFLAGS=-Wall -ggdb3 $(LIBOSMOCORE_CFLAGS)
noinst_PROGRAMS = sccp_test
sccp_test_SOURCES = sccp_test.c
-sccp_test_LDADD = $(top_builddir)/src/libsccp.a $(top_builddir)/src/libbsc.a
+sccp_test_LDADD = $(top_builddir)/src/libsccp.a $(top_builddir)/src/libbsc.a $(LIBOSMOCORE_LIBS)
diff --git a/openbsc/tests/sccp/sccp_test.c b/openbsc/tests/sccp/sccp_test.c
index bd28ed179..eb41d3eaf 100644
--- a/openbsc/tests/sccp/sccp_test.c
+++ b/openbsc/tests/sccp/sccp_test.c
@@ -2,7 +2,7 @@
* SCCP testing code
*
* (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
- * (C) 2009 by on-waves.com
+ * (C) 2009 by On-Waves
*
* All Rights Reserved
*
@@ -26,9 +26,11 @@
#include <arpa/inet.h>
-#include <sccp/sccp.h>
#include <openbsc/gsm_data.h>
#include <openbsc/debug.h>
+#include <osmocore/msgb.h>
+
+#include <sccp/sccp.h>
#define MIN(x, y) ((x) < (y) ? (x) : (y))
@@ -242,6 +244,52 @@ static const struct connection_test connection_tests[] = {
},
};
+struct sccp_parse_header_result {
+ /* results */
+ int msg_type;
+ int wanted_len;
+ int src_ssn;
+ int dst_ssn;
+
+ int has_src_ref, has_dst_ref;
+ struct sccp_source_reference src_ref;
+ struct sccp_source_reference dst_ref;
+
+ /* the input */
+ const u_int8_t *input;
+ int input_len;
+};
+
+static const u_int8_t it_test[] = {
+0x10, 0x01, 0x07,
+0x94, 0x01, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00 };
+
+static const struct sccp_parse_header_result parse_result[] = {
+ {
+ .msg_type = SCCP_MSG_TYPE_IT,
+ .wanted_len = 0,
+ .src_ssn = -1,
+ .dst_ssn = -1,
+ .has_src_ref = 1,
+ .has_dst_ref = 1,
+
+ .src_ref = {
+ .octet1 = 0x01,
+ .octet2 = 0x04,
+ .octet3 = 0x00
+ },
+ .dst_ref = {
+ .octet1 = 0x01,
+ .octet2 = 0x07,
+ .octet3 = 0x94,
+ },
+
+ .input = it_test,
+ .input_len = sizeof(it_test),
+ },
+};
+
+
/* testing procedure:
* - we will use sccp_write and see what will be set in the
* outgoing callback
@@ -712,6 +760,59 @@ static void test_sccp_system_crash(void)
printf("survived\n");
}
+static void test_sccp_parsing(void)
+{
+ for (current_test = 0; current_test < ARRAY_SIZE(parse_result); ++current_test) {
+ struct msgb *msg;
+ struct sccp_parse_result result;
+
+ msg = msgb_alloc_headroom(1024, 128, "parse-test");
+ msgb_put(msg, 1);
+ msg->l2h = msgb_put(msg, parse_result[current_test].input_len);
+ memcpy(msg->l2h, parse_result[current_test].input, msgb_l2len(msg));
+
+ memset(&result, 0, sizeof(result));
+ if (sccp_parse_header(msg, &result) != 0) {
+ fprintf(stderr, "Failed to parse test: %d\n", current_test);
+ } else {
+ if (parse_result[current_test].wanted_len != result.data_len) {
+ fprintf(stderr, "Unexpected data length.\n");
+ abort();
+ }
+
+ if (parse_result[current_test].has_src_ref) {
+ if (memcmp(result.source_local_reference,
+ &parse_result[current_test].src_ref,
+ sizeof(struct sccp_source_reference)) != 0) {
+ fprintf(stderr, "SRC REF did not match\n");
+ abort();
+ }
+ }
+
+ if (parse_result[current_test].has_dst_ref) {
+ if (memcmp(result.destination_local_reference,
+ &parse_result[current_test].dst_ref,
+ sizeof(struct sccp_source_reference)) != 0) {
+ fprintf(stderr, "DST REF did not match\n");
+ abort();
+ }
+ }
+
+ if (parse_result[current_test].src_ssn != -1) {
+ fprintf(stderr, "Not implemented.\n");
+ abort();
+ }
+
+ if (parse_result[current_test].dst_ssn != -1) {
+ fprintf(stderr, "Not implemented.\n");
+ abort();
+ }
+ }
+
+ msgb_free(msg);
+ }
+}
+
int main(int argc, char **argv)
{
@@ -720,5 +821,8 @@ int main(int argc, char **argv)
test_sccp_udt_communication();
test_sccp_connection();
test_sccp_system_crash();
+ test_sccp_parsing();
return 0;
}
+
+void db_store_counter() {}
diff --git a/openbsc/tests/sms/Makefile.am b/openbsc/tests/sms/Makefile.am
deleted file mode 100644
index 807c674e5..000000000
--- a/openbsc/tests/sms/Makefile.am
+++ /dev/null
@@ -1,5 +0,0 @@
-INCLUDES = $(all_includes) -I$(top_srcdir)/include
-noinst_PROGRAMS = sms_test
-
-sms_test_SOURCES = sms_test.c
-sms_test_LDADD = $(top_builddir)/src/libmsc.a $(top_builddir)/src/libbsc.a -ldl -ldbi
diff --git a/openbsc/tests/sms/sms_test.c b/openbsc/tests/sms/sms_test.c
deleted file mode 100644
index 2ce2cc6c4..000000000
--- a/openbsc/tests/sms/sms_test.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * (C) 2008 by Daniel Willmann <daniel@totalueberwachung.de>
- * 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <openbsc/debug.h>
-#include <openbsc/msgb.h>
-#include <openbsc/gsm_data.h>
-#include <openbsc/gsm_utils.h>
-
-int main(int argc, char** argv)
-{
- DEBUGP(DSMS, "SMS testing\n");
- struct msgb *msg;
- u_int8_t *sms;
- u_int8_t i;
-
- /* test 7-bit coding/decoding */
- const char *input = "test text";
- u_int8_t length;
- u_int8_t coded[256];
- char result[256];
-
- length = gsm_7bit_encode(coded, input);
- gsm_7bit_decode(result, coded, length);
- if (strcmp(result, input) != 0) {
- printf("7 Bit coding failed... life sucks\n");
- printf("Wanted: '%s' got '%s'\n", input, result);
- }
-}
-
-/* stubs */
-void input_event(void) {}
-void nm_state_event(void) {}
diff --git a/openbsc/tests/timer/Makefile.am b/openbsc/tests/timer/Makefile.am
deleted file mode 100644
index 9f12d23ac..000000000
--- a/openbsc/tests/timer/Makefile.am
+++ /dev/null
@@ -1,5 +0,0 @@
-INCLUDES = $(all_includes) -I$(top_srcdir)/include
-noinst_PROGRAMS = timer_test
-
-timer_test_SOURCES = timer_test.c $(top_srcdir)/src/timer.c $(top_srcdir)/src/select.c
-
diff --git a/openbsc/tests/timer/timer_test.c b/openbsc/tests/timer/timer_test.c
deleted file mode 100644
index 26fcbc938..000000000
--- a/openbsc/tests/timer/timer_test.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * (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 <stdio.h>
-
-#include <openbsc/timer.h>
-#include <openbsc/select.h>
-
-static void timer_fired(unsigned long data);
-
-static struct timer_list timer_one = {
- .cb = timer_fired,
- .data = (void*)1,
-};
-
-static struct timer_list timer_two = {
- .cb = timer_fired,
- .data = (void*)2,
-};
-
-static struct timer_list timer_three = {
- .cb = timer_fired,
- .data = (void*)3,
-};
-
-static void timer_fired(unsigned long data)
-{
- printf("Fired timer: %lu\n", data);
-
- if (data == 1) {
- bsc_schedule_timer(&timer_one, 3, 0);
- bsc_del_timer(&timer_two);
- } else if (data == 2) {
- printf("Should not be fired... bug in del_timer\n");
- } else if (data == 3) {
- printf("Timer fired not registering again\n");
- } else {
- printf("wtf... wrong data\n");
- }
-}
-
-int main(int argc, char** argv)
-{
- printf("Starting... timer\n");
-
- bsc_schedule_timer(&timer_one, 3, 0);
- bsc_schedule_timer(&timer_two, 5, 0);
- bsc_schedule_timer(&timer_three, 4, 0);
-
- while (1) {
- bsc_select_main(0);
- }
-}