update it
This commit is contained in:
parent
823f3c3a0f
commit
ab61064089
|
@ -4,11 +4,9 @@ bin_PROGRAMS = testcellwire
|
|||
|
||||
testcellwire_SOURCES = \
|
||||
abts.h abts_tests.h testutil.h \
|
||||
abts.c testutil.c \
|
||||
s1ap_enb_build.c \
|
||||
s1ap_message_test.c nas_message_test.c \
|
||||
enb_setup_test.c \
|
||||
security_test.c
|
||||
abts.c testutil.c tests1ap.h tests1ap.c \
|
||||
s1ap_message_test.c nas_message_test.c security_test.c \
|
||||
s1ap_sm_test.c
|
||||
|
||||
testcellwire_LDADD = \
|
||||
$(top_srcdir)/src/libcellwire.la
|
||||
|
|
|
@ -24,7 +24,7 @@ const struct testlist {
|
|||
abts_suite *(*func)(abts_suite *suite);
|
||||
} alltests[] = {
|
||||
{test_s1ap_message},
|
||||
{test_enb_setup},
|
||||
{test_s1ap_sm},
|
||||
{test_nas_message},
|
||||
{test_security},
|
||||
};
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
#ifndef _S1AP_ENB_BUILD_H__
|
||||
#define _S1AP_ENB_BUILD_H__
|
||||
|
||||
#include "s1ap_message.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
CORE_DECLARE(status_t) s1ap_build_setup_req(pkbuf_t **pkbuf, c_uint32_t enb_id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
|
|
@ -1,15 +1,12 @@
|
|||
#include "core.h"
|
||||
#include "core_errno.h"
|
||||
#include "core_general.h"
|
||||
#include "core_debug.h"
|
||||
#include "core_pkbuf.h"
|
||||
|
||||
#include "testutil.h"
|
||||
|
||||
#include "s1ap_build.h"
|
||||
#include "s1ap_enb_build.h"
|
||||
#include "s1ap_conv.h"
|
||||
|
||||
#include "testutil.h"
|
||||
#include "tests1ap.h"
|
||||
|
||||
static void s1ap_message_test1(abts_case *tc, void *data)
|
||||
{
|
||||
/* S1SetupRequest */
|
||||
|
@ -107,7 +104,7 @@ static void s1ap_message_test5(abts_case *tc, void *data)
|
|||
pkbuf_t *pkbuf;
|
||||
int result;
|
||||
|
||||
rv = s1ap_build_setup_req(&pkbuf, 0x54f64);
|
||||
rv = tests1ap_build_setup_req(&pkbuf, 0x54f64);
|
||||
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
ABTS_PTR_NOTNULL(tc, pkbuf);
|
||||
|
|
|
@ -1,72 +1,15 @@
|
|||
#include "core.h"
|
||||
#include "core_errno.h"
|
||||
#include "core_general.h"
|
||||
#include "core_debug.h"
|
||||
#include "core_pkbuf.h"
|
||||
|
||||
#include "testutil.h"
|
||||
|
||||
#include "s1ap_build.h"
|
||||
#include "s1ap_enb_build.h"
|
||||
#include "s1ap_conv.h"
|
||||
#include "s1ap_path.h"
|
||||
|
||||
net_sock_t *enb_net_open(void)
|
||||
{
|
||||
status_t rv;
|
||||
mme_ctx_t *mme = mme_self();
|
||||
net_sock_t *sock = NULL;
|
||||
|
||||
if (!mme) return NULL;
|
||||
|
||||
rv = net_open_with_addr(&sock, mme->enb_local_addr, "127.0.0.1", 0,
|
||||
mme->enb_s1ap_port, SOCK_SEQPACKET, IPPROTO_SCTP, 0);
|
||||
if (rv != CORE_OK) return NULL;
|
||||
|
||||
return sock;
|
||||
}
|
||||
|
||||
status_t enb_net_close(net_sock_t *sock)
|
||||
{
|
||||
return net_close(sock);
|
||||
}
|
||||
|
||||
int enb_net_send(net_sock_t *sock, pkbuf_t *sendbuf)
|
||||
{
|
||||
return s1ap_send(sock, sendbuf);
|
||||
}
|
||||
|
||||
int enb_net_read(net_sock_t *sock, pkbuf_t *recvbuf)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
while(1)
|
||||
{
|
||||
rc = net_read(sock, recvbuf->payload, recvbuf->len, 0);
|
||||
if (rc == -2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (rc <= 0)
|
||||
{
|
||||
if (sock->sndrcv_errno == EAGAIN)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
#include "testutil.h"
|
||||
#include "tests1ap.h"
|
||||
|
||||
#define NUM_OF_TEST_DUPLICATED_ENB 4
|
||||
|
||||
static void enb_setup_test1(abts_case *tc, void *data)
|
||||
static void s1ap_sm_test1(abts_case *tc, void *data)
|
||||
{
|
||||
status_t rv;
|
||||
net_sock_t *sock[NUM_OF_TEST_DUPLICATED_ENB];
|
||||
|
@ -78,21 +21,21 @@ static void enb_setup_test1(abts_case *tc, void *data)
|
|||
|
||||
for (i = 0; i < NUM_OF_TEST_DUPLICATED_ENB; i++)
|
||||
{
|
||||
sock[i] = enb_net_open();
|
||||
sock[i] = tests1ap_enb_connect();
|
||||
ABTS_PTR_NOTNULL(tc, sock[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < NUM_OF_TEST_DUPLICATED_ENB; i++)
|
||||
{
|
||||
rv = s1ap_build_setup_req(&sendbuf, 0x54f64);
|
||||
rv = tests1ap_build_setup_req(&sendbuf, 0x54f64);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
|
||||
rv = enb_net_send(sock[i], sendbuf);
|
||||
rv = tests1ap_enb_send(sock[i], sendbuf);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
|
||||
pkbuf_free(sendbuf);
|
||||
|
||||
rc = enb_net_read(sock[i], recvbuf);
|
||||
rc = tests1ap_enb_read(sock[i], recvbuf);
|
||||
ABTS_INT_NEQUAL(tc, 0, rc);
|
||||
|
||||
rv = s1ap_decode_pdu(&message, recvbuf);
|
||||
|
@ -103,7 +46,7 @@ static void enb_setup_test1(abts_case *tc, void *data)
|
|||
|
||||
for (i = 0; i < NUM_OF_TEST_DUPLICATED_ENB; i++)
|
||||
{
|
||||
rv = enb_net_close(sock[i]);
|
||||
rv = tests1ap_enb_close(sock[i]);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
}
|
||||
|
||||
|
@ -114,7 +57,7 @@ static void enb_setup_test1(abts_case *tc, void *data)
|
|||
|
||||
#define NUM_OF_TEST_ENB 32
|
||||
|
||||
static void enb_setup_test2(abts_case *tc, void *data)
|
||||
static void s1ap_sm_test2(abts_case *tc, void *data)
|
||||
{
|
||||
status_t rv;
|
||||
net_sock_t *sock[NUM_OF_TEST_ENB];
|
||||
|
@ -126,21 +69,21 @@ static void enb_setup_test2(abts_case *tc, void *data)
|
|||
|
||||
for (i = 0; i < NUM_OF_TEST_ENB; i++)
|
||||
{
|
||||
sock[i] = enb_net_open();
|
||||
sock[i] = tests1ap_enb_connect();
|
||||
ABTS_PTR_NOTNULL(tc, sock[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < NUM_OF_TEST_ENB; i++)
|
||||
{
|
||||
rv = s1ap_build_setup_req(&sendbuf, 0x54f64+i);
|
||||
rv = tests1ap_build_setup_req(&sendbuf, 0x54f64+i);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
|
||||
rv = enb_net_send(sock[i], sendbuf);
|
||||
rv = tests1ap_enb_send(sock[i], sendbuf);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
|
||||
pkbuf_free(sendbuf);
|
||||
|
||||
rc = enb_net_read(sock[i], recvbuf);
|
||||
rc = tests1ap_enb_read(sock[i], recvbuf);
|
||||
ABTS_INT_NEQUAL(tc, 0, rc);
|
||||
|
||||
rv = s1ap_decode_pdu(&message, recvbuf);
|
||||
|
@ -151,7 +94,7 @@ static void enb_setup_test2(abts_case *tc, void *data)
|
|||
|
||||
for (i = 0; i < NUM_OF_TEST_ENB; i++)
|
||||
{
|
||||
rv = enb_net_close(sock[i]);
|
||||
rv = tests1ap_enb_close(sock[i]);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
}
|
||||
|
||||
|
@ -160,12 +103,12 @@ static void enb_setup_test2(abts_case *tc, void *data)
|
|||
core_sleep(time_from_sec(1));
|
||||
}
|
||||
|
||||
abts_suite *test_enb_setup(abts_suite *suite)
|
||||
abts_suite *test_s1ap_sm(abts_suite *suite)
|
||||
{
|
||||
suite = ADD_SUITE(suite)
|
||||
|
||||
abts_run_test(suite, enb_setup_test1, NULL);
|
||||
abts_run_test(suite, enb_setup_test2, NULL);
|
||||
abts_run_test(suite, s1ap_sm_test1, NULL);
|
||||
abts_run_test(suite, s1ap_sm_test2, NULL);
|
||||
|
||||
return suite;
|
||||
}
|
|
@ -2,11 +2,67 @@
|
|||
|
||||
#include "core_debug.h"
|
||||
#include "core_pkbuf.h"
|
||||
|
||||
#include "context.h"
|
||||
#include "s1ap_build.h"
|
||||
#include "s1ap_conv.h"
|
||||
#include "s1ap_path.h"
|
||||
|
||||
status_t s1ap_build_setup_req(pkbuf_t **pkbuf, c_uint32_t enb_id)
|
||||
net_sock_t *tests1ap_enb_connect(void)
|
||||
{
|
||||
status_t rv;
|
||||
mme_ctx_t *mme = mme_self();
|
||||
net_sock_t *sock = NULL;
|
||||
|
||||
if (!mme) return NULL;
|
||||
|
||||
rv = net_open_with_addr(&sock, mme->enb_local_addr, "127.0.0.1", 0,
|
||||
mme->enb_s1ap_port, SOCK_SEQPACKET, IPPROTO_SCTP, 0);
|
||||
if (rv != CORE_OK) return NULL;
|
||||
|
||||
return sock;
|
||||
}
|
||||
|
||||
status_t tests1ap_enb_close(net_sock_t *sock)
|
||||
{
|
||||
return net_close(sock);
|
||||
}
|
||||
|
||||
int tests1ap_enb_send(net_sock_t *sock, pkbuf_t *sendbuf)
|
||||
{
|
||||
return s1ap_send(sock, sendbuf);
|
||||
}
|
||||
|
||||
int tests1ap_enb_read(net_sock_t *sock, pkbuf_t *recvbuf)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
while(1)
|
||||
{
|
||||
rc = net_read(sock, recvbuf->payload, recvbuf->len, 0);
|
||||
if (rc == -2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (rc <= 0)
|
||||
{
|
||||
if (sock->sndrcv_errno == EAGAIN)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
status_t tests1ap_build_setup_req(pkbuf_t **pkbuf, c_uint32_t enb_id)
|
||||
{
|
||||
int erval = -1;
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef __TESTS1AP_H__
|
||||
#define __TESTS1AP_H__
|
||||
|
||||
#include "core_net.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
CORE_DECLARE(net_sock_t) *tests1ap_enb_connect(void);
|
||||
CORE_DECLARE(status_t) tests1ap_enb_close(net_sock_t *sock);
|
||||
CORE_DECLARE(int) tests1ap_enb_send(net_sock_t *sock, pkbuf_t *sendbuf);
|
||||
CORE_DECLARE(int) tests1ap_enb_read(net_sock_t *sock, pkbuf_t *recvbuf);
|
||||
|
||||
CORE_DECLARE(status_t) tests1ap_build_setup_req(
|
||||
pkbuf_t **pkbuf, c_uint32_t enb_id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __TESTS1AP_H__ */
|
|
@ -17,8 +17,8 @@
|
|||
#include "core_general.h"
|
||||
#include "abts.h"
|
||||
|
||||
#ifndef __APR_TEST_UTIL__
|
||||
#define __APR_TEST_UTIL__
|
||||
#ifndef __TEST_UTIL__
|
||||
#define __TEST_UTIL__
|
||||
|
||||
/* XXX: FIXME - these all should become much more utilitarian
|
||||
* and part of core, itself
|
||||
|
@ -58,8 +58,8 @@ void core_assert_ok(abts_case* tc, const char *context,
|
|||
void test_initialize(void);
|
||||
|
||||
abts_suite *test_s1ap_message(abts_suite *suite);
|
||||
abts_suite *test_enb_setup(abts_suite *suite);
|
||||
abts_suite *test_s1ap_sm(abts_suite *suite);
|
||||
abts_suite *test_nas_message(abts_suite *suite);
|
||||
abts_suite *test_security(abts_suite *suite);
|
||||
|
||||
#endif /* CORE_TEST_INCLUDES */
|
||||
#endif /* __TESTUTIL_H__ */
|
||||
|
|
Loading…
Reference in New Issue