all attach test is successful
This commit is contained in:
parent
6480689da4
commit
308c6f1e66
|
@ -424,7 +424,6 @@ AC_CONFIG_FILES([lib/core/test/Makefile])
|
|||
AC_CONFIG_FILES([lib/core/Makefile])
|
||||
AC_CONFIG_FILES([lib/s1ap/asn1c/Makefile])
|
||||
AC_CONFIG_FILES([lib/s1ap/Makefile])
|
||||
AC_CONFIG_FILES([lib/s1ap/test/Makefile])
|
||||
AC_CONFIG_FILES([lib/nas/Makefile])
|
||||
AC_CONFIG_FILES([lib/fd/Makefile])
|
||||
AC_CONFIG_FILES([lib/gtp/Makefile])
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
## Process this file with automake to produce Makefile.in.
|
||||
|
||||
bin_PROGRAMS = tests1ap
|
||||
|
||||
tests1ap_SOURCES = \
|
||||
abts.c abts.h abts_tests.h testutil.c testutil.h \
|
||||
s1ap_conv.h s1ap_conv.c s1ap_build.h s1ap_build.c \
|
||||
s1ap_message_test.c
|
||||
|
||||
tests1ap_LDADD = \
|
||||
$(top_srcdir)/lib/s1ap/libs1ap.la
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir)/lib/core/include \
|
||||
-I$(top_srcdir)/lib/s1ap/asn1c \
|
||||
-I$(top_srcdir)/lib/s1ap \
|
||||
$(NULL)
|
||||
|
||||
AM_CFLAGS = \
|
||||
-Wall -Werror @OSCPPFLAGS@ \
|
||||
-Wno-unused-function -Wno-unused-variable
|
||||
|
||||
TESTS = tests1ap
|
||||
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
CLEANFILES = -R data
|
||||
MOSTLYCLEANFILES = core *.stackdump
|
|
@ -1,479 +0,0 @@
|
|||
/* 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_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;
|
||||
|
||||
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;
|
||||
|
||||
test_initialize();
|
||||
|
||||
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 (argv[i][0] == '-') {
|
||||
fprintf(stderr, "Invalid option: `%s'\n", argv[i]);
|
||||
exit(1);
|
||||
}
|
||||
list_provided = 1;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
@ -1,112 +0,0 @@
|
|||
/* 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
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
/* 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_s1ap_message},
|
||||
};
|
||||
|
||||
#endif /* APR_TEST_INCLUDES */
|
File diff suppressed because it is too large
Load Diff
|
@ -1,68 +0,0 @@
|
|||
#ifndef __S1AP_BUILD_H__
|
||||
#define __S1AP_BUILD_H__
|
||||
|
||||
#if 0
|
||||
#include "s1ap/s1ap_message.h"
|
||||
#else
|
||||
#include "s1ap_message.h"
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#include "mme_context.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
CORE_DECLARE(status_t) s1ap_build_setup_rsp(pkbuf_t **pkbuf);
|
||||
CORE_DECLARE(status_t) s1ap_build_setup_failure(
|
||||
pkbuf_t **pkbuf, S1AP_Cause_PR group, long cause, long time_to_wait);
|
||||
|
||||
CORE_DECLARE(status_t) s1ap_build_downlink_nas_transport(
|
||||
pkbuf_t **s1apbuf, enb_ue_t *enb_ue, pkbuf_t *emmbuf);
|
||||
#if 0
|
||||
CORE_DECLARE(status_t) s1ap_build_initial_context_setup_request(
|
||||
pkbuf_t **s1apbuf, mme_ue_t *mme_ue, pkbuf_t *emmbuf);
|
||||
CORE_DECLARE(status_t) s1ap_build_e_rab_setup_request(
|
||||
pkbuf_t **s1apbuf, mme_bearer_t *bearer, pkbuf_t *esmbuf);
|
||||
CORE_DECLARE(status_t) s1ap_build_e_rab_modify_request(
|
||||
pkbuf_t **s1apbuf, mme_bearer_t *bearer, pkbuf_t *esmbuf);
|
||||
CORE_DECLARE(status_t) s1ap_build_e_rab_release_command(pkbuf_t **s1apbuf,
|
||||
mme_bearer_t *bearer, pkbuf_t *esmbuf, S1ap_Cause_PR group, long cause);
|
||||
CORE_DECLARE(status_t) s1ap_build_ue_context_release_command(
|
||||
pkbuf_t **s1apbuf, enb_ue_t *enb_ue, S1ap_Cause_PR group, long cause);
|
||||
CORE_DECLARE(status_t) s1ap_build_paging(pkbuf_t **s1apbuf, mme_ue_t *mme_ue);
|
||||
|
||||
CORE_DECLARE(status_t) s1ap_build_path_switch_ack(
|
||||
pkbuf_t **s1apbuf, mme_ue_t *mme_ue);
|
||||
CORE_DECLARE(status_t) s1ap_build_path_switch_failure(pkbuf_t **s1apbuf,
|
||||
c_uint32_t enb_ue_s1ap_id, c_uint32_t mme_ue_s1ap_id,
|
||||
S1ap_Cause_PR group, long cause);
|
||||
|
||||
CORE_DECLARE(status_t) s1ap_build_handover_command(
|
||||
pkbuf_t **s1apbuf, enb_ue_t *source_ue);
|
||||
CORE_DECLARE(status_t) s1ap_build_handover_preparation_failure(
|
||||
pkbuf_t **s1apbuf, enb_ue_t *source_ue, S1ap_Cause_t *cause);
|
||||
|
||||
CORE_DECLARE(status_t) s1ap_build_handover_request(
|
||||
pkbuf_t **s1apbuf, mme_ue_t *mme_ue, enb_ue_t *target_ue,
|
||||
S1ap_HandoverRequiredIEs_t *required);
|
||||
|
||||
CORE_DECLARE(status_t) s1ap_build_handover_cancel_ack(
|
||||
pkbuf_t **s1apbuf, enb_ue_t *source_ue);
|
||||
|
||||
CORE_DECLARE(status_t) s1ap_build_mme_status_transfer(pkbuf_t **s1apbuf,
|
||||
enb_ue_t *target_ue, S1ap_ENBStatusTransferIEs_t *enb_ies);
|
||||
|
||||
CORE_DECLARE(status_t) s1ap_build_error_indication(
|
||||
pkbuf_t **s1apbuf, c_uint16_t presenceMask,
|
||||
c_uint32_t enb_ue_s1ap_id, c_uint32_t mme_ue_s1ap_id,
|
||||
S1ap_Cause_PR group, long cause);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __S1AP_BUILD_H__ */
|
|
@ -1,201 +0,0 @@
|
|||
#define TRACE_MODULE _s1ap_conv
|
||||
|
||||
#include "core_debug.h"
|
||||
#include "core_network.h"
|
||||
|
||||
#include "3gpp_types.h"
|
||||
#include "s1ap_conv.h"
|
||||
|
||||
void s1ap_uint8_to_OCTET_STRING(c_uint8_t uint8, OCTET_STRING_t *octet_string)
|
||||
{
|
||||
octet_string->size = 1;
|
||||
octet_string->buf = core_calloc(octet_string->size, sizeof(c_uint8_t));
|
||||
|
||||
octet_string->buf[0] = uint8;
|
||||
}
|
||||
|
||||
void s1ap_uint16_to_OCTET_STRING(c_uint16_t uint16, OCTET_STRING_t *octet_string)
|
||||
{
|
||||
octet_string->size = 2;
|
||||
octet_string->buf = core_calloc(octet_string->size, sizeof(c_uint8_t));
|
||||
|
||||
octet_string->buf[0] = uint16 >> 8;
|
||||
octet_string->buf[1] = uint16;
|
||||
}
|
||||
|
||||
void s1ap_uint32_to_OCTET_STRING(c_uint32_t uint32, OCTET_STRING_t *octet_string)
|
||||
{
|
||||
octet_string->size = 4;
|
||||
octet_string->buf = core_calloc(octet_string->size, sizeof(c_uint8_t));
|
||||
|
||||
octet_string->buf[0] = uint32 >> 24;
|
||||
octet_string->buf[1] = uint32 >> 16;
|
||||
octet_string->buf[2] = uint32 >> 8;
|
||||
octet_string->buf[3] = uint32;
|
||||
}
|
||||
|
||||
void s1ap_buffer_to_OCTET_STRING(
|
||||
void *buf, int size, S1AP_TBCD_STRING_t *tbcd_string)
|
||||
{
|
||||
tbcd_string->size = size;
|
||||
tbcd_string->buf = core_calloc(tbcd_string->size, sizeof(c_uint8_t));
|
||||
|
||||
memcpy(tbcd_string->buf, buf, size);
|
||||
}
|
||||
|
||||
void s1ap_uint32_to_ENB_ID(
|
||||
S1AP_ENB_ID_PR present, c_uint32_t enb_id, S1AP_ENB_ID_t *eNB_ID)
|
||||
{
|
||||
d_assert(eNB_ID, return, "Null param");
|
||||
|
||||
eNB_ID->present = present;
|
||||
if (present == S1AP_ENB_ID_PR_macroENB_ID)
|
||||
{
|
||||
BIT_STRING_t *bit_string = &eNB_ID->choice.macroENB_ID;
|
||||
d_assert(bit_string, return, "Null param");
|
||||
|
||||
bit_string->size = 3;
|
||||
bit_string->buf = core_calloc(bit_string->size, sizeof(c_uint8_t));
|
||||
|
||||
bit_string->buf[0] = enb_id >> 12;
|
||||
bit_string->buf[1] = enb_id >> 4;
|
||||
bit_string->buf[2] = (enb_id & 0xf) << 4;
|
||||
|
||||
bit_string->bits_unused = 4;
|
||||
}
|
||||
else if (present == S1AP_ENB_ID_PR_homeENB_ID)
|
||||
{
|
||||
BIT_STRING_t *bit_string = &eNB_ID->choice.homeENB_ID;
|
||||
d_assert(bit_string, return, "Null param");
|
||||
|
||||
bit_string->size = 4;
|
||||
bit_string->buf = core_calloc(bit_string->size, sizeof(c_uint8_t));
|
||||
|
||||
bit_string->buf[0] = enb_id >> 20;
|
||||
bit_string->buf[1] = enb_id >> 12;
|
||||
bit_string->buf[2] = enb_id >> 4;
|
||||
bit_string->buf[3] = (enb_id & 0xf) << 4;
|
||||
|
||||
bit_string->bits_unused = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
d_assert(0, return, "Invalid param");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void s1ap_ENB_ID_to_uint32(S1AP_ENB_ID_t *eNB_ID, c_uint32_t *uint32)
|
||||
{
|
||||
d_assert(uint32, return, "Null param");
|
||||
d_assert(eNB_ID, return, "Null param");
|
||||
|
||||
if (eNB_ID->present == S1AP_ENB_ID_PR_homeENB_ID)
|
||||
{
|
||||
c_uint8_t *buf = eNB_ID->choice.homeENB_ID.buf;
|
||||
d_assert(buf, return, "Null param");
|
||||
*uint32 = (buf[0] << 20) + (buf[1] << 12) + (buf[2] << 4) +
|
||||
((buf[3] & 0xf0) >> 4);
|
||||
|
||||
}
|
||||
else if (eNB_ID->present == S1AP_ENB_ID_PR_macroENB_ID)
|
||||
{
|
||||
c_uint8_t *buf = eNB_ID->choice.macroENB_ID.buf;
|
||||
d_assert(buf, return, "Null param");
|
||||
*uint32 = (buf[0] << 12) + (buf[1] << 4) + ((buf[2] & 0xf0) >> 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
d_assert(0, return, "Invalid param");
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
status_t s1ap_BIT_STRING_to_ip(BIT_STRING_t *bit_string, ip_t *ip)
|
||||
{
|
||||
char buf[CORE_ADDRSTRLEN], buf2[CORE_ADDRSTRLEN];
|
||||
|
||||
d_assert(bit_string, return CORE_ERROR,);
|
||||
d_assert(ip, return CORE_ERROR,);
|
||||
|
||||
if (bit_string->size == IPV4V6_LEN)
|
||||
{
|
||||
ip->ipv4 = 1;
|
||||
ip->ipv6 = 1;
|
||||
memcpy(&ip->both.addr, bit_string->buf, IPV4_LEN);
|
||||
memcpy(&ip->both.addr6, bit_string->buf+IPV4_LEN, IPV6_LEN);
|
||||
d_trace(5, " IPv4[%s] IPv6[%s]\n",
|
||||
INET_NTOP(&ip->both.addr, buf), INET6_NTOP(&ip->both.addr6, buf2));
|
||||
}
|
||||
else if (bit_string->size == IPV4_LEN)
|
||||
{
|
||||
ip->ipv4 = 1;
|
||||
memcpy(&ip->addr, bit_string->buf, IPV4_LEN);
|
||||
d_trace(5, " IPv4[%s]\n", INET_NTOP(&ip->addr, buf));
|
||||
}
|
||||
else if (bit_string->size == IPV6_LEN)
|
||||
{
|
||||
ip->ipv6 = 1;
|
||||
memcpy(&ip->addr6, bit_string->buf, IPV6_LEN);
|
||||
d_trace(5, " IPv6[%s]\n", INET_NTOP(&ip->addr6, buf));
|
||||
}
|
||||
else
|
||||
d_assert(0, return CORE_ERROR, "Invalid Length(%d)", bit_string->size);
|
||||
|
||||
ip->len = bit_string->size;
|
||||
|
||||
return CORE_OK;
|
||||
}
|
||||
status_t s1ap_ip_to_BIT_STRING(ip_t *ip, BIT_STRING_t *bit_string)
|
||||
{
|
||||
char buf[CORE_ADDRSTRLEN], buf2[CORE_ADDRSTRLEN];
|
||||
|
||||
d_assert(ip, return CORE_ERROR,);
|
||||
d_assert(bit_string, return CORE_ERROR,);
|
||||
|
||||
if (ip->ipv4 && ip->ipv6)
|
||||
{
|
||||
bit_string->size = IPV4V6_LEN;
|
||||
bit_string->buf = core_calloc(bit_string->size, sizeof(c_uint8_t));
|
||||
memcpy(bit_string->buf, &ip->both.addr, IPV4_LEN);
|
||||
memcpy(bit_string->buf+IPV4_LEN, &ip->both.addr6, IPV6_LEN);
|
||||
d_trace(5, " IPv4[%s] IPv6[%s]\n",
|
||||
INET_NTOP(&ip->both.addr, buf), INET6_NTOP(&ip->both.addr6, buf2));
|
||||
}
|
||||
else if (ip->ipv4)
|
||||
{
|
||||
bit_string->size = IPV4_LEN;
|
||||
bit_string->buf = core_calloc(bit_string->size, sizeof(c_uint8_t));
|
||||
memcpy(bit_string->buf, &ip->addr, IPV4_LEN);
|
||||
d_trace(5, " IPv4[%s]\n", INET_NTOP(&ip->addr, buf));
|
||||
}
|
||||
else if (ip->ipv6)
|
||||
{
|
||||
bit_string->size = IPV6_LEN;
|
||||
bit_string->buf = core_calloc(bit_string->size, sizeof(c_uint8_t));
|
||||
memcpy(bit_string->buf, &ip->addr6, IPV6_LEN);
|
||||
d_trace(5, " IPv6[%s]\n", INET_NTOP(&ip->addr6, buf));
|
||||
}
|
||||
else
|
||||
d_assert(0, return CORE_ERROR,);
|
||||
|
||||
return CORE_OK;
|
||||
}
|
||||
|
||||
S1ap_IE_t *s1ap_copy_ie(S1ap_IE_t *ie)
|
||||
{
|
||||
S1ap_IE_t *buff;
|
||||
|
||||
buff = core_malloc(sizeof (S1ap_IE_t));
|
||||
d_assert(buff, return NULL,);
|
||||
|
||||
memset((void *)buff, 0, sizeof(S1ap_IE_t));
|
||||
buff->id = ie->id;
|
||||
buff->criticality = ie->criticality;
|
||||
buff->value.size = ie->value.size;
|
||||
buff->value.buf = core_calloc(1, buff->value.size);
|
||||
memcpy(buff->value.buf, ie->value.buf, buff->value.size);
|
||||
|
||||
return buff;
|
||||
}
|
||||
#endif
|
|
@ -1,38 +0,0 @@
|
|||
#ifndef __S1AP_CONV_H__
|
||||
#define __S1AP_CONV_H__
|
||||
|
||||
#include "s1ap_message.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
CORE_DECLARE(void) s1ap_uint8_to_OCTET_STRING(
|
||||
c_uint8_t uint8, OCTET_STRING_t *octet_string);
|
||||
CORE_DECLARE(void) s1ap_uint16_to_OCTET_STRING(
|
||||
c_uint16_t uint16, OCTET_STRING_t *octet_string);
|
||||
CORE_DECLARE(void) s1ap_uint32_to_OCTET_STRING(
|
||||
c_uint32_t uint32, OCTET_STRING_t *octet_string);
|
||||
|
||||
CORE_DECLARE(void) s1ap_buffer_to_OCTET_STRING(
|
||||
void *buf, int size, S1AP_TBCD_STRING_t *tbcd_string);
|
||||
|
||||
CORE_DECLARE(void) s1ap_uint32_to_ENB_ID(
|
||||
S1AP_ENB_ID_PR present, c_uint32_t enb_id, S1AP_ENB_ID_t *eNB_ID);
|
||||
CORE_DECLARE(void) s1ap_ENB_ID_to_uint32(
|
||||
S1AP_ENB_ID_t *eNB_ID, c_uint32_t *uint32);
|
||||
|
||||
#if 0
|
||||
CORE_DECLARE(status_t) s1ap_BIT_STRING_to_ip(
|
||||
BIT_STRING_t *bit_string, ip_t *ip);
|
||||
CORE_DECLARE(status_t) s1ap_ip_to_BIT_STRING(
|
||||
ip_t *ip, BIT_STRING_t *bit_string);
|
||||
|
||||
CORE_DECLARE(S1ap_IE_t *) s1ap_copy_ie(S1ap_IE_t *ie);
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __S1AP_CONV_H__ */
|
||||
|
|
@ -1,362 +0,0 @@
|
|||
#define TRACE_MODULE __test__test
|
||||
|
||||
#include "core_debug.h"
|
||||
#include "core_pkbuf.h"
|
||||
#include "core_lib.h"
|
||||
|
||||
#include "3gpp_types.h"
|
||||
|
||||
#include "s1ap_message.h"
|
||||
#include "s1ap_build.h"
|
||||
#include "s1ap_conv.h"
|
||||
|
||||
#include "testutil.h"
|
||||
#if 0
|
||||
#include "testpacket.h"
|
||||
#endif
|
||||
|
||||
static void s1ap_message_test1(abts_case *tc, void *data)
|
||||
{
|
||||
/* S1Reset */
|
||||
char *payload =
|
||||
"000e"
|
||||
"0025000002000240 020000005c001840 02005b0004606400 04005b0004606300"
|
||||
"03005b0002402c";
|
||||
|
||||
pkbuf_t *pkbuf;
|
||||
s1ap_message_t message;
|
||||
int result;
|
||||
char hexbuf[MAX_SDU_LEN];
|
||||
|
||||
pkbuf = pkbuf_alloc(0, MAX_SDU_LEN);
|
||||
ABTS_PTR_NOTNULL(tc, pkbuf);
|
||||
pkbuf->len = 41;
|
||||
memcpy(pkbuf->payload,
|
||||
CORE_HEX(payload, strlen(payload), hexbuf), pkbuf->len);
|
||||
|
||||
result = s1ap_decode_pdu(&message, pkbuf);
|
||||
ABTS_INT_EQUAL(tc, 0, result);
|
||||
#if 0
|
||||
asn_fprint(stdout, &asn_DEF_S1AP_S1AP_PDU, &message);
|
||||
#endif
|
||||
s1ap_free_pdu(&message);
|
||||
|
||||
pkbuf_free(pkbuf);
|
||||
}
|
||||
|
||||
static void s1ap_message_test2(abts_case *tc, void *data)
|
||||
{
|
||||
/* InitialUE(Attach Request) */
|
||||
char *payload =
|
||||
"000c406f000006000800020001001a00"
|
||||
"3c3b17df675aa8050741020bf600f110"
|
||||
"000201030003e605f070000010000502"
|
||||
"15d011d15200f11030395c0a003103e5"
|
||||
"e0349011035758a65d0100e0c1004300"
|
||||
"060000f1103039006440080000f1108c"
|
||||
"3378200086400130004b00070000f110"
|
||||
"000201";
|
||||
|
||||
s1ap_message_t message;
|
||||
pkbuf_t *pkbuf;
|
||||
int result;
|
||||
char hexbuf[MAX_SDU_LEN];
|
||||
|
||||
pkbuf = pkbuf_alloc(0, MAX_SDU_LEN);
|
||||
ABTS_PTR_NOTNULL(tc, pkbuf);
|
||||
pkbuf->len = 115;
|
||||
memcpy(pkbuf->payload,
|
||||
CORE_HEX(payload, strlen(payload), hexbuf), pkbuf->len);
|
||||
|
||||
result = s1ap_decode_pdu(&message, pkbuf);
|
||||
ABTS_INT_EQUAL(tc, 0, result);
|
||||
#if 0
|
||||
asn_fprint(stdout, &asn_DEF_S1AP_S1AP_PDU, &message);
|
||||
#endif
|
||||
s1ap_free_pdu(&message);
|
||||
|
||||
pkbuf_free(pkbuf);
|
||||
}
|
||||
|
||||
static void s1ap_message_test3(abts_case *tc, void *data)
|
||||
{
|
||||
/* initial context setup response */
|
||||
char *payload =
|
||||
"2009002500000300004005c0020000bf"
|
||||
"0008400200010033400f000032400a0a"
|
||||
"1f0a0123c601000908";
|
||||
|
||||
s1ap_message_t message;
|
||||
pkbuf_t *pkbuf;
|
||||
int result;
|
||||
char hexbuf[MAX_SDU_LEN];
|
||||
|
||||
pkbuf = pkbuf_alloc(0, MAX_SDU_LEN);
|
||||
ABTS_PTR_NOTNULL(tc, pkbuf);
|
||||
pkbuf->len = 41;
|
||||
memcpy(pkbuf->payload,
|
||||
CORE_HEX(payload, strlen(payload), hexbuf), pkbuf->len);
|
||||
|
||||
result = s1ap_decode_pdu(&message, pkbuf);
|
||||
ABTS_INT_EQUAL(tc, 0, result);
|
||||
#if 0
|
||||
asn_fprint(stdout, &asn_DEF_S1AP_S1AP_PDU, &message);
|
||||
#endif
|
||||
s1ap_free_pdu(&message);
|
||||
|
||||
pkbuf_free(pkbuf);
|
||||
}
|
||||
|
||||
#if 0
|
||||
status_t s1ap_build_setup_failure(
|
||||
pkbuf_t **pkbuf, S1AP_Cause_PR group, long cause, long time_to_wait)
|
||||
{
|
||||
int erval;
|
||||
|
||||
s1ap_message_t message;
|
||||
struct S1AP_UnsuccessfulOutcome *unsuccessfulOutcome = NULL;
|
||||
S1AP_S1SetupFailure_t *s1SetupFailure = NULL;
|
||||
S1AP_S1SetupFailureIEs_t *ies = NULL;
|
||||
|
||||
memset(&message, 0, sizeof(s1ap_message_t));
|
||||
|
||||
unsuccessfulOutcome = message.choice.unsuccessfulOutcome;
|
||||
s1SetupFailure = &unsuccessfulOutcome->value.choice.S1SetupFailure;
|
||||
|
||||
memset(&message, 0, sizeof(s1ap_message_t));
|
||||
|
||||
ies = core_calloc(1, sizeof(S1AP_S1SetupFailureIEs_t));
|
||||
ies->value.choice.Cause.present = group;
|
||||
ies->value.choice.Cause.choice.radioNetwork = cause;
|
||||
d_trace(5, " Gruop[%d] Cause[%d] TimeToWait[%ld]\n",
|
||||
group, cause, time_to_wait);
|
||||
|
||||
#if 0
|
||||
if (time_to_wait > -1)
|
||||
{
|
||||
ies->presenceMask |= S1AP_S1SETUPFAILUREIES_TIMETOWAIT_PRESENT;
|
||||
ies->timeToWait = time_to_wait;
|
||||
}
|
||||
#endif
|
||||
printf("__LINE__ = %d\n", __LINE__);
|
||||
ASN_SEQUENCE_ADD(&s1SetupFailure, ies);
|
||||
|
||||
printf("__LINE__ = %d\n", __LINE__);
|
||||
message.choice.unsuccessfulOutcome->procedureCode =
|
||||
S1AP_ProcedureCode_S1AP_id_S1Setup;
|
||||
|
||||
printf("__LINE__ = %d\n", __LINE__);
|
||||
erval = s1ap_encode_pdu(pkbuf, &message);
|
||||
printf("__LINE__ = %d\n", __LINE__);
|
||||
s1ap_free_pdu(&message);
|
||||
printf("__LINE__ = %d\n", __LINE__);
|
||||
|
||||
if (erval < 0)
|
||||
{
|
||||
d_error("s1ap_encode_error : (%d)", erval);
|
||||
return CORE_ERROR;
|
||||
}
|
||||
|
||||
return CORE_OK;
|
||||
}
|
||||
|
||||
#define MAX_PLMN_ID 6
|
||||
#define GRP_PER_MME 256 /* According to spec it is 65535 */
|
||||
#define CODE_PER_MME 256 /* According to spec it is 256 */
|
||||
typedef struct _served_gummei {
|
||||
c_uint32_t num_of_plmn_id;
|
||||
plmn_id_t plmn_id[MAX_PLMN_ID];
|
||||
|
||||
c_uint32_t num_of_mme_gid;
|
||||
c_uint16_t mme_gid[GRP_PER_MME];
|
||||
c_uint32_t num_of_mme_code;
|
||||
c_uint8_t mme_code[CODE_PER_MME];
|
||||
} served_gummei_t;
|
||||
|
||||
status_t s1ap_build_setup_rsp(pkbuf_t **pkbuf)
|
||||
{
|
||||
int erval;
|
||||
int i, j;
|
||||
|
||||
s1ap_message_t message;
|
||||
struct S1AP_SuccessfulOutcome *successfulOutcome = NULL;
|
||||
S1AP_S1SetupResponse_t *s1setupResponse = NULL;
|
||||
S1AP_S1SetupResponseIEs_t *ies = NULL;
|
||||
S1AP_ServedGUMMEIsItem_t *servedGUMMEI;
|
||||
S1AP_PLMNidentity_t *plmnIdentity;
|
||||
S1AP_MME_Group_ID_t *mmeGroupId;
|
||||
S1AP_MME_Code_t *mmeCode;
|
||||
|
||||
memset(&message, 0, sizeof(s1ap_message_t));
|
||||
|
||||
successfulOutcome = message.choice.successfulOutcome;
|
||||
s1setupResponse = &successfulOutcome->value.choice.S1SetupResponse;
|
||||
|
||||
for (i = 0; i < 1; i++)
|
||||
{
|
||||
servedGUMMEI = (S1AP_ServedGUMMEIsItem_t *)
|
||||
core_calloc(1, sizeof(S1AP_ServedGUMMEIsItem_t));
|
||||
|
||||
served_gummei_t *served_gummei = NULL, s;
|
||||
served_gummei = &s;
|
||||
memset(served_gummei, 0, sizeof(served_gummei_t));
|
||||
served_gummei->num_of_plmn_id = 1;
|
||||
plmn_id_build(&served_gummei->plmn_id[0], 1, 1, 2);
|
||||
served_gummei->num_of_mme_gid = 1;
|
||||
served_gummei->mme_gid[0] = 2;
|
||||
served_gummei->num_of_mme_code = 1;
|
||||
served_gummei->mme_code[0] = 1;
|
||||
|
||||
for (j = 0; j < served_gummei->num_of_plmn_id; j++)
|
||||
{
|
||||
plmnIdentity = (S1AP_PLMNidentity_t *)
|
||||
core_calloc(1, sizeof(S1AP_PLMNidentity_t));
|
||||
s1ap_buffer_to_OCTET_STRING(
|
||||
&served_gummei->plmn_id[j], PLMN_ID_LEN, plmnIdentity);
|
||||
ASN_SEQUENCE_ADD(&servedGUMMEI->servedPLMNs, plmnIdentity);
|
||||
d_trace(5, " PLMN_ID[MCC:%d MNC:%d]\n",
|
||||
plmn_id_mcc(&served_gummei->plmn_id[j]),
|
||||
plmn_id_mnc(&served_gummei->plmn_id[j]));
|
||||
}
|
||||
|
||||
for (j = 0; j < served_gummei->num_of_mme_gid; j++)
|
||||
{
|
||||
mmeGroupId = (S1AP_MME_Group_ID_t *)
|
||||
core_calloc(1, sizeof(S1AP_MME_Group_ID_t));
|
||||
s1ap_uint16_to_OCTET_STRING(
|
||||
served_gummei->mme_gid[j], mmeGroupId);
|
||||
ASN_SEQUENCE_ADD(&servedGUMMEI->servedGroupIDs, mmeGroupId);
|
||||
d_trace(5, " MME Group[%d]\n", served_gummei->mme_gid[j]);
|
||||
}
|
||||
|
||||
for (j = 0; j < served_gummei->num_of_mme_code; j++)
|
||||
{
|
||||
mmeCode = (S1AP_MME_Code_t *)
|
||||
core_calloc(1, sizeof(S1AP_MME_Code_t));
|
||||
s1ap_uint8_to_OCTET_STRING(
|
||||
served_gummei->mme_code[j], mmeCode);
|
||||
ASN_SEQUENCE_ADD(&servedGUMMEI->servedMMECs, mmeCode);
|
||||
d_trace(5, " MME Code[%d]\n", served_gummei->mme_code[j]);
|
||||
}
|
||||
ASN_SEQUENCE_ADD(&s1setupResponse->protocolIEs.list, servedGUMMEI);
|
||||
}
|
||||
|
||||
ies->relativeMMECapacity = 44;
|
||||
|
||||
message.procedureCode = S1ap_ProcedureCode_id_S1Setup;
|
||||
message.direction = S1AP_PDU_PR_successfulOutcome;
|
||||
|
||||
erval = s1ap_encode_pdu(pkbuf, &message);
|
||||
s1ap_free_pdu(&message);
|
||||
|
||||
if (erval < 0)
|
||||
{
|
||||
d_error("s1ap_encode_error : (%d)", erval);
|
||||
return CORE_ERROR;
|
||||
}
|
||||
|
||||
return CORE_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void s1ap_message_test4(abts_case *tc, void *data)
|
||||
{
|
||||
s1ap_message_t message;
|
||||
status_t rv;
|
||||
pkbuf_t *pkbuf;
|
||||
int result;
|
||||
|
||||
rv = s1ap_build_setup_failure(&pkbuf, 2, 0, 0);
|
||||
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
ABTS_PTR_NOTNULL(tc, pkbuf);
|
||||
ABTS_PTR_NOTNULL(tc, pkbuf->payload);
|
||||
#if 0
|
||||
ABTS_INT_EQUAL(tc, 27, pkbuf->len);
|
||||
#endif
|
||||
|
||||
result = s1ap_decode_pdu(&message, pkbuf);
|
||||
ABTS_INT_EQUAL(tc, 0, result);
|
||||
#if 1
|
||||
asn_fprint(stdout, &asn_DEF_S1AP_S1AP_PDU, &message);
|
||||
#endif
|
||||
|
||||
s1ap_free_pdu(&message);
|
||||
pkbuf_free(pkbuf);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void s1ap_message_test5(abts_case *tc, void *data)
|
||||
{
|
||||
s1ap_message_t message;
|
||||
status_t rv;
|
||||
pkbuf_t *pkbuf;
|
||||
int result;
|
||||
|
||||
rv = tests1ap_build_setup_req(&pkbuf, S1ap_ENB_ID_PR_macroENB_ID, 0x54f64);
|
||||
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
ABTS_PTR_NOTNULL(tc, pkbuf);
|
||||
ABTS_PTR_NOTNULL(tc, pkbuf->payload);
|
||||
ABTS_INT_EQUAL(tc, 35, pkbuf->len);
|
||||
|
||||
result = s1ap_decode_pdu(&message, pkbuf);
|
||||
ABTS_INT_EQUAL(tc, 0, result);
|
||||
|
||||
s1ap_free_pdu(&message);
|
||||
pkbuf_free(pkbuf);
|
||||
}
|
||||
|
||||
static void s1ap_message_test6(abts_case *tc, void *data)
|
||||
{
|
||||
pkbuf_t *s1apbuf = NULL;
|
||||
int i;
|
||||
s1ap_message_t message;
|
||||
S1ap_DownlinkNASTransport_IEs_t *ies =
|
||||
&message.s1ap_DownlinkNASTransport_IEs;
|
||||
S1ap_NAS_PDU_t *nasPdu = &ies->nas_pdu;
|
||||
char buffer[1024];
|
||||
char *_result =
|
||||
"000b4080 8c000003 00000002 00010008 00020001 001a0079 78efefef efefefef"
|
||||
"efefefef efefefef efefefef efefefef efefefef efefefef efefefef efefefef"
|
||||
"efefefef efefefef efefefef efefefef efefefef efefefef efefefef efefefef"
|
||||
"efefefef efefefef efefefef efefefef efefefef efefefef efefefef efefefef"
|
||||
"efefefef efefefef efefefef efefefef ef";
|
||||
|
||||
memset(&message, 0, sizeof(s1ap_message_t));
|
||||
|
||||
ies->mme_ue_s1ap_id = 1;
|
||||
ies->eNB_UE_S1AP_ID = 1;
|
||||
|
||||
nasPdu->size = 120;
|
||||
nasPdu->buf = core_calloc(nasPdu->size, sizeof(c_uint8_t));
|
||||
for (i = 0; i < nasPdu->size; i++)
|
||||
nasPdu->buf[i] = 0xef;
|
||||
|
||||
message.procedureCode = S1ap_ProcedureCode_id_downlinkNASTransport;
|
||||
message.direction = S1AP_PDU_PR_initiatingMessage;
|
||||
|
||||
s1ap_encode_pdu(&s1apbuf, &message);
|
||||
s1ap_free_pdu(&message);
|
||||
ABTS_TRUE(tc, memcmp(CORE_HEX(_result, strlen(_result), buffer),
|
||||
s1apbuf->payload, s1apbuf->len) == 0);
|
||||
|
||||
pkbuf_free(s1apbuf);
|
||||
}
|
||||
#endif
|
||||
|
||||
abts_suite *test_s1ap_message(abts_suite *suite)
|
||||
{
|
||||
suite = ADD_SUITE(suite)
|
||||
|
||||
abts_run_test(suite, s1ap_message_test1, NULL);
|
||||
abts_run_test(suite, s1ap_message_test2, NULL);
|
||||
abts_run_test(suite, s1ap_message_test3, NULL);
|
||||
abts_run_test(suite, s1ap_message_test4, NULL);
|
||||
#if 0
|
||||
abts_run_test(suite, s1ap_message_test5, NULL);
|
||||
abts_run_test(suite, s1ap_message_test6, NULL);
|
||||
#endif
|
||||
|
||||
return suite;
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
/* 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.h"
|
||||
#include "abts.h"
|
||||
#include "testutil.h"
|
||||
|
||||
void core_assert_ok(abts_case* tc, const char* context, status_t rv,
|
||||
int lineno)
|
||||
{
|
||||
if (rv == CORE_ENOTIMPL)
|
||||
{
|
||||
abts_not_impl(tc, context, lineno);
|
||||
} else if (rv != CORE_OK)
|
||||
{
|
||||
char buf[STRING_MAX], ebuf[128];
|
||||
sprintf(buf, "%s (%d): %s\n", context, rv,
|
||||
core_strerror(rv, ebuf, sizeof ebuf));
|
||||
abts_fail(tc, buf, lineno);
|
||||
}
|
||||
}
|
||||
|
||||
void test_initialize(void)
|
||||
{
|
||||
core_initialize();
|
||||
atexit(core_terminate);
|
||||
}
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
/* 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 __APR_TEST_UTIL__
|
||||
#define __APR_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__)
|
||||
|
||||
void test_initialize(void);
|
||||
|
||||
abts_suite *test_s1ap_message(abts_suite *suite);
|
||||
|
||||
#endif /* CORE_TEST_INCLUDES */
|
|
@ -423,7 +423,7 @@ void emm_state_authentication(fsm_t *s, event_t *e)
|
|||
switch(authentication_failure->emm_cause)
|
||||
{
|
||||
case EMM_CAUSE_MAC_FAILURE:
|
||||
d_error("Authentication failure(MAC failure)");
|
||||
d_warn("Authentication failure(MAC failure)");
|
||||
break;
|
||||
case EMM_CAUSE_NON_EPS_AUTHENTICATION_UNACCEPTABLE:
|
||||
d_error("Authentication failure"
|
||||
|
|
|
@ -250,10 +250,10 @@ status_t s1ap_build_downlink_nas_transport(
|
|||
NAS_PDU->size = emmbuf->len;
|
||||
NAS_PDU->buf = core_calloc(NAS_PDU->size, sizeof(c_uint8_t));
|
||||
memcpy(NAS_PDU->buf, emmbuf->payload, NAS_PDU->size);
|
||||
pkbuf_free(emmbuf);
|
||||
|
||||
rv = s1ap_encode_pdu(s1apbuf, &pdu);
|
||||
s1ap_free_pdu(&pdu);
|
||||
pkbuf_free(emmbuf);
|
||||
|
||||
if (rv != CORE_OK)
|
||||
{
|
||||
|
@ -457,6 +457,7 @@ status_t s1ap_build_initial_context_setup_request(
|
|||
nasPdu->buf = core_calloc(nasPdu->size, sizeof(c_uint8_t));
|
||||
memcpy(nasPdu->buf, emmbuf->payload, nasPdu->size);
|
||||
e_rab->nAS_PDU = nasPdu;
|
||||
pkbuf_free(emmbuf);
|
||||
}
|
||||
|
||||
bearer = mme_bearer_next(bearer);
|
||||
|
@ -511,7 +512,6 @@ status_t s1ap_build_initial_context_setup_request(
|
|||
|
||||
rv = s1ap_encode_pdu(s1apbuf, &pdu);
|
||||
s1ap_free_pdu(&pdu);
|
||||
pkbuf_free(emmbuf);
|
||||
|
||||
if (rv != CORE_OK)
|
||||
{
|
||||
|
|
|
@ -479,7 +479,6 @@ out:
|
|||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/**************************************************************
|
||||
* eNB : HOME
|
||||
* UE : IMSI
|
||||
|
@ -796,7 +795,6 @@ static void attach_test2(abts_case *tc, void *data)
|
|||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
pkbuf_free(recvbuf);
|
||||
|
||||
d_log_set_level(D_MSG_TO_STDOUT, D_LOG_LEVEL_FATAL);
|
||||
/* Send Authentication Authentication Failure */
|
||||
rv = tests1ap_build_authentication_failure(&sendbuf, msgindex+1);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
|
@ -814,7 +812,6 @@ static void attach_test2(abts_case *tc, void *data)
|
|||
rv = tests1ap_enb_read(sock, recvbuf);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
pkbuf_free(recvbuf);
|
||||
d_log_set_level(D_MSG_TO_STDOUT, D_LOG_LEVEL_ERROR);
|
||||
|
||||
/* Send UE Context Release Complete */
|
||||
rv = tests1ap_build_ue_context_release_complete(&sendbuf, msgindex+2);
|
||||
|
@ -1649,19 +1646,16 @@ out:
|
|||
rv = tests1ap_enb_close(sock);
|
||||
ABTS_INT_EQUAL(tc, CORE_OK, rv);
|
||||
}
|
||||
#endif
|
||||
|
||||
abts_suite *test_attach(abts_suite *suite)
|
||||
{
|
||||
suite = ADD_SUITE(suite)
|
||||
|
||||
abts_run_test(suite, attach_test1, NULL);
|
||||
#if 0
|
||||
abts_run_test(suite, attach_test2, NULL);
|
||||
abts_run_test(suite, attach_test3, NULL);
|
||||
abts_run_test(suite, attach_test4, NULL);
|
||||
abts_run_test(suite, attach_test5, NULL);
|
||||
#endif
|
||||
|
||||
return suite;
|
||||
}
|
||||
|
|
|
@ -233,11 +233,11 @@ status_t tests1ap_build_initial_ue_msg(pkbuf_t **pkbuf, int i)
|
|||
"00000a005c0a0090 11034f18a6f15d01 00004300060000f1 1030390064400800"
|
||||
"00f110002343d000 86400130",
|
||||
|
||||
"000c405300000500 080003001100001a 002a2917acba67c4 8207410108091010"
|
||||
"000c405200000500 0800020011001a 002a2917acba67c4 8207410108091010"
|
||||
"103254866205f0f0 000000000e023cd0 11d1270780000a00 000d00c100430006"
|
||||
"0000f11030390064 40080000f1109d67 aa500086400130",
|
||||
|
||||
"000c405300000500 080003002100001a 002a2917bcba67c4 8207410108091010"
|
||||
"000c405200000500 0800020021001a 002a2917bcba67c4 8207410108091010"
|
||||
"000000003005f0f0 000000000e023cd0 11d1270780000a00 000d00c100430006"
|
||||
"0000f11030390064 40080000f1109d67 aa500086400130",
|
||||
|
||||
|
@ -285,8 +285,8 @@ status_t tests1ap_build_initial_ue_msg(pkbuf_t **pkbuf, int i)
|
|||
160,
|
||||
|
||||
108,
|
||||
87,
|
||||
87,
|
||||
86,
|
||||
86,
|
||||
|
||||
80,
|
||||
0,
|
||||
|
@ -450,7 +450,7 @@ status_t tests1ap_build_authentication_failure(pkbuf_t **pkbuf, int i)
|
|||
"403d000005000000 0200030008000200 21001a001413075c 15300e61640edcfb"
|
||||
"605d25911423ee1f 9e006440080000f1 100019b010004340 060000f1100001",
|
||||
"000d"
|
||||
"402e000005000000 0200030008000300 2100001a00040307 5c14006440080000"
|
||||
"402d000005000000 0200030008000200 21001a00040307 5c14006440080000"
|
||||
"f1101a2d10100043 40060000f1100001",
|
||||
"",
|
||||
|
||||
|
@ -471,7 +471,7 @@ status_t tests1ap_build_authentication_failure(pkbuf_t **pkbuf, int i)
|
|||
0,
|
||||
|
||||
65,
|
||||
50,
|
||||
49,
|
||||
0,
|
||||
|
||||
0,
|
||||
|
@ -1102,22 +1102,28 @@ status_t tests1ap_build_ue_context_release_complete(pkbuf_t **pkbuf, int i)
|
|||
return CORE_OK;
|
||||
}
|
||||
|
||||
#if 0
|
||||
status_t tests1ap_build_service_request(pkbuf_t **pkbuf,
|
||||
c_uint32_t enb_ue_s1ap_id, c_uint8_t seq,
|
||||
c_uint16_t mac, c_uint32_t m_tmsi)
|
||||
{
|
||||
char *payload[TESTS1AP_MAX_MESSAGE] = {
|
||||
"000c"
|
||||
"4037000006000800 020004001a0005 04c7049551004300 060000f110303900"
|
||||
"6440080000f11007 87b8000086400140 0060000600400000 0001",
|
||||
|
||||
"000c"
|
||||
"4038000006000800 03400700001a0005 04c7049551004300 060000f110303900"
|
||||
"6440080000f11007 87b8000086400140 0060000600400000 0001",
|
||||
|
||||
};
|
||||
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
|
||||
59,
|
||||
60,
|
||||
};
|
||||
char hexbuf[MAX_SDU_LEN];
|
||||
int i = 0;
|
||||
|
||||
if (enb_ue_s1ap_id & 0x400000) i = 1;
|
||||
|
||||
*pkbuf = pkbuf_alloc(0, MAX_SDU_LEN);
|
||||
if (!(*pkbuf)) return CORE_ERROR;
|
||||
|
@ -1127,16 +1133,15 @@ status_t tests1ap_build_service_request(pkbuf_t **pkbuf,
|
|||
(*pkbuf)->len);
|
||||
|
||||
enb_ue_s1ap_id = htonl(enb_ue_s1ap_id << 8);
|
||||
memcpy((*pkbuf)->payload + 11, &enb_ue_s1ap_id, 3);
|
||||
memcpy((*pkbuf)->payload + 11, &enb_ue_s1ap_id, 2+i);
|
||||
mac = htons(mac);
|
||||
memcpy((*pkbuf)->payload + 20, &seq, 1);
|
||||
memcpy((*pkbuf)->payload + 21, &mac, 2);
|
||||
memcpy((*pkbuf)->payload + 19+i, &seq, 1);
|
||||
memcpy((*pkbuf)->payload + 20+i, &mac, 2);
|
||||
m_tmsi = htonl(m_tmsi);
|
||||
memcpy((*pkbuf)->payload + 56, &m_tmsi, 4);
|
||||
memcpy((*pkbuf)->payload + 55+i, &m_tmsi, 4);
|
||||
|
||||
return CORE_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
status_t tests1ap_build_tau_request(pkbuf_t **pkbuf, int i,
|
||||
c_uint32_t mme_ue_s1ap_id, c_uint32_t enb_ue_s1ap_id, c_uint8_t active_flag,
|
||||
|
|
Loading…
Reference in New Issue