aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2017-04-03 21:49:07 +0200
committerHarald Welte <laforge@gnumonks.org>2017-04-03 22:11:42 +0200
commit2cc1564969d9512b0fab7e0ff1345091901146df (patch)
tree47f4379c2bf18a5c9c3732c6f1fd2d04260051e1
parent5ab1f2b81ce22186a4442e9bb9fc22412255d042 (diff)
remove tests/sigtran: it's not a test case
in tests/* we have unit tests that are run as part of the autotest suite during 'make check'. The code in tests/sigtran is an example, but not a test. As the API is changing anyway, let's remove it for now and re-introduce actual tests and examples after the changes in API required by the upcoming new SCCP core. Change-Id: Ie471a197856c875eb4987bf9858d757312de24fb
-rw-r--r--configure.ac1
-rw-r--r--tests/Makefile.am2
-rw-r--r--tests/sigtran/Makefile.am11
-rw-r--r--tests/sigtran/sua_client_test.c56
-rw-r--r--tests/sigtran/sua_server_test.c78
-rw-r--r--tests/sigtran/sua_test_common.c87
-rw-r--r--tests/sigtran/sua_test_common.h32
7 files changed, 1 insertions, 266 deletions
diff --git a/configure.ac b/configure.ac
index 09e7adb..c7c2b3b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -55,7 +55,6 @@ AC_OUTPUT(
tests/sccp/Makefile
tests/mtp/Makefile
tests/m2ua/Makefile
- tests/sigtran/Makefile
tests/xua/Makefile
tests/ss7/Makefile
Makefile)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6d3c96f..70e8a00 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = xua sccp mtp m2ua sigtran ss7
+SUBDIRS = xua sccp mtp m2ua ss7
# The `:;' works around a Bash 3.2 bug when the output is not writeable.
$(srcdir)/package.m4: $(top_srcdir)/configure.ac
diff --git a/tests/sigtran/Makefile.am b/tests/sigtran/Makefile.am
deleted file mode 100644
index 91c0960..0000000
--- a/tests/sigtran/Makefile.am
+++ /dev/null
@@ -1,11 +0,0 @@
-AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir)
-AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS)
-
-noinst_HEADERS = sua_test_common.h
-noinst_PROGRAMS = sua_server_test sua_client_test
-
-sua_server_test_SOURCES = sua_server_test.c sua_test_common.c
-sua_server_test_LDADD = $(top_builddir)/src/libosmo-sigtran.la $(LIBOSMOCORE_LIBS) $(TALLOC_LIBS)
-
-sua_client_test_SOURCES = sua_client_test.c sua_test_common.c
-sua_client_test_LDADD = $(top_builddir)/src/libosmo-sigtran.la $(LIBOSMOCORE_LIBS) $(TALLOC_LIBS)
diff --git a/tests/sigtran/sua_client_test.c b/tests/sigtran/sua_client_test.c
deleted file mode 100644
index 3cbd937..0000000
--- a/tests/sigtran/sua_client_test.c
+++ /dev/null
@@ -1,56 +0,0 @@
-#include "sua_test_common.h"
-
-struct osmo_sccp_user *g_user;
-struct osmo_sccp_link *g_link;
-
-static int sccp_sap_up(struct osmo_prim_hdr *oph, void *link)
-{
- struct osmo_scu_prim *prim = (struct osmo_scu_prim *) oph;
- struct osmo_prim_hdr *resp = NULL;
- uint8_t payload[] = { 0xa1, 0xa2, 0xa3 };
-
- printf("sccp_sap_up(%s)\n", osmo_scu_prim_name(oph));
-
- switch (OSMO_PRIM_HDR(oph)) {
- case OSMO_PRIM(OSMO_SCU_PRIM_N_CONNECT, PRIM_OP_CONFIRM):
- printf("N-CONNECT.ind(%u), issuing DATA.req\n",
- prim->u.connect.conn_id);
- resp = make_dt1_req(prim->u.connect.conn_id, payload, sizeof(payload));
- break;
- }
-
- if (resp)
- osmo_sua_user_link_down(link, resp);
-
- msgb_free(oph->msg);
- return 0;
-}
-
-
-int main(int argc, char **argv)
-{
- void *ctx = talloc_named_const(NULL, 1, "root");
- int rc;
-
- osmo_sua_set_log_area(DSUA);
-
- osmo_init_logging(&test_log_info);
-
- g_user = osmo_sua_user_create(ctx, sccp_sap_up, NULL);
-
- rc = osmo_sua_client_connect(g_user, "127.0.0.1", 2342);
- if (rc < 0) {
- exit(1);
- }
-
- g_link = osmo_sua_client_get_link(g_user);
-
- int i = 8000;
-
- while (1) {
- if (i < 8010)
- tx_conn_req(g_link, i++);
- //tx_unitdata(g_link);
- osmo_select_main(0);
- }
-}
diff --git a/tests/sigtran/sua_server_test.c b/tests/sigtran/sua_server_test.c
deleted file mode 100644
index 97b2baf..0000000
--- a/tests/sigtran/sua_server_test.c
+++ /dev/null
@@ -1,78 +0,0 @@
-#include "sua_test_common.h"
-
-struct osmo_prim_hdr *make_conn_resp(struct osmo_scu_connect_param *param)
-{
- struct msgb *msg = msgb_alloc(1024, "conn_resp");
- struct osmo_scu_prim *prim;
-
- prim = (struct osmo_scu_prim *) msgb_put(msg, sizeof(*prim));
- osmo_prim_init(&prim->oph, SCCP_SAP_USER,
- OSMO_SCU_PRIM_N_CONNECT,
- PRIM_OP_RESPONSE, msg);
- memcpy(&prim->u.connect, param, sizeof(prim->u.connect));
- return &prim->oph;
-}
-
-static int sccp_sap_up(struct osmo_prim_hdr *oph, void *link)
-{
- struct osmo_scu_prim *prim = (struct osmo_scu_prim *) oph;
- struct osmo_prim_hdr *resp = NULL;
- const uint8_t payload[] = { 0xb1, 0xb2, 0xb3 };
-
- printf("sccp_sap_up(%s)\n", osmo_scu_prim_name(oph));
-
- switch (OSMO_PRIM_HDR(oph)) {
- case OSMO_PRIM(OSMO_SCU_PRIM_N_CONNECT, PRIM_OP_CONFIRM):
- /* confirmation of outbound connection */
- break;
- case OSMO_PRIM(OSMO_SCU_PRIM_N_CONNECT, PRIM_OP_INDICATION):
- /* indication of new inbound connection request*/
- printf("N-CONNECT.ind(X->%u)\n", prim->u.connect.conn_id);
- resp = make_conn_resp(&prim->u.connect);
- break;
- case OSMO_PRIM(OSMO_SCU_PRIM_N_DISCONNECT, PRIM_OP_INDICATION):
- /* indication of disconnect */
- printf("N-DISCONNECT.ind(%u)\n", prim->u.disconnect.conn_id);
- break;
- case OSMO_PRIM(OSMO_SCU_PRIM_N_DATA, PRIM_OP_INDICATION):
- /* connection-oriented data received */
- printf("N-DATA.ind(%u, %s)\n", prim->u.data.conn_id,
- osmo_hexdump(msgb_l2(oph->msg), msgb_l2len(oph->msg)));
- resp = make_dt1_req(prim->u.data.conn_id, payload, sizeof(payload));
- break;
- case OSMO_PRIM(OSMO_SCU_PRIM_N_UNITDATA, PRIM_OP_INDICATION):
- /* connection-oriented data received */
- printf("N-UNITDATA.ind(%s)\n",
- osmo_hexdump(msgb_l2(oph->msg), msgb_l2len(oph->msg)));
- tx_unitdata(link);
- break;
- }
-
- if (resp)
- osmo_sua_user_link_down(link, resp);
-
- msgb_free(oph->msg);
- return 0;
-}
-
-int main(int argc, char **argv)
-{
- struct osmo_sccp_user *user;
- void *ctx = talloc_named_const(NULL, 1, "root");
- int rc;
-
- osmo_sua_set_log_area(DSUA);
-
- osmo_init_logging(&test_log_info);
-
- user = osmo_sua_user_create(ctx, sccp_sap_up, NULL);
-
- rc = osmo_sua_server_listen(user, "127.0.0.1", 2342);
- if (rc < 0) {
- exit(1);
- }
-
- while (1) {
- osmo_select_main(0);
- }
-}
diff --git a/tests/sigtran/sua_test_common.c b/tests/sigtran/sua_test_common.c
deleted file mode 100644
index db1f5f3..0000000
--- a/tests/sigtran/sua_test_common.c
+++ /dev/null
@@ -1,87 +0,0 @@
-#include "sua_test_common.h"
-
-static const struct log_info_cat log_cat[] = {
- [DMAIN] = {
- .name = "DMAIN", .loglevel = LOGL_DEBUG, .enabled = 1,
- .color = "",
- .description = "Main program",
- },
- [DSUA] = {
- .name = "DSUA", .loglevel = LOGL_DEBUG, .enabled = 1,
- .color = "",
- .description = "SCCP User Adaption",
- },
-};
-
-const struct log_info test_log_info = {
- .cat = log_cat,
- .num_cat = ARRAY_SIZE(log_cat),
-};
-
-int tx_unitdata(struct osmo_sccp_link *link)
-{
- struct msgb *msg = msgb_alloc(1024, "tx_unitdata");
- struct osmo_scu_prim *prim;
- struct osmo_scu_unitdata_param *param;
- uint8_t *cur;
-
- prim = (struct osmo_scu_prim *) msgb_put(msg, sizeof(*prim));
- param = &prim->u.unitdata;
- param->calling_addr.presence = OSMO_SCCP_ADDR_T_SSN;
- param->called_addr.presence = OSMO_SCCP_ADDR_T_SSN;
- osmo_prim_init(&prim->oph, SCCP_SAP_USER, OSMO_SCU_PRIM_N_UNITDATA, PRIM_OP_REQUEST, msg);
-
- cur = msg->l2h = msgb_put(msg, 3);
- cur[0] = 1; cur[1] = 2; cur[2] = 3;
-
- return osmo_sua_user_link_down(link, &prim->oph);
-}
-
-static void sccp_make_addr_pc_ssn(struct osmo_sccp_addr *addr, uint32_t pc, uint32_t ssn)
-{
- addr->presence = OSMO_SCCP_ADDR_T_SSN | OSMO_SCCP_ADDR_T_PC;
- addr->ssn = ssn;
- addr->pc = pc;
-}
-
-struct osmo_prim_hdr *make_conn_req(uint32_t conn_id)
-{
- struct msgb *msg = msgb_alloc(1024, "conn_req");
- struct osmo_scu_prim *prim;
-
- prim = (struct osmo_scu_prim *) msgb_put(msg, sizeof(*prim));
- osmo_prim_init(&prim->oph, SCCP_SAP_USER,
- OSMO_SCU_PRIM_N_CONNECT,
- PRIM_OP_REQUEST, msg);
- /* Set SSN for calling and called addr */
- sccp_make_addr_pc_ssn(&prim->u.connect.called_addr, 2, OSMO_SCCP_SSN_RANAP);
- sccp_make_addr_pc_ssn(&prim->u.connect.calling_addr, 1, OSMO_SCCP_SSN_RANAP);
- prim->u.connect.sccp_class = 2;
- prim->u.connect.conn_id = conn_id;
-
- return &prim->oph;
-}
-
-int tx_conn_req(struct osmo_sccp_link *link, uint32_t conn_id)
-{
- struct osmo_prim_hdr *prim = make_conn_req(conn_id);
- return osmo_sua_user_link_down(link, prim);
-}
-
-struct osmo_prim_hdr *
-make_dt1_req(uint32_t conn_id, const uint8_t *data, unsigned int len)
-{
- struct msgb *msg = msgb_alloc(1024, "dt1");
- struct osmo_scu_prim *prim;
-
- prim = (struct osmo_scu_prim *) msgb_put(msg, sizeof(*prim));
- osmo_prim_init(&prim->oph, SCCP_SAP_USER,
- OSMO_SCU_PRIM_N_DATA,
- PRIM_OP_REQUEST, msg);
- prim->u.data.conn_id = conn_id;
-
- msg->l2h = msgb_put(msg, len);
- memcpy(msg->l2h, data, len);
-
- return &prim->oph;
-}
diff --git a/tests/sigtran/sua_test_common.h b/tests/sigtran/sua_test_common.h
deleted file mode 100644
index b1883cd..0000000
--- a/tests/sigtran/sua_test_common.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#pragma once
-
-#include <stdint.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <osmocom/core/select.h>
-#include <osmocom/core/prim.h>
-#include <osmocom/core/talloc.h>
-#include <osmocom/core/logging.h>
-#include <osmocom/core/application.h>
-#include <osmocom/vty/logging.h>
-
-#include <osmocom/sigtran/sua.h>
-#include <osmocom/sigtran/sccp_sap.h>
-
-
-enum log_cat {
- DMAIN,
- DSUA,
- DXUA,
-};
-
-extern const struct log_info test_log_info;
-
-int tx_unitdata(struct osmo_sccp_link *link);
-int tx_conn_req(struct osmo_sccp_link *link, uint32_t conn_id);
-
-struct osmo_prim_hdr *make_conn_req(uint32_t conn_id);
-struct osmo_prim_hdr *make_dt1_req(uint32_t conn_id, const uint8_t *data, unsigned int len);