aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/db/Makefile.am1
-rw-r--r--tests/db/db_test.c39
-rw-r--r--tests/db/db_test.err28
-rw-r--r--tests/gsup/Makefile.am36
-rw-r--r--tests/gsup/gsup_test.c113
-rw-r--r--tests/gsup/gsup_test.err0
-rw-r--r--tests/gsup/gsup_test.ok32
-rw-r--r--tests/gsup_server/Makefile.am2
-rw-r--r--tests/test_nodes.vty2
-rw-r--r--tests/testsuite.at7
11 files changed, 233 insertions, 28 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 776f8a9..9015494 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -2,6 +2,7 @@ SUBDIRS = \
auc \
gsup_server \
db \
+ gsup \
db_upgrade \
mslookup \
$(NULL)
diff --git a/tests/db/Makefile.am b/tests/db/Makefile.am
index f13824d..0194957 100644
--- a/tests/db/Makefile.am
+++ b/tests/db/Makefile.am
@@ -30,6 +30,7 @@ db_test_LDADD = \
$(top_builddir)/src/db_auc.o \
$(top_builddir)/src/db_hlr.o \
$(top_builddir)/src/db.o \
+ $(top_builddir)/src/ipa_name.o \
$(LIBOSMOCORE_LIBS) \
$(LIBOSMOGSM_LIBS) \
$(LIBOSMOABIS_LIBS) \
diff --git a/tests/db/db_test.c b/tests/db/db_test.c
index b9b263d..c53baed 100644
--- a/tests/db/db_test.c
+++ b/tests/db/db_test.c
@@ -27,6 +27,7 @@
#include <osmocom/core/utils.h>
#include <osmocom/core/logging.h>
+#include <osmocom/gsupclient/ipa_name.h>
#include <osmocom/hlr/db.h>
#include <osmocom/hlr/logging.h>
@@ -145,6 +146,8 @@ void dump_subscr(struct hlr_subscriber *subscr)
#define Ps(name) \
if (*subscr->name) \
Pfo(name, "'%s'", subscr)
+#define Pgt(name) \
+ Pfv(name, "%s", osmo_ipa_name_to_str(&subscr->name))
#define Pd(name) \
Pfv(name, "%"PRId64, (int64_t)subscr->name)
#define Pd_nonzero(name) \
@@ -235,6 +238,14 @@ static const char *imsi2 = "123456789000002";
static const char *short_imsi = "123456";
static const char *unknown_imsi = "999999999";
+static int db_subscr_lu_str(struct db_context *dbc, int64_t subscr_id,
+ const char *vlr_or_sgsn_number, bool is_ps)
+{
+ struct osmo_ipa_name vlr_nr;
+ osmo_ipa_name_set_str(&vlr_nr, vlr_or_sgsn_number);
+ return db_subscr_lu(dbc, subscr_id, &vlr_nr, is_ps, NULL);
+}
+
static void test_subscr_create_update_sel_delete()
{
int64_t id0, id1, id2, id_short;
@@ -386,39 +397,39 @@ static void test_subscr_create_update_sel_delete()
comment("Record LU for PS and CS (SGSN and VLR names)");
- ASSERT_RC(db_subscr_lu(dbc, id0, "5952", true), 0);
+ ASSERT_RC(db_subscr_lu_str(dbc, id0, "5952", true), 0);
ASSERT_SEL(id, id0, 0);
- ASSERT_RC(db_subscr_lu(dbc, id0, "712", false), 0);
+ ASSERT_RC(db_subscr_lu_str(dbc, id0, "712", false), 0);
ASSERT_SEL(id, id0, 0);
comment("Record LU for PS and CS (SGSN and VLR names) *again*");
- ASSERT_RC(db_subscr_lu(dbc, id0, "111", true), 0);
+ ASSERT_RC(db_subscr_lu_str(dbc, id0, "111", true), 0);
ASSERT_SEL(id, id0, 0);
- ASSERT_RC(db_subscr_lu(dbc, id0, "111", true), 0);
+ ASSERT_RC(db_subscr_lu_str(dbc, id0, "111", true), 0);
ASSERT_SEL(id, id0, 0);
- ASSERT_RC(db_subscr_lu(dbc, id0, "222", false), 0);
+ ASSERT_RC(db_subscr_lu_str(dbc, id0, "222", false), 0);
ASSERT_SEL(id, id0, 0);
- ASSERT_RC(db_subscr_lu(dbc, id0, "222", false), 0);
+ ASSERT_RC(db_subscr_lu_str(dbc, id0, "222", false), 0);
ASSERT_SEL(id, id0, 0);
comment("Unset LU info for PS and CS (SGSN and VLR names)");
- ASSERT_RC(db_subscr_lu(dbc, id0, "", true), 0);
+ ASSERT_RC(db_subscr_lu_str(dbc, id0, "", true), 0);
ASSERT_SEL(id, id0, 0);
- ASSERT_RC(db_subscr_lu(dbc, id0, "", false), 0);
+ ASSERT_RC(db_subscr_lu_str(dbc, id0, "", false), 0);
ASSERT_SEL(id, id0, 0);
- ASSERT_RC(db_subscr_lu(dbc, id0, "111", true), 0);
- ASSERT_RC(db_subscr_lu(dbc, id0, "222", false), 0);
+ ASSERT_RC(db_subscr_lu_str(dbc, id0, "111", true), 0);
+ ASSERT_RC(db_subscr_lu_str(dbc, id0, "222", false), 0);
ASSERT_SEL(id, id0, 0);
- ASSERT_RC(db_subscr_lu(dbc, id0, NULL, true), 0);
+ ASSERT_RC(db_subscr_lu_str(dbc, id0, NULL, true), 0);
ASSERT_SEL(id, id0, 0);
- ASSERT_RC(db_subscr_lu(dbc, id0, NULL, false), 0);
+ ASSERT_RC(db_subscr_lu_str(dbc, id0, NULL, false), 0);
ASSERT_SEL(id, id0, 0);
comment("Record LU for non-existent ID");
- ASSERT_RC(db_subscr_lu(dbc, 99999, "5952", true), -ENOENT);
- ASSERT_RC(db_subscr_lu(dbc, 99999, "712", false), -ENOENT);
+ ASSERT_RC(db_subscr_lu_str(dbc, 99999, "5952", true), -ENOENT);
+ ASSERT_RC(db_subscr_lu_str(dbc, 99999, "712", false), -ENOENT);
ASSERT_SEL(id, 99999, -ENOENT);
comment("Purge and un-purge PS and CS");
diff --git a/tests/db/db_test.err b/tests/db/db_test.err
index 6423550..e4d43c9 100644
--- a/tests/db/db_test.err
+++ b/tests/db/db_test.err
@@ -435,7 +435,7 @@ DAUC Cannot disable CS: no such subscriber: IMSI='foobar'
--- Record LU for PS and CS (SGSN and VLR names)
-db_subscr_lu(dbc, id0, "5952", true) --> 0
+db_subscr_lu_str(dbc, id0, "5952", true) --> 0
db_subscr_get_by_id(dbc, id0, &g_subscr) --> 0
struct hlr_subscriber {
@@ -445,7 +445,7 @@ struct hlr_subscriber {
.sgsn_number = '5952',
}
-db_subscr_lu(dbc, id0, "712", false) --> 0
+db_subscr_lu_str(dbc, id0, "712", false) --> 0
db_subscr_get_by_id(dbc, id0, &g_subscr) --> 0
struct hlr_subscriber {
@@ -459,7 +459,7 @@ struct hlr_subscriber {
--- Record LU for PS and CS (SGSN and VLR names) *again*
-db_subscr_lu(dbc, id0, "111", true) --> 0
+db_subscr_lu_str(dbc, id0, "111", true) --> 0
db_subscr_get_by_id(dbc, id0, &g_subscr) --> 0
struct hlr_subscriber {
@@ -470,7 +470,7 @@ struct hlr_subscriber {
.sgsn_number = '111',
}
-db_subscr_lu(dbc, id0, "111", true) --> 0
+db_subscr_lu_str(dbc, id0, "111", true) --> 0
db_subscr_get_by_id(dbc, id0, &g_subscr) --> 0
struct hlr_subscriber {
@@ -481,7 +481,7 @@ struct hlr_subscriber {
.sgsn_number = '111',
}
-db_subscr_lu(dbc, id0, "222", false) --> 0
+db_subscr_lu_str(dbc, id0, "222", false) --> 0
db_subscr_get_by_id(dbc, id0, &g_subscr) --> 0
struct hlr_subscriber {
@@ -492,7 +492,7 @@ struct hlr_subscriber {
.sgsn_number = '111',
}
-db_subscr_lu(dbc, id0, "222", false) --> 0
+db_subscr_lu_str(dbc, id0, "222", false) --> 0
db_subscr_get_by_id(dbc, id0, &g_subscr) --> 0
struct hlr_subscriber {
@@ -506,7 +506,7 @@ struct hlr_subscriber {
--- Unset LU info for PS and CS (SGSN and VLR names)
-db_subscr_lu(dbc, id0, "", true) --> 0
+db_subscr_lu_str(dbc, id0, "", true) --> 0
db_subscr_get_by_id(dbc, id0, &g_subscr) --> 0
struct hlr_subscriber {
@@ -516,7 +516,7 @@ struct hlr_subscriber {
.vlr_number = '222',
}
-db_subscr_lu(dbc, id0, "", false) --> 0
+db_subscr_lu_str(dbc, id0, "", false) --> 0
db_subscr_get_by_id(dbc, id0, &g_subscr) --> 0
struct hlr_subscriber {
@@ -525,9 +525,9 @@ struct hlr_subscriber {
.msisdn = '543210123456789',
}
-db_subscr_lu(dbc, id0, "111", true) --> 0
+db_subscr_lu_str(dbc, id0, "111", true) --> 0
-db_subscr_lu(dbc, id0, "222", false) --> 0
+db_subscr_lu_str(dbc, id0, "222", false) --> 0
db_subscr_get_by_id(dbc, id0, &g_subscr) --> 0
struct hlr_subscriber {
@@ -538,7 +538,7 @@ struct hlr_subscriber {
.sgsn_number = '111',
}
-db_subscr_lu(dbc, id0, NULL, true) --> 0
+db_subscr_lu_str(dbc, id0, NULL, true) --> 0
db_subscr_get_by_id(dbc, id0, &g_subscr) --> 0
struct hlr_subscriber {
@@ -548,7 +548,7 @@ struct hlr_subscriber {
.vlr_number = '222',
}
-db_subscr_lu(dbc, id0, NULL, false) --> 0
+db_subscr_lu_str(dbc, id0, NULL, false) --> 0
db_subscr_get_by_id(dbc, id0, &g_subscr) --> 0
struct hlr_subscriber {
@@ -560,10 +560,10 @@ struct hlr_subscriber {
--- Record LU for non-existent ID
-db_subscr_lu(dbc, 99999, "5952", true) --> -ENOENT
+db_subscr_lu_str(dbc, 99999, "5952", true) --> -ENOENT
DAUC Cannot update SGSN number for subscriber ID=99999: no such subscriber
-db_subscr_lu(dbc, 99999, "712", false) --> -ENOENT
+db_subscr_lu_str(dbc, 99999, "712", false) --> -ENOENT
DAUC Cannot update VLR number for subscriber ID=99999: no such subscriber
db_subscr_get_by_id(dbc, 99999, &g_subscr) --> -ENOENT
diff --git a/tests/gsup/Makefile.am b/tests/gsup/Makefile.am
new file mode 100644
index 0000000..5dbb180
--- /dev/null
+++ b/tests/gsup/Makefile.am
@@ -0,0 +1,36 @@
+AM_CPPFLAGS = \
+ $(all_includes) \
+ $(NULL)
+
+AM_CFLAGS = \
+ -I$(top_srcdir)/include \
+ $(LIBOSMOCORE_CFLAGS) \
+ $(LIBOSMOGSM_CFLAGS) \
+ $(NULL)
+
+AM_LDFLAGS = \
+ -no-install \
+ $(NULL)
+
+EXTRA_DIST = \
+ gsup_test.ok \
+ gsup_test.err \
+ $(NULL)
+
+noinst_PROGRAMS = \
+ gsup_test \
+ $(NULL)
+
+gsup_test_SOURCES = \
+ gsup_test.c \
+ $(NULL)
+
+gsup_test_LDADD = \
+ $(top_builddir)/src/gsupclient/libosmo-gsup-client.la \
+ $(LIBOSMOCORE_LIBS) \
+ $(LIBOSMOGSM_LIBS) \
+ $(NULL)
+
+.PHONY: update_exp
+update_exp:
+ $(builddir)/gsup_test >"$(srcdir)/gsup_test.ok" 2>"$(srcdir)/gsup_test.err"
diff --git a/tests/gsup/gsup_test.c b/tests/gsup/gsup_test.c
new file mode 100644
index 0000000..1a7bb76
--- /dev/null
+++ b/tests/gsup/gsup_test.c
@@ -0,0 +1,113 @@
+/* (C) 2018 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
+ *
+ * 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 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 <string.h>
+
+#include <osmocom/core/logging.h>
+#include <osmocom/core/utils.h>
+#include <osmocom/core/application.h>
+#include <osmocom/gsupclient/gsup_req.h>
+
+void *ctx = NULL;
+
+static void test_gsup_make_response(void)
+{
+ char *source_name = "incoming-source-name";
+ char *destination_name = "preset-destination-name";
+ uint8_t sm_rp_mr = 23;
+ uint8_t other_sm_rp_mr = 17;
+ struct osmo_gsup_message rx = {
+ .message_type = OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST,
+ .imsi = "1234567",
+ .message_class = OSMO_GSUP_MESSAGE_CLASS_SUBSCRIBER_MANAGEMENT,
+ .source_name = (uint8_t*)source_name,
+ .source_name_len = strlen(source_name) + 1,
+ .sm_rp_mr = &sm_rp_mr,
+ .session_id = 42,
+ .session_state = OSMO_GSUP_SESSION_STATE_BEGIN,
+ };
+ struct osmo_gsup_message nonempty = {
+ .message_type = OSMO_GSUP_MSGT_ROUTING_ERROR,
+ .imsi = "987654321",
+ .message_class = OSMO_GSUP_MESSAGE_CLASS_INTER_MSC,
+ .destination_name = (uint8_t*)destination_name,
+ .destination_name_len = strlen(destination_name) + 1,
+ .sm_rp_mr = &other_sm_rp_mr,
+ .session_id = 11,
+ .session_state = OSMO_GSUP_SESSION_STATE_END,
+ };
+ void *name_ctx = talloc_named_const(ctx, 0, __func__);
+ int error;
+ int final;
+ char *nonempty_str;
+ int rc;
+
+ printf("\n%s()\n", __func__);
+ printf("rx = %s\n", osmo_gsup_message_to_str_c(name_ctx, &rx));
+
+ printf("\nwriting to an empty struct osmo_gsup_message should populate values as needed:\n");
+ for (error = 0; error <= 1; error++) {
+ for (final = 0; final <= 1; final++) {
+ struct osmo_gsup_message target = {};
+ printf("- args (error=%d, final=%d)\n", error, final);
+ rc = osmo_gsup_make_response(&target, &rx, error, final);
+ printf(" %s\n", osmo_gsup_message_to_str_c(name_ctx, &target));
+ printf(" rc = %d\n", rc);
+ }
+ }
+
+ printf("\nwriting to an already populated struct osmo_gsup_message, should have no effect:\n");
+ nonempty_str = osmo_gsup_message_to_str_c(name_ctx, &nonempty);
+ for (error = 0; error <= 1; error++) {
+ for (final = 0; final <= 1; final++) {
+ struct osmo_gsup_message target = nonempty;
+ char *result;
+ printf("- args (error=%d, final=%d)\n", error, final);
+ rc = osmo_gsup_make_response(&target, &rx, error, final);
+ result = osmo_gsup_message_to_str_c(name_ctx, &target);
+ printf(" %s\n", result);
+ if (strcmp(result, nonempty_str))
+ printf(" ERROR: expected: %s\n", nonempty_str);
+ printf(" rc = %d\n", rc);
+ }
+ }
+}
+
+const struct log_info_cat default_categories[] = {
+};
+
+static struct log_info info = {
+ .cat = default_categories,
+ .num_cat = ARRAY_SIZE(default_categories),
+};
+
+int main(int argc, char **argv)
+{
+ ctx = talloc_named_const(NULL, 0, "gsup_test");
+ osmo_init_logging2(ctx, &info);
+ log_set_print_filename(osmo_stderr_target, 0);
+ log_set_print_timestamp(osmo_stderr_target, 0);
+ log_set_use_color(osmo_stderr_target, 0);
+ log_set_print_category(osmo_stderr_target, 1);
+
+ test_gsup_make_response();
+
+ printf("Done.\n");
+ return EXIT_SUCCESS;
+}
diff --git a/tests/gsup/gsup_test.err b/tests/gsup/gsup_test.err
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/gsup/gsup_test.err
diff --git a/tests/gsup/gsup_test.ok b/tests/gsup/gsup_test.ok
new file mode 100644
index 0000000..0899633
--- /dev/null
+++ b/tests/gsup/gsup_test.ok
@@ -0,0 +1,32 @@
+
+test_gsup_make_response()
+rx = Subscriber-Management OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST: imsi="1234567" source_name="incoming-source-name\0" session_id=42 session_state=BEGIN sm_rp_mr=23
+
+writing to an empty struct osmo_gsup_message should populate values as needed:
+- args (error=0, final=0)
+ Subscriber-Management OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT: imsi="1234567" destination_name="incoming-source-name\0" session_id=42 session_state=CONTINUE sm_rp_mr=23
+ rc = 0
+- args (error=0, final=1)
+ Subscriber-Management OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT: imsi="1234567" destination_name="incoming-source-name\0" session_id=42 session_state=END sm_rp_mr=23
+ rc = 0
+- args (error=1, final=0)
+ Subscriber-Management OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR: imsi="1234567" destination_name="incoming-source-name\0" session_id=42 session_state=CONTINUE sm_rp_mr=23
+ rc = 0
+- args (error=1, final=1)
+ Subscriber-Management OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR: imsi="1234567" destination_name="incoming-source-name\0" session_id=42 session_state=END sm_rp_mr=23
+ rc = 0
+
+writing to an already populated struct osmo_gsup_message, should have no effect:
+- args (error=0, final=0)
+ Inter-MSC OSMO_GSUP_MSGT_ROUTING_ERROR: imsi="987654321" destination_name="preset-destination-name\0" session_id=11 session_state=END sm_rp_mr=17
+ rc = 15
+- args (error=0, final=1)
+ Inter-MSC OSMO_GSUP_MSGT_ROUTING_ERROR: imsi="987654321" destination_name="preset-destination-name\0" session_id=11 session_state=END sm_rp_mr=17
+ rc = 15
+- args (error=1, final=0)
+ Inter-MSC OSMO_GSUP_MSGT_ROUTING_ERROR: imsi="987654321" destination_name="preset-destination-name\0" session_id=11 session_state=END sm_rp_mr=17
+ rc = 15
+- args (error=1, final=1)
+ Inter-MSC OSMO_GSUP_MSGT_ROUTING_ERROR: imsi="987654321" destination_name="preset-destination-name\0" session_id=11 session_state=END sm_rp_mr=17
+ rc = 15
+Done.
diff --git a/tests/gsup_server/Makefile.am b/tests/gsup_server/Makefile.am
index e64ac4a..48fda88 100644
--- a/tests/gsup_server/Makefile.am
+++ b/tests/gsup_server/Makefile.am
@@ -31,6 +31,8 @@ gsup_server_test_SOURCES = \
gsup_server_test_LDADD = \
$(top_srcdir)/src/gsup_server.c \
$(top_srcdir)/src/gsup_router.c \
+ $(top_srcdir)/src/gsupclient/ipa_name.c \
+ $(top_srcdir)/src/gsupclient/gsup_req.c \
$(LIBOSMOCORE_LIBS) \
$(LIBOSMOGSM_LIBS) \
$(LIBOSMOABIS_LIBS) \
diff --git a/tests/test_nodes.vty b/tests/test_nodes.vty
index a752c93..3f31b0d 100644
--- a/tests/test_nodes.vty
+++ b/tests/test_nodes.vty
@@ -148,6 +148,8 @@ log stderr
logging level db notice
logging level auc notice
logging level ss info
+ logging level mslookup notice
+ logging level lu notice
...
hlr
store-imei
diff --git a/tests/testsuite.at b/tests/testsuite.at
index d30b5e9..956ef87 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -15,6 +15,13 @@ cat $abs_srcdir/auc/auc_ts_55_205_test_sets.err > experr
AT_CHECK([$abs_top_builddir/tests/auc/auc_ts_55_205_test_sets], [], [expout], [experr])
AT_CLEANUP
+AT_SETUP([gsup])
+AT_KEYWORDS([gsup])
+cat $abs_srcdir/gsup/gsup_test.ok > expout
+cat $abs_srcdir/gsup/gsup_test.err > experr
+AT_CHECK([$abs_top_builddir/tests/gsup/gsup_test], [], [expout], [experr])
+AT_CLEANUP
+
AT_SETUP([gsup_server])
AT_KEYWORDS([gsup_server])
cat $abs_srcdir/gsup_server/gsup_server_test.ok > expout