diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2011-12-01 09:12:47 +0100 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2011-12-01 09:14:32 +0100 |
commit | b0985e3fa5ad539f1ab51ebf89724eb8e616a750 (patch) | |
tree | 211803084bedbda9ad4968a46be4195f3688bb6a | |
parent | 467e1497630a093cff94670da0e8fa39fd21c278 (diff) |
test: Introduce a very simple test for the paging subsystem
Check that adding a paging command works, check that it is expired
after the first call to paging_gen_msg. The test will be extended
to test the scheduling and selection of the various paging messages.
-rw-r--r-- | .gitignore | 7 | ||||
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | tests/Makefile.am | 41 | ||||
-rw-r--r-- | tests/paging/Makefile.am | 8 | ||||
-rw-r--r-- | tests/paging/paging_test.c | 126 | ||||
-rw-r--r-- | tests/paging/paging_test.ok | 2 | ||||
-rw-r--r-- | tests/testsuite.at | 8 |
8 files changed, 196 insertions, 1 deletions
@@ -18,3 +18,10 @@ core.* src/osmo-bts-sysmo/l1fwd-proxy src/osmo-bts-sysmo/sysmobts src/osmo-bts-sysmo/sysmobts-remote + + +tests/atconfig +tests/package.m4 +tests/paging/paging_test +tests/testsuite +tests/testsuite.log diff --git a/Makefile.am b/Makefile.am index bc3910fa..7434f5c9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,3 +1,3 @@ AUTOMAKE_OPTIONS = foreign dist-bzip2 1.6 -SUBDIRS = include src +SUBDIRS = include src tests diff --git a/configure.ac b/configure.ac index 46599633..7330df86 100644 --- a/configure.ac +++ b/configure.ac @@ -4,6 +4,7 @@ AC_INIT([osmo-bts], [openbsc-devel@lists.openbsc.org]) AM_INIT_AUTOMAKE([dist-bzip2]) +AC_CONFIG_TESTDIR(tests) dnl kernel style compile messages m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) @@ -40,4 +41,6 @@ AC_OUTPUT( src/osmo-bts-bb/Makefile include/Makefile include/osmo-bts/Makefile + tests/Makefile + tests/paging/Makefile Makefile) diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 00000000..fe1b3093 --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,41 @@ +SUBDIRS = paging + +# The `:;' works around a Bash 3.2 bug when the output is not writeable. +$(srcdir)/package.m4: $(top_srcdir)/configure.ac + :;{ \ + echo '# Signature of the current package.' && \ + echo 'm4_define([AT_PACKAGE_NAME],' && \ + echo ' [$(PACKAGE_NAME)])' && \ + echo 'm4_define([AT_PACKAGE_TARNAME],' && \ + echo ' [$(PACKAGE_TARNAME)])' && \ + echo 'm4_define([AT_PACKAGE_VERSION],' && \ + echo ' [$(PACKAGE_VERSION)])' && \ + echo 'm4_define([AT_PACKAGE_STRING],' && \ + echo ' [$(PACKAGE_STRING)])' && \ + echo 'm4_define([AT_PACKAGE_BUGREPORT],' && \ + echo ' [$(PACKAGE_BUGREPORT)])'; \ + echo 'm4_define([AT_PACKAGE_URL],' && \ + echo ' [$(PACKAGE_URL)])'; \ + } >'$(srcdir)/package.m4' + +EXTRA_DIST = testsuite.at $(srcdir)/package.m4 $(TESTSUITE) +TESTSUITE = $(srcdir)/testsuite + +check-local: atconfig $(TESTSUITE) + $(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS) + +installcheck-local: atconfig $(TESTSUITE) + $(SHELL) '$(TESTSUITE)' AUTOTEST_PATH='$(bindir)' \ + $(TESTSUITEFLAGS) + +clean-local: + test ! -f '$(TESTSUITE)' || \ + $(SHELL) '$(TESTSUITE)' --clean + $(RM) -f atconfig + +AUTOM4TE = $(SHELL) $(top_srcdir)/missing --run autom4te +AUTOTEST = $(AUTOM4TE) --language=autotest +$(TESTSUITE): $(srcdir)/testsuite.at $(srcdir)/package.m4 + $(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at + mv $@.tmp $@ + diff --git a/tests/paging/Makefile.am b/tests/paging/Makefile.am new file mode 100644 index 00000000..d5743a65 --- /dev/null +++ b/tests/paging/Makefile.am @@ -0,0 +1,8 @@ +INCLUDES = $(all_includes) -I$(top_srcdir)/include +AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(LIBOSMOTRAU_CFLAGS) +LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) $(LIBOSMOTRAU_LIBS) -lortp +noinst_PROGRAMS = paging_test +EXTRA_DIST = paging_test.ok + +paging_test_SOURCES = paging_test.c +paging_test_LDADD = $(top_builddir)/src/common/libbts.a $(LDADD) diff --git a/tests/paging/paging_test.c b/tests/paging/paging_test.c new file mode 100644 index 00000000..6ce8220d --- /dev/null +++ b/tests/paging/paging_test.c @@ -0,0 +1,126 @@ +/* testing the paging code */ + +/* (C) 2011 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 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 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 <osmocom/core/talloc.h> + +#include <osmo-bts/bts.h> +#include <osmo-bts/logging.h> +#include <osmo-bts/paging.h> +#include <osmo-bts/gsm_data.h> + +static struct gsm_bts *bts; +static struct gsm_bts_role_bts *btsb; + +static const uint8_t static_ilv[] = { + 0x08, 0x59, 0x51, 0x30, 0x99, 0x00, 0x00, 0x00, 0x19 +}; + +#define ASSERT_TRUE(rc) \ + if (!(rc)) { \ + printf("Assert failed in %s:%d.\n", \ + __FILE__, __LINE__); \ + abort(); \ + } + +static void test_paging_smoke(void) +{ + int rc; + uint8_t out_buf[GSM_MACBLOCK_LEN]; + struct gsm_time g_time; + printf("Testing that paging messages expire.\n"); + + /* add paging entry */ + rc = paging_add_identity(btsb->paging_state, 0, static_ilv, 0); + ASSERT_TRUE(rc == 0); + ASSERT_TRUE(paging_queue_length(btsb->paging_state) == 1); + + /* generate messages */ + g_time.fn = 0; + g_time.t1 = 0; + g_time.t2 = 0; + g_time.t3 = 6; + rc = paging_gen_msg(btsb->paging_state, out_buf, &g_time); + ASSERT_TRUE(rc == 13); + + ASSERT_TRUE(paging_group_queue_empty(btsb->paging_state, 0)); + ASSERT_TRUE(paging_queue_length(btsb->paging_state) == 0); + + /* + * TODO: test all the cases of different amount tmsi/imsi and check + * if we fill the slots in a optimal way. + */ +} + +int main(int argc, char **argv) +{ + void *tall_msgb_ctx; + + tall_bts_ctx = talloc_named_const(NULL, 1, "OsmoBTS context"); + tall_msgb_ctx = talloc_named_const(tall_bts_ctx, 1, "msgb"); + msgb_set_talloc_ctx(tall_msgb_ctx); + + bts_log_init(NULL); + + bts = gsm_bts_alloc(tall_bts_ctx); + if (bts_init(bts) < 0) { + fprintf(stderr, "unable to to open bts\n"); + exit(1); + } + + btsb = bts_role_bts(bts); + test_paging_smoke(); + printf("Success\n"); + + return 0; +} + +/* stub to link */ +const uint8_t abis_mac[6] = { 0,1,2,3,4,5 }; +const char *software_version = "0815"; + +int bts_model_chg_adm_state(struct gsm_bts *bts, struct gsm_abis_mo *mo, + void *obj, uint8_t adm_state) +{ return 0; } +int bts_model_init(struct gsm_bts *bts) +{ return 0; } +int bts_model_apply_oml(struct gsm_bts *bts, struct msgb *msg, + struct tlv_parsed *new_attr, void *obj) +{ return 0; } +int bts_model_rsl_chan_rel(struct gsm_lchan *lchan) +{ return 0;} + +int bts_model_rsl_deact_sacch(struct gsm_lchan *lchan) +{ return 0; } + +int bts_model_trx_deact_rf(struct gsm_bts_trx *trx) +{ return 0; } +int bts_model_check_oml(struct gsm_bts *bts, uint8_t msg_type, + struct tlv_parsed *old_attr, struct tlv_parsed *new_attr, + void *obj) +{ return 0; } +int bts_model_opstart(struct gsm_bts *bts, struct gsm_abis_mo *mo, + void *obj) +{ return 0; } +int bts_model_rsl_chan_act(struct gsm_lchan *lchan, struct tlv_parsed *tp) +{ return 0; } +int bts_model_rsl_mode_modify(struct gsm_lchan *lchan) +{ return 0; } +void bts_model_rtp_rx_cb(struct osmo_rtp_socket *rs, const uint8_t *rtp_pl, + unsigned int rtp_pl_len) {} diff --git a/tests/paging/paging_test.ok b/tests/paging/paging_test.ok new file mode 100644 index 00000000..bbea0090 --- /dev/null +++ b/tests/paging/paging_test.ok @@ -0,0 +1,2 @@ +Testing that paging messages expire. +Success diff --git a/tests/testsuite.at b/tests/testsuite.at new file mode 100644 index 00000000..d97f27b3 --- /dev/null +++ b/tests/testsuite.at @@ -0,0 +1,8 @@ +AT_INIT +AT_BANNER([Regression tests.]) + +AT_SETUP([paging]) +AT_KEYWORDS([paging]) +cat $abs_srcdir/paging/paging_test.ok > expout +AT_CHECK([$abs_top_builddir/tests/paging/paging_test], [], [expout], [ignore]) +AT_CLEANUP |