test framework for crash

This commit is contained in:
Sukchan Lee 2019-06-13 18:22:34 +09:00
parent a550cf5b1d
commit 88217ff11e
4 changed files with 230 additions and 8 deletions

View File

@ -611,6 +611,7 @@ void s1ap_handle_initial_context_setup_failure(
{
ogs_debug(" NOT EMM-Registered");
ogs_assert(mme_ue);
ogs_msleep(300);
rv = mme_send_delete_session_or_ue_context_release(mme_ue, enb_ue);
ogs_assert(rv == OGS_OK);
}

View File

@ -86,7 +86,7 @@ void pgw_gx_send_ccr(pgw_sess_t *sess, gtp_xact_t *xact,
message = gtpbuf->data;
ogs_assert(message);
ogs_debug("[PGW2] Credit-Control-Request");
ogs_debug("[Credit-Control-Request]");
/* Create the request */
ret = fd_msg_new(gx_cmd_ccr, MSGFL_ALLOC_ETEID, &req);
@ -100,6 +100,8 @@ void pgw_gx_send_ccr(pgw_sess_t *sess, gtp_xact_t *xact,
ogs_assert(ret == 0);
ogs_assert(new == 0);
ogs_debug(" Found GX Session-Id: [%s]", sess->gx_sid);
/* Add Session-Id to the message */
ret = fd_message_session_id_set(req, (os0_t)sess->gx_sid, sidlen);
ogs_assert(ret == 0);
@ -113,6 +115,7 @@ void pgw_gx_send_ccr(pgw_sess_t *sess, gtp_xact_t *xact,
ogs_assert(ret == 0);
ret = fd_msg_sess_get(fd_g_config->cnf_dict, req, &session, NULL);
ogs_assert(ret == 0);
ogs_debug(" Create a New Session");
}
/* Retrieve session state in this session */
@ -128,9 +131,12 @@ void pgw_gx_send_ccr(pgw_sess_t *sess, gtp_xact_t *xact,
sess_data = new_state(sid);
ogs_assert(sess_data);
ogs_debug(" Allocate new session: [%s]", sess_data->gx_sid);
/* Save Session-Id to PGW Session Context */
sess->gx_sid = (char*)sess_data->gx_sid;
}
} else
ogs_debug(" Retrieve session: [%s]", sess_data->gx_sid);
/* Update session state */
sess_data->sess = sess;
@ -144,6 +150,9 @@ void pgw_gx_send_ccr(pgw_sess_t *sess, gtp_xact_t *xact,
else
sess_data->cc_request_number++;
ogs_debug(" CC Request Type[%d] Number[%d]",
sess_data->cc_request_type, sess_data->cc_request_number);
/* Set Origin-Host & Origin-Realm */
ret = fd_msg_add_origin(req, 0);
ogs_assert(ret == 0);
@ -454,7 +463,7 @@ static void pgw_gx_cca_cb(void *data, struct msg **msg)
gx_message_t *gx_message = NULL;
uint16_t gxbuf_len = 0;
ogs_debug("[PGW] Credit-Control-Answer");
ogs_debug("[Credit-Control-Answer]");
ret = clock_gettime(CLOCK_REALTIME, &ts);
ogs_assert(ret == 0);
@ -463,12 +472,16 @@ static void pgw_gx_cca_cb(void *data, struct msg **msg)
ret = fd_msg_sess_get(fd_g_config->cnf_dict, *msg, &session, &new);
ogs_assert(ret == 0);
ogs_assert(new == 0);
ogs_debug(" Search the session");
ret = fd_sess_state_retrieve(pgw_gx_reg, session, &sess_data);
ogs_assert(ret == 0);
ogs_assert(sess_data);
ogs_assert((void *)sess_data == data);
ogs_debug(" Retrieve its data: [%s]", sess_data->gx_sid);
xact = sess_data->xact;
ogs_assert(xact);
sess = sess_data->sess;
@ -736,10 +749,12 @@ out:
(long)(1000000000 + ts.tv_nsec - sess_data->ts.tv_nsec) / 1000);
if (sess_data->cc_request_type != GX_CC_REQUEST_TYPE_TERMINATION_REQUEST) {
ogs_debug(" fd_sess_state_store(): [%s]", sess_data->gx_sid);
ret = fd_sess_state_store(pgw_gx_reg, session, &sess_data);
ogs_assert(ret == 0);
ogs_assert(sess_data == NULL);
} else {
ogs_debug(" state_cleanup(): [%s]", sess_data->gx_sid);
state_cleanup(sess_data, NULL, NULL);
}
@ -781,7 +796,7 @@ static int pgw_gx_rar_cb( struct msg **msg, struct avp *avp,
ogs_assert(msg);
ogs_debug("[PGW] Re-Auth-Request");
ogs_debug("Re-Auth-Request");
gxbuf_len = sizeof(gx_message_t);
ogs_assert(gxbuf_len < 8192);
@ -935,7 +950,7 @@ static int pgw_gx_rar_cb( struct msg **msg, struct avp *avp,
ret = fd_msg_send(msg, NULL, NULL);
ogs_assert(ret == 0);
ogs_debug("[PGW] Re-Auth-Answer");
ogs_debug("Re-Auth-Answer");
/* Add this value to the stats */
ogs_assert(pthread_mutex_lock(&fd_logger_self()->stats_lock) == 0);

View File

@ -944,11 +944,27 @@ int tests1ap_build_initial_context_setup_failure(ogs_pkbuf_t **pkbuf, int i)
"",
"",
"",
"",
"",
"",
"",
"4009001500000300 0040020001000840 0200010002400202 a0",
};
uint16_t len[TESTS1AP_MAX_MESSAGE] = {
25,
0,
0,
0,
0,
0,
0,
0,
25,
};
char hexbuf[MAX_SDU_LEN];
@ -1134,9 +1150,8 @@ int tests1ap_build_ue_context_release_request(ogs_pkbuf_t **pkbuf, int i)
"0012"
"4018000003000000 05c0020000c80008 0002000200024002 0280",
"",
"",
"0012401500000300 0000020001000800 0200010002400202 a0",
};
uint16_t len[TESTS1AP_MAX_MESSAGE] = {
@ -1150,7 +1165,7 @@ int tests1ap_build_ue_context_release_request(ogs_pkbuf_t **pkbuf, int i)
28,
0,
0,
25,
};
char hexbuf[MAX_SDU_LEN];

View File

@ -1680,15 +1680,206 @@ static void attach_test5(abts_case *tc, void *data)
ogs_msleep(300);
}
/**************************************************************
* eNB : MACRO
* UE : IMSI
* Protocol Configuration Options without default APN */
static void attach_test6(abts_case *tc, void *data)
{
int rv;
ogs_socknode_t *s1ap;
ogs_socknode_t *gtpu;
ogs_pkbuf_t *sendbuf;
ogs_pkbuf_t *recvbuf;
s1ap_message_t message;
int i;
int msgindex = 8;
uint8_t tmp[MAX_SDU_LEN];
mongoc_collection_t *collection = NULL;
bson_t *doc = NULL;
int64_t count = 0;
bson_error_t error;
const char *json =
"{"
"\"_id\" : { \"$oid\" : \"597223258b8861d7605378c7\" }, "
"\"imsi\" : \"001010000000002\", "
"\"pdn\" : ["
"{"
"\"apn\" : \"internet\", "
"\"_id\" : { \"$oid\" : \"598223158b8861d7605378c8\" }, "
"\"ambr\" : {"
"\"uplink\" : { \"$numberLong\" : \"1024000\" }, "
"\"downlink\" : { \"$numberLong\" : \"1024000\" } "
"},"
"\"qos\" : { "
"\"qci\" : 9, "
"\"arp\" : { "
"\"priority_level\" : 8,"
"\"pre_emption_vulnerability\" : 1, "
"\"pre_emption_capability\" : 1"
"} "
"}, "
"\"type\" : 2"
"}"
"],"
"\"ambr\" : { "
"\"uplink\" : { \"$numberLong\" : \"1024000\" }, "
"\"downlink\" : { \"$numberLong\" : \"1024000\" } "
"},"
"\"subscribed_rau_tau_timer\" : 12,"
"\"network_access_mode\" : 2, "
"\"subscriber_status\" : 0, "
"\"access_restriction_data\" : 32, "
"\"security\" : { "
"\"k\" : \"00112233 44556677 8899AABB CCDDEEFF\", "
"\"opc\" : \"00010203 04050607 08090A0B 0C0D0E0F\", "
"\"amf\" : \"9001\", "
"\"sqn\" : { \"$numberLong\" : \"96\" }, "
"\"rand\" : \"9bdbfb93 16be4d52 80153094 38326671\" "
"}, "
"\"__v\" : 0 "
"}";
ogs_msleep(300);
/* eNB connects to MME */
s1ap = testenb_s1ap_client("127.0.0.1");
ABTS_PTR_NOTNULL(tc, s1ap);
/* eNB connects to SGW */
gtpu = testenb_gtpu_server("127.0.0.5");
ABTS_PTR_NOTNULL(tc, gtpu);
/* Send S1-Setup Reqeust */
rv = tests1ap_build_setup_req(
&sendbuf, S1AP_ENB_ID_PR_macroENB_ID, 0x54f64, 12345, 1, 1, 2);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testenb_s1ap_send(s1ap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/* Receive S1-Setup Response */
recvbuf = testenb_s1ap_read(s1ap);
ABTS_PTR_NOTNULL(tc, recvbuf);
rv = s1ap_decode_pdu(&message, recvbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
s1ap_free_pdu(&message);
ogs_pkbuf_free(recvbuf);
collection = mongoc_client_get_collection(
context_self()->db.client,
context_self()->db.name, "subscribers");
ABTS_PTR_NOTNULL(tc, collection);
/********** Insert Subscriber in Database */
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("001010000000002"));
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 */
ogs_msleep(300);
mme_self()->mme_ue_s1ap_id = 0;
rv = tests1ap_build_initial_ue_msg(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testenb_s1ap_send(s1ap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/* Receive Authentication Request */
recvbuf = testenb_s1ap_read(s1ap);
ABTS_PTR_NOTNULL(tc, recvbuf);
ogs_pkbuf_free(recvbuf);
/* Send Authentication Response */
rv = tests1ap_build_authentication_response(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testenb_s1ap_send(s1ap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/* Receive Security mode Command */
recvbuf = testenb_s1ap_read(s1ap);
ABTS_PTR_NOTNULL(tc, recvbuf);
ogs_pkbuf_free(recvbuf);
/* Send Security mode Complete */
rv = tests1ap_build_security_mode_complete(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testenb_s1ap_send(s1ap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/* Receive Initial Context Setup Request */
recvbuf = testenb_s1ap_read(s1ap);
ABTS_PTR_NOTNULL(tc, recvbuf);
ogs_pkbuf_free(recvbuf);
/* Send Initial Context Setup Failure */
rv = tests1ap_build_initial_context_setup_failure(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testenb_s1ap_send(s1ap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/* Send UE Context Release Request */
rv = tests1ap_build_ue_context_release_request(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testenb_s1ap_send(s1ap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
/* Receive UE Context Release Command */
recvbuf = testenb_s1ap_read(s1ap);
ABTS_PTR_NOTNULL(tc, recvbuf);
ogs_pkbuf_free(recvbuf);
/* Send UE Context Release Complete */
rv = tests1ap_build_ue_context_release_complete(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
rv = testenb_s1ap_send(s1ap, sendbuf);
ABTS_INT_EQUAL(tc, OGS_OK, rv);
ogs_msleep(300);
doc = BCON_NEW("imsi", BCON_UTF8("001010000000002"));
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 */
testenb_s1ap_close(s1ap);
/* eNB disonncect from SGW */
testenb_gtpu_close(gtpu);
ogs_msleep(300);
}
abts_suite *test_attach(abts_suite *suite)
{
suite = ADD_SUITE(suite)
#if 0
abts_run_test(suite, attach_test1, NULL);
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
abts_run_test(suite, attach_test6, NULL);
return suite;
}