summaryrefslogtreecommitdiffstats
path: root/Src/osmocom-bb/src/shared/libosmocore/tests
diff options
context:
space:
mode:
Diffstat (limited to 'Src/osmocom-bb/src/shared/libosmocore/tests')
-rw-r--r--Src/osmocom-bb/src/shared/libosmocore/tests/Makefile.am6
-rw-r--r--Src/osmocom-bb/src/shared/libosmocore/tests/msgfile/Makefile.am5
-rw-r--r--Src/osmocom-bb/src/shared/libosmocore/tests/msgfile/msgconfig.cfg2
-rw-r--r--Src/osmocom-bb/src/shared/libosmocore/tests/msgfile/msgfile_test.c50
-rw-r--r--Src/osmocom-bb/src/shared/libosmocore/tests/sms/Makefile.am5
-rw-r--r--Src/osmocom-bb/src/shared/libosmocore/tests/sms/sms_test.c121
-rw-r--r--Src/osmocom-bb/src/shared/libosmocore/tests/smscb/Makefile.am5
-rw-r--r--Src/osmocom-bb/src/shared/libosmocore/tests/smscb/smscb_test.c41
-rw-r--r--Src/osmocom-bb/src/shared/libosmocore/tests/timer/Makefile.am6
-rw-r--r--Src/osmocom-bb/src/shared/libosmocore/tests/timer/timer_test.c77
-rw-r--r--Src/osmocom-bb/src/shared/libosmocore/tests/ussd/Makefile.am5
-rw-r--r--Src/osmocom-bb/src/shared/libosmocore/tests/ussd/ussd_test.c91
12 files changed, 0 insertions, 414 deletions
diff --git a/Src/osmocom-bb/src/shared/libosmocore/tests/Makefile.am b/Src/osmocom-bb/src/shared/libosmocore/tests/Makefile.am
deleted file mode 100644
index 2b4ac6e..0000000
--- a/Src/osmocom-bb/src/shared/libosmocore/tests/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-if ENABLE_TESTS
-SUBDIRS = timer sms ussd smscb
-if ENABLE_MSGFILE
-SUBDIRS += msgfile
-endif
-endif
diff --git a/Src/osmocom-bb/src/shared/libosmocore/tests/msgfile/Makefile.am b/Src/osmocom-bb/src/shared/libosmocore/tests/msgfile/Makefile.am
deleted file mode 100644
index c9f4bec..0000000
--- a/Src/osmocom-bb/src/shared/libosmocore/tests/msgfile/Makefile.am
+++ /dev/null
@@ -1,5 +0,0 @@
-INCLUDES = $(all_includes) -I$(top_srcdir)/include
-noinst_PROGRAMS = msgfile_test
-
-msgfile_test_SOURCES = msgfile_test.c
-msgfile_test_LDADD = $(top_builddir)/src/libosmocore.la
diff --git a/Src/osmocom-bb/src/shared/libosmocore/tests/msgfile/msgconfig.cfg b/Src/osmocom-bb/src/shared/libosmocore/tests/msgfile/msgconfig.cfg
deleted file mode 100644
index 28d7432..0000000
--- a/Src/osmocom-bb/src/shared/libosmocore/tests/msgfile/msgconfig.cfg
+++ /dev/null
@@ -1,2 +0,0 @@
-# This is a comment
-*:*::Hello Welt
diff --git a/Src/osmocom-bb/src/shared/libosmocore/tests/msgfile/msgfile_test.c b/Src/osmocom-bb/src/shared/libosmocore/tests/msgfile/msgfile_test.c
deleted file mode 100644
index ed7aa97..0000000
--- a/Src/osmocom-bb/src/shared/libosmocore/tests/msgfile/msgfile_test.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * (C) 2010 by Holger Hans Peter Freyther
- * (C) 2010 by On-Waves
- * 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 <osmocom/core/msgfile.h>
-
-#include <stdio.h>
-
-static void dump_entries(struct osmo_config_list *entries)
-{
- struct osmo_config_entry *entry;
-
- if (!entries) {
- fprintf(stderr, "Failed to parse the file\n");
- return;
- }
-
- llist_for_each_entry(entry, &entries->entry, list) {
- printf("Entry '%s:%s:%s:%s'\n",
- entry->mcc, entry->mnc, entry->option, entry->text);
- }
-}
-
-int main(int argc, char **argv)
-{
- struct osmo_config_list *entries;
-
- /* todo use msgfile_test.c.in and replace the path */
- entries = osmo_config_list_parse(NULL, "msgconfig.cfg");
- dump_entries(entries);
-
- return 0;
-}
diff --git a/Src/osmocom-bb/src/shared/libosmocore/tests/sms/Makefile.am b/Src/osmocom-bb/src/shared/libosmocore/tests/sms/Makefile.am
deleted file mode 100644
index fa4e387..0000000
--- a/Src/osmocom-bb/src/shared/libosmocore/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/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la
diff --git a/Src/osmocom-bb/src/shared/libosmocore/tests/sms/sms_test.c b/Src/osmocom-bb/src/shared/libosmocore/tests/sms/sms_test.c
deleted file mode 100644
index b4ed631..0000000
--- a/Src/osmocom-bb/src/shared/libosmocore/tests/sms/sms_test.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * (C) 2008 by Daniel Willmann <daniel@totalueberwachung.de>
- * (C) 2010 by Nico Golde <nico@ngolde.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 <osmocom/core/msgb.h>
-#include <osmocom/gsm/gsm_utils.h>
-#include <osmocom/core/utils.h>
-
-struct test_case {
- const uint8_t *input;
- const uint16_t input_length;
-
- const uint8_t *expected;
- const uint16_t expected_length;
-};
-
-static const char simple_text[] = "test text";
-static const uint8_t simple_enc[] = {
- 0xf4, 0xf2, 0x9c, 0x0e, 0xa2, 0x97, 0xf1, 0x74
-};
-
-static const char escape_text[] = "!$ a more#^- complicated test@@?_\%! case";
-static const uint8_t escape_enc[] = {
- 0x21, 0x01, 0x28, 0x0c, 0x6a, 0xbf, 0xe5, 0xe5, 0xd1,
- 0x86, 0xd2, 0x02, 0x8d, 0xdf, 0x6d, 0x38, 0x3b, 0x3d,
- 0x0e, 0xd3, 0xcb, 0x64, 0x10, 0xbd, 0x3c, 0xa7, 0x03,
- 0x00, 0xbf, 0x48, 0x29, 0x04, 0x1a, 0x87, 0xe7, 0x65,
-};
-
-static const struct test_case test_encode[] =
-{
- {
- .input = simple_text,
- .expected = simple_enc,
- .expected_length = sizeof(simple_enc),
- },
- {
- .input = escape_text,
- .expected = escape_enc,
- .expected_length = sizeof(escape_enc),
- },
-};
-
-static const struct test_case test_decode[] =
-{
- {
- .input = simple_enc,
- .input_length = sizeof(simple_enc),
- .expected = simple_text,
- },
- {
- .input = escape_enc,
- .input_length = sizeof(escape_enc),
- .expected = escape_text,
- },
-};
-
-int main(int argc, char** argv)
-{
- printf("SMS testing\n");
- struct msgb *msg;
- uint8_t *sms;
- uint8_t i;
-
- uint8_t length;
- uint8_t coded[256];
- char result[256];
-
- /* test 7-bit encoding */
- for (i = 0; i < ARRAY_SIZE(test_encode); ++i) {
- memset(coded, 0x42, sizeof(coded));
- length = gsm_7bit_encode(coded, test_encode[i].input);
-
- if (length != test_encode[i].expected_length) {
- fprintf(stderr, "Failed to encode case %d. Got %d, expected %d\n",
- i, length, test_encode[i].expected_length);
- return -1;
- }
-
- if (memcmp(coded, test_encode[i].expected, length) != 0) {
- fprintf(stderr, "Encoded content does not match for %d\n",
- i);
- return -1;
- }
- }
-
- /* test 7-bit decoding */
- for (i = 0; i < ARRAY_SIZE(test_decode); ++i) {
- memset(result, 0x42, sizeof(coded));
- gsm_7bit_decode(result, test_decode[i].input,
- test_decode[i].input_length);
-
- if (strcmp(result, test_decode[i].expected) != 0) {
- fprintf(stderr, "Test case %d failed to decode.\n", i);
- return -1;
- }
- }
-
- printf("OK\n");
- return 0;
-}
diff --git a/Src/osmocom-bb/src/shared/libosmocore/tests/smscb/Makefile.am b/Src/osmocom-bb/src/shared/libosmocore/tests/smscb/Makefile.am
deleted file mode 100644
index 9a6fb4f..0000000
--- a/Src/osmocom-bb/src/shared/libosmocore/tests/smscb/Makefile.am
+++ /dev/null
@@ -1,5 +0,0 @@
-INCLUDES = $(all_includes) -I$(top_srcdir)/include
-noinst_PROGRAMS = smscb_test
-
-smscb_test_SOURCES = smscb_test.c
-smscb_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la
diff --git a/Src/osmocom-bb/src/shared/libosmocore/tests/smscb/smscb_test.c b/Src/osmocom-bb/src/shared/libosmocore/tests/smscb/smscb_test.c
deleted file mode 100644
index e10e12d..0000000
--- a/Src/osmocom-bb/src/shared/libosmocore/tests/smscb/smscb_test.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * (C) 2010 Holger Hans Peter Freyther
- * 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 <osmocom/gsm/protocol/gsm_03_41.h>
-
-#include <stdio.h>
-
-static uint8_t smscb_msg[] = { 0x40, 0x10, 0x05, 0x0d, 0x01, 0x11 };
-
-int main(int argc, char **argv)
-{
- struct gsm341_ms_message *msg;
-
- msg = (struct gsm341_ms_message *) smscb_msg;
- printf("(srl) GS: %d MSG_CODE: %d UPDATE: %d\n",
- msg->serial.gs, GSM341_MSG_CODE(msg), msg->serial.update);
- printf("(msg) msg_id: %d\n", htons(msg->msg_id));
- printf("(dcs) group: %d language: %d\n",
- msg->dcs.language, msg->dcs.group);
- printf("(pge) page total: %d current: %d\n",
- msg->page.total, msg->page.current);
-
- return 0;
-}
diff --git a/Src/osmocom-bb/src/shared/libosmocore/tests/timer/Makefile.am b/Src/osmocom-bb/src/shared/libosmocore/tests/timer/Makefile.am
deleted file mode 100644
index d3decf5..0000000
--- a/Src/osmocom-bb/src/shared/libosmocore/tests/timer/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-INCLUDES = $(all_includes) -I$(top_srcdir)/include
-noinst_PROGRAMS = timer_test
-
-timer_test_SOURCES = timer_test.c
-timer_test_LDADD = $(top_builddir)/src/libosmocore.la
-
diff --git a/Src/osmocom-bb/src/shared/libosmocore/tests/timer/timer_test.c b/Src/osmocom-bb/src/shared/libosmocore/tests/timer/timer_test.c
deleted file mode 100644
index 240bc48..0000000
--- a/Src/osmocom-bb/src/shared/libosmocore/tests/timer/timer_test.c
+++ /dev/null
@@ -1,77 +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 <osmocom/core/timer.h>
-#include <osmocom/core/select.h>
-
-#include "../../config.h"
-
-static void timer_fired(void *data);
-
-static struct osmo_timer_list timer_one = {
- .cb = timer_fired,
- .data = (void*)1,
-};
-
-static struct osmo_timer_list timer_two = {
- .cb = timer_fired,
- .data = (void*)2,
-};
-
-static struct osmo_timer_list timer_three = {
- .cb = timer_fired,
- .data = (void*)3,
-};
-
-static void timer_fired(void *_data)
-{
- unsigned long data = (unsigned long) _data;
- printf("Fired timer: %lu\n", data);
-
- if (data == 1) {
- osmo_timer_schedule(&timer_one, 3, 0);
- osmo_timer_del(&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");
-
- osmo_timer_schedule(&timer_one, 3, 0);
- osmo_timer_schedule(&timer_two, 5, 0);
- osmo_timer_schedule(&timer_three, 4, 0);
-
-#ifdef HAVE_SYS_SELECT_H
- while (1) {
- osmo_select_main(0);
- }
-#else
- printf("Select not supported on this platform!\n");
-#endif
-}
diff --git a/Src/osmocom-bb/src/shared/libosmocore/tests/ussd/Makefile.am b/Src/osmocom-bb/src/shared/libosmocore/tests/ussd/Makefile.am
deleted file mode 100644
index ef9aa49..0000000
--- a/Src/osmocom-bb/src/shared/libosmocore/tests/ussd/Makefile.am
+++ /dev/null
@@ -1,5 +0,0 @@
-INCLUDES = $(all_includes) -I$(top_srcdir)/include
-noinst_PROGRAMS = ussd_test
-
-ussd_test_SOURCES = ussd_test.c
-ussd_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la
diff --git a/Src/osmocom-bb/src/shared/libosmocore/tests/ussd/ussd_test.c b/Src/osmocom-bb/src/shared/libosmocore/tests/ussd/ussd_test.c
deleted file mode 100644
index 6d2a8c9..0000000
--- a/Src/osmocom-bb/src/shared/libosmocore/tests/ussd/ussd_test.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * (C) 2010 by Holger Hans Peter Freyther
- * (C) 2010 by On-Waves
- * 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 <osmocom/gsm/gsm0480.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-static const uint8_t ussd_request[] = {
- 0x0b, 0x7b, 0x1c, 0x15, 0xa1, 0x13, 0x02, 0x01,
- 0x03, 0x02, 0x01, 0x3b, 0x30, 0x0b, 0x04, 0x01,
- 0x0f, 0x04, 0x06, 0x2a, 0xd5, 0x4c, 0x16, 0x1b,
- 0x01, 0x7f, 0x01, 0x00
-};
-
-static int parse_ussd(const uint8_t *_data, int len)
-{
- uint8_t *data;
- int rc;
- struct ussd_request req;
- struct gsm48_hdr *hdr;
-
- data = malloc(len);
- memcpy(data, _data, len);
- hdr = (struct gsm48_hdr *) &data[0];
- rc = gsm0480_decode_ussd_request(hdr, len, &req);
- free(data);
-
- return rc;
-}
-
-static int parse_mangle_ussd(const uint8_t *_data, int len)
-{
- uint8_t *data;
- int rc;
- struct ussd_request req;
- struct gsm48_hdr *hdr;
-
- data = malloc(len);
- memcpy(data, _data, len);
- hdr = (struct gsm48_hdr *) &data[0];
- hdr->data[1] = len - sizeof(*hdr) - 2;
- rc = gsm0480_decode_ussd_request(hdr, len, &req);
- free(data);
-
- return rc;
-}
-
-int main(int argc, char **argv)
-{
- struct ussd_request req;
- const int size = sizeof(ussd_request);
- int i;
-
- gsm0480_decode_ussd_request((struct gsm48_hdr *) ussd_request, size, &req);
- printf("Tested if it still works. Text was: %s\n", req.text);
-
-
- printf("Testing parsing a USSD request and truncated versions\n");
-
- for (i = size; i > sizeof(struct gsm48_hdr); --i) {
- int rc = parse_ussd(&ussd_request[0], i);
- printf("Result for %d is %d\n", rc, i);
- }
-
- printf("Mangling the container now\n");
- for (i = size; i > sizeof(struct gsm48_hdr) + 2; --i) {
- int rc = parse_mangle_ussd(&ussd_request[0], i);
- printf("Result for %d is %d\n", rc, i);
- }
-
- return 0;
-}