From c6796927b2f5e9c742234b9a3d1f7fef8953bdee Mon Sep 17 00:00:00 2001 From: Alice Frosi Date: Thu, 16 Feb 2023 15:29:08 +0100 Subject: tests: test reference for a_return Signed-off-by: Alice Frosi --- tests/unit/test_actions.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/unit/test_actions.c b/tests/unit/test_actions.c index a2de8b7..99799e5 100644 --- a/tests/unit/test_actions.c +++ b/tests/unit/test_actions.c @@ -236,7 +236,7 @@ START_TEST(test_act_return) struct action actions[] = { { .type = A_RETURN, - .ret = { .value = 1 }, + .ret = { .type = IMMEDIATE, .value = 1 }, }, }; int ret = do_actions(actions, sizeof(actions) / sizeof(actions[0]), -1, @@ -246,6 +246,36 @@ START_TEST(test_act_return) } END_TEST +START_TEST(test_act_return_ref) +{ + int64_t v = 2; + struct action actions[] = { + { + .type = A_RETURN, + .ret = { .type = REFERENCE, .value_p = &v }, + }, + }; + int ret = do_actions(actions, sizeof(actions) / sizeof(actions[0]), -1, + notifyfd, req.id); + ck_assert_msg(ret == 0, strerror(errno)); + check_target_result(v, 0); +} +END_TEST + +START_TEST(test_act_return_empty_ref) +{ + struct action actions[] = { + { + .type = A_RETURN, + .ret = { .type = REFERENCE, .value_p = NULL }, + }, + }; + int ret = do_actions(actions, sizeof(actions) / sizeof(actions[0]), -1, + notifyfd, req.id); + ck_assert_int_eq(ret, -1); +} +END_TEST + static void test_inject(struct action actions[], int n) { int fd_inj; @@ -295,6 +325,8 @@ Suite *action_call_suite(void) tcase_add_checked_fixture(ret, setup_without_fd, teardown); tcase_set_timeout(ret, timeout); tcase_add_test(ret, test_act_return); + tcase_add_test(ret, test_act_return_ref); + tcase_add_test(ret, test_act_return_empty_ref); suite_add_tcase(s, ret); block = tcase_create("a_block"); -- cgit v1.2.3