aboutsummaryrefslogtreecommitdiff
path: root/helper/test/cli.c
diff options
context:
space:
mode:
Diffstat (limited to 'helper/test/cli.c')
-rw-r--r--helper/test/cli.c44
1 files changed, 42 insertions, 2 deletions
diff --git a/helper/test/cli.c b/helper/test/cli.c
index e7ed0e06f..475a99b90 100644
--- a/helper/test/cli.c
+++ b/helper/test/cli.c
@@ -7,6 +7,16 @@
#include <odp_api.h>
#include <odp/helper/odph_api.h>
+static int cli_server(void *arg ODP_UNUSED)
+{
+ if (odph_cli_run()) {
+ ODPH_ERR("odph_cli_run() failed.\n");
+ exit(EXIT_FAILURE);
+ }
+
+ return 0;
+}
+
int main(int argc, char *argv[])
{
odp_instance_t instance;
@@ -43,16 +53,46 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
- if (odph_cli_start()) {
- ODPH_ERR("Error: odph_cli_start() failed.\n");
+ odp_cpumask_t cpumask;
+ odph_thread_common_param_t thr_common;
+ odph_thread_param_t thr_param;
+ odph_thread_t thr_server;
+
+ if (odp_cpumask_default_control(&cpumask, 1) != 1) {
+ ODPH_ERR("Failed to get default CPU mask.\n");
exit(EXIT_FAILURE);
}
+ odph_thread_common_param_init(&thr_common);
+ thr_common.instance = instance;
+ thr_common.cpumask = &cpumask;
+
+ odph_thread_param_init(&thr_param);
+ thr_param.thr_type = ODP_THREAD_CONTROL;
+ thr_param.start = cli_server;
+
+ memset(&thr_server, 0, sizeof(thr_server));
+
+ if (odph_thread_create(&thr_server, &thr_common, &thr_param, 1) != 1) {
+ ODPH_ERR("Failed to create server thread.\n");
+ exit(EXIT_FAILURE);
+ }
+
+ /*
+ * Wait for a bit to ensure that the server thread has time to start.
+ */
+ odp_time_wait_ns(ODP_TIME_SEC_IN_NS / 10);
+
if (odph_cli_stop()) {
ODPH_ERR("Error: odph_cli_stop() failed.\n");
exit(EXIT_FAILURE);
}
+ if (odph_thread_join(&thr_server, 1) != 1) {
+ ODPH_ERR("Failed to join server thread.\n");
+ exit(EXIT_FAILURE);
+ }
+
if (odph_cli_term()) {
ODPH_ERR("Error: odph_cli_term() failed.\n");
exit(EXIT_FAILURE);