diff options
author | Jere Leppänen <jere.leppanen@nokia.com> | 2021-01-28 20:53:23 +0200 |
---|---|---|
committer | Petri Savolainen <petri.savolainen@nokia.com> | 2021-02-23 11:01:07 +0200 |
commit | f9f29f9aad106bfd31b0e50ff5b886d9a7a7a5bf (patch) | |
tree | bb8a72ebde2d083181141fc7c39aa8cbcbbb7c55 /helper | |
parent | b1b10b702674378905a9cca643f7d404a3ca15db (diff) |
helper: test: implement CLI helper test
Test CLI helper by starting and stopping the ODP CLI server.
Signed-off-by: Jere Leppänen <jere.leppanen@nokia.com>
Reviewed-by: Matias Elo <matias.elo@nokia.com>
Diffstat (limited to 'helper')
-rw-r--r-- | helper/test/.gitignore | 1 | ||||
-rw-r--r-- | helper/test/Makefile.am | 5 | ||||
-rw-r--r-- | helper/test/cli.c | 62 |
3 files changed, 68 insertions, 0 deletions
diff --git a/helper/test/.gitignore b/helper/test/.gitignore index 23fab7b30..e1e5ab7b2 100644 --- a/helper/test/.gitignore +++ b/helper/test/.gitignore @@ -1,6 +1,7 @@ *.trs *.log chksum +cli cuckootable iplookuptable odpthreads diff --git a/helper/test/Makefile.am b/helper/test/Makefile.am index ef3e2e370..400e7c080 100644 --- a/helper/test/Makefile.am +++ b/helper/test/Makefile.am @@ -19,6 +19,11 @@ linux_pthread_SOURCES = linux/pthread.c linux_process_SOURCES = linux/process.c endif +if helper_cli +EXECUTABLES += cli +cli_SOURCES = cli.c +endif + COMPILE_ONLY = odpthreads TESTSCRIPTS = odpthreads_as_processes \ diff --git a/helper/test/cli.c b/helper/test/cli.c new file mode 100644 index 000000000..ff3ea2f53 --- /dev/null +++ b/helper/test/cli.c @@ -0,0 +1,62 @@ +/* Copyright (c) 2021, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include <odp_api.h> +#include <odp/helper/odph_api.h> + +int main(int argc, char *argv[]) +{ + odp_instance_t instance; + odph_helper_options_t helper_options; + odp_init_t init_param; + + argc = odph_parse_options(argc, argv); + if (odph_options(&helper_options)) { + ODPH_ERR("Error: reading ODP helper options failed.\n"); + exit(EXIT_FAILURE); + } + + odp_init_param_init(&init_param); + init_param.mem_model = helper_options.mem_model; + + memset(&instance, 0, sizeof(instance)); + + if (odp_init_global(&instance, NULL, NULL)) { + ODPH_ERR("Error: ODP global init failed.\n"); + exit(EXIT_FAILURE); + } + + if (odp_init_local(instance, ODP_THREAD_CONTROL)) { + ODPH_ERR("Error: ODP local init failed.\n"); + exit(EXIT_FAILURE); + } + + odph_cli_param_t cli_param; + + odph_cli_param_init(&cli_param); + + if (odph_cli_start(instance, &cli_param)) { + ODPH_ERR("Error: odph_cli_start() failed.\n"); + exit(EXIT_FAILURE); + } + + if (odph_cli_stop()) { + ODPH_ERR("Error: odph_cli_stop() failed.\n"); + exit(EXIT_FAILURE); + } + + if (odp_term_local()) { + ODPH_ERR("Error: ODP local term failed.\n"); + exit(EXIT_FAILURE); + } + + if (odp_term_global(instance)) { + ODPH_ERR("Error: ODP global term failed.\n"); + exit(EXIT_FAILURE); + } + + return EXIT_SUCCESS; +} |