diff options
author | Alice Frosi <afrosi@redhat.com> | 2023-02-16 15:29:08 +0100 |
---|---|---|
committer | Alice Frosi <afrosi@redhat.com> | 2023-02-16 15:29:08 +0100 |
commit | c6796927b2f5e9c742234b9a3d1f7fef8953bdee (patch) | |
tree | 561aa41c3e78c445bf076259f11cf82eccbe26c8 | |
parent | 3b82d1514d30db14823849a978d7fab5989f9762 (diff) | |
download | seitan-c6796927b2f5e9c742234b9a3d1f7fef8953bdee.tar seitan-c6796927b2f5e9c742234b9a3d1f7fef8953bdee.tar.gz seitan-c6796927b2f5e9c742234b9a3d1f7fef8953bdee.tar.bz2 seitan-c6796927b2f5e9c742234b9a3d1f7fef8953bdee.tar.lz seitan-c6796927b2f5e9c742234b9a3d1f7fef8953bdee.tar.xz seitan-c6796927b2f5e9c742234b9a3d1f7fef8953bdee.tar.zst seitan-c6796927b2f5e9c742234b9a3d1f7fef8953bdee.zip |
tests: test reference for a_return
Signed-off-by: Alice Frosi <afrosi@redhat.com>
-rw-r--r-- | tests/unit/test_actions.c | 34 |
1 files changed, 33 insertions, 1 deletions
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"); |