aboutgitcodelistschat:MatrixIRC
path: root/tests
diff options
context:
space:
mode:
authorAlice Frosi <afrosi@redhat.com>2023-05-11 11:26:11 +0200
committerAlice Frosi <afrosi@redhat.com>2023-05-11 17:48:29 +0200
commit46a3a54c0a0e1ce9d8f5705184e46386565d2319 (patch)
tree37b92e09745d9e02d98406d2f9bdc92c1fa818fc /tests
parent1b40d186058e1c8c16a9fe0ada522e2a6dee37a0 (diff)
downloadseitan-46a3a54c0a0e1ce9d8f5705184e46386565d2319.tar
seitan-46a3a54c0a0e1ce9d8f5705184e46386565d2319.tar.gz
seitan-46a3a54c0a0e1ce9d8f5705184e46386565d2319.tar.bz2
seitan-46a3a54c0a0e1ce9d8f5705184e46386565d2319.tar.lz
seitan-46a3a54c0a0e1ce9d8f5705184e46386565d2319.tar.xz
seitan-46a3a54c0a0e1ce9d8f5705184e46386565d2319.tar.zst
seitan-46a3a54c0a0e1ce9d8f5705184e46386565d2319.zip
Adjust op_call with gluten_offset
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/test_operations.c59
-rw-r--r--tests/unit/testutil.h2
2 files changed, 30 insertions, 31 deletions
diff --git a/tests/unit/test_operations.c b/tests/unit/test_operations.c
index 0e22754..a83db5a 100644
--- a/tests/unit/test_operations.c
+++ b/tests/unit/test_operations.c
@@ -129,13 +129,12 @@ END_TEST
START_TEST(test_op_call)
{
- struct op operations[] = {
- { OP_CALL, { .call = { __NR_getppid, false } } },
- { OP_CONT, { { 0 } } },
- { OP_END, { { 0 } } },
- { 0 },
- };
-
+ long nr = __NR_getppid;
+ struct op operations[] = { { OP_CALL,
+ { .call = { .nr = { OFFSET_DATA, 0 } } } },
+ { OP_CONT, OP_EMPTY },
+ { OP_END, OP_EMPTY } };
+ ck_write_gluten(gluten, operations[0].op.call.nr, nr);
ck_assert_int_eq(eval(&gluten, operations, &req, notifyfd), 0);
check_target_result(1, 0, true);
}
@@ -143,16 +142,18 @@ END_TEST
START_TEST(test_op_call_ret)
{
+ long nr = __NR_getppid;
long r;
struct op operations[] = {
{ OP_CALL,
- { .call = { __NR_getppid, true,
- .ret = { .type = OFFSET_DATA, .offset = 0 } } } },
- { OP_CONT, { { 0 } } },
- { OP_END, { { 0 } } },
- { 0 },
+ { .call = { .nr = { OFFSET_DATA, 0 },
+ .ret = { OFFSET_DATA, sizeof(nr) },
+ .has_ret = true } } },
+ { OP_CONT, OP_EMPTY },
+ { OP_END, OP_EMPTY },
};
+ ck_write_gluten(gluten, operations[0].op.call.nr, nr);
ck_assert_int_eq(eval(&gluten, operations, &req, notifyfd), 0);
check_target_result(1, 0, true);
ck_read_gluten(gluten, operations[0].op.call.ret, r);
@@ -211,8 +212,7 @@ START_TEST(test_op_load)
sizeof(struct sockaddr_un) } } },
{ OP_RETURN,
{ .ret = { { OFFSET_DATA, sizeof(struct sockaddr_un) } } } },
- { OP_END, { { 0 } } },
- { 0 },
+ { OP_END, OP_EMPTY },
};
struct sockaddr_un addr;
int v = 2;
@@ -237,9 +237,9 @@ static void test_op_cmp_int(int a, int b, enum op_cmp_type cmp)
cmp,
3 } } },
{ OP_BLOCK, { .block = { -1 } } },
- { OP_END, { { 0 } } },
- { OP_CONT, { { 0 } } },
- { OP_END, { { 0 } } },
+ { OP_END, OP_EMPTY },
+ { OP_CONT, OP_EMPTY },
+ { OP_END, OP_EMPTY },
{ 0 },
};
@@ -298,9 +298,9 @@ START_TEST(test_op_cmp_string_eq)
CMP_EQ,
3 } } },
{ OP_BLOCK, { .block = { -1 } } },
- { OP_END, { { 0 } } },
- { OP_CONT, { { 0 } } },
- { OP_END, { { 0 } } },
+ { OP_END, OP_EMPTY },
+ { OP_CONT, OP_EMPTY },
+ { OP_END, OP_EMPTY },
{ 0 },
};
ck_write_gluten(gluten, operations[0].op.cmp.x, s1);
@@ -322,10 +322,10 @@ START_TEST(test_op_cmp_string_false)
sizeof(s1),
CMP_EQ,
2 } } },
- { OP_CONT, { { 0 } } },
- { OP_END, { { 0 } } },
+ { OP_CONT, OP_EMPTY },
+ { OP_END, OP_EMPTY },
{ OP_BLOCK, { .block = { -1 } } },
- { OP_END, { { 0 } } },
+ { OP_END, OP_EMPTY },
{ 0 },
};
@@ -346,9 +346,9 @@ START_TEST(test_op_resolvedfd_eq)
sizeof(path),
3 } } },
{ OP_BLOCK, { .block = { -1 } } },
- { OP_END, { { 0 } } },
- { OP_CONT, { { 0 } } },
- { OP_END, { { 0 } } },
+ { OP_END, OP_EMPTY },
+ { OP_CONT, OP_EMPTY },
+ { OP_END, OP_EMPTY },
{ 0 },
};
@@ -370,10 +370,9 @@ START_TEST(test_op_resolvedfd_neq)
sizeof(path),
3 } } },
{ OP_BLOCK, { .block = { -1 } } },
- { OP_END, { { 0 } } },
- { OP_CONT, { { 0 } } },
- { OP_END, { { 0 } } },
- { 0 },
+ { OP_END, OP_EMPTY },
+ { OP_CONT, OP_EMPTY },
+ { OP_END, OP_EMPTY },
};
ck_write_gluten(gluten, operations[0].op.resfd.fd, at->fd);
diff --git a/tests/unit/testutil.h b/tests/unit/testutil.h
index 861efb0..638dd0a 100644
--- a/tests/unit/testutil.h
+++ b/tests/unit/testutil.h
@@ -16,7 +16,7 @@
#include "common/gluten.h"
#define STACK_SIZE (1024 * 1024 / 8)
-
+#define _EMPTY_ { .cont = { false } }
static inline void *test_gluten_write_ptr(struct gluten *g,
const struct gluten_offset x)
{