aboutgitcodelistschat:MatrixIRC
path: root/tests/unit/testutil.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/testutil.h')
-rw-r--r--tests/unit/testutil.h40
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 */