improve testrx code

This commit is contained in:
Sukchan Lee
2018-01-04 21:22:21 +09:00
parent 627077247c
commit 9675c47a10
5 changed files with 33 additions and 17 deletions

View File

@@ -45,4 +45,4 @@ CORE_DECLARE(void) pcrf_terminate(void);
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif /* !__NEXTEPC_H__ */ #endif /* __APP_H__ */

View File

@@ -4,7 +4,7 @@ bin_PROGRAMS = testrx
testrx_SOURCES = \ testrx_SOURCES = \
abts.h abts_tests.h testutil.h \ abts.h abts_tests.h testutil.h \
abts.c testutil.c testpacket.h testpacket.c \ abts.c testutil.c testpacket.h testpacket.c testapp.h testapp.c \
volte_test.c \ volte_test.c \
$(NULL) $(NULL)

View File

@@ -13,7 +13,6 @@
#include "gtp/gtp_path.h" #include "gtp/gtp_path.h"
#include "app/context.h" #include "app/context.h"
#include "mme/mme_context.h"
extern int test_only_control_plane; extern int test_only_control_plane;
@@ -26,6 +25,9 @@ extern int test_only_control_plane;
static c_sockaddr_t *test_enb_addr = NULL; static c_sockaddr_t *test_enb_addr = NULL;
static c_sockaddr_t *test_enb_addr6 = NULL; static c_sockaddr_t *test_enb_addr6 = NULL;
static list_t s1ap_list;
static list_t s1ap_list6;
status_t testpacket_init() status_t testpacket_init()
{ {
status_t rv; status_t rv;
@@ -42,6 +44,12 @@ status_t testpacket_init()
d_assert(rv == CORE_OK, return CORE_ERROR,); d_assert(rv == CORE_OK, return CORE_ERROR,);
#endif #endif
list_init(&s1ap_list);
list_init(&s1ap_list6);
rv = sock_probe_node(&s1ap_list, &s1ap_list6, NULL, 36412);
d_assert(rv == CORE_OK, return CORE_ERROR,);
return CORE_OK; return CORE_OK;
} }
@@ -58,6 +66,9 @@ status_t testpacket_final()
test_enb_addr6 = NULL; test_enb_addr6 = NULL;
} }
sock_remove_all_nodes(&s1ap_list);
sock_remove_all_nodes(&s1ap_list6);
return CORE_OK; return CORE_OK;
} }
@@ -66,8 +77,8 @@ status_t tests1ap_enb_connect(sock_id *new)
status_t rv; status_t rv;
sock_node_t *snode = NULL; sock_node_t *snode = NULL;
snode = list_first(&mme_self()->s1ap_list); snode = list_first(&s1ap_list);
if (!snode) snode = list_first(&mme_self()->s1ap_list6); if (!snode) snode = list_first(&s1ap_list6);
d_assert(snode, return CORE_ERROR,); d_assert(snode, return CORE_ERROR,);
rv = sctp_client(new, SOCK_STREAM, snode->list); rv = sctp_client(new, SOCK_STREAM, snode->list);
@@ -96,6 +107,7 @@ status_t tests1ap_build_setup_req(
{ {
int erval = -1; int erval = -1;
int tac = 12345; int tac = 12345;
plmn_id_t plmn_id;
s1ap_message_t message; s1ap_message_t message;
S1ap_S1SetupRequestIEs_t *ies; S1ap_S1SetupRequestIEs_t *ies;
@@ -106,21 +118,19 @@ status_t tests1ap_build_setup_req(
ies = &message.s1ap_S1SetupRequestIEs; ies = &message.s1ap_S1SetupRequestIEs;
plmn_id_build(&plmn_id, 1, 1, 2);
s1ap_uint32_to_ENB_ID(present, enb_id, &ies->global_ENB_ID.eNB_ID); s1ap_uint32_to_ENB_ID(present, enb_id, &ies->global_ENB_ID.eNB_ID);
s1ap_buffer_to_OCTET_STRING(&mme_self()->served_gummei[0].plmn_id[0], s1ap_buffer_to_OCTET_STRING(
PLMN_ID_LEN, &ies->global_ENB_ID.pLMNidentity); &plmn_id, PLMN_ID_LEN, &ies->global_ENB_ID.pLMNidentity);
supportedTA = (S1ap_SupportedTAs_Item_t *) supportedTA = (S1ap_SupportedTAs_Item_t *)
core_calloc(1, sizeof(S1ap_SupportedTAs_Item_t)); core_calloc(1, sizeof(S1ap_SupportedTAs_Item_t));
if (mme_self()->served_tai[0].list2.tai[0].tac)
tac = mme_self()->served_tai[0].list2.tai[0].tac;
else
tac = mme_self()->served_tai[0].list0.tai[0].tac[0];
s1ap_uint16_to_OCTET_STRING(tac, &supportedTA->tAC); s1ap_uint16_to_OCTET_STRING(tac, &supportedTA->tAC);
plmnIdentity = (S1ap_PLMNidentity_t *) plmnIdentity = (S1ap_PLMNidentity_t *)
core_calloc(1, sizeof(S1ap_PLMNidentity_t)); core_calloc(1, sizeof(S1ap_PLMNidentity_t));
s1ap_buffer_to_OCTET_STRING(&mme_self()->served_gummei[0].plmn_id[0], s1ap_buffer_to_OCTET_STRING(
PLMN_ID_LEN, plmnIdentity); &plmn_id, PLMN_ID_LEN, plmnIdentity);
ASN_SEQUENCE_ADD(&supportedTA->broadcastPLMNs, plmnIdentity); ASN_SEQUENCE_ADD(&supportedTA->broadcastPLMNs, plmnIdentity);
ASN_SEQUENCE_ADD(&ies->supportedTAs, supportedTA); ASN_SEQUENCE_ADD(&ies->supportedTAs, supportedTA);

View File

@@ -21,7 +21,10 @@
#include "app/app.h" #include "app/app.h"
#include "app/context.h" #include "app/context.h"
#include "testpacket.h" #include "testpacket.h"
#include "testapp.h"
#include "abts.h" #include "abts.h"
#include "testutil.h" #include "testutil.h"
@@ -41,7 +44,7 @@ void test_terminate(void)
d_trace_global_on(); d_trace_global_on();
testpacket_final(); testpacket_final();
app_terminate(); test_app_terminate();
core_terminate(); core_terminate();
} }
@@ -54,7 +57,7 @@ status_t test_initialize(char *config_path)
atexit(test_terminate); atexit(test_terminate);
core_initialize(); core_initialize();
rv = app_initialize(config_path, NULL); rv = test_app_initialize(config_path, NULL);
testpacket_init(); testpacket_init();
if (rv == CORE_OK) if (rv == CORE_OK)
{ {

View File

@@ -2,12 +2,13 @@
#include "core_debug.h" #include "core_debug.h"
#include "core_pkbuf.h" #include "core_pkbuf.h"
#include "core_lib.h" #include "core_lib.h"
#include "3gpp_types.h"
#include <mongoc.h> #include <mongoc.h>
#include "app/context.h"
#include "mme/mme_context.h"
#include "s1ap/s1ap_message.h" #include "s1ap/s1ap_message.h"
#include "app/context.h"
#include "testutil.h" #include "testutil.h"
#include "testpacket.h" #include "testpacket.h"
@@ -582,7 +583,9 @@ abts_suite *test_volte(abts_suite *suite)
suite = ADD_SUITE(suite) suite = ADD_SUITE(suite)
abts_run_test(suite, volte_test1, NULL); abts_run_test(suite, volte_test1, NULL);
#if 0
abts_run_test(suite, volte_test2, NULL); abts_run_test(suite, volte_test2, NULL);
#endif
return suite; return suite;
} }