2019-06-15 10:37:34 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
|
|
|
|
*
|
|
|
|
* This file is part of Open5GS.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ogs-core.h"
|
|
|
|
#include "core/abts.h"
|
|
|
|
|
|
|
|
#include "fd/fd-lib.h"
|
|
|
|
|
|
|
|
#include "app/application.h"
|
|
|
|
#include "app/context.h"
|
|
|
|
|
|
|
|
#include "app-init.h"
|
|
|
|
#include "test-packet.h"
|
2019-06-18 06:32:01 +00:00
|
|
|
#include "test-app.h"
|
2019-06-15 10:37:34 +00:00
|
|
|
|
2019-07-08 00:18:17 +00:00
|
|
|
abts_suite *test_mo_idle(abts_suite *suite);
|
|
|
|
abts_suite *test_mt_idle(abts_suite *suite);
|
2019-07-10 13:04:52 +00:00
|
|
|
abts_suite *test_mo_active(abts_suite *suite);
|
2019-07-11 09:14:32 +00:00
|
|
|
abts_suite *test_mt_active(abts_suite *suite);
|
2019-07-13 02:51:28 +00:00
|
|
|
abts_suite *test_mo_sms(abts_suite *suite);
|
2019-06-15 10:37:34 +00:00
|
|
|
|
|
|
|
const struct testlist {
|
|
|
|
abts_suite *(*func)(abts_suite *suite);
|
|
|
|
} alltests[] = {
|
2019-07-08 00:18:17 +00:00
|
|
|
{test_mo_idle},
|
|
|
|
{test_mt_idle},
|
2019-07-10 13:04:52 +00:00
|
|
|
{test_mo_active},
|
2019-07-11 09:14:32 +00:00
|
|
|
{test_mt_active},
|
2019-07-13 02:51:28 +00:00
|
|
|
{test_mo_sms},
|
2019-06-15 10:37:34 +00:00
|
|
|
{NULL},
|
|
|
|
};
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2019-06-15 14:34:42 +00:00
|
|
|
ogs_msleep(300);
|
2019-06-15 10:37:34 +00:00
|
|
|
|
|
|
|
testpacket_final();
|
2019-06-18 06:32:01 +00:00
|
|
|
test_app_terminate();
|
2019-06-15 10:37:34 +00:00
|
|
|
|
|
|
|
base_finalize();
|
|
|
|
ogs_core_finalize();
|
|
|
|
}
|
|
|
|
|
|
|
|
int test_initialize(app_param_t *param, int argc, const char *const argv[])
|
|
|
|
{
|
|
|
|
int rv;
|
|
|
|
fd_logger_register(test_fd_logger_handler);
|
|
|
|
|
|
|
|
atexit(test_terminate);
|
|
|
|
|
|
|
|
ogs_core_initialize();
|
|
|
|
base_initialize();
|
|
|
|
|
2019-06-18 06:32:01 +00:00
|
|
|
rv = test_app_initialize(param);
|
2019-06-15 10:37:34 +00:00
|
|
|
if (rv != OGS_OK) {
|
|
|
|
ogs_error("app_initialize() failed");
|
|
|
|
return OGS_ERROR;
|
|
|
|
}
|
2019-06-18 06:32:01 +00:00
|
|
|
|
2019-06-15 10:37:34 +00:00
|
|
|
rv = testpacket_init();
|
|
|
|
if (rv != OGS_OK) {
|
|
|
|
ogs_error("testpacket() failed");
|
|
|
|
return OGS_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
while(1) {
|
|
|
|
if (connected_count == 1) break;
|
|
|
|
ogs_msleep(50);
|
|
|
|
}
|
|
|
|
|
2019-07-05 09:16:58 +00:00
|
|
|
ogs_msleep(100); /* waiting for running SCTP server */
|
|
|
|
|
2019-06-15 10:37:34 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, const char **argv)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
app_param_t param;
|
|
|
|
const char *debug_mask = NULL;
|
|
|
|
const char *trace_mask = NULL;
|
|
|
|
char config_dir[MAX_FILEPATH_LEN/2];
|
|
|
|
char config_path[MAX_FILEPATH_LEN];
|
|
|
|
abts_suite *suite = NULL;
|
|
|
|
|
|
|
|
abts_init(argc, argv);
|
|
|
|
|
|
|
|
memset(¶m, 0, sizeof(param));
|
|
|
|
for (i = 1; i < argc; i++) {
|
|
|
|
/* abts_init(argc, argv) handles the following options */
|
|
|
|
if (!strcmp(argv[i], "-v")) continue;
|
|
|
|
if (!strcmp(argv[i], "-x")) continue;
|
|
|
|
if (!strcmp(argv[i], "-l")) continue;
|
|
|
|
if (!strcmp(argv[i], "-q")) continue;
|
|
|
|
|
|
|
|
if (!strcmp(argv[i], "-d")) {
|
|
|
|
param.log_level = OGS_LOG_DEBUG;
|
|
|
|
param.log_domain = argv[++i];
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!strcmp(argv[i], "-t")) {
|
|
|
|
param.log_level = OGS_LOG_TRACE;
|
|
|
|
param.log_domain = argv[++i];
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!strcmp(argv[i], "-f")) {
|
|
|
|
param.config_path = argv[++i];
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (argv[i][0] == '-') {
|
|
|
|
fprintf(stderr, "Invalid option: `%s'\n", argv[i]);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!param.config_path) {
|
|
|
|
ogs_path_remove_last_component(config_dir, argv[0]);
|
|
|
|
if (strstr(config_dir, ".libs"))
|
|
|
|
ogs_path_remove_last_component(config_dir, config_dir);
|
|
|
|
ogs_snprintf(config_path, sizeof config_path,
|
|
|
|
"%s/sample-csfb.conf", config_dir);
|
|
|
|
param.config_path = config_path;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (param.log_level)
|
|
|
|
ogs_core()->log.level = OGS_LOG_DEFAULT;
|
|
|
|
else
|
|
|
|
ogs_core()->log.level = OGS_LOG_ERROR;
|
|
|
|
test_initialize(¶m, argc, argv);
|
|
|
|
|
|
|
|
for (i = 0; alltests[i].func; i++)
|
|
|
|
{
|
|
|
|
suite = alltests[i].func(suite);
|
|
|
|
}
|
|
|
|
|
|
|
|
return abts_report(suite);
|
|
|
|
}
|