diff options
author | Alan Maguire <alan.maguire@oracle.com> | 2021-07-15 17:15:25 +0200 |
---|---|---|
committer | Andrii Nakryiko <andrii@kernel.org> | 2021-07-16 22:46:59 +0200 |
commit | 17283337ff86a1956940bc6bfb3f7dafe82304f3 (patch) | |
tree | f3989126e5c0bd1651a6b54499b26e56867cc232 /tools | |
parent | libbpf: BTF dumper support for typed data (diff) | |
download | linux-17283337ff86a1956940bc6bfb3f7dafe82304f3.tar.xz linux-17283337ff86a1956940bc6bfb3f7dafe82304f3.zip |
selftests/bpf: Add ASSERT_STRNEQ() variant for test_progs
It will support strncmp()-style string comparisons.
Suggested-by: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/1626362126-27775-3-git-send-email-alan.maguire@oracle.com
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/selftests/bpf/test_progs.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/test_progs.h b/tools/testing/selftests/bpf/test_progs.h index 8ef7f334e715..c8c2bf878f67 100644 --- a/tools/testing/selftests/bpf/test_progs.h +++ b/tools/testing/selftests/bpf/test_progs.h @@ -221,6 +221,18 @@ extern int test__join_cgroup(const char *path); ___ok; \ }) +#define ASSERT_STRNEQ(actual, expected, len, name) ({ \ + static int duration = 0; \ + const char *___act = actual; \ + const char *___exp = expected; \ + int ___len = len; \ + bool ___ok = strncmp(___act, ___exp, ___len) == 0; \ + CHECK(!___ok, (name), \ + "unexpected %s: actual '%.*s' != expected '%.*s'\n", \ + (name), ___len, ___act, ___len, ___exp); \ + ___ok; \ +}) + #define ASSERT_OK(res, name) ({ \ static int duration = 0; \ long long ___res = (res); \ |