diff options
author | Alice Frosi <afrosi@redhat.com> | 2023-05-05 17:04:15 +0200 |
---|---|---|
committer | Alice Frosi <afrosi@redhat.com> | 2023-05-08 14:47:22 +0200 |
commit | 384d09cd3d2e62bae19b59b615bc57b7a23d0b0a (patch) | |
tree | 3b6ba748a07d8e7e1b687314517e3379c59a69e3 /tests/unit/testutil.h | |
parent | c29157e78df7fa335c56d0d7f2cca7dc50bfffd6 (diff) | |
download | seitan-384d09cd3d2e62bae19b59b615bc57b7a23d0b0a.tar seitan-384d09cd3d2e62bae19b59b615bc57b7a23d0b0a.tar.gz seitan-384d09cd3d2e62bae19b59b615bc57b7a23d0b0a.tar.bz2 seitan-384d09cd3d2e62bae19b59b615bc57b7a23d0b0a.tar.lz seitan-384d09cd3d2e62bae19b59b615bc57b7a23d0b0a.tar.xz seitan-384d09cd3d2e62bae19b59b615bc57b7a23d0b0a.tar.zst seitan-384d09cd3d2e62bae19b59b615bc57b7a23d0b0a.zip |
test: fix operations
Adjust the tests after the refactoring and to use struct gluten_offset
Diffstat (limited to 'tests/unit/testutil.h')
-rw-r--r-- | tests/unit/testutil.h | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/tests/unit/testutil.h b/tests/unit/testutil.h index d6a1c46..45fe08f 100644 --- a/tests/unit/testutil.h +++ b/tests/unit/testutil.h @@ -8,10 +8,44 @@ #include <limits.h> #include <check.h> -#include "filter.h" +#include "cooker/filter.h" + +#ifndef SEITAN_TEST +#define SEITAN_TEST +#endif +#include "common/gluten.h" #define STACK_SIZE (1024 * 1024 / 8) +static inline void *test_gluten_write_ptr(struct gluten *g, + const struct gluten_offset x) +{ + switch (x.type) { + case OFFSET_DATA: + return (char *)g->data + x.offset; + case OFFSET_RO_DATA: + return (char *)g->ro_data + x.offset; + case OFFSET_INSTRUCTION: + return (struct op *)(g->inst) + x.offset; + default: + return NULL; + } +} + +#define ck_write_gluten(gluten, value, ref) \ + do { \ + void *p = test_gluten_write_ptr(&gluten, value); \ + ck_assert_ptr_nonnull(p); \ + memcpy(p, &ref, sizeof(ref)); \ + } while (0) + +#define ck_read_gluten(gluten, value, ref) \ + do { \ + void *p = test_gluten_write_ptr(&gluten, value); \ + ck_assert_ptr_nonnull(p); \ + memcpy(&ref, p, sizeof(ref)); \ + } while (0) + struct args_target { long ret; int err; @@ -32,7 +66,7 @@ extern int pipefd[2]; extern pid_t pid; extern char path[PATH_MAX]; -extern uint16_t tmp_data[TMP_DATA_SIZE]; +extern struct gluten gluten; int target(); pid_t do_clone(int (*fn)(void *), void *arg); @@ -48,5 +82,5 @@ int install_notification_filter(struct args_target *at); void continue_target(); void mock_syscall_target(); void set_args_no_check(struct args_target *at); - +void check_target_result_nonegative(); #endif /* TESTUTIL_H */ |