Diameter Rx Test Simualtor is initially implemented.

This commit is contained in:
Sukchan Lee 2018-01-04 20:52:19 +09:00
parent b8ef9e9e2a
commit 627077247c
11 changed files with 3475 additions and 0 deletions

View file

@ -466,6 +466,7 @@ AC_CONFIG_FILES([support/logrotate/Makefile])
AC_CONFIG_FILES([support/newsyslog/nextepc.conf])
AC_CONFIG_FILES([support/newsyslog/Makefile])
AC_CONFIG_FILES([support/Makefile])
AC_CONFIG_FILES([test/rx/Makefile])
AC_CONFIG_FILES([test/Makefile])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

View file

@ -1,5 +1,7 @@
## Process this file with automake to produce Makefile.in.
SUBDIRS = rx
bin_PROGRAMS = testepc
testepc_SOURCES = \

31
test/rx/Makefile.am Normal file
View file

@ -0,0 +1,31 @@
## Process this file with automake to produce Makefile.in.
bin_PROGRAMS = testrx
testrx_SOURCES = \
abts.h abts_tests.h testutil.h \
abts.c testutil.c testpacket.h testpacket.c \
volte_test.c \
$(NULL)
testrx_LDADD = \
$(top_srcdir)/src/libepc.la \
$(NULL)
AM_CPPFLAGS = \
-I$(top_srcdir)/lib/core/include \
-I$(top_srcdir)/lib \
-I$(top_srcdir)/src \
-I$(top_srcdir)/lib/s1ap/asn1c \
-I$(top_srcdir)/lib/@FREEDIAMETER_DIR@/include \
@MONGOC_CFLAGS@ \
$(NULL)
AM_CFLAGS = \
-Wall -Werror \
-Wno-unused-function -Wno-unused-variable \
@OSCPPFLAGS@ \
$(NULL)
MAINTAINERCLEANFILES = Makefile.in
MOSTLYCLEANFILES = core *.stackdump

501
test/rx/abts.c Normal file
View file

@ -0,0 +1,501 @@
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "abts.h"
#include "abts_tests.h"
#include "testutil.h"
#include "core_debug.h"
#include "core_pkbuf.h"
#define ABTS_STAT_SIZE 6
static char status[ABTS_STAT_SIZE] = {'|', '/', '-', '|', '\\', '-'};
static int curr_char;
static int verbose = 1;
static int exclude = 0;
static int quiet = 0;
static int list_tests = 0;
int test_only_control_plane = 0;
const char **testlist = NULL;
static int find_test_name(const char *testname) {
int i;
for (i = 0; testlist[i] != NULL; i++) {
if (!strcmp(testlist[i], testname)) {
return 1;
}
}
return 0;
}
/* Determine if the test should be run at all */
static int should_test_run(const char *testname) {
int found = 0;
if (list_tests == 1) {
return 0;
}
if (testlist == NULL) {
return 1;
}
found = find_test_name(testname);
if ((found && !exclude) || (!found && exclude)) {
return 1;
}
return 0;
}
static void reset_status(void)
{
curr_char = 0;
}
static void update_status(void)
{
if (!quiet) {
curr_char = (curr_char + 1) % ABTS_STAT_SIZE;
fprintf(stdout, "\b%c", status[curr_char]);
fflush(stdout);
}
}
static void end_suite(abts_suite *suite)
{
if (suite != NULL) {
sub_suite *last = suite->tail;
if (!quiet) {
fprintf(stdout, "\b");
fflush(stdout);
}
if (last->failed == 0) {
fprintf(stdout, "SUCCESS\n");
fflush(stdout);
}
else {
fprintf(stdout, "FAILED %d of %d\n", last->failed, last->num_test);
fflush(stdout);
}
}
}
abts_suite *abts_add_suite(abts_suite *suite, const char *suite_name_full)
{
sub_suite *subsuite;
char *p;
const char *suite_name;
curr_char = 0;
/* Only end the suite if we actually ran it */
if (suite && suite->tail &&!suite->tail->not_run) {
end_suite(suite);
}
subsuite = core_malloc(sizeof(*subsuite));
subsuite->num_test = 0;
subsuite->failed = 0;
subsuite->next = NULL;
/* suite_name_full may be an absolute path depending on __FILE__
* expansion */
suite_name = strrchr(suite_name_full, '/');
if (suite_name) {
suite_name++;
} else {
suite_name = suite_name_full;
}
p = strrchr(suite_name, '.');
if (p) {
subsuite->name = memcpy(core_calloc(p - suite_name + 1, 1),
suite_name, p - suite_name);
}
else {
subsuite->name = suite_name;
}
if (list_tests) {
fprintf(stdout, "%s\n", subsuite->name);
}
subsuite->not_run = 0;
if (suite == NULL) {
suite = core_malloc(sizeof(*suite));
suite->head = subsuite;
suite->tail = subsuite;
}
else {
suite->tail->next = subsuite;
suite->tail = subsuite;
}
if (!should_test_run(subsuite->name)) {
subsuite->not_run = 1;
return suite;
}
reset_status();
fprintf(stdout, "%-20s: ", subsuite->name);
update_status();
fflush(stdout);
return suite;
}
void abts_run_test(abts_suite *ts, test_func f, void *value)
{
abts_case tc;
sub_suite *ss;
if (!should_test_run(ts->tail->name)) {
return;
}
ss = ts->tail;
tc.failed = 0;
tc.suite = ss;
ss->num_test++;
update_status();
f(&tc, value);
if (tc.failed) {
ss->failed++;
}
}
static int report(abts_suite *suite)
{
int count = 0;
sub_suite *dptr;
if (suite && suite->tail &&!suite->tail->not_run) {
end_suite(suite);
}
for (dptr = suite->head; dptr; dptr = dptr->next) {
count += dptr->failed;
}
if (list_tests) {
return 0;
}
if (count == 0) {
printf("All tests passed.\n");
return 0;
}
dptr = suite->head;
fprintf(stdout, "%-15s\t\tTotal\tFail\tFailed %%\n", "Failed Tests");
fprintf(stdout, "===================================================\n");
while (dptr != NULL) {
if (dptr->failed != 0) {
float percent = ((float)dptr->failed / (float)dptr->num_test);
fprintf(stdout, "%-15s\t\t%5d\t%4d\t%6.2f%%\n", dptr->name,
dptr->num_test, dptr->failed, percent * 100);
}
dptr = dptr->next;
}
return 1;
}
static void abts_free(abts_suite *suite)
{
sub_suite *ptr = NULL, *next_ptr = NULL;
ptr = suite->head;
while (ptr != NULL) {
next_ptr = ptr->next;
core_free((void*)ptr->name);
core_free(ptr);
ptr = next_ptr;
}
core_free(suite);
}
void abts_log_message(const char *fmt, ...)
{
va_list args;
update_status();
if (verbose) {
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
fprintf(stderr, "\n");
fflush(stderr);
}
}
void abts_int_equal(abts_case *tc, const int expected, const int actual, int lineno)
{
update_status();
if (tc->failed) return;
if (expected == actual) return;
tc->failed = TRUE;
if (verbose) {
fprintf(stderr, "Line %d: expected <%d>, but saw <%d>\n", lineno, expected, actual);
fflush(stderr);
}
}
void abts_int_nequal(abts_case *tc, const int expected, const int actual, int lineno)
{
update_status();
if (tc->failed) return;
if (expected != actual) return;
tc->failed = TRUE;
if (verbose) {
fprintf(stderr, "Line %d: expected <%d>, but saw <%d>\n", lineno, expected, actual);
fflush(stderr);
}
}
void abts_size_equal(abts_case *tc, size_t expected, size_t actual, int lineno)
{
update_status();
if (tc->failed) return;
if (expected == actual) return;
tc->failed = TRUE;
if (verbose) {
/* Note that the comparison is type-exact, reporting must be a best-fit */
fprintf(stderr, "Line %d: expected %lu, but saw %lu\n", lineno,
(unsigned long)expected, (unsigned long)actual);
fflush(stderr);
}
}
void abts_str_equal(abts_case *tc, const char *expected, const char *actual, int lineno)
{
update_status();
if (tc->failed) return;
if (!expected && !actual) return;
if (expected && actual)
if (!strcmp(expected, actual)) return;
tc->failed = TRUE;
if (verbose) {
fprintf(stderr, "Line %d: expected <%s>, but saw <%s>\n", lineno, expected, actual);
fflush(stderr);
}
}
void abts_str_nequal(abts_case *tc, const char *expected, const char *actual,
size_t n, int lineno)
{
update_status();
if (tc->failed) return;
if (!strncmp(expected, actual, n)) return;
tc->failed = TRUE;
if (verbose) {
fprintf(stderr, "Line %d: expected <%s>, but saw <%s>\n", lineno, expected, actual);
fflush(stderr);
}
}
void abts_ptr_null(abts_case *tc, const void *ptr, int lineno)
{
update_status();
if (tc->failed) return;
if (ptr == NULL) return;
tc->failed = TRUE;
if (verbose) {
fprintf(stderr, "Line %d: Expected NULL, but saw <%p>\n", lineno, ptr);
fflush(stderr);
}
}
void abts_ptr_notnull(abts_case *tc, const void *ptr, int lineno)
{
update_status();
if (tc->failed) return;
if (ptr != NULL) return;
tc->failed = TRUE;
if (verbose) {
fprintf(stderr, "Line %d: Expected not NULL, but saw <%p>\n", lineno, ptr);
fflush(stderr);
}
}
void abts_ptr_equal(abts_case *tc, const void *expected, const void *actual, int lineno)
{
update_status();
if (tc->failed) return;
if (expected == actual) return;
tc->failed = TRUE;
if (verbose) {
fprintf(stderr, "Line %d: expected <%p>, but saw <%p>\n", lineno, expected, actual);
fflush(stderr);
}
}
void abts_fail(abts_case *tc, const char *message, int lineno)
{
update_status();
if (tc->failed) return;
tc->failed = TRUE;
if (verbose) {
fprintf(stderr, "Line %d: %s\n", lineno, message);
fflush(stderr);
}
}
void abts_assert(abts_case *tc, const char *message, int condition, int lineno)
{
update_status();
if (tc->failed) return;
if (condition) return;
tc->failed = TRUE;
if (verbose) {
fprintf(stderr, "Line %d: %s\n", lineno, message);
fflush(stderr);
}
}
void abts_true(abts_case *tc, int condition, int lineno)
{
update_status();
if (tc->failed) return;
if (condition) return;
tc->failed = TRUE;
if (verbose) {
fprintf(stderr, "Line %d: Condition is false, but expected true\n", lineno);
fflush(stderr);
}
}
void abts_false(abts_case *tc, int condition, int lineno)
{
update_status();
if (tc->failed) return;
if (!condition) return;
tc->failed = TRUE;
if (verbose) {
fprintf(stderr, "Line %d: Condition is true, but expected false\n", lineno);
fflush(stderr);
}
}
void abts_not_impl(abts_case *tc, const char *message, int lineno)
{
update_status();
tc->suite->not_impl++;
if (verbose) {
fprintf(stderr, "Line %d: %s\n", lineno, message);
fflush(stderr);
}
}
int main(int argc, const char *const argv[]) {
int i;
int rv;
int list_provided = 0;
abts_suite *suite = NULL;
const char *config_path = NULL;
d_trace_global_off();
d_log_set_level(D_MSG_TO_STDOUT, D_LOG_LEVEL_ERROR);
quiet = !isatty(STDOUT_FILENO);
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "-v")) {
verbose = 1;
continue;
}
if (!strcmp(argv[i], "-x")) {
exclude = 1;
continue;
}
if (!strcmp(argv[i], "-l")) {
list_tests = 1;
continue;
}
if (!strcmp(argv[i], "-q")) {
quiet = 1;
continue;
}
if (!strcmp(argv[i], "-t")) {
d_trace_global_on();
d_log_set_level(D_MSG_TO_STDOUT, D_LOG_LEVEL_FULL);
continue;
}
if (!strcmp(argv[i], "-f")) {
config_path = argv[++i];
continue;
}
if (!strcmp(argv[i], "-c")) {
test_only_control_plane = 1;
continue;
}
if (argv[i][0] == '-') {
fprintf(stderr, "Invalid option: `%s'\n", argv[i]);
exit(1);
}
list_provided = 1;
}
rv = test_initialize((char*)config_path);
if (rv != CORE_OK)
return EXIT_FAILURE;
if (list_provided) {
/* Waste a little space here, because it is easier than counting the
* number of tests listed. Besides it is at most three char *.
*/
testlist = core_calloc(argc + 1, sizeof(char *));
for (i = 1; i < argc; i++) {
testlist[i - 1] = argv[i];
}
}
for (i = 0; i < (sizeof(alltests) / sizeof(struct testlist *)); i++) {
suite = alltests[i].func(suite);
}
rv = report(suite);
abts_free(suite);
core_free(testlist);
return rv;
}

112
test/rx/abts.h Normal file
View file

@ -0,0 +1,112 @@
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef WIN32
#include <io.h>
#else
#include <unistd.h>
#endif
#ifndef ABTS_H
#define ABTS_H
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
struct sub_suite {
const char *name;
int num_test;
int failed;
int not_run;
int not_impl;
struct sub_suite *next;
};
typedef struct sub_suite sub_suite;
struct abts_suite {
sub_suite *head;
sub_suite *tail;
};
typedef struct abts_suite abts_suite;
struct abts_case {
int failed;
sub_suite *suite;
};
typedef struct abts_case abts_case;
typedef void (*test_func)(abts_case *tc, void *data);
#define ADD_SUITE(suite) abts_add_suite(suite, __FILE__);
abts_suite *abts_add_suite(abts_suite *suite, const char *suite_name);
void abts_run_test(abts_suite *ts, test_func f, void *value);
void abts_log_message(const char *fmt, ...);
void abts_int_equal(abts_case *tc, const int expected, const int actual, int lineno);
void abts_int_nequal(abts_case *tc, const int expected, const int actual, int lineno);
void abts_str_equal(abts_case *tc, const char *expected, const char *actual, int lineno);
void abts_str_nequal(abts_case *tc, const char *expected, const char *actual,
size_t n, int lineno);
void abts_ptr_null(abts_case *tc, const void *ptr, int lineno);
void abts_ptr_notnull(abts_case *tc, const void *ptr, int lineno);
void abts_ptr_equal(abts_case *tc, const void *expected, const void *actual, int lineno);
void abts_true(abts_case *tc, int condition, int lineno);
void abts_false(abts_case *tc, int condition, int lineno);
void abts_fail(abts_case *tc, const char *message, int lineno);
void abts_not_impl(abts_case *tc, const char *message, int lineno);
void abts_assert(abts_case *tc, const char *message, int condition, int lineno);
void abts_size_equal(abts_case *tc, size_t expected, size_t actual, int lineno);
/* Convenience macros. Ryan hates these! */
#define ABTS_INT_EQUAL(a, b, c) abts_int_equal(a, b, c, __LINE__)
#define ABTS_INT_NEQUAL(a, b, c) abts_int_nequal(a, b, c, __LINE__)
#define ABTS_STR_EQUAL(a, b, c) abts_str_equal(a, b, c, __LINE__)
#define ABTS_STR_NEQUAL(a, b, c, d) abts_str_nequal(a, b, c, d, __LINE__)
#define ABTS_PTR_NULL(a, b) abts_ptr_null(a, b, __LINE__)
#define ABTS_PTR_NOTNULL(a, b) abts_ptr_notnull(a, b, __LINE__)
#define ABTS_PTR_EQUAL(a, b, c) abts_ptr_equal(a, b, c, __LINE__)
#define ABTS_TRUE(a, b) abts_true(a, b, __LINE__);
#define ABTS_FALSE(a, b) abts_false(a, b, __LINE__);
#define ABTS_FAIL(a, b) abts_fail(a, b, __LINE__);
#define ABTS_NOT_IMPL(a, b) abts_not_impl(a, b, __LINE__);
#define ABTS_ASSERT(a, b, c) abts_assert(a, b, c, __LINE__);
#define ABTS_SIZE_EQUAL(a, b, c) abts_size_equal(a, b, c, __LINE__)
abts_suite *run_tests(abts_suite *suite);
abts_suite *run_tests1(abts_suite *suite);
#endif
#ifdef __cplusplus
}
#endif

29
test/rx/abts_tests.h Normal file
View file

@ -0,0 +1,29 @@
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef APR_TEST_INCLUDES
#define APR_TEST_INCLUDES
#include "abts.h"
#include "testutil.h"
const struct testlist {
abts_suite *(*func)(abts_suite *suite);
} alltests[] = {
{test_volte},
};
#endif /* APR_TEST_INCLUDES */

1986
test/rx/testpacket.c Normal file

File diff suppressed because it is too large Load diff

93
test/rx/testpacket.h Normal file
View file

@ -0,0 +1,93 @@
#ifndef __TESTS1AP_H__
#define __TESTS1AP_H__
#include "core_network.h"
#include "core_pkbuf.h"
#include "s1ap/s1ap_message.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
CORE_DECLARE(status_t) testpacket_init();
CORE_DECLARE(status_t) testpacket_final();
CORE_DECLARE(status_t) tests1ap_enb_connect(sock_id *new);
CORE_DECLARE(status_t) tests1ap_enb_close(sock_id id);
CORE_DECLARE(status_t) tests1ap_enb_send(sock_id id, pkbuf_t *sendbuf);
CORE_DECLARE(status_t) tests1ap_enb_read(sock_id id, pkbuf_t *recvbuf);
CORE_DECLARE(status_t) tests1ap_build_setup_req(
pkbuf_t **pkbuf, S1ap_ENB_ID_PR present, c_uint32_t enb_id);
CORE_DECLARE(status_t) tests1ap_build_initial_ue_msg(pkbuf_t **pkbuf, int i);
CORE_DECLARE(status_t) tests1ap_build_identity_response(pkbuf_t **pkbuf, int i);
CORE_DECLARE(status_t) tests1ap_build_authentication_response(
pkbuf_t **pkbuf, int i);
CORE_DECLARE(status_t) tests1ap_build_authentication_failure(
pkbuf_t **pkbuf, int i);
CORE_DECLARE(status_t) tests1ap_build_security_mode_complete(
pkbuf_t **pkbuf, int i);
CORE_DECLARE(status_t) tests1ap_build_esm_information_response(
pkbuf_t **pkbuf, int i);
CORE_DECLARE(status_t) tests1ap_build_ue_capability_info_indication(
pkbuf_t **pkbuf, int i);
CORE_DECLARE(status_t) tests1ap_build_initial_context_setup_response(
pkbuf_t **pkbuf,
c_uint32_t mme_ue_s1ap_id, c_uint32_t enb_ue_s1ap_id,
c_uint8_t ebi, c_uint32_t teid);
CORE_DECLARE(status_t) tests1ap_build_attach_complete(pkbuf_t **pkbuf, int i);
CORE_DECLARE(status_t) tests1ap_build_emm_status(pkbuf_t **pkbuf, int i);
CORE_DECLARE(status_t) tests1ap_build_detach_request(pkbuf_t **pkbuf, int i);
CORE_DECLARE(status_t) tests1ap_build_ue_context_release_request(
pkbuf_t **pkbuf, int i);
CORE_DECLARE(status_t) tests1ap_build_ue_context_release_complete(
pkbuf_t **pkbuf, int i);
CORE_DECLARE(status_t) tests1ap_build_service_request(
pkbuf_t **pkbuf, int i);
CORE_DECLARE(status_t) tests1ap_build_pdn_connectivity_request(
pkbuf_t **pkbuf, int i);
CORE_DECLARE(status_t) tests1ap_build_pdn_disconnectivity_request(
pkbuf_t **pkbuf, int i);
CORE_DECLARE(status_t) tests1ap_build_e_rab_setup_response(
pkbuf_t **pkbuf,
c_uint32_t mme_ue_s1ap_id, c_uint32_t enb_ue_s1ap_id,
c_uint8_t ebi, c_uint32_t teid);
CORE_DECLARE(status_t) tests1ap_build_e_rab_release_response(
pkbuf_t **pkbuf, int i);
CORE_DECLARE(status_t) tests1ap_build_activate_default_bearer_accept(
pkbuf_t **pkbuf, int i);
CORE_DECLARE(status_t) tests1ap_build_activate_dedicated_bearer_accept(
pkbuf_t **pkbuf, int i);
CORE_DECLARE(status_t) tests1ap_build_deactivate_bearer_accept(
pkbuf_t **pkbuf, int i);
CORE_DECLARE(status_t) tests1ap_build_path_switch_request(
pkbuf_t **pkbuf,
c_uint32_t mme_ue_s1ap_id, c_uint32_t enb_ue_s1ap_id,
int num_of_bearer, c_uint8_t ebi, c_uint32_t teid);
CORE_DECLARE(status_t) tests1ap_build_handover_required(pkbuf_t **pkbuf, int i);
CORE_DECLARE(status_t) tests1ap_build_handover_request_ack(
pkbuf_t **pkbuf,
c_uint32_t mme_ue_s1ap_id, c_uint32_t enb_ue_s1ap_id,
int num_of_bearer, c_uint8_t ebi, c_uint32_t teid);
CORE_DECLARE(status_t) tests1ap_build_handover_request_ack_static(
pkbuf_t **pkbuf, int i);
CORE_DECLARE(status_t) tests1ap_build_enb_status_transfer(
pkbuf_t **pkbuf, int i);
CORE_DECLARE(status_t) tests1ap_build_handover_notify(pkbuf_t **pkbuf, int i);
CORE_DECLARE(status_t) tests1ap_build_handover_cancel(pkbuf_t **pkbuf, int i);
CORE_DECLARE(status_t) testgtpu_enb_connect(sock_id *new);
CORE_DECLARE(status_t) testgtpu_enb_close(sock_id sock);
CORE_DECLARE(status_t) testgtpu_enb_read(sock_id sock, pkbuf_t *recvbuf);
CORE_DECLARE(status_t) testgtpu_enb_send(pkbuf_t *sendbuf);
CORE_DECLARE(status_t) testgtpu_build_ping(pkbuf_t **sendbuf,
const char *src_ip, const char *dst_ip);
CORE_DECLARE(status_t) testgtpu_build_slacc_rs(pkbuf_t **sendbuf, int i);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __TESTS1AP_H__ */

70
test/rx/testutil.c Normal file
View file

@ -0,0 +1,70 @@
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "core_general.h"
#include "core_debug.h"
#include "core_semaphore.h"
#include "fd/fd_lib.h"
#include "app/app.h"
#include "app/context.h"
#include "testpacket.h"
#include "abts.h"
#include "testutil.h"
static int connected_count = 0;
static void test_fd_logger_handler(enum fd_hook_type type, struct msg * msg,
struct peer_hdr * peer, void * other, struct fd_hook_permsgdata *pmd,
void * regdata)
{
if (type == HOOK_PEER_CONNECT_SUCCESS)
{
connected_count++;
}
}
void test_terminate(void)
{
d_trace_global_on();
testpacket_final();
app_terminate();
core_terminate();
}
status_t test_initialize(char *config_path)
{
status_t rv;
fd_logger_register(test_fd_logger_handler);
atexit(test_terminate);
core_initialize();
rv = app_initialize(config_path, NULL);
testpacket_init();
if (rv == CORE_OK)
{
while(1)
{
if (connected_count == 1) break;
core_sleep(time_from_msec(50));
}
}
return rv;
}

62
test/rx/testutil.h Normal file
View file

@ -0,0 +1,62 @@
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "core_general.h"
#include "abts.h"
#ifndef __TEST_UTIL__
#define __TEST_UTIL__
/* XXX: FIXME - these all should become much more utilitarian
* and part of core, itself
*/
#ifdef WIN32
#ifdef BINPATH
#define TESTBINPATH APR_STRINGIFY(BINPATH) "/"
#else
#define TESTBINPATH ""
#endif
#else
#define TESTBINPATH "./"
#endif
#ifdef WIN32
#define EXTENSION ".exe"
#elif NETWARE
#define EXTENSION ".nlm"
#else
#define EXTENSION
#endif
#define STRING_MAX 8096
/* Some simple functions to make the test apps easier to write and
* a bit more consistent...
*/
/* Assert that RV is an CORE_OK value; else fail giving strerror
* for RV and CONTEXT message. */
void core_assert_ok(abts_case* tc, const char *context,
status_t rv, int lineno);
#define CORE_ASSERT_OK(tc, ctxt, rv) \
core_assert_ok(tc, ctxt, rv, __LINE__)
status_t test_initialize(char *config_path);
abts_suite *test_volte(abts_suite *suite);
#endif /* __TESTUTIL_H__ */

588
test/rx/volte_test.c Normal file
View file

@ -0,0 +1,588 @@
#include "core_debug.h"
#include "core_pkbuf.h"
#include "core_lib.h"
#include <mongoc.h>
#include "app/context.h"
#include "mme/mme_context.h"
#include "s1ap/s1ap_message.h"
#include "testutil.h"
#include "testpacket.h"
static void volte_test1(abts_case *tc, void *data)
{
status_t rv;
sock_id sock;
pkbuf_t *sendbuf;
pkbuf_t *recvbuf;
s1ap_message_t message;
int i;
int msgindex = 0;
mongoc_collection_t *collection = NULL;
bson_t *doc = NULL;
c_int64_t count = 0;
bson_error_t error;
const char *json =
"{"
"\"_id\" : { \"$oid\" : \"599eb929c850caabcbfdcd2b\" },"
"\"imsi\" : \"001010123456819\","
"\"pdn\" : ["
"{ \"apn\" : \"internet\","
"\"_id\" : { \"$oid\" : \"599eb929c850caabcbfdcd32\" },"
"\"qos\" : {"
"\"qci\" : 9,"
"\"arp\" : {"
"\"priority_level\" : 8,"
"\"pre_emption_vulnerability\" : 1,"
"\"pre_emption_capability\" : 1 } },"
"\"type\" : 2 },"
"{ \"apn\" : \"internet.ng2.mnet\","
"\"_id\" : { \"$oid\" : \"599eb929c850caabcbfdcd2c\" },"
"\"pcc_rule\" : ["
"{ \"_id\" : { \"$oid\" : \"599eb929c850caabcbfdcd2d\" },"
"\"qos\" : {"
"\"qci\" : 1,"
"\"gbr\" : {"
"\"downlink\" : { \"$numberLong\" : \"64\" },"
"\"uplink\" : { \"$numberLong\" : \"44\" } },"
"\"mbr\" : {"
"\"downlink\" : { \"$numberLong\" : \"64\" },"
"\"uplink\" : { \"$numberLong\" : \"44\" } },"
"\"arp\" : {"
"\"priority_level\" : 3,"
"\"pre_emption_vulnerability\" : 0,"
"\"pre_emption_capability\" : 0 } },"
"\"flow\" : ["
"{ \"direction\" : 2,"
"\"description\" : \"permit out udp from any 1-65535 to 10.200.136.98/32 23454\","
"\"_id\" : { \"$oid\" : \"599eb929c850caabcbfdcd31\" } },"
"{ \"direction\" : 1,"
"\"description\" : \"permit out udp from any 50020 to 10.200.136.98/32 1-65535\","
"\"_id\" : { \"$oid\" : \"599eb929c850caabcbfdcd30\" } },"
"{ \"direction\" : 2,"
"\"description\" : \"permit out udp from any 1-65535 to 10.200.136.98/32 23455\","
"\"_id\" : { \"$oid\" : \"599eb929c850caabcbfdcd2f\" } },"
"{ \"direction\" : 1,"
"\"description\" : \"permit out udp from any 50021 to 10.200.136.98/32 1-65535\","
"\"_id\" : { \"$oid\" : \"599eb929c850caabcbfdcd2e\" } } ]"
"} ],"
"\"ambr\" : {"
"\"downlink\" : { \"$numberLong\" : \"35840\" },"
"\"uplink\" : { \"$numberLong\" : \"15360\" } },"
"\"qos\" : {"
"\"qci\" : 6,"
"\"arp\" : {"
"\"priority_level\" : 6,"
"\"pre_emption_vulnerability\" : 1,"
"\"pre_emption_capability\" : 1 } },"
"\"type\" : 2 }"
"],"
"\"ambr\" : {"
"\"downlink\" : { \"$numberLong\" : \"1024000\" },"
"\"uplink\" : { \"$numberLong\" : \"1024000\" } },"
"\"subscribed_rau_tau_timer\" : 12,"
"\"network_access_mode\" : 2,"
"\"subscriber_status\" : 0,"
"\"access_restriction_data\" : 32,"
"\"security\" : {"
"\"k\" : \"465B5CE8 B199B49F AA5F0A2E E238A6BC\","
"\"op\" : \"5F1D289C 5D354D0A 140C2548 F5F3E3BA\","
"\"amf\" : \"8000\","
"\"sqn\" : { \"$numberLong\" : \"64\" }, "
"\"rand\" : \"20080C38 18183B52 2614162C 07601D0D\" }, "
"\"__v\" : 0"
"}";
/* eNB connects to MME */
rv = tests1ap_enb_connect(&sock);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
/* Send S1-Setup Reqeust */
rv = tests1ap_build_setup_req(
&sendbuf, S1ap_ENB_ID_PR_macroENB_ID, 0x54f64);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
/* Receive S1-Setup Response */
recvbuf = pkbuf_alloc(0, MAX_SDU_LEN);
rv = tests1ap_enb_read(sock, recvbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = s1ap_decode_pdu(&message, recvbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
s1ap_free_pdu(&message);
pkbuf_free(recvbuf);
collection = mongoc_client_get_collection(
context_self()->db_client,
context_self()->db_name, "subscribers");
ABTS_PTR_NOTNULL(tc, collection);
doc = bson_new_from_json((const uint8_t *)json, -1, &error);;
ABTS_PTR_NOTNULL(tc, doc);
ABTS_TRUE(tc, mongoc_collection_insert(collection,
MONGOC_INSERT_NONE, doc, NULL, &error));
bson_destroy(doc);
doc = BCON_NEW("imsi", BCON_UTF8("001010123456819"));
ABTS_PTR_NOTNULL(tc, doc);
do
{
count = mongoc_collection_count (
collection, MONGOC_QUERY_NONE, doc, 0, 0, NULL, &error);
} while (count == 0);
bson_destroy(doc);
/***********************************************************************
* Attach Request : Known IMSI, Integrity Protected, No Security Context
* Send Initial-UE Message + Attach Request + PDN Connectivity */
rv = tests1ap_build_initial_ue_msg(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
/* Receive Authentication Request */
recvbuf = pkbuf_alloc(0, MAX_SDU_LEN);
rv = tests1ap_enb_read(sock, recvbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
pkbuf_free(recvbuf);
/* Send Authentication Response */
rv = tests1ap_build_authentication_response(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
/* Receive Security mode Command */
recvbuf = pkbuf_alloc(0, MAX_SDU_LEN);
rv = tests1ap_enb_read(sock, recvbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
pkbuf_free(recvbuf);
/* Send Security mode Complete */
rv = tests1ap_build_security_mode_complete(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
/* Receive ESM Information Request */
recvbuf = pkbuf_alloc(0, MAX_SDU_LEN);
rv = tests1ap_enb_read(sock, recvbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
pkbuf_free(recvbuf);
/* Send ESM Information Response */
rv = tests1ap_build_esm_information_response(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
/* Receive Initial Context Setup Request +
* Attach Accept +
* Activate Default Bearer Context Request */
recvbuf = pkbuf_alloc(0, MAX_SDU_LEN);
rv = tests1ap_enb_read(sock, recvbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
pkbuf_free(recvbuf);
/* Send UE Capability Info Indication */
rv = tests1ap_build_ue_capability_info_indication(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
core_sleep(time_from_msec(300));
/* Send Initial Context Setup Response */
rv = tests1ap_build_initial_context_setup_response(&sendbuf,
16777373, 1, 5, 1);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
/* Send Attach Complete + Activate default EPS bearer cotext accept */
rv = tests1ap_build_attach_complete(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
/* Receive EMM information */
recvbuf = pkbuf_alloc(0, MAX_SDU_LEN);
rv = tests1ap_enb_read(sock, recvbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
pkbuf_free(recvbuf);
/* Send PDN Connectivity Request */
rv = tests1ap_build_pdn_connectivity_request(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
core_sleep(time_from_msec(300));
/* Receive E-RAB Setup Request +
* Activate default EPS bearer context request */
recvbuf = pkbuf_alloc(0, MAX_SDU_LEN);
rv = tests1ap_enb_read(sock, recvbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
pkbuf_free(recvbuf);
/* Send E-RAB Setup Response */
rv = tests1ap_build_e_rab_setup_response(&sendbuf, 33554492, 1, 6, 2);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
core_sleep(time_from_msec(300));
/* Send Activate default EPS bearer context accept */
rv = tests1ap_build_activate_default_bearer_accept(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
/* Receive E-RAB Setup Request +
* Activate dedicated EPS bearer context request */
recvbuf = pkbuf_alloc(0, MAX_SDU_LEN);
rv = tests1ap_enb_read(sock, recvbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
pkbuf_free(recvbuf);
/* Send Activate dedicated EPS bearer context accept */
rv = tests1ap_build_activate_dedicated_bearer_accept(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
core_sleep(time_from_msec(300));
/* Send E-RAB Setup Response */
rv = tests1ap_build_e_rab_setup_response(&sendbuf, 33554492, 1, 7, 3);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
core_sleep(time_from_msec(300));
/* Send PDN disconnectivity request */
rv = tests1ap_build_pdn_disconnectivity_request(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
/* Receive E-RAB Release Command +
* Deactivate EPS bearer context request */
recvbuf = pkbuf_alloc(0, MAX_SDU_LEN);
rv = tests1ap_enb_read(sock, recvbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
pkbuf_free(recvbuf);
/* Send E-RAB Release Response */
rv = tests1ap_build_e_rab_release_response(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
/* Deactivate EPS bearer context accept */
rv = tests1ap_build_deactivate_bearer_accept(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
core_sleep(time_from_msec(300));
/* Send INVALID PDN Connectivity Request */
rv = tests1ap_build_pdn_connectivity_request(&sendbuf, msgindex+1);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
/* Receive PDN Connectivity Reject */
recvbuf = pkbuf_alloc(0, MAX_SDU_LEN);
rv = tests1ap_enb_read(sock, recvbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
pkbuf_free(recvbuf);
/********** Remove Subscriber in Database */
doc = BCON_NEW("imsi", BCON_UTF8("001010123456819"));
ABTS_PTR_NOTNULL(tc, doc);
ABTS_TRUE(tc, mongoc_collection_remove(collection,
MONGOC_REMOVE_SINGLE_REMOVE, doc, NULL, &error))
bson_destroy(doc);
mongoc_collection_destroy(collection);
/* eNB disonncect from MME */
rv = tests1ap_enb_close(sock);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
core_sleep(time_from_msec(300));
}
static void volte_test2(abts_case *tc, void *data)
{
status_t rv;
sock_id sock;
pkbuf_t *sendbuf;
pkbuf_t *recvbuf;
s1ap_message_t message;
int i;
int msgindex = 0;
mongoc_collection_t *collection = NULL;
bson_t *doc = NULL;
c_int64_t count = 0;
bson_error_t error;
const char *json =
"{"
"\"_id\" : { \"$oid\" : \"599eb929c850caabcbfdcd2b\" },"
"\"imsi\" : \"001010123456819\","
"\"pdn\" : ["
"{ \"apn\" : \"internet.ng2.mnet\","
"\"_id\" : { \"$oid\" : \"599eb929c850caabcbfdcd32\" },"
"\"qos\" : {"
"\"qci\" : 9,"
"\"arp\" : {"
"\"priority_level\" : 8,"
"\"pre_emption_vulnerability\" : 1,"
"\"pre_emption_capability\" : 1 } },"
"\"type\" : 2 },"
"{ \"apn\" : \"internet\","
"\"_id\" : { \"$oid\" : \"599eb929c850caabcbfdcd2c\" },"
"\"pcc_rule\" : ["
"{ \"_id\" : { \"$oid\" : \"599eb929c850caabcbfdcd2d\" },"
"\"qos\" : {"
"\"qci\" : 1,"
"\"gbr\" : {"
"\"downlink\" : { \"$numberLong\" : \"64\" },"
"\"uplink\" : { \"$numberLong\" : \"44\" } },"
"\"mbr\" : {"
"\"downlink\" : { \"$numberLong\" : \"64\" },"
"\"uplink\" : { \"$numberLong\" : \"44\" } },"
"\"arp\" : {"
"\"priority_level\" : 3,"
"\"pre_emption_vulnerability\" : 0,"
"\"pre_emption_capability\" : 0 } },"
"\"flow\" : ["
"{ \"direction\" : 2,"
"\"description\" : \"permit out udp from any 1-65535 to 10.200.136.98/32 23454\","
"\"_id\" : { \"$oid\" : \"599eb929c850caabcbfdcd31\" } },"
"{ \"direction\" : 1,"
"\"description\" : \"permit out ip from 45.45.0.1 to any\","
"\"_id\" : { \"$oid\" : \"599eb929c850caabcbfdcd30\" } },"
"{ \"direction\" : 2,"
"\"description\" : \"permit out udp from any 1-65535 to 10.200.136.98/24 23455\","
"\"_id\" : { \"$oid\" : \"599eb929c850caabcbfdcd2f\" } },"
"{ \"direction\" : 1,"
"\"description\" : \"permit out ip from cafe::1 to any\","
"\"_id\" : { \"$oid\" : \"599eb929c850caabcbfdcd2e\" } } ]"
"} ],"
"\"ambr\" : {"
"\"downlink\" : { \"$numberLong\" : \"35840\" },"
"\"uplink\" : { \"$numberLong\" : \"15360\" } },"
"\"qos\" : {"
"\"qci\" : 6,"
"\"arp\" : {"
"\"priority_level\" : 6,"
"\"pre_emption_vulnerability\" : 1,"
"\"pre_emption_capability\" : 1 } },"
"\"type\" : 2 }"
"],"
"\"ambr\" : {"
"\"downlink\" : { \"$numberLong\" : \"1024000\" },"
"\"uplink\" : { \"$numberLong\" : \"1024000\" } },"
"\"subscribed_rau_tau_timer\" : 12,"
"\"network_access_mode\" : 2,"
"\"subscriber_status\" : 0,"
"\"access_restriction_data\" : 32,"
"\"security\" : {"
"\"k\" : \"465B5CE8 B199B49F AA5F0A2E E238A6BC\","
"\"op\" : \"5F1D289C 5D354D0A 140C2548 F5F3E3BA\","
"\"amf\" : \"8000\","
"\"sqn\" : { \"$numberLong\" : \"64\" }, "
"\"rand\" : \"20080C38 18183B52 2614162C 07601D0D\" }, "
"\"__v\" : 0"
"}";
/* eNB connects to MME */
rv = tests1ap_enb_connect(&sock);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
/* Send S1-Setup Reqeust */
rv = tests1ap_build_setup_req(
&sendbuf, S1ap_ENB_ID_PR_macroENB_ID, 0x54f64);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
/* Receive S1-Setup Response */
recvbuf = pkbuf_alloc(0, MAX_SDU_LEN);
rv = tests1ap_enb_read(sock, recvbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = s1ap_decode_pdu(&message, recvbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
s1ap_free_pdu(&message);
pkbuf_free(recvbuf);
collection = mongoc_client_get_collection(
context_self()->db_client,
context_self()->db_name, "subscribers");
ABTS_PTR_NOTNULL(tc, collection);
doc = bson_new_from_json((const uint8_t *)json, -1, &error);;
ABTS_PTR_NOTNULL(tc, doc);
ABTS_TRUE(tc, mongoc_collection_insert(collection,
MONGOC_INSERT_NONE, doc, NULL, &error));
bson_destroy(doc);
doc = BCON_NEW("imsi", BCON_UTF8("001010123456819"));
ABTS_PTR_NOTNULL(tc, doc);
do
{
count = mongoc_collection_count (
collection, MONGOC_QUERY_NONE, doc, 0, 0, NULL, &error);
} while (count == 0);
bson_destroy(doc);
/***********************************************************************
* Attach Request : Known IMSI, Integrity Protected, No Security Context
* Send Initial-UE Message + Attach Request + PDN Connectivity */
rv = tests1ap_build_initial_ue_msg(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
/* Receive Authentication Request */
recvbuf = pkbuf_alloc(0, MAX_SDU_LEN);
rv = tests1ap_enb_read(sock, recvbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
pkbuf_free(recvbuf);
/* Send Authentication Response */
rv = tests1ap_build_authentication_response(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
/* Receive Security mode Command */
recvbuf = pkbuf_alloc(0, MAX_SDU_LEN);
rv = tests1ap_enb_read(sock, recvbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
pkbuf_free(recvbuf);
/* Send Security mode Complete */
rv = tests1ap_build_security_mode_complete(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
/* Receive ESM Information Request */
recvbuf = pkbuf_alloc(0, MAX_SDU_LEN);
rv = tests1ap_enb_read(sock, recvbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
pkbuf_free(recvbuf);
/* Send ESM Information Response */
rv = tests1ap_build_esm_information_response(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
/* Receive Initial Context Setup Request +
* Attach Accept +
* Activate Default Bearer Context Request */
recvbuf = pkbuf_alloc(0, MAX_SDU_LEN);
rv = tests1ap_enb_read(sock, recvbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
pkbuf_free(recvbuf);
/* Send UE Capability Info Indication */
rv = tests1ap_build_ue_capability_info_indication(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
core_sleep(time_from_msec(300));
/* Send Initial Context Setup Response */
rv = tests1ap_build_initial_context_setup_response(&sendbuf,
16777373, 1, 5, 1);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
/* Send Attach Complete + Activate default EPS bearer cotext accept */
rv = tests1ap_build_attach_complete(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
/* Receive EMM information */
recvbuf = pkbuf_alloc(0, MAX_SDU_LEN);
rv = tests1ap_enb_read(sock, recvbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
pkbuf_free(recvbuf);
/* Receive E-RAB Setup Request +
* Activate dedicated EPS bearer context request */
recvbuf = pkbuf_alloc(0, MAX_SDU_LEN);
rv = tests1ap_enb_read(sock, recvbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
pkbuf_free(recvbuf);
/* Send E-RAB Setup Response */
rv = tests1ap_build_e_rab_setup_response(&sendbuf, 33554492, 1, 6, 2);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
core_sleep(time_from_msec(300));
/* Send Activate dedicated EPS bearer context accept */
rv = tests1ap_build_activate_dedicated_bearer_accept(&sendbuf, msgindex+1);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
#if 0 /* TFT Rule Tester */
core_sleep(time_from_msec(300));
/* Send GTP-U ICMP Packet */
#if 1
rv = testgtpu_build_ping(&sendbuf, "45.45.0.2", "45.45.0.1");
#else
rv = testgtpu_build_ping(&sendbuf, "cafe::2", "cafe::1");
#endif
rv = testgtpu_enb_send(sendbuf);
core_sleep(time_from_msec(300));
#endif
/********** Remove Subscriber in Database */
doc = BCON_NEW("imsi", BCON_UTF8("001010123456819"));
ABTS_PTR_NOTNULL(tc, doc);
ABTS_TRUE(tc, mongoc_collection_remove(collection,
MONGOC_REMOVE_SINGLE_REMOVE, doc, NULL, &error))
bson_destroy(doc);
mongoc_collection_destroy(collection);
/* eNB disonncect from MME */
rv = tests1ap_enb_close(sock);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
core_sleep(time_from_msec(300));
}
abts_suite *test_volte(abts_suite *suite)
{
suite = ADD_SUITE(suite)
abts_run_test(suite, volte_test1, NULL);
abts_run_test(suite, volte_test2, NULL);
return suite;
}