aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am3
-rw-r--r--tests/channel/Makefile.am1
-rw-r--r--tests/channel/channel_test.c74
-rw-r--r--tests/channel/channel_test.ok2
-rw-r--r--tests/ctrl_test_runner.py46
-rw-r--r--tests/db/db_test.c7
-rw-r--r--tests/mm_auth/Makefile.am37
-rw-r--r--tests/mm_auth/mm_auth_test.c340
-rw-r--r--tests/mm_auth/mm_auth_test.ok40
-rw-r--r--tests/sms_queue/Makefile.am45
-rw-r--r--tests/sms_queue/sms_queue_test.c215
-rw-r--r--tests/sms_queue/sms_queue_test.err0
-rw-r--r--tests/sms_queue/sms_queue_test.ok98
-rw-r--r--tests/subscr/Makefile.am18
-rw-r--r--tests/subscr/subscr_test.c117
-rw-r--r--tests/subscr/subscr_test.ok3
-rw-r--r--tests/testsuite.at27
-rw-r--r--tests/vty_test_runner.py166
18 files changed, 400 insertions, 839 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 72161eeea..acfe7d297 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,6 +1,5 @@
SUBDIRS = \
gsm0408 \
- db \
channel \
mgcp \
gprs \
@@ -8,8 +7,8 @@ SUBDIRS = \
gbproxy \
trau \
subscr \
- mm_auth \
nanobts_omlattr \
+ sms_queue \
$(NULL)
if BUILD_NAT
diff --git a/tests/channel/Makefile.am b/tests/channel/Makefile.am
index ca470ace4..c7164b475 100644
--- a/tests/channel/Makefile.am
+++ b/tests/channel/Makefile.am
@@ -26,6 +26,7 @@ channel_test_SOURCES = \
channel_test_LDADD = \
$(top_builddir)/src/libmsc/libmsc.a \
$(top_builddir)/src/libbsc/libbsc.a \
+ $(top_builddir)/src/libvlr/libvlr.a \
$(top_builddir)/src/libcommon-cs/libcommon-cs.a \
$(top_builddir)/src/libcommon/libcommon.a \
$(LIBOSMOCORE_LIBS) \
diff --git a/tests/channel/channel_test.c b/tests/channel/channel_test.c
index 88293d0a8..f6869691c 100644
--- a/tests/channel/channel_test.c
+++ b/tests/channel/channel_test.c
@@ -29,68 +29,7 @@
#include <openbsc/abis_rsl.h>
#include <openbsc/debug.h>
#include <openbsc/gsm_subscriber.h>
-
-static int s_end = 0;
-static struct gsm_subscriber_connection s_conn;
-static void *s_data;
-static gsm_cbfn *s_cbfn = NULL;
-
-/* our handler */
-static int subscr_cb(unsigned int hook, unsigned int event, struct msgb *msg, void *data, void *param)
-{
- assert(hook == 101);
- assert(event == 200);
- assert(msg == (void*)0x1323L);
- assert(data == &s_conn);
- assert(param == (void*)0x2342L);
- printf("Reached, didn't crash, test passed\n");
- s_end = true;
- return 0;
-}
-
-/* mock object for testing, directly invoke the cb... maybe later through the timer */
-int paging_request(struct gsm_bts *bts, struct bsc_subscr *bsub, int type, gsm_cbfn *cbfn, void *data)
-{
- s_data = data;
- s_cbfn = cbfn;
-
- /* claim we have patched */
- return 1;
-}
-
-
-void test_request_chan(void)
-{
- struct gsm_network *network;
- struct gsm_bts *bts;
-
- printf("Testing the gsm_subscriber chan logic\n");
-
- /* Create a dummy network */
- network = bsc_network_init(tall_bsc_ctx, 1, 1, NULL);
- if (!network)
- exit(1);
- bts = gsm_bts_alloc(network);
- bts->location_area_code = 23;
- s_conn.network = network;
-
- /* Create a dummy subscriber */
- struct gsm_subscriber *subscr = subscr_alloc();
- subscr->lac = 23;
- subscr->group = network->subscr_group;
-
- OSMO_ASSERT(subscr->group);
- OSMO_ASSERT(subscr->group->net == network);
-
- /* Ask for a channel... */
- struct subscr_request *sr;
- sr = subscr_request_channel(subscr, RSL_CHANNEED_TCH_F, subscr_cb, (void*)0x2342L);
- OSMO_ASSERT(sr);
- OSMO_ASSERT(s_cbfn);
- s_cbfn(101, 200, (void*)0x1323L, &s_conn, s_data);
-
- OSMO_ASSERT(s_end);
-}
+#include <openbsc/vlr.h>
void test_dyn_ts_subslots(void)
{
@@ -126,7 +65,6 @@ int main(int argc, char **argv)
{
osmo_init_logging(&log_info);
- test_request_chan();
test_dyn_ts_subslots();
return EXIT_SUCCESS;
@@ -140,5 +78,13 @@ void gsm48_secure_channel() {}
void paging_request_stop() {}
void vty_out() {}
-struct tlv_definition nm_att_tlvdef;
+void ipa_client_conn_clear_queue() {}
+void ipa_client_conn_close() {}
+void ipa_client_conn_create() {}
+void ipa_client_conn_destroy() {}
+void ipa_client_conn_open() {}
+void ipa_client_conn_send() {}
+void ipa_msg_push_header() {}
+void ipaccess_bts_handle_ccm() {}
+struct tlv_definition nm_att_tlvdef;
diff --git a/tests/channel/channel_test.ok b/tests/channel/channel_test.ok
index 33c819350..e4d625a65 100644
--- a/tests/channel/channel_test.ok
+++ b/tests/channel/channel_test.ok
@@ -1,3 +1 @@
-Testing the gsm_subscriber chan logic
-Reached, didn't crash, test passed
Testing subslot numbers for pchan types
diff --git a/tests/ctrl_test_runner.py b/tests/ctrl_test_runner.py
index 0a99c8992..75961a1de 100644
--- a/tests/ctrl_test_runner.py
+++ b/tests/ctrl_test_runner.py
@@ -474,54 +474,14 @@ class TestCtrlNITB(TestCtrlBase):
self.assertEquals(r['var'], 'number-of-bts')
self.assertEquals(r['value'], '1')
- def testSubscriberAddWithKi(self):
- """Test that we can set the algorithm to none, xor, comp128v1"""
-
- r = self.do_set('subscriber-modify-v1', '2620345,445566')
- self.assertEquals(r['mtype'], 'SET_REPLY')
- self.assertEquals(r['var'], 'subscriber-modify-v1')
- self.assertEquals(r['value'], 'OK')
-
- r = self.do_set('subscriber-modify-v1', '2620345,445566,none')
- self.assertEquals(r['mtype'], 'SET_REPLY')
- self.assertEquals(r['var'], 'subscriber-modify-v1')
- self.assertEquals(r['value'], 'OK')
-
- r = self.do_set('subscriber-modify-v1', '2620345,445566,xor')
- self.assertEquals(r['mtype'], 'ERROR')
- self.assertEquals(r['error'], 'Value failed verification.')
-
- r = self.do_set('subscriber-modify-v1', '2620345,445566,comp128v1,00112233445566778899AABBCCDDEEFF')
- self.assertEquals(r['mtype'], 'SET_REPLY')
- self.assertEquals(r['var'], 'subscriber-modify-v1')
- self.assertEquals(r['value'], 'OK')
-
- r = self.do_set('subscriber-modify-v1', '2620345,445566,none')
- self.assertEquals(r['mtype'], 'SET_REPLY')
- self.assertEquals(r['var'], 'subscriber-modify-v1')
- self.assertEquals(r['value'], 'OK')
-
def testSubscriberAddRemove(self):
r = self.do_set('subscriber-modify-v1', '2620345,445566')
- self.assertEquals(r['mtype'], 'SET_REPLY')
- self.assertEquals(r['var'], 'subscriber-modify-v1')
- self.assertEquals(r['value'], 'OK')
-
- r = self.do_set('subscriber-modify-v1', '2620345,445567')
- self.assertEquals(r['mtype'], 'SET_REPLY')
- self.assertEquals(r['var'], 'subscriber-modify-v1')
- self.assertEquals(r['value'], 'OK')
-
- # TODO. verify that the entry has been created and modified? Invoke
- # the sqlite3 CLI or do it through the DB libraries?
-
- r = self.do_set('subscriber-delete-v1', '2620345')
- self.assertEquals(r['mtype'], 'SET_REPLY')
- self.assertEquals(r['value'], 'Removed')
+ self.assertEquals(r['mtype'], 'ERROR')
+ self.assertEquals(r['error'], 'Command moved to osmo-hlr, no longer available here')
r = self.do_set('subscriber-delete-v1', '2620345')
self.assertEquals(r['mtype'], 'ERROR')
- self.assertEquals(r['error'], 'Failed to find subscriber')
+ self.assertEquals(r['error'], 'Command moved to osmo-hlr, no longer available here')
def testSubscriberList(self):
# TODO. Add command to mark a subscriber as active
diff --git a/tests/db/db_test.c b/tests/db/db_test.c
index 755a6e9eb..a54f11b26 100644
--- a/tests/db/db_test.c
+++ b/tests/db/db_test.c
@@ -254,3 +254,10 @@ int main()
/* stubs */
void vty_out() {}
+void vlr_subscr_disconnected() {}
+void vlr_subscr_rx_tmsi_reall_compl() {}
+void vlr_subscr_rx_id_resp() {}
+void vlr_subscr_rx_auth_resp() {}
+void vlr_loc_update() {}
+void vlr_proc_acc_req() {}
+void vlr_init() {}
diff --git a/tests/mm_auth/Makefile.am b/tests/mm_auth/Makefile.am
deleted file mode 100644
index cb351988b..000000000
--- a/tests/mm_auth/Makefile.am
+++ /dev/null
@@ -1,37 +0,0 @@
-AM_CPPFLAGS = \
- $(all_includes) \
- -I$(top_srcdir)/include \
- $(NULL)
-
-AM_CFLAGS = \
- -Wall \
- $(LIBOSMOCORE_CFLAGS) \
- $(LIBOSMOABIS_CFLAGS) \
- $(LIBOSMOGSM_CFLAGS) \
- $(LIBCRYPTO_CFLAGS) \
- $(NULL)
-
-noinst_PROGRAMS = \
- mm_auth_test \
- $(NULL)
-
-EXTRA_DIST = \
- mm_auth_test.ok \
- $(NULL)
-
-mm_auth_test_SOURCES = \
- mm_auth_test.c \
- $(NULL)
-
-mm_auth_test_LDFLAGS = \
- -Wl,--wrap=db_get_authinfo_for_subscr \
- -Wl,--wrap=db_get_lastauthtuple_for_subscr \
- -Wl,--wrap=db_sync_lastauthtuple_for_subscr \
- $(NULL)
-
-mm_auth_test_LDADD = \
- $(top_builddir)/src/libmsc/libmsc.a \
- $(top_builddir)/src/libcommon/libcommon.a \
- $(LIBOSMOCORE_LIBS) \
- $(LIBOSMOGSM_LIBS) \
- $(NULL)
diff --git a/tests/mm_auth/mm_auth_test.c b/tests/mm_auth/mm_auth_test.c
deleted file mode 100644
index b8777a8c5..000000000
--- a/tests/mm_auth/mm_auth_test.c
+++ /dev/null
@@ -1,340 +0,0 @@
-#include <stdbool.h>
-
-#include <osmocom/core/application.h>
-#include <osmocom/core/logging.h>
-
-#include <openbsc/debug.h>
-#include <openbsc/gsm_data.h>
-#include <openbsc/gsm_subscriber.h>
-#include <openbsc/auth.h>
-
-#define min(A,B) ((A)>(B)? (B) : (A))
-
-static char *auth_tuple_str(struct gsm_auth_tuple *atuple)
-{
- static char buf[256];
- char *pos = buf;
- int len = sizeof(buf);
- int l;
-
-#define print2buf(FMT, args...) do {\
- l = snprintf(pos, len, FMT, ## args); \
- pos += l;\
- len -= l;\
- } while (0)
-
- print2buf("gsm_auth_tuple {\n");
- print2buf(" .use_count = %d\n", atuple->use_count);
- print2buf(" .key_seq = %d\n", atuple->key_seq);
- print2buf(" .rand = %s\n", osmo_hexdump(atuple->vec.rand, sizeof(atuple->vec.rand)));
- print2buf(" .sres = %s\n", osmo_hexdump(atuple->vec.sres, sizeof(atuple->vec.sres)));
- print2buf(" .kc = %s\n", osmo_hexdump(atuple->vec.kc, sizeof(atuple->vec.kc)));
- print2buf("}\n");
-#undef print2buf
-
- return buf;
-}
-
-static bool auth_tuple_is(struct gsm_auth_tuple *atuple,
- const char *expect_str)
-{
- int l, l1, l2;
- int i;
- char *tuple_str = auth_tuple_str(atuple);
- bool same = (strcmp(expect_str, tuple_str) == 0);
- if (!same) {
- l1 = strlen(expect_str);
- l2 = strlen(tuple_str);
- printf("Expected %d:\n%s\nGot %d:\n%s\n",
- l1, expect_str, l2, tuple_str);
- l = min(l1, l2);
- for (i = 0; i < l; i++) {
- if (expect_str[i] != tuple_str[i]) {
- printf("Difference at pos %d"
- " (%c 0x%0x != %c 0x%0x)\n",
- i, expect_str[i], expect_str[i],
- tuple_str[i], tuple_str[i]);
- break;
- }
- }
- }
- return same;
-}
-
-/* override, requires '-Wl,--wrap=db_get_authinfo_for_subscr' */
-int __real_db_get_authinfo_for_subscr(struct gsm_auth_info *ainfo,
- struct gsm_subscriber *subscr);
-
-int test_get_authinfo_rc = 0;
-struct gsm_auth_info test_auth_info = {0};
-struct gsm_auth_info default_auth_info = {
- .auth_algo = AUTH_ALGO_COMP128v1,
- .a3a8_ki_len = 16,
- .a3a8_ki = { 0 }
-};
-
-int __wrap_db_get_authinfo_for_subscr(struct gsm_auth_info *ainfo,
- struct gsm_subscriber *subscr)
-{
- *ainfo = test_auth_info;
- printf("wrapped: db_get_authinfo_for_subscr(): rc = %d\n", test_get_authinfo_rc);
- return test_get_authinfo_rc;
-}
-
-/* override, requires '-Wl,--wrap=db_get_lastauthtuple_for_subscr' */
-int __real_db_get_lastauthtuple_for_subscr(struct gsm_auth_tuple *atuple,
- struct gsm_subscriber *subscr);
-
-int test_get_lastauthtuple_rc = 0;
-struct gsm_auth_tuple test_last_auth_tuple = { 0 };
-struct gsm_auth_tuple default_auth_tuple = { 0 };
-
-int __wrap_db_get_lastauthtuple_for_subscr(struct gsm_auth_tuple *atuple,
- struct gsm_subscriber *subscr)
-{
- *atuple = test_last_auth_tuple;
- printf("wrapped: db_get_lastauthtuple_for_subscr(): rc = %d\n", test_get_lastauthtuple_rc);
- return test_get_lastauthtuple_rc;
-}
-
-/* override, requires '-Wl,--wrap=db_sync_lastauthtuple_for_subscr' */
-int __real_db_sync_lastauthtuple_for_subscr(struct gsm_auth_tuple *atuple,
- struct gsm_subscriber *subscr);
-int test_sync_lastauthtuple_rc = 0;
-int __wrap_db_sync_lastauthtuple_for_subscr(struct gsm_auth_tuple *atuple,
- struct gsm_subscriber *subscr)
-{
- test_last_auth_tuple = *atuple;
- printf("wrapped: db_sync_lastauthtuple_for_subscr(): rc = %d\n", test_sync_lastauthtuple_rc);
- return test_sync_lastauthtuple_rc;
-}
-
-int auth_get_tuple_for_subscr_verbose(struct gsm_auth_tuple *atuple,
- struct gsm_subscriber *subscr,
- int key_seq)
-{
- int auth_action;
- auth_action = auth_get_tuple_for_subscr(atuple, subscr, key_seq);
- printf("auth_get_tuple_for_subscr(key_seq=%d) --> auth_action == %s\n",
- key_seq, auth_action_str(auth_action));
- return auth_action;
-}
-
-/* override libssl RAND_bytes() to get testable crypto results */
-int RAND_bytes(uint8_t *rand, int len)
-{
- memset(rand, 23, len);
- return 1;
-}
-
-static void test_error()
-{
- int auth_action;
-
- struct gsm_auth_tuple atuple = {0};
- struct gsm_subscriber subscr = {0};
- int key_seq = 0;
-
- printf("\n* test_error()\n");
-
- /* any error (except -ENOENT) */
- test_get_authinfo_rc = -EIO;
- auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr,
- key_seq);
- OSMO_ASSERT(auth_action == AUTH_ERROR);
-}
-
-static void test_auth_not_avail()
-{
- int auth_action;
-
- struct gsm_auth_tuple atuple = {0};
- struct gsm_subscriber subscr = {0};
- int key_seq = 0;
-
- printf("\n* test_auth_not_avail()\n");
-
- /* no entry */
- test_get_authinfo_rc = -ENOENT;
- auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr,
- key_seq);
- OSMO_ASSERT(auth_action == AUTH_NOT_AVAIL);
-}
-
-static void test_auth_then_ciph1()
-{
- int auth_action;
-
- struct gsm_auth_tuple atuple = {0};
- struct gsm_subscriber subscr = {0};
- int key_seq;
-
- printf("\n* test_auth_then_ciph1()\n");
-
- /* Ki entry, but no auth tuple negotiated yet */
- test_auth_info = default_auth_info;
- test_last_auth_tuple = default_auth_tuple;
- test_get_authinfo_rc = 0;
- test_get_lastauthtuple_rc = -ENOENT;
- key_seq = 0;
- auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr,
- key_seq);
- OSMO_ASSERT(auth_action == AUTH_DO_AUTH_THEN_CIPH);
- OSMO_ASSERT(auth_tuple_is(&atuple,
- "gsm_auth_tuple {\n"
- " .use_count = 1\n"
- " .key_seq = 0\n"
- " .rand = 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 \n"
- " .sres = a1 ab c6 90 \n"
- " .kc = 0f 27 ed f3 ac 97 ac 00 \n"
- "}\n"
- ));
-
- /* With a different last saved key_seq stored in the out-arg of
- * db_get_lastauthtuple_for_subscr() by coincidence, expect absolutely
- * the same as above. */
- test_auth_info = default_auth_info;
- test_last_auth_tuple = default_auth_tuple;
- test_last_auth_tuple.key_seq = 3;
- test_get_authinfo_rc = 0;
- test_get_lastauthtuple_rc = -ENOENT;
- key_seq = 0;
- auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr,
- key_seq);
- OSMO_ASSERT(auth_action == AUTH_DO_AUTH_THEN_CIPH);
- OSMO_ASSERT(auth_tuple_is(&atuple,
- "gsm_auth_tuple {\n"
- " .use_count = 1\n"
- " .key_seq = 0\n"
- " .rand = 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 \n"
- " .sres = a1 ab c6 90 \n"
- " .kc = 0f 27 ed f3 ac 97 ac 00 \n"
- "}\n"
- ));
-}
-
-static void test_auth_then_ciph2()
-{
- int auth_action;
-
- struct gsm_auth_tuple atuple = {0};
- struct gsm_subscriber subscr = {0};
- int key_seq;
-
- printf("\n* test_auth_then_ciph2()\n");
-
- /* Ki entry, auth tuple negotiated, but invalid incoming key_seq */
- test_auth_info = default_auth_info;
- test_last_auth_tuple = default_auth_tuple;
- test_last_auth_tuple.key_seq = 2;
- test_get_authinfo_rc = 0;
- test_get_lastauthtuple_rc = 0;
- key_seq = GSM_KEY_SEQ_INVAL;
- auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr,
- key_seq);
- OSMO_ASSERT(auth_action == AUTH_DO_AUTH_THEN_CIPH);
- OSMO_ASSERT(auth_tuple_is(&atuple,
- "gsm_auth_tuple {\n"
- " .use_count = 1\n"
- " .key_seq = 3\n"
- " .rand = 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 \n"
- " .sres = a1 ab c6 90 \n"
- " .kc = 0f 27 ed f3 ac 97 ac 00 \n"
- "}\n"
- ));
-
- /* Change the last saved key_seq, expect last_auth_tuple.key_seq + 1 */
- test_auth_info = default_auth_info;
- test_last_auth_tuple = default_auth_tuple;
- test_last_auth_tuple.key_seq = 3;
- test_get_authinfo_rc = 0;
- test_get_lastauthtuple_rc = 0;
- key_seq = GSM_KEY_SEQ_INVAL;
- auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr,
- key_seq);
- OSMO_ASSERT(auth_action == AUTH_DO_AUTH_THEN_CIPH);
- OSMO_ASSERT(auth_tuple_is(&atuple,
- "gsm_auth_tuple {\n"
- " .use_count = 1\n"
- " .key_seq = 4\n"
- " .rand = 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 \n"
- " .sres = a1 ab c6 90 \n"
- " .kc = 0f 27 ed f3 ac 97 ac 00 \n"
- "}\n"
- ));
-}
-
-static void test_auth_reuse()
-{
- int auth_action;
- struct gsm_auth_tuple atuple = {0};
- struct gsm_subscriber subscr = {0};
- int key_seq;
-
- printf("\n* test_auth_reuse()\n");
-
- /* Ki entry, auth tuple negotiated, valid+matching incoming key_seq */
- test_auth_info = default_auth_info;
- test_last_auth_tuple = default_auth_tuple;
- test_last_auth_tuple.key_seq = key_seq = 3;
- test_last_auth_tuple.use_count = 1;
- test_get_authinfo_rc = 0;
- test_get_lastauthtuple_rc = 0;
- auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr,
- key_seq);
- OSMO_ASSERT(auth_action == AUTH_DO_CIPH);
- OSMO_ASSERT(auth_tuple_is(&atuple,
- "gsm_auth_tuple {\n"
- " .use_count = 2\n"
- " .key_seq = 3\n"
- " .rand = 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \n"
- " .sres = 00 00 00 00 \n"
- " .kc = 00 00 00 00 00 00 00 00 \n"
- "}\n"
- ));
-}
-
-static void test_auth_reuse_key_seq_mismatch()
-{
- int auth_action;
- struct gsm_auth_tuple atuple = {0};
- struct gsm_subscriber subscr = {0};
- int key_seq;
-
- printf("\n* test_auth_reuse_key_seq_mismatch()\n");
-
- /* Ki entry, auth tuple negotiated, valid+matching incoming key_seq */
- test_auth_info = default_auth_info;
- test_last_auth_tuple = default_auth_tuple;
- test_last_auth_tuple.key_seq = 3;
- key_seq = 4;
- test_last_auth_tuple.use_count = 1;
- test_get_authinfo_rc = 0;
- test_get_lastauthtuple_rc = 0;
- auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr,
- key_seq);
- OSMO_ASSERT(auth_action == AUTH_DO_AUTH_THEN_CIPH);
- OSMO_ASSERT(auth_tuple_is(&atuple,
- "gsm_auth_tuple {\n"
- " .use_count = 1\n"
- " .key_seq = 4\n"
- " .rand = 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 \n"
- " .sres = a1 ab c6 90 \n"
- " .kc = 0f 27 ed f3 ac 97 ac 00 \n"
- "}\n"
- ));
-}
-
-int main(void)
-{
- osmo_init_logging(&log_info);
- log_set_log_level(osmo_stderr_target, LOGL_INFO);
-
- test_error();
- test_auth_not_avail();
- test_auth_then_ciph1();
- test_auth_then_ciph2();
- test_auth_reuse();
- test_auth_reuse_key_seq_mismatch();
- return 0;
-}
diff --git a/tests/mm_auth/mm_auth_test.ok b/tests/mm_auth/mm_auth_test.ok
deleted file mode 100644
index 6c49f97b7..000000000
--- a/tests/mm_auth/mm_auth_test.ok
+++ /dev/null
@@ -1,40 +0,0 @@
-
-* test_error()
-wrapped: db_get_authinfo_for_subscr(): rc = -5
-auth_get_tuple_for_subscr(key_seq=0) --> auth_action == AUTH_ERROR
-
-* test_auth_not_avail()
-wrapped: db_get_authinfo_for_subscr(): rc = -2
-auth_get_tuple_for_subscr(key_seq=0) --> auth_action == AUTH_NOT_AVAIL
-
-* test_auth_then_ciph1()
-wrapped: db_get_authinfo_for_subscr(): rc = 0
-wrapped: db_get_lastauthtuple_for_subscr(): rc = -2
-wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0
-auth_get_tuple_for_subscr(key_seq=0) --> auth_action == AUTH_DO_AUTH_THEN_CIPH
-wrapped: db_get_authinfo_for_subscr(): rc = 0
-wrapped: db_get_lastauthtuple_for_subscr(): rc = -2
-wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0
-auth_get_tuple_for_subscr(key_seq=0) --> auth_action == AUTH_DO_AUTH_THEN_CIPH
-
-* test_auth_then_ciph2()
-wrapped: db_get_authinfo_for_subscr(): rc = 0
-wrapped: db_get_lastauthtuple_for_subscr(): rc = 0
-wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0
-auth_get_tuple_for_subscr(key_seq=7) --> auth_action == AUTH_DO_AUTH_THEN_CIPH
-wrapped: db_get_authinfo_for_subscr(): rc = 0
-wrapped: db_get_lastauthtuple_for_subscr(): rc = 0
-wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0
-auth_get_tuple_for_subscr(key_seq=7) --> auth_action == AUTH_DO_AUTH_THEN_CIPH
-
-* test_auth_reuse()
-wrapped: db_get_authinfo_for_subscr(): rc = 0
-wrapped: db_get_lastauthtuple_for_subscr(): rc = 0
-wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0
-auth_get_tuple_for_subscr(key_seq=3) --> auth_action == AUTH_DO_CIPH
-
-* test_auth_reuse_key_seq_mismatch()
-wrapped: db_get_authinfo_for_subscr(): rc = 0
-wrapped: db_get_lastauthtuple_for_subscr(): rc = 0
-wrapped: db_sync_lastauthtuple_for_subscr(): rc = 0
-auth_get_tuple_for_subscr(key_seq=4) --> auth_action == AUTH_DO_AUTH_THEN_CIPH
diff --git a/tests/sms_queue/Makefile.am b/tests/sms_queue/Makefile.am
new file mode 100644
index 000000000..b2266ebb8
--- /dev/null
+++ b/tests/sms_queue/Makefile.am
@@ -0,0 +1,45 @@
+AM_CPPFLAGS = \
+ $(all_includes) \
+ -I$(top_srcdir)/include \
+ $(NULL)
+
+AM_CFLAGS = \
+ -Wall \
+ -ggdb3 \
+ $(LIBOSMOCORE_CFLAGS) \
+ $(LIBOSMOGSM_CFLAGS) \
+ $(NULL)
+
+EXTRA_DIST = \
+ sms_queue_test.ok \
+ sms_queue_test.err \
+ $(NULL)
+
+noinst_PROGRAMS = \
+ sms_queue_test \
+ $(NULL)
+
+sms_queue_test_SOURCES = \
+ sms_queue_test.c \
+ $(NULL)
+
+sms_queue_test_LDADD = \
+ $(top_builddir)/src/libmsc/libmsc.a \
+ $(top_builddir)/src/libvlr/libvlr.a \
+ $(top_builddir)/src/libbsc/libbsc.a \
+ $(top_builddir)/src/libtrau/libtrau.a \
+ $(top_builddir)/src/libcommon/libcommon.a \
+ $(top_builddir)/src/libcommon-cs/libcommon-cs.a \
+ $(LIBSMPP34_LIBS) \
+ $(LIBOSMOCORE_LIBS) \
+ $(LIBOSMOGSM_LIBS) \
+ $(LIBCRYPTO_LIBS) \
+ $(LIBOSMOVTY_LIBS) \
+ $(LIBOSMOABIS_LIBS) \
+ -ldbi \
+ -lrt \
+ $(NULL)
+
+sms_queue_test_LDFLAGS = \
+ -Wl,--wrap=db_sms_get_next_unsent_rr_msisdn \
+ $(NULL)
diff --git a/tests/sms_queue/sms_queue_test.c b/tests/sms_queue/sms_queue_test.c
new file mode 100644
index 000000000..af25b0645
--- /dev/null
+++ b/tests/sms_queue/sms_queue_test.c
@@ -0,0 +1,215 @@
+/* Test Osmocom SMS queue */
+
+/*
+ * (C) 2017 by sysmocom s.f.m.c. GmbH
+ * All Rights Reserved
+ *
+ * Author: Neels Hofmeyr <nhofmeyr@sysmocom.de>
+ *
+ * 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 Affero 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/application.h>
+
+#include <openbsc/debug.h>
+#include <openbsc/vlr.h>
+
+static void *talloc_ctx = NULL;
+
+struct gsm_sms *smsq_take_next_sms(struct gsm_network *net,
+ char *last_msisdn,
+ size_t last_msisdn_buflen);
+
+static void _test_take_next_sms_print(int i,
+ struct gsm_sms *sms,
+ const char *last_msisdn)
+{
+ printf("#%d: ", i);
+ if (sms)
+ printf("sending SMS to %s", sms->text);
+ else
+ printf("no SMS to send");
+ printf(" (last_msisdn='%s')\n", last_msisdn? last_msisdn : "NULL");
+}
+
+static struct gsm_sms fake_sms = { 0 };
+
+struct {
+ const char *msisdn;
+ int nr_of_sms;
+ int failed_attempts;
+ bool vsub_attached;
+} fake_sms_db[] = {
+ {
+ .msisdn = "1111",
+ .nr_of_sms = 0,
+ .vsub_attached = true,
+ },
+ {
+ .msisdn = "2222",
+ .nr_of_sms = 2,
+ .failed_attempts = 2,
+ .vsub_attached = true,
+ },
+ {
+ .msisdn = "3333",
+ .nr_of_sms = 2,
+ .failed_attempts = 3,
+ .vsub_attached = true,
+ },
+ {
+ .msisdn = "4444",
+ .nr_of_sms = 0,
+ .vsub_attached = true,
+ },
+ {
+ .msisdn = "5555",
+ .nr_of_sms = 2,
+ .failed_attempts = 5,
+ .vsub_attached = false,
+ },
+};
+
+/* override, requires '-Wl,--wrap=db_sms_get_next_unsent_rr_msisdn' */
+struct gsm_sms *__real_db_sms_get_next_unsent_rr_msisdn(struct gsm_network *net,
+ const char *last_msisdn,
+ unsigned int max_failed);
+struct gsm_sms *__wrap_db_sms_get_next_unsent_rr_msisdn(struct gsm_network *net,
+ const char *last_msisdn,
+ unsigned int max_failed)
+{
+ static struct vlr_subscr arbitrary_vsub = { .lu_complete = true };
+ int i;
+ printf(" hitting database: looking for MSISDN > '%s', failed_attempts <= %d\n",
+ last_msisdn, max_failed);
+
+ for (i = 0; i < ARRAY_SIZE(fake_sms_db); i++) {
+ if (!fake_sms_db[i].nr_of_sms)
+ continue;
+ if (strcmp(fake_sms_db[i].msisdn, last_msisdn) <= 0)
+ continue;
+ if (fake_sms_db[i].failed_attempts > max_failed)
+ continue;
+ osmo_strlcpy(fake_sms.dst.addr, fake_sms_db[i].msisdn,
+ sizeof(fake_sms.dst.addr));
+ fake_sms.receiver = fake_sms_db[i].vsub_attached? &arbitrary_vsub : NULL;
+ osmo_strlcpy(fake_sms.text, fake_sms_db[i].msisdn, sizeof(fake_sms.text));
+ if (fake_sms_db[i].vsub_attached)
+ fake_sms_db[i].nr_of_sms --;
+ return &fake_sms;
+ }
+ return NULL;
+}
+
+void show_fake_sms_db()
+{
+ int i;
+ for (i = 0; i < ARRAY_SIZE(fake_sms_db); i++) {
+ printf(" %s%s has %u SMS pending, %u failed attempts\n",
+ fake_sms_db[i].msisdn,
+ fake_sms_db[i].vsub_attached ? "" : " (NOT attached)",
+ fake_sms_db[i].nr_of_sms,
+ fake_sms_db[i].failed_attempts);
+ }
+ printf("-->\n");
+}
+
+static void test_next_sms()
+{
+ int i;
+ char last_msisdn[GSM_EXTENSION_LENGTH+1] = "";
+
+ printf("Testing smsq_take_next_sms()\n");
+
+ printf("\n- vsub 2, 3 and 5 each have 2 SMS pending, but 5 is not attached\n");
+ last_msisdn[0] = '\0';
+ show_fake_sms_db();
+ for (i = 0; i < 7; i++) {
+ struct gsm_sms *sms = smsq_take_next_sms(NULL, last_msisdn, sizeof(last_msisdn));
+ _test_take_next_sms_print(i, sms, last_msisdn);
+ OSMO_ASSERT(i >= 4 || sms);
+ }
+
+ printf("\n- SMS are pending at various nr failed attempts (cutoff at >= 10)\n");
+ last_msisdn[0] = '\0';
+ for (i = 0; i < ARRAY_SIZE(fake_sms_db); i++) {
+ fake_sms_db[i].vsub_attached = true;
+ fake_sms_db[i].nr_of_sms = 1 + i;
+ fake_sms_db[i].failed_attempts = i*5;
+
+ }
+ show_fake_sms_db();
+ for (i = 0; i < 7; i++) {
+ struct gsm_sms *sms = smsq_take_next_sms(NULL, last_msisdn, sizeof(last_msisdn));
+ _test_take_next_sms_print(i, sms, last_msisdn);
+ OSMO_ASSERT(i >= 2 || sms);
+ }
+
+ printf("\n- iterate the SMS DB at most once\n");
+ osmo_strlcpy(last_msisdn, "2345", sizeof(last_msisdn));
+ for (i = 0; i < ARRAY_SIZE(fake_sms_db); i++) {
+ fake_sms_db[i].vsub_attached = false;
+ fake_sms_db[i].nr_of_sms = 1;
+ fake_sms_db[i].failed_attempts = 0;
+ }
+ show_fake_sms_db();
+ for (i = 0; i < 3; i++) {
+ struct gsm_sms *sms = smsq_take_next_sms(NULL, last_msisdn, sizeof(last_msisdn));
+ _test_take_next_sms_print(i, sms, last_msisdn);
+ OSMO_ASSERT(!sms);
+ }
+
+ printf("\n- there are no SMS in the DB\n");
+ last_msisdn[0] = '\0';
+ for (i = 0; i < ARRAY_SIZE(fake_sms_db); i++) {
+ fake_sms_db[i].vsub_attached = true;
+ fake_sms_db[i].nr_of_sms = 0;
+ fake_sms_db[i].failed_attempts = 0;
+ }
+ show_fake_sms_db();
+ for (i = 0; i < 3; i++) {
+ struct gsm_sms *sms = smsq_take_next_sms(NULL, last_msisdn, sizeof(last_msisdn));
+ _test_take_next_sms_print(i, sms, last_msisdn);
+ OSMO_ASSERT(!sms);
+ }
+}
+
+
+static struct log_info_cat sms_queue_test_categories[] = {
+};
+
+static struct log_info info = {
+ .cat = sms_queue_test_categories,
+ .num_cat = ARRAY_SIZE(sms_queue_test_categories),
+};
+
+int main(int argc, char **argv)
+{
+ talloc_ctx = talloc_named_const(NULL, 1, "sms_queue_test");
+ msgb_talloc_ctx_init(talloc_ctx, 0);
+ osmo_init_logging(&info);
+
+ OSMO_ASSERT(osmo_stderr_target);
+ log_set_use_color(osmo_stderr_target, 0);
+ log_set_print_timestamp(osmo_stderr_target, 0);
+ log_set_print_filename(osmo_stderr_target, 0);
+ log_set_print_category(osmo_stderr_target, 1);
+ log_parse_category_mask(osmo_stderr_target, "DLOAP,1");
+
+ test_next_sms();
+ printf("Done\n");
+
+ return 0;
+}
diff --git a/tests/sms_queue/sms_queue_test.err b/tests/sms_queue/sms_queue_test.err
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/sms_queue/sms_queue_test.err
diff --git a/tests/sms_queue/sms_queue_test.ok b/tests/sms_queue/sms_queue_test.ok
new file mode 100644
index 000000000..146400d21
--- /dev/null
+++ b/tests/sms_queue/sms_queue_test.ok
@@ -0,0 +1,98 @@
+Testing smsq_take_next_sms()
+
+- vsub 2, 3 and 5 each have 2 SMS pending, but 5 is not attached
+ 1111 has 0 SMS pending, 0 failed attempts
+ 2222 has 2 SMS pending, 2 failed attempts
+ 3333 has 2 SMS pending, 3 failed attempts
+ 4444 has 0 SMS pending, 0 failed attempts
+ 5555 (NOT attached) has 2 SMS pending, 5 failed attempts
+-->
+ hitting database: looking for MSISDN > '', failed_attempts <= 9
+#0: sending SMS to 2222 (last_msisdn='2222')
+ hitting database: looking for MSISDN > '2222', failed_attempts <= 9
+#1: sending SMS to 3333 (last_msisdn='3333')
+ hitting database: looking for MSISDN > '3333', failed_attempts <= 9
+ hitting database: looking for MSISDN > '5555', failed_attempts <= 9
+ hitting database: looking for MSISDN > '', failed_attempts <= 9
+#2: sending SMS to 2222 (last_msisdn='2222')
+ hitting database: looking for MSISDN > '2222', failed_attempts <= 9
+#3: sending SMS to 3333 (last_msisdn='3333')
+ hitting database: looking for MSISDN > '3333', failed_attempts <= 9
+ hitting database: looking for MSISDN > '5555', failed_attempts <= 9
+ hitting database: looking for MSISDN > '', failed_attempts <= 9
+#4: no SMS to send (last_msisdn='5555')
+ hitting database: looking for MSISDN > '5555', failed_attempts <= 9
+ hitting database: looking for MSISDN > '', failed_attempts <= 9
+#5: no SMS to send (last_msisdn='5555')
+ hitting database: looking for MSISDN > '5555', failed_attempts <= 9
+ hitting database: looking for MSISDN > '', failed_attempts <= 9
+#6: no SMS to send (last_msisdn='5555')
+
+- SMS are pending at various nr failed attempts (cutoff at >= 10)
+ 1111 has 1 SMS pending, 0 failed attempts
+ 2222 has 2 SMS pending, 5 failed attempts
+ 3333 has 3 SMS pending, 10 failed attempts
+ 4444 has 4 SMS pending, 15 failed attempts
+ 5555 has 5 SMS pending, 20 failed attempts
+-->
+ hitting database: looking for MSISDN > '', failed_attempts <= 9
+#0: sending SMS to 1111 (last_msisdn='1111')
+ hitting database: looking for MSISDN > '1111', failed_attempts <= 9
+#1: sending SMS to 2222 (last_msisdn='2222')
+ hitting database: looking for MSISDN > '2222', failed_attempts <= 9
+ hitting database: looking for MSISDN > '', failed_attempts <= 9
+#2: sending SMS to 2222 (last_msisdn='2222')
+ hitting database: looking for MSISDN > '2222', failed_attempts <= 9
+ hitting database: looking for MSISDN > '', failed_attempts <= 9
+#3: no SMS to send (last_msisdn='')
+ hitting database: looking for MSISDN > '', failed_attempts <= 9
+#4: no SMS to send (last_msisdn='')
+ hitting database: looking for MSISDN > '', failed_attempts <= 9
+#5: no SMS to send (last_msisdn='')
+ hitting database: looking for MSISDN > '', failed_attempts <= 9
+#6: no SMS to send (last_msisdn='')
+
+- iterate the SMS DB at most once
+ 1111 (NOT attached) has 1 SMS pending, 0 failed attempts
+ 2222 (NOT attached) has 1 SMS pending, 0 failed attempts
+ 3333 (NOT attached) has 1 SMS pending, 0 failed attempts
+ 4444 (NOT attached) has 1 SMS pending, 0 failed attempts
+ 5555 (NOT attached) has 1 SMS pending, 0 failed attempts
+-->
+ hitting database: looking for MSISDN > '2345', failed_attempts <= 9
+ hitting database: looking for MSISDN > '3333', failed_attempts <= 9
+ hitting database: looking for MSISDN > '4444', failed_attempts <= 9
+ hitting database: looking for MSISDN > '5555', failed_attempts <= 9
+ hitting database: looking for MSISDN > '', failed_attempts <= 9
+ hitting database: looking for MSISDN > '1111', failed_attempts <= 9
+ hitting database: looking for MSISDN > '2222', failed_attempts <= 9
+#0: no SMS to send (last_msisdn='3333')
+ hitting database: looking for MSISDN > '3333', failed_attempts <= 9
+ hitting database: looking for MSISDN > '4444', failed_attempts <= 9
+ hitting database: looking for MSISDN > '5555', failed_attempts <= 9
+ hitting database: looking for MSISDN > '', failed_attempts <= 9
+ hitting database: looking for MSISDN > '1111', failed_attempts <= 9
+ hitting database: looking for MSISDN > '2222', failed_attempts <= 9
+#1: no SMS to send (last_msisdn='3333')
+ hitting database: looking for MSISDN > '3333', failed_attempts <= 9
+ hitting database: looking for MSISDN > '4444', failed_attempts <= 9
+ hitting database: looking for MSISDN > '5555', failed_attempts <= 9
+ hitting database: looking for MSISDN > '', failed_attempts <= 9
+ hitting database: looking for MSISDN > '1111', failed_attempts <= 9
+ hitting database: looking for MSISDN > '2222', failed_attempts <= 9
+#2: no SMS to send (last_msisdn='3333')
+
+- there are no SMS in the DB
+ 1111 has 0 SMS pending, 0 failed attempts
+ 2222 has 0 SMS pending, 0 failed attempts
+ 3333 has 0 SMS pending, 0 failed attempts
+ 4444 has 0 SMS pending, 0 failed attempts
+ 5555 has 0 SMS pending, 0 failed attempts
+-->
+ hitting database: looking for MSISDN > '', failed_attempts <= 9
+#0: no SMS to send (last_msisdn='')
+ hitting database: looking for MSISDN > '', failed_attempts <= 9
+#1: no SMS to send (last_msisdn='')
+ hitting database: looking for MSISDN > '', failed_attempts <= 9
+#2: no SMS to send (last_msisdn='')
+Done
diff --git a/tests/subscr/Makefile.am b/tests/subscr/Makefile.am
index 6342444ff..5b770bcb2 100644
--- a/tests/subscr/Makefile.am
+++ b/tests/subscr/Makefile.am
@@ -18,32 +18,14 @@ AM_LDFLAGS = \
$(NULL)
EXTRA_DIST = \
- subscr_test.ok \
bsc_subscr_test.ok \
bsc_subscr_test.err \
$(NULL)
noinst_PROGRAMS = \
- subscr_test \
bsc_subscr_test \
$(NULL)
-subscr_test_SOURCES = \
- subscr_test.c \
- $(NULL)
-
-subscr_test_LDADD = \
- $(top_builddir)/src/libbsc/libbsc.a \
- $(top_builddir)/src/libcommon-cs/libcommon-cs.a \
- $(top_builddir)/src/libtrau/libtrau.a \
- $(top_builddir)/src/libcommon/libcommon.a \
- $(LIBOSMOCORE_LIBS) \
- $(LIBOSMOABIS_LIBS) \
- $(LIBOSMOGSM_LIBS) \
- $(LIBSMPP34_LIBS) \
- $(LIBOSMOVTY_LIBS) \
- $(NULL)
-
bsc_subscr_test_SOURCES = \
bsc_subscr_test.c \
$(NULL)
diff --git a/tests/subscr/subscr_test.c b/tests/subscr/subscr_test.c
deleted file mode 100644
index 2a5d0e1c2..000000000
--- a/tests/subscr/subscr_test.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/* (C) 2008 by Jan Luebbe <jluebbe@debian.org>
- * (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
- * (C) 2014 by Alexander Chemeris <Alexander.Chemeris@fairwaves.co>
- * 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 <openbsc/debug.h>
-#include <openbsc/db.h>
-#include <openbsc/gsm_subscriber.h>
-#include <openbsc/gsm_04_11.h>
-
-#include <osmocom/core/application.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <inttypes.h>
-
-static struct gsm_network dummy_net;
-static struct gsm_subscriber_group dummy_sgrp;
-
-static void test_subscr(void)
-{
- struct gsm_subscriber *subscr;
- const char *imsi = "1234567890";
-
- printf("Test subscriber allocation and deletion\n");
-
- /* Don't keep subscr */
-
- dummy_sgrp.keep_subscr = 0;
-
- OSMO_ASSERT(llist_empty(&active_subscribers));
-
- subscr = subscr_get_or_create(&dummy_sgrp, imsi);
-
- OSMO_ASSERT(!llist_empty(&active_subscribers));
- OSMO_ASSERT(subscr->use_count == 1);
-
- subscr_put(subscr);
-
- OSMO_ASSERT(llist_empty(&active_subscribers));
-
- /* Keep subscr */
-
- dummy_sgrp.keep_subscr = 1;
-
- subscr = subscr_get_or_create(&dummy_sgrp, imsi);
-
- OSMO_ASSERT(!llist_empty(&active_subscribers));
- OSMO_ASSERT(subscr->use_count == 1);
-
- subscr_put(subscr);
- OSMO_ASSERT(!llist_empty(&active_subscribers));
- OSMO_ASSERT(subscr->use_count == 0);
-
- subscr_get(subscr);
- OSMO_ASSERT(subscr->use_count == 1);
-
- subscr_purge_inactive(&dummy_sgrp);
-
- OSMO_ASSERT(!llist_empty(&active_subscribers));
- OSMO_ASSERT(subscr->use_count == 1);
-
- subscr_put(subscr);
- OSMO_ASSERT(!llist_empty(&active_subscribers));
- OSMO_ASSERT(subscr->use_count == 0);
-
- subscr_purge_inactive(&dummy_sgrp);
-
- OSMO_ASSERT(llist_empty(&active_subscribers));
-
- /* Test force_no_keep */
-
- dummy_sgrp.keep_subscr = 0;
-
- subscr = subscr_get_or_create(&dummy_sgrp, imsi);
- OSMO_ASSERT(subscr);
- subscr->keep_in_ram = 1;
-
- OSMO_ASSERT(!llist_empty(&active_subscribers));
- OSMO_ASSERT(subscr->use_count == 1);
-
- subscr->keep_in_ram = 0;
-
- subscr_put(subscr);
- OSMO_ASSERT(llist_empty(&active_subscribers));
-}
-
-int main()
-{
- printf("Testing subscriber core code.\n");
- osmo_init_logging(&log_info);
- log_set_print_filename(osmo_stderr_target, 0);
-
- dummy_net.subscr_group = &dummy_sgrp;
- dummy_sgrp.net = &dummy_net;
-
- test_subscr();
-
- printf("Done\n");
- return 0;
-}
diff --git a/tests/subscr/subscr_test.ok b/tests/subscr/subscr_test.ok
deleted file mode 100644
index 72a376944..000000000
--- a/tests/subscr/subscr_test.ok
+++ /dev/null
@@ -1,3 +0,0 @@
-Testing subscriber core code.
-Test subscriber allocation and deletion
-Done
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 280aeb2ed..84e83f1bf 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -7,12 +7,6 @@ cat $abs_srcdir/gsm0408/gsm0408_test.ok > expout
AT_CHECK([$abs_top_builddir/tests/gsm0408/gsm0408_test], [], [expout], [ignore])
AT_CLEANUP
-AT_SETUP([subscr])
-AT_KEYWORDS([subscr])
-cat $abs_srcdir/subscr/subscr_test.ok > expout
-AT_CHECK([$abs_top_builddir/tests/subscr/subscr_test], [], [expout], [ignore])
-AT_CLEANUP
-
AT_SETUP([bsc_subscr])
AT_KEYWORDS([bsc_subscr])
cat $abs_srcdir/subscr/bsc_subscr_test.ok > expout
@@ -20,14 +14,6 @@ cat $abs_srcdir/subscr/bsc_subscr_test.err > experr
AT_CHECK([$abs_top_builddir/tests/subscr/bsc_subscr_test], [], [expout], [experr])
AT_CLEANUP
-AT_SETUP([db])
-AT_KEYWORDS([db])
-cat $abs_srcdir/db/db_test.ok > expout
-cat $abs_srcdir/db/db_test.err > experr
-cat $abs_srcdir/db/hlr.sqlite3 > hlr.sqlite3
-AT_CHECK([$abs_top_builddir/tests/db/db_test], [], [expout], [experr])
-AT_CLEANUP
-
AT_SETUP([channel])
AT_KEYWORDS([channel])
cat $abs_srcdir/channel/channel_test.ok > expout
@@ -126,12 +112,6 @@ cat $abs_srcdir/gtphub/gtphub_test.ok > expout
AT_CHECK([$abs_top_builddir/tests/gtphub/gtphub_test], [], [expout], [ignore])
AT_CLEANUP
-AT_SETUP([mm_auth])
-AT_KEYWORDS([mm_auth])
-cat $abs_srcdir/mm_auth/mm_auth_test.ok > expout
-AT_CHECK([$abs_top_builddir/tests/mm_auth/mm_auth_test], [], [expout], [ignore])
-AT_CLEANUP
-
AT_SETUP([xid])
AT_KEYWORDS([xid])
AT_CHECK([test "$enable_sgsn_test" != no || exit 77])
@@ -165,3 +145,10 @@ AT_KEYWORDS([nanobts_omlattr])
cat $abs_srcdir/nanobts_omlattr/nanobts_omlattr_test.ok > expout
AT_CHECK([$abs_top_builddir/tests/nanobts_omlattr/nanobts_omlattr_test], [], [expout], [ignore])
AT_CLEANUP
+
+AT_SETUP([sms_queue_test])
+AT_KEYWORDS([sms_queue_test])
+cat $abs_srcdir/sms_queue/sms_queue_test.ok > expout
+cat $abs_srcdir/sms_queue/sms_queue_test.err > experr
+AT_CHECK([$abs_top_builddir/tests/sms_queue/sms_queue_test], [], [expout], [experr])
+AT_CLEANUP
diff --git a/tests/vty_test_runner.py b/tests/vty_test_runner.py
index 68a697d78..e19b12b14 100644
--- a/tests/vty_test_runner.py
+++ b/tests/vty_test_runner.py
@@ -250,8 +250,10 @@ class TestVTYNITB(TestVTYGenericBSC):
self.vty.command("end")
self.vty.command("configure terminal")
self.vty.command("nitb")
- self.assertTrue(self.vty.verify("subscriber-create-on-demand", ['']))
- self.assertTrue(self.vty.verify("subscriber-create-on-demand no-extension", ['']))
+ self.assertTrue(self.vty.verify('subscriber-create-on-demand',
+ ["% 'subscriber-create-on-demand' is no longer supported.", '% This is now up to osmo-hlr.']))
+ self.assertTrue(self.vty.verify("subscriber-create-on-demand no-extension",
+ ["% 'subscriber-create-on-demand' is no longer supported.", '% This is now up to osmo-hlr.']))
self.vty.command("end")
def testSi2Q(self):
@@ -367,133 +369,26 @@ class TestVTYNITB(TestVTYGenericBSC):
if classNum != 10:
self.assertEquals(res.find("rach access-control-class " + str(classNum) + " barred"), -1)
- def testSubscriberCreateDeleteTwice(self):
- """
- OS#1657 indicates that there might be an issue creating the
- same subscriber twice. This test will use the VTY command to
- create a subscriber and then issue a second create command
- with the same IMSI. The test passes if the VTY continues to
- respond to VTY commands.
- """
- self.vty.enable()
-
- imsi = "204300854013739"
-
- # Initially we don't have this subscriber
- self.vty.verify('show subscriber imsi '+imsi, ['% No subscriber found for imsi '+imsi])
-
- # Lets create one
- res = self.vty.command('subscriber create imsi '+imsi)
- self.assert_(res.find(" IMSI: "+imsi) > 0)
- # And now create one again.
- res2 = self.vty.command('subscriber create imsi '+imsi)
- self.assert_(res2.find(" IMSI: "+imsi) > 0)
- self.assertEqual(res, res2)
-
- # Verify it has been created
- res = self.vty.command('show subscriber imsi '+imsi)
- self.assert_(res.find(" IMSI: "+imsi) > 0)
-
- # Delete it
- res = self.vty.command('subscriber imsi ' + imsi + ' delete')
- self.assert_("" == res)
-
- # Now it should not be there anymore
- res = self.vty.command('show subscriber imsi '+imsi)
- self.assert_(('% No subscriber found for imsi ' + imsi) == res)
-
-
def testSubscriberCreateDelete(self):
self.vty.enable()
imsi = "204300854013739"
- imsi2 = "222301824913762"
- imsi3 = "333500854113763"
- imsi4 = "444583744053764"
# Initially we don't have this subscriber
- self.vty.verify('show subscriber imsi '+imsi, ['% No subscriber found for imsi '+imsi])
+ self.assertTrue(self.vty.verify('show subscriber imsi '+imsi, ['% No subscriber found for imsi '+imsi]))
- # Lets create one
- res = self.vty.command('subscriber create imsi '+imsi)
- self.assert_(res.find(" IMSI: "+imsi) > 0)
- self.assert_(res.find("Extension") > 0)
-
- # Now we have it
- res = self.vty.command('show subscriber imsi '+imsi)
- self.assert_(res.find(" IMSI: "+imsi) > 0)
-
- # With narrow random interval
- self.vty.command("configure terminal")
- self.vty.command("nitb")
- self.assertTrue(self.vty.verify("subscriber-create-on-demand", ['']))
- # wrong interval
- res = self.vty.command("subscriber-create-on-demand random 221 122")
- # error string will contain arguments
- self.assert_(res.find("122") > 0)
- self.assert_(res.find("221") > 0)
- # correct interval - silent ok
- self.assertTrue(self.vty.verify("subscriber-create-on-demand random 221 222", ['']))
- self.vty.command("end")
-
- res = self.vty.command('subscriber create imsi ' + imsi2)
- self.assert_(res.find(" IMSI: " + imsi2) > 0)
- self.assert_(res.find("221") > 0 or res.find("222") > 0)
- self.assert_(res.find(" Extension: ") > 0)
-
- # Without extension
- self.vty.command("configure terminal")
- self.vty.command("nitb")
- self.assertTrue(self.vty.verify("subscriber-create-on-demand no-extension", ['']))
- self.vty.command("end")
- res = self.vty.command('subscriber create imsi ' + imsi3)
- self.assert_(res.find(" IMSI: " + imsi3) > 0)
- self.assertEquals(res.find("Extension"), -1)
-
- # With extension again
- self.vty.command("configure terminal")
- self.vty.command("nitb")
- self.assertTrue(self.vty.verify("no subscriber-create-on-demand", ['']))
- self.assertTrue(self.vty.verify("subscriber-create-on-demand", ['']))
- self.assertTrue(self.vty.verify("subscriber-create-on-demand random 221 666", ['']))
- self.vty.command("end")
-
- res = self.vty.command('subscriber create imsi ' + imsi4)
- self.assert_(res.find(" IMSI: " + imsi4) > 0)
- self.assert_(res.find(" Extension: ") > 0)
-
- # Delete it
- res = self.vty.command('subscriber imsi ' + imsi + ' delete')
- self.assert_("" == res)
- res = self.vty.command('subscriber imsi ' + imsi2 + ' delete')
- self.assert_("" == res)
- res = self.vty.command('subscriber imsi ' + imsi3 + ' delete')
- self.assert_("" == res)
- res = self.vty.command('subscriber imsi ' + imsi4 + ' delete')
- self.assert_("" == res)
-
- # Now it should not be there anymore
- res = self.vty.command('show subscriber imsi '+imsi)
- self.assert_(('% No subscriber found for imsi ' + imsi) == res)
+ # deprecated
+ self.assertTrue(self.vty.verify('subscriber create imsi '+imsi, ["% 'subscriber create' now needs to be done at osmo-hlr"]))
# range
self.vty.command("end")
self.vty.command("configure terminal")
self.vty.command("nitb")
- self.assertTrue(self.vty.verify("subscriber-create-on-demand random 9999999998 9999999999", ['']))
+ self.assertTrue(self.vty.verify('subscriber-create-on-demand', ["% 'subscriber-create-on-demand' is no longer supported.", '% This is now up to osmo-hlr.']))
res = self.vty.command("show running-config")
- self.assert_(res.find("subscriber-create-on-demand random 9999999998 9999999999"))
+ self.assert_(res.find("subscriber-create-on-demand") < 0)
self.vty.command("end")
- res = self.vty.command('subscriber create imsi ' + imsi)
- print(res)
- self.assert_(res.find(" IMSI: " + imsi) > 0)
- self.assert_(res.find("9999999998") > 0 or res.find("9999999999") > 0)
- self.assert_(res.find(" Extension: ") > 0)
-
- res = self.vty.command('subscriber imsi ' + imsi + ' delete')
- self.assert_("" == res)
-
res = self.vty.command('show subscriber imsi '+imsi)
self.assert_(('% No subscriber found for imsi ' + imsi) == res)
@@ -502,50 +397,15 @@ class TestVTYNITB(TestVTYGenericBSC):
self.vty.enable()
imsi = "204300854013739"
- imsi2 = "204301824913769"
- wrong_imsi = "204300999999999"
-
- # Lets create one
- res = self.vty.command('subscriber create imsi '+imsi)
- self.assert_(res.find(" IMSI: "+imsi) > 0)
- self.assert_(res.find("Extension") > 0)
- self.vty.verify('subscriber imsi '+wrong_imsi+' name wrong', ['% No subscriber found for imsi '+wrong_imsi])
- res = self.vty.command('subscriber imsi '+imsi+' name '+('X' * 160))
- self.assert_(res.find("NAME is too long") > 0)
-
- self.vty.verify('subscriber imsi '+imsi+' name '+('G' * 159), [''])
-
- self.vty.verify('subscriber imsi '+wrong_imsi+' extension 840', ['% No subscriber found for imsi '+wrong_imsi])
- res = self.vty.command('subscriber imsi '+imsi+' extension '+('9' * 15))
- self.assert_(res.find("EXTENSION is too long") > 0)
-
- self.vty.verify('subscriber imsi '+imsi+' extension '+('1' * 14), [''])
+ self.assertTrue(self.vty.verify('subscriber imsi '+imsi+' name foo', ["% 'subscriber name' is no longer supported.", '% This is now up to osmo-hlr.']))
+ self.assertTrue(self.vty.verify('subscriber imsi '+imsi+' extension 1234', ["% 'subscriber extension' is no longer supported.", '% This is now up to osmo-hlr.']))
+ self.assertTrue(self.vty.verify('subscriber imsi '+imsi+' delete', ["% 'subscriber delete' is no longer supported.", '% This is now up to osmo-hlr.']))
# With narrow random interval
self.vty.command("configure terminal")
self.vty.command("nitb")
- self.assertTrue(self.vty.verify("subscriber-create-on-demand", ['']))
- # wrong interval
- res = self.vty.command("subscriber-create-on-demand random 221 122")
- self.assert_(res.find("122") > 0)
- self.assert_(res.find("221") > 0)
- # correct interval
- self.assertTrue(self.vty.verify("subscriber-create-on-demand random 221 222", ['']))
- self.vty.command("end")
-
- # create subscriber with extension in a configured interval
- res = self.vty.command('subscriber create imsi ' + imsi2)
- self.assert_(res.find(" IMSI: " + imsi2) > 0)
- self.assert_(res.find("221") > 0 or res.find("222") > 0)
- self.assert_(res.find(" Extension: ") > 0)
-
- # Delete it
- res = self.vty.command('subscriber imsi ' + imsi + ' delete')
- self.assert_(res != "")
- # imsi2 is inactive so deletion should succeed
- res = self.vty.command('subscriber imsi ' + imsi2 + ' delete')
- self.assert_("" == res)
+ self.assertTrue(self.vty.verify('subscriber-create-on-demand', ["% 'subscriber-create-on-demand' is no longer supported.", '% This is now up to osmo-hlr.']))
def testShowPagingGroup(self):
res = self.vty.command("show paging-group 255 1234567")