From: Alan Maguire <alan.maguire@oracle.com>
To: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org
Cc: kafai@fb.com, songliubraving@fb.com, yhs@fb.com,
john.fastabend@gmail.com, kpsingh@kernel.org, morbo@google.com,
shuah@kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
Alan Maguire <alan.maguire@oracle.com>
Subject: [PATCH v6 bpf-next 2/3] selftests/bpf: add ASSERT_STRNEQ() variant for test_progs
Date: Thu, 15 Jul 2021 16:15:25 +0100 [thread overview]
Message-ID: <1626362126-27775-3-git-send-email-alan.maguire@oracle.com> (raw)
In-Reply-To: <1626362126-27775-1-git-send-email-alan.maguire@oracle.com>
It will support strncmp()-style string comparisons.
Suggested-by: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
---
tools/testing/selftests/bpf/test_progs.h | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/tools/testing/selftests/bpf/test_progs.h b/tools/testing/selftests/bpf/test_progs.h
index 8ef7f33..c8c2bf8 100644
--- a/tools/testing/selftests/bpf/test_progs.h
+++ b/tools/testing/selftests/bpf/test_progs.h
@@ -221,6 +221,18 @@ struct test_env {
___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); \
--
1.8.3.1
next prev parent reply other threads:[~2021-07-15 15:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-15 15:15 [PATCH v6 bpf-next 0/3] libbpf: BTF dumper support for typed data Alan Maguire
2021-07-15 15:15 ` [PATCH v6 bpf-next 1/3] " Alan Maguire
2021-07-16 6:24 ` Andrii Nakryiko
2021-07-16 20:55 ` Andrii Nakryiko
2021-07-16 21:58 ` Andrii Nakryiko
2021-07-19 12:11 ` Naresh Kamboju
2021-07-19 14:15 ` Alan Maguire
2021-07-15 15:15 ` Alan Maguire [this message]
2021-07-15 15:15 ` [PATCH v6 bpf-next 3/3] selftests/bpf: add dump type data tests to btf dump tests Alan Maguire
2021-07-16 6:24 ` Andrii Nakryiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1626362126-27775-3-git-send-email-alan.maguire@oracle.com \
--to=alan.maguire@oracle.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=morbo@google.com \
--cc=netdev@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=songliubraving@fb.com \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).