Commit 17283337 authored by Alan Maguire's avatar Alan Maguire Committed by Andrii Nakryiko

selftests/bpf: Add ASSERT_STRNEQ() variant for test_progs

It will support strncmp()-style string comparisons.
Suggested-by: default avatarAndrii Nakryiko <andrii.nakryiko@gmail.com>
Signed-off-by: default avatarAlan Maguire <alan.maguire@oracle.com>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/1626362126-27775-3-git-send-email-alan.maguire@oracle.com
parent 920d16af
......@@ -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); \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment