Skip to content

Commit

Permalink
validation: init: test new odp_abort_fn_get() function
Browse files Browse the repository at this point in the history
Test that odp_abort_fn_get() API function returns the currently set
abort function.

Signed-off-by: Jere Leppänen <[email protected]>
  • Loading branch information
JereLeppanen committed Dec 3, 2024
1 parent 22d270f commit 856a22f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/validation/api/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions test/validation/api/init/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
3 changes: 3 additions & 0 deletions test/validation/api/init/init_abort_fn_get.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
TEST_DIR="${TEST_DIR:-$(dirname $0)/..}/init"
$TEST_DIR/init_main$EXEEXT 10
30 changes: 30 additions & 0 deletions test/validation/api/init/init_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(&param);
param.abort_fn = &my_abort_func;

ret = odp_init_global(&instance, &param, 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;
Expand Down Expand Up @@ -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[] = {
Expand Down

0 comments on commit 856a22f

Please sign in to comment.