aboutgitcodelistschat:MatrixIRC
path: root/tests
diff options
context:
space:
mode:
authorAlice Frosi <afrosi@redhat.com>2023-02-21 14:18:12 +0100
committerAlice Frosi <afrosi@redhat.com>2023-02-21 14:18:12 +0100
commit54d77774c65b100fbbe3b28c55ccd93cd40c8f45 (patch)
tree176ab7eca64fcc93fdbc8b004fcca0f278653907 /tests
parent371064324dda4d761178975dedc2537f42865904 (diff)
downloadseitan-54d77774c65b100fbbe3b28c55ccd93cd40c8f45.tar
seitan-54d77774c65b100fbbe3b28c55ccd93cd40c8f45.tar.gz
seitan-54d77774c65b100fbbe3b28c55ccd93cd40c8f45.tar.bz2
seitan-54d77774c65b100fbbe3b28c55ccd93cd40c8f45.tar.lz
seitan-54d77774c65b100fbbe3b28c55ccd93cd40c8f45.tar.xz
seitan-54d77774c65b100fbbe3b28c55ccd93cd40c8f45.tar.zst
seitan-54d77774c65b100fbbe3b28c55ccd93cd40c8f45.zip
tests: add act_call and saving return value
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/test_actions.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/unit/test_actions.c b/tests/unit/test_actions.c
index 4916200..2bf92d4 100644
--- a/tests/unit/test_actions.c
+++ b/tests/unit/test_actions.c
@@ -36,6 +36,8 @@ int pipefd[2];
int nr = __NR_getpid;
pid_t pid;
+uint16_t tmp_data[TMP_DATA_SIZE];
+
static int install_notification_filter()
{
int fd;
@@ -294,6 +296,25 @@ START_TEST(test_act_call)
}
END_TEST
+START_TEST(test_act_call_ret)
+{
+ struct action actions[] = {
+ {
+ .type = A_CALL,
+ .call = { .nr = __NR_getppid, .has_ret = true, .ret_off = 2 },
+ },
+ { .type = A_CONT },
+ };
+ int ret = do_actions(&tmp_data, actions, sizeof(actions) / sizeof(actions[0]), -1,
+ notifyfd, req.id);
+ long r;
+ ck_assert_msg(ret == 0, strerror(errno));
+ check_target_result(1, 0, true);
+ memcpy(&r, &tmp_data[2], sizeof(r));
+ ck_assert_int_eq(r, getpid());
+}
+END_TEST
+
static void test_inject(struct action actions[], int n)
{
int fd_inj;
@@ -357,6 +378,7 @@ Suite *action_call_suite(void)
tcase_add_checked_fixture(call, setup_without_fd, teardown);
tcase_set_timeout(call, timeout);
tcase_add_test(call, test_act_call);
+ tcase_add_test(call, test_act_call_ret);
suite_add_tcase(s, call);
inject = tcase_create("a_inject");