From 856a22f6346f9fda9a79fcfd27d4248bda1ea520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jere=20Lepp=C3=A4nen?= Date: Wed, 16 Oct 2024 14:22:40 +0300 Subject: [PATCH] validation: init: test new odp_abort_fn_get() function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test that odp_abort_fn_get() API function returns the currently set abort function. Signed-off-by: Jere Leppänen --- test/validation/api/Makefile.am | 1 + test/validation/api/init/Makefile.am | 1 + test/validation/api/init/init_abort_fn_get.sh | 3 ++ test/validation/api/init/init_main.c | 30 +++++++++++++++++++ 4 files changed, 35 insertions(+) create mode 100755 test/validation/api/init/init_abort_fn_get.sh diff --git a/test/validation/api/Makefile.am b/test/validation/api/Makefile.am index 2a44d790c3..c02ce01615 100644 --- a/test/validation/api/Makefile.am +++ b/test/validation/api/Makefile.am @@ -57,6 +57,7 @@ TESTS = \ hints/hints_main$(EXEEXT) \ init/init_defaults.sh \ init/init_abort.sh \ + init/init_abort_fn_get.sh \ init/init_log.sh \ init/init_log_thread.sh \ init/init_log_fn_get.sh \ diff --git a/test/validation/api/init/Makefile.am b/test/validation/api/init/Makefile.am index 504c8ac59f..302ce73d94 100644 --- a/test/validation/api/init/Makefile.am +++ b/test/validation/api/init/Makefile.am @@ -6,6 +6,7 @@ init_main_SOURCES = init_main.c EXTRA_DIST = \ init_defaults.sh \ init_abort.sh \ + init_abort_fn_get.sh \ init_log.sh \ init_log_fn_get.sh \ init_num_thr.sh \ diff --git a/test/validation/api/init/init_abort_fn_get.sh b/test/validation/api/init/init_abort_fn_get.sh new file mode 100755 index 0000000000..5a65c22ec9 --- /dev/null +++ b/test/validation/api/init/init_abort_fn_get.sh @@ -0,0 +1,3 @@ +#!/bin/sh +TEST_DIR="${TEST_DIR:-$(dirname $0)/..}/init" +$TEST_DIR/init_main$EXEEXT 10 diff --git a/test/validation/api/init/init_main.c b/test/validation/api/init/init_main.c index 494ca2d53b..42a1df81d1 100644 --- a/test/validation/api/init/init_main.c +++ b/test/validation/api/init/init_main.c @@ -113,6 +113,35 @@ static void init_test_abort(void) CU_ASSERT(ret == 0); } +static void init_test_abort_fn_get(void) +{ + int ret; + odp_instance_t instance; + odp_init_t param; + odp_abort_func_t fn; + + fn = odp_abort_fn_get(); + CU_ASSERT(fn == NULL); + + odp_init_param_init(¶m); + param.abort_fn = &my_abort_func; + + ret = odp_init_global(&instance, ¶m, NULL); + CU_ASSERT_FATAL(ret == 0); + + ret = odp_init_local(instance, ODP_THREAD_WORKER); + CU_ASSERT_FATAL(ret == 0); + + fn = odp_abort_fn_get(); + CU_ASSERT(fn == &my_abort_func); + + ret = odp_term_local(); + CU_ASSERT_FATAL(ret == 0); + + ret = odp_term_global(instance); + CU_ASSERT(ret == 0); +} + static void init_test_log(void) { int ret; @@ -310,6 +339,7 @@ odp_testinfo_t testinfo[] = { ODP_TEST_INFO(init_test_param_init), ODP_TEST_INFO(init_test_term_abnormal), ODP_TEST_INFO(init_test_log_fn_get), + ODP_TEST_INFO(init_test_abort_fn_get), }; odp_testinfo_t init_suite[] = {