aboutgitcodelistschat:MatrixIRC
path: root/tests/unit/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/util.c')
-rw-r--r--tests/unit/util.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/unit/util.c b/tests/unit/util.c
index 66448bb..4fee6e7 100644
--- a/tests/unit/util.c
+++ b/tests/unit/util.c
@@ -293,3 +293,17 @@ void ck_error_msg(char *s)
ck_assert_msg(strstr(stderr_buff, s) != NULL, "err=\"%s\" doesn't contain \"%s\" ",
stderr_buff, s);
}
+
+int read_filter(struct sock_filter filter[], char *file)
+{
+ int fd, n;
+
+ fd = open(file, O_CLOEXEC | O_RDONLY);
+ ck_assert_int_ge(fd, 0);
+
+ n = read(fd, filter, sizeof(struct sock_filter) * MAX_FILTER);
+ ck_assert_int_ge(n, 0);
+ close(fd);
+
+ return n / sizeof(struct sock_filter);
+}