mirror of
https://github.com/torvalds/linux.git
synced 2024-12-11 13:41:55 +00:00
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
This commit is contained in:
parent
920d16af9b
commit
17283337ff
@ -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); \
|
||||
|
Loading…
Reference in New Issue
Block a user