2017-02-13 07:26:07 +00:00
|
|
|
#include "core_debug.h"
|
|
|
|
#include "core_pkbuf.h"
|
|
|
|
|
2017-02-20 10:46:58 +00:00
|
|
|
#include "s1ap_build.h"
|
2017-02-13 07:26:07 +00:00
|
|
|
#include "s1ap_conv.h"
|
|
|
|
|
2017-03-05 06:02:12 +00:00
|
|
|
#include "testutil.h"
|
|
|
|
#include "tests1ap.h"
|
2017-02-13 07:26:07 +00:00
|
|
|
|
2017-02-13 12:56:03 +00:00
|
|
|
#define NUM_OF_TEST_DUPLICATED_ENB 4
|
|
|
|
|
2017-03-05 06:02:12 +00:00
|
|
|
static void s1ap_sm_test1(abts_case *tc, void *data)
|
2017-02-13 07:26:07 +00:00
|
|
|
{
|
|
|
|
status_t rv;
|
2017-02-13 12:56:03 +00:00
|
|
|
net_sock_t *sock[NUM_OF_TEST_DUPLICATED_ENB];
|
2017-02-13 07:26:07 +00:00
|
|
|
pkbuf_t *sendbuf;
|
2017-03-05 14:36:17 +00:00
|
|
|
pkbuf_t *recvbuf = pkbuf_alloc(0, MESSAGE_SDU_SIZE);
|
2017-02-13 07:26:07 +00:00
|
|
|
s1ap_message message;
|
|
|
|
int rc;
|
2017-02-13 11:49:58 +00:00
|
|
|
int i;
|
|
|
|
|
2017-02-13 12:56:03 +00:00
|
|
|
for (i = 0; i < NUM_OF_TEST_DUPLICATED_ENB; i++)
|
2017-02-13 11:49:58 +00:00
|
|
|
{
|
2017-03-05 06:02:12 +00:00
|
|
|
sock[i] = tests1ap_enb_connect();
|
2017-02-13 11:49:58 +00:00
|
|
|
ABTS_PTR_NOTNULL(tc, sock[i]);
|
|
|
|
}
|
2017-02-13 07:26:07 +00:00
|
|
|
|
2017-02-13 12:56:03 +00:00
|
|
|
for (i = 0; i < NUM_OF_TEST_DUPLICATED_ENB; i++)
|
2017-02-13 11:49:58 +00:00
|
|
|
{
|
2017-03-05 06:02:12 +00:00
|
|
|
rv = tests1ap_build_setup_req(&sendbuf, 0x54f64);
|
2017-02-13 11:49:58 +00:00
|
|
|
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
2017-02-13 07:26:07 +00:00
|
|
|
|
2017-03-05 06:02:12 +00:00
|
|
|
rv = tests1ap_enb_send(sock[i], sendbuf);
|
2017-02-13 11:49:58 +00:00
|
|
|
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
2017-02-13 07:26:07 +00:00
|
|
|
|
2017-02-13 11:49:58 +00:00
|
|
|
pkbuf_free(sendbuf);
|
2017-02-13 07:26:07 +00:00
|
|
|
|
2017-03-05 06:02:12 +00:00
|
|
|
rc = tests1ap_enb_read(sock[i], recvbuf);
|
2017-02-14 13:39:04 +00:00
|
|
|
ABTS_INT_NEQUAL(tc, 0, rc);
|
2017-02-13 07:26:07 +00:00
|
|
|
|
2017-02-13 11:49:58 +00:00
|
|
|
rv = s1ap_decode_pdu(&message, recvbuf);
|
|
|
|
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
|
|
|
|
|
|
|
s1ap_free_pdu(&message);
|
|
|
|
}
|
|
|
|
|
2017-02-13 12:56:03 +00:00
|
|
|
for (i = 0; i < NUM_OF_TEST_DUPLICATED_ENB; i++)
|
2017-02-13 11:49:58 +00:00
|
|
|
{
|
2017-03-05 06:02:12 +00:00
|
|
|
rv = tests1ap_enb_close(sock[i]);
|
2017-02-13 11:49:58 +00:00
|
|
|
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
|
|
|
}
|
2017-02-13 07:26:07 +00:00
|
|
|
|
|
|
|
pkbuf_free(recvbuf);
|
2017-02-15 00:17:44 +00:00
|
|
|
|
|
|
|
core_sleep(time_from_msec(300));
|
2017-02-13 12:31:03 +00:00
|
|
|
}
|
|
|
|
|
2017-02-13 13:40:42 +00:00
|
|
|
#define NUM_OF_TEST_ENB 32
|
2017-02-13 12:56:03 +00:00
|
|
|
|
2017-03-05 06:02:12 +00:00
|
|
|
static void s1ap_sm_test2(abts_case *tc, void *data)
|
2017-02-13 12:31:03 +00:00
|
|
|
{
|
|
|
|
status_t rv;
|
|
|
|
net_sock_t *sock[NUM_OF_TEST_ENB];
|
|
|
|
pkbuf_t *sendbuf;
|
2017-03-05 14:36:17 +00:00
|
|
|
pkbuf_t *recvbuf = pkbuf_alloc(0, MESSAGE_SDU_SIZE);
|
2017-02-13 12:31:03 +00:00
|
|
|
s1ap_message message;
|
|
|
|
int rc;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_OF_TEST_ENB; i++)
|
|
|
|
{
|
2017-03-05 06:02:12 +00:00
|
|
|
sock[i] = tests1ap_enb_connect();
|
2017-02-13 12:31:03 +00:00
|
|
|
ABTS_PTR_NOTNULL(tc, sock[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_OF_TEST_ENB; i++)
|
|
|
|
{
|
2017-03-05 06:02:12 +00:00
|
|
|
rv = tests1ap_build_setup_req(&sendbuf, 0x54f64+i);
|
2017-02-13 12:31:03 +00:00
|
|
|
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
|
|
|
|
2017-03-05 06:02:12 +00:00
|
|
|
rv = tests1ap_enb_send(sock[i], sendbuf);
|
2017-02-13 12:31:03 +00:00
|
|
|
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
|
|
|
|
|
|
|
pkbuf_free(sendbuf);
|
|
|
|
|
2017-03-05 06:02:12 +00:00
|
|
|
rc = tests1ap_enb_read(sock[i], recvbuf);
|
2017-02-14 13:39:04 +00:00
|
|
|
ABTS_INT_NEQUAL(tc, 0, rc);
|
2017-02-13 12:31:03 +00:00
|
|
|
|
|
|
|
rv = s1ap_decode_pdu(&message, recvbuf);
|
|
|
|
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
|
|
|
|
|
|
|
s1ap_free_pdu(&message);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_OF_TEST_ENB; i++)
|
|
|
|
{
|
2017-03-05 06:02:12 +00:00
|
|
|
rv = tests1ap_enb_close(sock[i]);
|
2017-02-13 12:31:03 +00:00
|
|
|
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
pkbuf_free(recvbuf);
|
2017-02-15 00:17:44 +00:00
|
|
|
|
|
|
|
core_sleep(time_from_sec(1));
|
2017-02-13 07:26:07 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 06:02:12 +00:00
|
|
|
abts_suite *test_s1ap_sm(abts_suite *suite)
|
2017-02-13 07:26:07 +00:00
|
|
|
{
|
|
|
|
suite = ADD_SUITE(suite)
|
|
|
|
|
2017-03-05 06:02:12 +00:00
|
|
|
abts_run_test(suite, s1ap_sm_test1, NULL);
|
|
|
|
abts_run_test(suite, s1ap_sm_test2, NULL);
|
2017-02-13 07:26:07 +00:00
|
|
|
|
|
|
|
return suite;
|
|
|
|
}
|