aboutgitcodelistschat:MatrixIRC
path: root/tests/unit
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/Makefile18
-rw-r--r--tests/unit/test_op_call.c (renamed from tests/unit/test_action_call.c)26
-rw-r--r--tests/unit/test_operations.c (renamed from tests/unit/test_actions.c)96
3 files changed, 70 insertions, 70 deletions
diff --git a/tests/unit/Makefile b/tests/unit/Makefile
index 87f64c4..3ae4fd7 100644
--- a/tests/unit/Makefile
+++ b/tests/unit/Makefile
@@ -1,16 +1,16 @@
CFLAGS += -lcheck
-test: test-filter test-actions test-action-call
+test: test-filter test-operations test-op-call
test-filter: test-filter.c
$(CC) $(CFLAGS) -o test-filter ../../filter.c ../../disasm.c test-filter.c
./test-filter
-test-action-call: test_action_call.c ../../actions.c ../../actions.h ../../gluten.h
- $(CC) $(CFLAGS) -o test-action-call ../../actions.c test_action_call.c
- ./test-action-call
+test-op-call: test_op_call.c ../../operations.c ../../operations.h ../../gluten.h
+ $(CC) $(CFLAGS) -o test-op-call ../../operations.c test_op_call.c
+ ./test-op-call
-test-actions: test_actions.c ../../actions.c ../../actions.h ../../common.h
- $(CC) $(CFLAGS) -o test-actions \
- ../../common.c ../../actions.c \
- test_actions.c
- ./test-actions
+test-operations: test_operations.c ../../operations.c ../../operations.h ../../common.h
+ $(CC) $(CFLAGS) -o test-operations \
+ ../../common.c ../../operations.c \
+ test_operations.c
+ ./test-operations
diff --git a/tests/unit/test_action_call.c b/tests/unit/test_op_call.c
index 8621174..6ffef99 100644
--- a/tests/unit/test_action_call.c
+++ b/tests/unit/test_op_call.c
@@ -13,7 +13,7 @@
#include <check.h>
#include "../../gluten.h"
-#include "../../actions.h"
+#include "../../operations.h"
struct args_write_file {
char *file;
@@ -102,7 +102,7 @@ START_TEST(test_with_open_read_ns)
char test_file[] = "/tmp/test.txt";
char t[PATH_MAX] = "Hello Test";
struct args_write_file args = { test_file, t, sizeof(t) };
- struct act_call call;
+ struct op_call call;
int flags = O_RDWR;
struct arg_clone c;
char buf[PATH_MAX];
@@ -142,7 +142,7 @@ START_TEST(test_with_read)
{
char test_file[] = "/tmp/test.txt";
char t[PATH_MAX] = "Hello Test";
- struct act_call call;
+ struct op_call call;
struct arg_clone c;
char buf[PATH_MAX];
unsigned i;
@@ -168,7 +168,7 @@ END_TEST
START_TEST(test_with_getppid)
{
- struct act_call call;
+ struct op_call call;
struct arg_clone c;
unsigned i;
long pid = (long)getpid();
@@ -185,19 +185,19 @@ START_TEST(test_with_getppid)
}
END_TEST
-Suite *action_call_suite(void)
+Suite *op_call_suite(void)
{
Suite *s;
- TCase *tactions;
+ TCase *tops;
- s = suite_create("Perform actions call");
- tactions = tcase_create("action calls");
+ s = suite_create("Perform ops call");
+ tops = tcase_create("op calls");
- tcase_add_test(tactions, test_with_getppid);
- tcase_add_test(tactions, test_with_read);
- tcase_add_test(tactions, test_with_open_read_ns);
+ tcase_add_test(tops, test_with_getppid);
+ tcase_add_test(tops, test_with_read);
+ tcase_add_test(tops, test_with_open_read_ns);
- suite_add_tcase(s, tactions);
+ suite_add_tcase(s, tops);
return s;
}
@@ -208,7 +208,7 @@ int main(void)
Suite *s;
SRunner *runner;
- s = action_call_suite();
+ s = op_call_suite();
runner = srunner_create(s);
srunner_run_all(runner, CK_VERBOSE);
diff --git a/tests/unit/test_actions.c b/tests/unit/test_operations.c
index 8893722..6c5952f 100644
--- a/tests/unit/test_actions.c
+++ b/tests/unit/test_operations.c
@@ -19,7 +19,7 @@
#include <check.h>
#include "../../gluten.h"
-#include "../../actions.h"
+#include "../../operations.h"
#include "../../common.h"
struct args_target {
@@ -209,11 +209,11 @@ void setup_fd()
START_TEST(test_act_continue)
{
- struct action actions[] = {
- { .type = A_CONT },
+ struct op operations[] = {
+ { .type = OP_CONT },
};
- int ret = do_actions(NULL, actions,
- sizeof(actions) / sizeof(actions[0]), -1, notifyfd,
+ int ret = do_operations(NULL, operations,
+ sizeof(operations) / sizeof(operations[0]), -1, notifyfd,
req.id);
ck_assert_msg(ret == 0, strerror(errno));
ck_assert_int_eq(at->err, 0);
@@ -222,14 +222,14 @@ END_TEST
START_TEST(test_act_block)
{
- struct action actions[] = {
+ struct op operations[] = {
{
- .type = A_BLOCK,
+ .type = OP_BLOCK,
.block = { .error = -1 },
},
};
- int ret = do_actions(NULL, actions,
- sizeof(actions) / sizeof(actions[0]), -1, notifyfd,
+ int ret = do_operations(NULL, operations,
+ sizeof(operations) / sizeof(operations[0]), -1, notifyfd,
req.id);
ck_assert_msg(ret == 0, strerror(errno));
check_target_result(-1, 0, false);
@@ -238,14 +238,14 @@ END_TEST
START_TEST(test_act_return)
{
- struct action actions[] = {
+ struct op operations[] = {
{
- .type = A_RETURN,
+ .type = OP_RETURN,
.ret = { .type = IMMEDIATE, .value = 1 },
},
};
- int ret = do_actions(NULL, actions,
- sizeof(actions) / sizeof(actions[0]), -1, notifyfd,
+ int ret = do_operations(NULL, operations,
+ sizeof(operations) / sizeof(operations[0]), -1, notifyfd,
req.id);
ck_assert_msg(ret == 0, strerror(errno));
check_target_result(1, 0, false);
@@ -256,16 +256,16 @@ START_TEST(test_act_return_ref)
{
int64_t v = 2;
uint16_t offset = 4;
- struct action actions[] = {
+ struct op operations[] = {
{
- .type = A_RETURN,
+ .type = OP_RETURN,
.ret = { .type = REFERENCE, .value_off = offset },
},
};
memcpy((uint16_t *)&tmp_data + offset, &v, sizeof(v));
- int ret = do_actions(&tmp_data, actions,
- sizeof(actions) / sizeof(actions[0]), -1, notifyfd,
+ int ret = do_operations(&tmp_data, operations,
+ sizeof(operations) / sizeof(operations[0]), -1, notifyfd,
req.id);
ck_assert_msg(ret == 0, strerror(errno));
check_target_result(v, 0, false);
@@ -274,15 +274,15 @@ END_TEST
START_TEST(test_act_call)
{
- struct action actions[] = {
+ struct op operations[] = {
{
- .type = A_CALL,
+ .type = OP_CALL,
.call = { .nr = __NR_getppid, .has_ret = false },
},
- { .type = A_CONT },
+ { .type = OP_CONT },
};
- int ret = do_actions(NULL, actions,
- sizeof(actions) / sizeof(actions[0]), -1, notifyfd,
+ int ret = do_operations(NULL, operations,
+ sizeof(operations) / sizeof(operations[0]), -1, notifyfd,
req.id);
ck_assert_msg(ret == 0, strerror(errno));
check_target_result(1, 0, true);
@@ -291,17 +291,17 @@ END_TEST
START_TEST(test_act_call_ret)
{
- struct action actions[] = {
+ struct op operations[] = {
{
- .type = A_CALL,
+ .type = OP_CALL,
.call = { .nr = __NR_getppid,
.has_ret = true,
.ret_off = 2 },
},
- { .type = A_CONT },
+ { .type = OP_CONT },
};
- int ret = do_actions(&tmp_data, actions,
- sizeof(actions) / sizeof(actions[0]), -1, notifyfd,
+ int ret = do_operations(&tmp_data, operations,
+ sizeof(operations) / sizeof(operations[0]), -1, notifyfd,
req.id);
long r;
ck_assert_msg(ret == 0, strerror(errno));
@@ -311,7 +311,7 @@ START_TEST(test_act_call_ret)
}
END_TEST
-static void test_inject(struct action actions[], int n, bool reference)
+static void test_inject(struct op operations[], int n, bool reference)
{
uint16_t new_off = 2, old_off = 4;
int fd_inj;
@@ -326,58 +326,58 @@ static void test_inject(struct action actions[], int n, bool reference)
memcpy((uint16_t *)&tmp_data + old_off, &test_fd,
sizeof(test_fd));
- actions[0].inj.newfd.fd_off = new_off;
- actions[0].inj.newfd.type = REFERENCE;
- actions[0].inj.oldfd.fd_off = old_off;
- actions[0].inj.oldfd.type = REFERENCE;
+ operations[0].inj.newfd.fd_off = new_off;
+ operations[0].inj.newfd.type = REFERENCE;
+ operations[0].inj.oldfd.fd_off = old_off;
+ operations[0].inj.oldfd.type = REFERENCE;
} else {
- actions[0].inj.newfd.fd = fd_inj;
- actions[0].inj.newfd.type = IMMEDIATE;
- actions[0].inj.oldfd.fd = test_fd;
- actions[0].inj.oldfd.type = IMMEDIATE;
+ operations[0].inj.newfd.fd = fd_inj;
+ operations[0].inj.newfd.type = IMMEDIATE;
+ operations[0].inj.oldfd.fd = test_fd;
+ operations[0].inj.oldfd.type = IMMEDIATE;
}
- ret = do_actions(&tmp_data, actions, n, -1, notifyfd, req.id);
+ ret = do_operations(&tmp_data, operations, n, -1, notifyfd, req.id);
ck_assert_msg(ret == 0, strerror(errno));
check_target_fd(pid, test_fd);
}
START_TEST(test_act_inject_a)
{
- struct action actions[] = { { .type = A_INJECT_A } };
- test_inject(actions, sizeof(actions) / sizeof(actions[0]), false);
+ struct op operations[] = { { .type = OP_INJECT_A } };
+ test_inject(operations, sizeof(operations) / sizeof(operations[0]), false);
}
END_TEST
START_TEST(test_act_inject_a_ref)
{
- struct action actions[] = { { .type = A_INJECT_A } };
- test_inject(actions, sizeof(actions) / sizeof(actions[0]), true);
+ struct op operations[] = { { .type = OP_INJECT_A } };
+ test_inject(operations, sizeof(operations) / sizeof(operations[0]), true);
}
END_TEST
START_TEST(test_act_inject)
{
- struct action actions[] = { { .type = A_INJECT } };
- test_inject(actions, sizeof(actions) / sizeof(actions[0]), false);
+ struct op operations[] = { { .type = OP_INJECT } };
+ test_inject(operations, sizeof(operations) / sizeof(operations[0]), false);
}
END_TEST
START_TEST(test_act_inject_ref)
{
- struct action actions[] = { { .type = A_INJECT } };
- test_inject(actions, sizeof(actions) / sizeof(actions[0]), true);
+ struct op operations[] = { { .type = OP_INJECT } };
+ test_inject(operations, sizeof(operations) / sizeof(operations[0]), true);
}
END_TEST
-Suite *action_call_suite(void)
+Suite *op_call_suite(void)
{
Suite *s;
int timeout = 30;
TCase *cont, *block, *ret, *call;
TCase *inject, *inject_a;
- s = suite_create("Perform actions");
+ s = suite_create("Perform operations");
cont = tcase_create("a_continue");
tcase_add_checked_fixture(cont, setup_without_fd, teardown);
@@ -428,7 +428,7 @@ int main(void)
Suite *s;
SRunner *runner;
- s = action_call_suite();
+ s = op_call_suite();
runner = srunner_create(s);
srunner_run_all(runner, CK_VERBOSE);