From: Yonghong Song <yhs@fb.com>
To: <bpf@vger.kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>, <kernel-team@fb.com>
Subject: [PATCH bpf-next 2/5] selftests/bpf: add BTF_KIND_DECL_TAG typedef unit tests
Date: Thu, 21 Oct 2021 12:56:33 -0700 [thread overview]
Message-ID: <20211021195633.4019472-1-yhs@fb.com> (raw)
In-Reply-To: <20211021195622.4018339-1-yhs@fb.com>
Test good and bad variants of typedef BTF_KIND_DECL_TAG encoding.
Signed-off-by: Yonghong Song <yhs@fb.com>
---
tools/testing/selftests/bpf/prog_tests/btf.c | 36 ++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/tools/testing/selftests/bpf/prog_tests/btf.c b/tools/testing/selftests/bpf/prog_tests/btf.c
index fa67f25bbef5..a00418b8b252 100644
--- a/tools/testing/selftests/bpf/prog_tests/btf.c
+++ b/tools/testing/selftests/bpf/prog_tests/btf.c
@@ -3903,6 +3903,42 @@ static struct btf_raw_test raw_tests[] = {
.btf_load_err = true,
.err_str = "Invalid component_idx",
},
+{
+ .descr = "decl_tag test #13, typedef, well-formed",
+ .raw_types = {
+ BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
+ BTF_TYPEDEF_ENC(NAME_TBD, 1), /* [2] */
+ BTF_DECL_TAG_ENC(NAME_TBD, 2, -1),
+ BTF_END_RAW,
+ },
+ BTF_STR_SEC("\0t\0tag"),
+ .map_type = BPF_MAP_TYPE_ARRAY,
+ .map_name = "tag_type_check_btf",
+ .key_size = sizeof(int),
+ .value_size = 4,
+ .key_type_id = 1,
+ .value_type_id = 1,
+ .max_entries = 1,
+},
+{
+ .descr = "decl_tag test #14, typedef, invalid component_idx",
+ .raw_types = {
+ BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
+ BTF_TYPEDEF_ENC(NAME_TBD, 1), /* [2] */
+ BTF_DECL_TAG_ENC(NAME_TBD, 2, 0),
+ BTF_END_RAW,
+ },
+ BTF_STR_SEC("\0local\0tag"),
+ .map_type = BPF_MAP_TYPE_ARRAY,
+ .map_name = "tag_type_check_btf",
+ .key_size = sizeof(int),
+ .value_size = 4,
+ .key_type_id = 1,
+ .value_type_id = 1,
+ .max_entries = 1,
+ .btf_load_err = true,
+ .err_str = "Invalid component_idx",
+},
}; /* struct btf_raw_test raw_tests[] */
--
2.30.2
next prev parent reply other threads:[~2021-10-21 19:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-21 19:56 [PATCH bpf-next 0/5] bpf: add support for BTF_KIND_DECL_TAG typedef Yonghong Song
2021-10-21 19:56 ` [PATCH bpf-next 1/5] bpf: add BTF_KIND_DECL_TAG typedef support Yonghong Song
2021-10-21 19:56 ` Yonghong Song [this message]
2021-10-21 19:56 ` [PATCH bpf-next 3/5] selftests/bpf: test deduplication for BTF_KIND_DECL_TAG typedef Yonghong Song
2021-10-21 19:56 ` [PATCH bpf-next 4/5] selftests/bpf: add BTF_KIND_DECL_TAG typedef example in tag.c Yonghong Song
2021-10-21 19:56 ` [PATCH bpf-next 5/5] docs/bpf: update documentation for BTF_KIND_DECL_TAG typedef support Yonghong Song
2021-10-23 0:05 ` [PATCH bpf-next 0/5] bpf: add support for BTF_KIND_DECL_TAG typedef Alexei Starovoitov
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=20211021195633.4019472-1-yhs@fb.com \
--to=yhs@fb.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@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