From ea0bdcf104654ec45d4a32055a4fb2573613ea16 Mon Sep 17 00:00:00 2001 From: Alice Frosi Date: Fri, 19 May 2023 16:53:53 +0200 Subject: filter: adjust filter build Add filter_flush_args() to flush the arguments when finish to add the syscall arguments. Fixed test compilation after refactoring. --- tests/unit/util.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests/unit/util.c') 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); +} -- cgit v1.2.3