From f98a4974d764a4b6f8da5a8a5cadacae83eb87b7 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sat, 20 Feb 2010 17:29:27 +0100 Subject: finish openbsc / libosmocore separation * use pkg-config from openbsc to find header and library * move sms and timer tests to libosmocore itself * ensure "make distcheck" works on both packages --- libosmocore/Makefile.am | 2 +- libosmocore/configure.in | 3 ++ libosmocore/include/osmocore/Makefile.am | 6 ++- libosmocore/libosmocore.pc.in | 3 +- libosmocore/tests/Makefile.am | 1 + libosmocore/tests/sms/Makefile.am | 5 +++ libosmocore/tests/sms/sms_test.c | 47 +++++++++++++++++++++ libosmocore/tests/timer/Makefile.am | 6 +++ libosmocore/tests/timer/timer_test.c | 70 ++++++++++++++++++++++++++++++++ openbsc/configure.in | 5 +-- openbsc/include/openbsc/Makefile.am | 14 +++---- openbsc/src/Makefile.am | 12 +++--- openbsc/tests/Makefile.am | 2 +- openbsc/tests/channel/Makefile.am | 10 +---- openbsc/tests/channel/channel_test.c | 2 +- openbsc/tests/db/Makefile.am | 2 +- openbsc/tests/debug/Makefile.am | 3 +- openbsc/tests/gsm0408/Makefile.am | 2 +- openbsc/tests/sccp/Makefile.am | 2 +- openbsc/tests/sccp/sccp_test.c | 2 +- openbsc/tests/sms/Makefile.am | 5 --- openbsc/tests/sms/sms_test.c | 53 ------------------------ openbsc/tests/timer/Makefile.am | 5 --- openbsc/tests/timer/timer_test.c | 70 -------------------------------- 24 files changed, 161 insertions(+), 171 deletions(-) create mode 100644 libosmocore/tests/Makefile.am create mode 100644 libosmocore/tests/sms/Makefile.am create mode 100644 libosmocore/tests/sms/sms_test.c create mode 100644 libosmocore/tests/timer/Makefile.am create mode 100644 libosmocore/tests/timer/timer_test.c delete mode 100644 openbsc/tests/sms/Makefile.am delete mode 100644 openbsc/tests/sms/sms_test.c delete mode 100644 openbsc/tests/timer/Makefile.am delete mode 100644 openbsc/tests/timer/timer_test.c diff --git a/libosmocore/Makefile.am b/libosmocore/Makefile.am index 6bda10a1c..8007b7458 100644 --- a/libosmocore/Makefile.am +++ b/libosmocore/Makefile.am @@ -1,7 +1,7 @@ AUTOMAKE_OPTIONS = foreign dist-bzip2 1.6 INCLUDES = $(all_includes) -I$(top_srcdir)/include -SUBDIRS = include src +SUBDIRS = include src tests pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libosmocore.pc diff --git a/libosmocore/configure.in b/libosmocore/configure.in index 8c0fe6727..d9fa6e810 100644 --- a/libosmocore/configure.in +++ b/libosmocore/configure.in @@ -34,4 +34,7 @@ AC_OUTPUT( include/osmocore/Makefile include/Makefile src/Makefile + tests/Makefile + tests/timer/Makefile + tests/sms/Makefile Makefile) diff --git a/libosmocore/include/osmocore/Makefile.am b/libosmocore/include/osmocore/Makefile.am index aec27d19c..189c7676d 100644 --- a/libosmocore/include/osmocore/Makefile.am +++ b/libosmocore/include/osmocore/Makefile.am @@ -1,2 +1,4 @@ -pkginclude_HEADERS = signal.h linuxlist.h timer.h talloc.h msgb.h select.h \ - tlv.h bitvec.h comp128.h statistics.h gsm_utils.h +osmocore_HEADERS = signal.h linuxlist.h timer.h talloc.h msgb.h select.h \ + tlv.h bitvec.h comp128.h statistics.h gsm_utils.h utils.h + +osmocoredir = $(includedir)/osmocore diff --git a/libosmocore/libosmocore.pc.in b/libosmocore/libosmocore.pc.in index 0d09cb823..7c298693a 100644 --- a/libosmocore/libosmocore.pc.in +++ b/libosmocore/libosmocore.pc.in @@ -1,4 +1,5 @@ -prefix=@exec_prefix@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ diff --git a/libosmocore/tests/Makefile.am b/libosmocore/tests/Makefile.am new file mode 100644 index 000000000..56e8b6f64 --- /dev/null +++ b/libosmocore/tests/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = timer sms diff --git a/libosmocore/tests/sms/Makefile.am b/libosmocore/tests/sms/Makefile.am new file mode 100644 index 000000000..a8f1ff6a2 --- /dev/null +++ b/libosmocore/tests/sms/Makefile.am @@ -0,0 +1,5 @@ +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 diff --git a/libosmocore/tests/sms/sms_test.c b/libosmocore/tests/sms/sms_test.c new file mode 100644 index 000000000..106635ffd --- /dev/null +++ b/libosmocore/tests/sms/sms_test.c @@ -0,0 +1,47 @@ +/* + * (C) 2008 by Daniel Willmann + * 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 +#include +#include +#include +#include +#include + +int main(int argc, char** argv) +{ + printf("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); + } +} diff --git a/libosmocore/tests/timer/Makefile.am b/libosmocore/tests/timer/Makefile.am new file mode 100644 index 000000000..d3decf556 --- /dev/null +++ b/libosmocore/tests/timer/Makefile.am @@ -0,0 +1,6 @@ +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/libosmocore/tests/timer/timer_test.c b/libosmocore/tests/timer/timer_test.c new file mode 100644 index 000000000..ec29ef048 --- /dev/null +++ b/libosmocore/tests/timer/timer_test.c @@ -0,0 +1,70 @@ +/* + * (C) 2008 by 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 + +#include +#include + +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); + } +} diff --git a/openbsc/configure.in b/openbsc/configure.in index 88a3f61f4..71ed10b5f 100644 --- a/openbsc/configure.in +++ b/openbsc/configure.in @@ -16,6 +16,8 @@ dnl checks for libraries AC_SEARCH_LIBS(crypt, crypt, [LIBCRYPT="-lcrypt"; AC_DEFINE([VTY_CRYPT_PW], [], [Use crypt functionality of vty.])]) +PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore) + dnl checks for header files AC_HEADER_STDC @@ -38,7 +40,6 @@ AM_CONFIG_HEADER(bscconfig.h) AC_OUTPUT( openbsc.pc - liblaf0rge1.pc libsccp.pc include/openbsc/Makefile include/vty/Makefile @@ -47,8 +48,6 @@ AC_OUTPUT( src/Makefile tests/Makefile tests/debug/Makefile - tests/timer/Makefile - tests/sms/Makefile tests/gsm0408/Makefile tests/db/Makefile tests/channel/Makefile diff --git a/openbsc/include/openbsc/Makefile.am b/openbsc/include/openbsc/Makefile.am index 8aa90c31b..234354906 100644 --- a/openbsc/include/openbsc/Makefile.am +++ b/openbsc/include/openbsc/Makefile.am @@ -1,15 +1,11 @@ noinst_HEADERS = abis_nm.h abis_rsl.h db.h gsm_04_08.h gsm_data.h \ - gsm_subscriber.h gsm_04_11.h \ - timer.h misdn.h chan_alloc.h telnet_interface.h paging.h \ + gsm_subscriber.h gsm_04_11.h debug.h signal.h \ + misdn.h chan_alloc.h telnet_interface.h paging.h \ subchan_demux.h trau_frame.h e1_input.h trau_mux.h \ - gsm_utils.h ipaccess.h rs232.h openbscdefines.h rtp_proxy.h \ + ipaccess.h rs232.h openbscdefines.h rtp_proxy.h \ bsc_rll.h mncc.h transaction.h ussd.h gsm_04_80.h \ - silent_call.h mgcp.h meas_rep.h bitvec.h rest_octets.h \ - system_information.h handover.h statistics.h - -laforge_HEADERS = signal.h linuxlist.h timer.h talloc.h msgb.h select.h tlv.h \ - debug.h -laforgedir= $(includedir)/laf0rge1 + silent_call.h mgcp.h meas_rep.h rest_octets.h \ + system_information.h handover.h openbsc_HEADERS = gsm_04_08.h meas_rep.h openbscdir = $(includedir)/openbsc diff --git a/openbsc/src/Makefile.am b/openbsc/src/Makefile.am index 2edaf00e5..cfe025e48 100644 --- a/openbsc/src/Makefile.am +++ b/openbsc/src/Makefile.am @@ -1,5 +1,6 @@ INCLUDES = $(all_includes) -I$(top_srcdir)/include -AM_CFLAGS=-Wall +AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) +AM_LDFLAGS = $(LIBOSMOCORE_LIBS) sbin_PROGRAMS = bsc_hack bs11_config ipaccess-find ipaccess-config \ isdnsync bsc_mgcp ipaccess-proxy @@ -28,22 +29,19 @@ libvty_a_SOURCES = vty/buffer.c vty/command.c vty/vector.c vty/vty.c libsccp_a_SOURCES = sccp/sccp.c bsc_hack_SOURCES = bsc_hack.c bsc_init.c vty_interface.c vty_interface_layer3.c -bsc_hack_LDADD = libmsc.a libbsc.a libmsc.a libvty.a -losmocore -ldl -ldbi $(LIBCRYPT) +bsc_hack_LDADD = libmsc.a libbsc.a libmsc.a libvty.a -ldl -ldbi $(LIBCRYPT) bs11_config_SOURCES = bs11_config.c abis_nm.c gsm_data.c debug.c \ rs232.c bts_siemens_bs11.c -bs11_config_LDADD = -losmocore ipaccess_find_SOURCES = ipaccess/ipaccess-find.c -ipaccess_find_LDADD = -losmocore ipaccess_config_SOURCES = ipaccess/ipaccess-config.c ipaccess/ipaccess-firmware.c -ipaccess_config_LDADD = libbsc.a libmsc.a libbsc.a libvty.a -losmocore -ldl -ldbi $(LIBCRYPT) +ipaccess_config_LDADD = libbsc.a libmsc.a libbsc.a libvty.a -ldl -ldbi $(LIBCRYPT) isdnsync_SOURCES = isdnsync.c bsc_mgcp_SOURCES = mgcp/mgcp_main.c mgcp/mgcp_protocol.c debug.c telnet_interface.c -bsc_mgcp_LDADD = libvty.a -losmocore +bsc_mgcp_LDADD = libvty.a ipaccess_proxy_SOURCES = ipaccess/ipaccess-proxy.c debug.c -ipaccess_proxy_LDADD = -losmocore diff --git a/openbsc/tests/Makefile.am b/openbsc/tests/Makefile.am index f40105fbf..3b1b93120 100644 --- a/openbsc/tests/Makefile.am +++ b/openbsc/tests/Makefile.am @@ -1 +1 @@ -SUBDIRS = debug timer sms gsm0408 db channel sccp +SUBDIRS = debug gsm0408 db channel sccp diff --git a/openbsc/tests/channel/Makefile.am b/openbsc/tests/channel/Makefile.am index 6b9f6e3cb..8e57b8d0c 100644 --- a/openbsc/tests/channel/Makefile.am +++ b/openbsc/tests/channel/Makefile.am @@ -8,14 +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 \ - $(top_srcdir)/src/statistics.c \ $(top_srcdir)/src/bts_ipaccess_nanobts.c \ - $(top_srcdir)/src/bts_siemens_bs11.c \ - $(top_srcdir)/src/tlv_parser.c -channel_test_LDADD = -ldl -ldbi + $(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 36d057273..759001c57 100644 --- a/openbsc/tests/channel/channel_test.c +++ b/openbsc/tests/channel/channel_test.c @@ -23,7 +23,7 @@ #include -#include +#include #include #include diff --git a/openbsc/tests/db/Makefile.am b/openbsc/tests/db/Makefile.am index 310763aec..85f2c146a 100644 --- a/openbsc/tests/db/Makefile.am +++ b/openbsc/tests/db/Makefile.am @@ -4,5 +4,5 @@ AM_CFLAGS=-Wall -ggdb3 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 $(top_builddir)/src/liblaf0rge1.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 62c906e72..86cd7b323 100644 --- a/openbsc/tests/debug/Makefile.am +++ b/openbsc/tests/debug/Makefile.am @@ -1,4 +1,5 @@ INCLUDES = $(all_includes) -I$(top_srcdir)/include noinst_PROGRAMS = debug_test -debug_test_SOURCES = debug_test.c $(top_srcdir)/src/debug.c $(top_srcdir)/src/talloc.c +debug_test_SOURCES = debug_test.c $(top_srcdir)/src/debug.c +debug_test_LDADD = $(LIBOSMOCORE_LIBS) diff --git a/openbsc/tests/gsm0408/Makefile.am b/openbsc/tests/gsm0408/Makefile.am index 69f1e4e69..44ca96cf0 100644 --- a/openbsc/tests/gsm0408/Makefile.am +++ b/openbsc/tests/gsm0408/Makefile.am @@ -2,4 +2,4 @@ INCLUDES = $(all_includes) -I$(top_srcdir)/include 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 $(top_builddir)/src/liblaf0rge1.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/sccp/Makefile.am b/openbsc/tests/sccp/Makefile.am index 3e350143a..4152a9a54 100644 --- a/openbsc/tests/sccp/Makefile.am +++ b/openbsc/tests/sccp/Makefile.am @@ -4,5 +4,5 @@ AM_CFLAGS=-Wall -ggdb3 noinst_PROGRAMS = sccp_test sccp_test_SOURCES = sccp_test.c -sccp_test_LDADD = $(top_builddir)/src/libsccp.a $(top_builddir)/src/libbsc.a $(top_builddir)/src/liblaf0rge1.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 562e1345f..982c168be 100644 --- a/openbsc/tests/sccp/sccp_test.c +++ b/openbsc/tests/sccp/sccp_test.c @@ -28,7 +28,7 @@ #include #include -#include +#include #include diff --git a/openbsc/tests/sms/Makefile.am b/openbsc/tests/sms/Makefile.am deleted file mode 100644 index c1eeec74e..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 $(top_builddir)/src/liblaf0rge1.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 - * 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 -#include -#include -#include -#include -#include -#include -#include - -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 - * 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 - -#include -#include - -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); - } -} -- cgit v1.2.3