2019-04-27 14:54:30 +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/>.
|
|
|
|
*/
|
|
|
|
|
2021-02-08 19:25:40 +00:00
|
|
|
#include "ogs-core.h"
|
|
|
|
#include "core/abts.h"
|
2019-04-27 14:54:30 +00:00
|
|
|
|
|
|
|
abts_suite *test_s1ap_message(abts_suite *suite);
|
|
|
|
abts_suite *test_nas_message(abts_suite *suite);
|
|
|
|
abts_suite *test_gtp_message(abts_suite *suite);
|
2021-01-25 04:43:42 +00:00
|
|
|
abts_suite *test_ngap_message(abts_suite *suite);
|
2020-05-18 21:00:37 +00:00
|
|
|
abts_suite *test_sbi_message(abts_suite *suite);
|
2019-04-27 14:54:30 +00:00
|
|
|
abts_suite *test_security(abts_suite *suite);
|
2019-07-25 13:20:18 +00:00
|
|
|
abts_suite *test_crash(abts_suite *suite);
|
2019-04-27 14:54:30 +00:00
|
|
|
|
|
|
|
const struct testlist {
|
|
|
|
abts_suite *(*func)(abts_suite *suite);
|
|
|
|
} alltests[] = {
|
|
|
|
{test_s1ap_message},
|
|
|
|
{test_nas_message},
|
|
|
|
{test_gtp_message},
|
2021-01-25 04:43:42 +00:00
|
|
|
{test_ngap_message},
|
2020-05-18 21:00:37 +00:00
|
|
|
{test_sbi_message},
|
2019-04-27 14:54:30 +00:00
|
|
|
{test_security},
|
2019-07-25 13:20:18 +00:00
|
|
|
{test_crash},
|
2019-04-27 14:54:30 +00:00
|
|
|
{NULL},
|
|
|
|
};
|
|
|
|
|
2019-08-25 11:15:20 +00:00
|
|
|
static void terminate(void)
|
2019-04-27 14:54:30 +00:00
|
|
|
{
|
2019-08-25 11:15:20 +00:00
|
|
|
ogs_pkbuf_default_destroy();
|
2019-04-27 14:54:30 +00:00
|
|
|
|
2019-09-13 12:07:47 +00:00
|
|
|
ogs_core_terminate();
|
2019-04-27 14:54:30 +00:00
|
|
|
}
|
|
|
|
|
2019-10-27 08:41:14 +00:00
|
|
|
int main(int argc, const char *const argv[])
|
2019-04-27 14:54:30 +00:00
|
|
|
{
|
2019-08-25 11:15:20 +00:00
|
|
|
int rv, i, opt;
|
|
|
|
ogs_getopt_t options;
|
|
|
|
struct {
|
|
|
|
char *log_level;
|
|
|
|
char *domain_mask;
|
|
|
|
} optarg;
|
2019-10-27 08:41:14 +00:00
|
|
|
const char *argv_out[argc+2]; /* '-e error' is always added */
|
2019-08-25 11:15:20 +00:00
|
|
|
|
|
|
|
abts_suite *suite = NULL;
|
|
|
|
ogs_pkbuf_config_t config;
|
|
|
|
|
|
|
|
rv = abts_main(argc, argv, argv_out);
|
|
|
|
if (rv != OGS_OK) return rv;
|
|
|
|
|
|
|
|
memset(&optarg, 0, sizeof(optarg));
|
2019-10-27 08:41:14 +00:00
|
|
|
ogs_getopt_init(&options, (char**)argv_out);
|
2019-08-25 11:15:20 +00:00
|
|
|
|
|
|
|
while ((opt = ogs_getopt(&options, "e:m:")) != -1) {
|
|
|
|
switch (opt) {
|
|
|
|
case 'e':
|
|
|
|
optarg.log_level = options.optarg;
|
|
|
|
break;
|
|
|
|
case 'm':
|
|
|
|
optarg.domain_mask = options.optarg;
|
|
|
|
break;
|
|
|
|
case '?':
|
|
|
|
default:
|
|
|
|
fprintf(stderr, "%s: should not be reached\n", OGS_FUNC);
|
|
|
|
return OGS_ERROR;
|
|
|
|
}
|
|
|
|
}
|
2019-04-27 14:54:30 +00:00
|
|
|
|
|
|
|
ogs_core_initialize();
|
|
|
|
|
2019-08-25 11:15:20 +00:00
|
|
|
ogs_pkbuf_default_init(&config);
|
|
|
|
ogs_pkbuf_default_create(&config);
|
2019-05-06 11:43:50 +00:00
|
|
|
|
2019-08-25 11:15:20 +00:00
|
|
|
atexit(terminate);
|
2019-04-27 14:54:30 +00:00
|
|
|
|
2019-08-25 11:15:20 +00:00
|
|
|
rv = ogs_log_config_domain(optarg.domain_mask, optarg.log_level);
|
|
|
|
if (rv != OGS_OK) return rv;
|
2019-04-27 14:54:30 +00:00
|
|
|
|
|
|
|
for (i = 0; alltests[i].func; i++)
|
|
|
|
suite = alltests[i].func(suite);
|
|
|
|
|
|
|
|
return abts_report(suite);
|
|
|
|
}
|