diff options
author | Alice Frosi <afrosi@redhat.com> | 2023-06-30 11:22:52 +0200 |
---|---|---|
committer | Alice Frosi <afrosi@redhat.com> | 2023-07-03 17:28:33 +0200 |
commit | 876a52e95a9d24a4b9fa37325d83bcb7d3c7b160 (patch) | |
tree | 69edae1a49a42fb9abdf749797d8286b16c2ca3e /tests/unit/util.c | |
parent | 06791d85cff567ff038ececc19d6e775dab84840 (diff) | |
download | seitan-876a52e95a9d24a4b9fa37325d83bcb7d3c7b160.tar seitan-876a52e95a9d24a4b9fa37325d83bcb7d3c7b160.tar.gz seitan-876a52e95a9d24a4b9fa37325d83bcb7d3c7b160.tar.bz2 seitan-876a52e95a9d24a4b9fa37325d83bcb7d3c7b160.tar.lz seitan-876a52e95a9d24a4b9fa37325d83bcb7d3c7b160.tar.xz seitan-876a52e95a9d24a4b9fa37325d83bcb7d3c7b160.tar.zst seitan-876a52e95a9d24a4b9fa37325d83bcb7d3c7b160.zip |
test: fix filter-build test and bugs
The tests for checking the filter build recompile and are successfull.
Changes:
- spotted a couple of bugs for adding the arguments in the filter
- readded function `filter_flush_args` to flush_args; this is needed
to distinguish when the arguments belong to the same block or are different
entries to the same syscall
- build the filter in a way that CMP_EQ corresponds to BPF_JEQ and we
don't need to awkwardly negate the operations (still TODO for AND_EQ)
Diffstat (limited to 'tests/unit/util.c')
-rw-r--r-- | tests/unit/util.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/tests/unit/util.c b/tests/unit/util.c index 96d6663..26f13e0 100644 --- a/tests/unit/util.c +++ b/tests/unit/util.c @@ -13,6 +13,7 @@ #include <signal.h> #include <limits.h> #include <fcntl.h> +#include <stdarg.h> #include <errno.h> #include <sys/prctl.h> #include <sys/syscall.h> @@ -38,6 +39,19 @@ struct gluten gluten; char stderr_buff[BUFSIZ]; char stdout_buff[BUFSIZ]; +#define logfn(name) \ +void name(const char *format, ...) { \ + va_list args; \ + \ + va_start(args, format); \ + (void)vfprintf(stderr, format, args); \ + va_end(args); \ + if (format[strlen(format)] != '\n') \ + fprintf(stderr, "\n"); \ +} + +logfn(debug) + int install_single_syscall(long nr) { /* filter a single syscall for the tests */ @@ -209,7 +223,7 @@ void mock_syscall_target() void set_args_no_check(struct args_target *at) { for (unsigned int i = 0; i < 6; i++) - at->args[i].cmp = NO_CHECK; + at->bpf_fields[i].cmp = NO_CHECK; } static int set_ns_flags(bool ns[], int flags) @@ -217,8 +231,9 @@ static int set_ns_flags(bool ns[], int flags) unsigned int i; for (i = 0; i < NS_NUM; i++) { - if (!ns[i] || i == NS_NONE) + if (!ns[i]) continue; + switch (i) { case NS_CGROUP: flags |= CLONE_NEWCGROUP; |