Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

authored by

Alan Maguire and committed by
Andrii Nakryiko
17283337 920d16af

+12
+12
tools/testing/selftests/bpf/test_progs.h
··· 221 221 ___ok; \ 222 222 }) 223 223 224 + #define ASSERT_STRNEQ(actual, expected, len, name) ({ \ 225 + static int duration = 0; \ 226 + const char *___act = actual; \ 227 + const char *___exp = expected; \ 228 + int ___len = len; \ 229 + bool ___ok = strncmp(___act, ___exp, ___len) == 0; \ 230 + CHECK(!___ok, (name), \ 231 + "unexpected %s: actual '%.*s' != expected '%.*s'\n", \ 232 + (name), ___len, ___act, ___len, ___exp); \ 233 + ___ok; \ 234 + }) 235 + 224 236 #define ASSERT_OK(res, name) ({ \ 225 237 static int duration = 0; \ 226 238 long long ___res = (res); \