Skip to content

Commit 557c8c4

Browse files
yonghong-songAlexei Starovoitov
authored and
Alexei Starovoitov
committed
selftests/bpf: Test deduplication for BTF_KIND_DECL_TAG typedef
Add unit tests for deduplication of BTF_KIND_DECL_TAG to typedef types. Also changed a few comments from "tag" to "decl_tag" to match BTF_KIND_DECL_TAG enum value name. Signed-off-by: Yonghong Song <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 9d19a12 commit 557c8c4

File tree

1 file changed

+41
-6
lines changed
  • tools/testing/selftests/bpf/prog_tests

1 file changed

+41
-6
lines changed

tools/testing/selftests/bpf/prog_tests/btf.c

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6877,11 +6877,12 @@ const struct btf_dedup_test dedup_tests[] = {
68776877
BTF_FUNC_PROTO_ARG_ENC(NAME_TBD, 8),
68786878
BTF_FUNC_ENC(NAME_TBD, 12), /* [13] func */
68796879
BTF_TYPE_FLOAT_ENC(NAME_TBD, 2), /* [14] float */
6880-
BTF_DECL_TAG_ENC(NAME_TBD, 13, -1), /* [15] tag */
6881-
BTF_DECL_TAG_ENC(NAME_TBD, 13, 1), /* [16] tag */
6880+
BTF_DECL_TAG_ENC(NAME_TBD, 13, -1), /* [15] decl_tag */
6881+
BTF_DECL_TAG_ENC(NAME_TBD, 13, 1), /* [16] decl_tag */
6882+
BTF_DECL_TAG_ENC(NAME_TBD, 7, -1), /* [17] decl_tag */
68826883
BTF_END_RAW,
68836884
},
6884-
BTF_STR_SEC("\0A\0B\0C\0D\0E\0F\0G\0H\0I\0J\0K\0L\0M\0N\0O\0P"),
6885+
BTF_STR_SEC("\0A\0B\0C\0D\0E\0F\0G\0H\0I\0J\0K\0L\0M\0N\0O\0P\0Q"),
68856886
},
68866887
.expect = {
68876888
.raw_types = {
@@ -6905,11 +6906,12 @@ const struct btf_dedup_test dedup_tests[] = {
69056906
BTF_FUNC_PROTO_ARG_ENC(NAME_TBD, 8),
69066907
BTF_FUNC_ENC(NAME_TBD, 12), /* [13] func */
69076908
BTF_TYPE_FLOAT_ENC(NAME_TBD, 2), /* [14] float */
6908-
BTF_DECL_TAG_ENC(NAME_TBD, 13, -1), /* [15] tag */
6909-
BTF_DECL_TAG_ENC(NAME_TBD, 13, 1), /* [16] tag */
6909+
BTF_DECL_TAG_ENC(NAME_TBD, 13, -1), /* [15] decl_tag */
6910+
BTF_DECL_TAG_ENC(NAME_TBD, 13, 1), /* [16] decl_tag */
6911+
BTF_DECL_TAG_ENC(NAME_TBD, 7, -1), /* [17] decl_tag */
69106912
BTF_END_RAW,
69116913
},
6912-
BTF_STR_SEC("\0A\0B\0C\0D\0E\0F\0G\0H\0I\0J\0K\0L\0M\0N\0O\0P"),
6914+
BTF_STR_SEC("\0A\0B\0C\0D\0E\0F\0G\0H\0I\0J\0K\0L\0M\0N\0O\0P\0Q"),
69136915
},
69146916
.opts = {
69156917
.dont_resolve_fwds = false,
@@ -7204,6 +7206,39 @@ const struct btf_dedup_test dedup_tests[] = {
72047206
.dont_resolve_fwds = false,
72057207
},
72067208
},
7209+
{
7210+
.descr = "dedup: typedef tags",
7211+
.input = {
7212+
.raw_types = {
7213+
/* int */
7214+
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
7215+
BTF_TYPEDEF_ENC(NAME_NTH(1), 1), /* [2] */
7216+
BTF_TYPEDEF_ENC(NAME_NTH(1), 1), /* [3] */
7217+
/* tag -> t: tag1, tag2 */
7218+
BTF_DECL_TAG_ENC(NAME_NTH(2), 2, -1), /* [4] */
7219+
BTF_DECL_TAG_ENC(NAME_NTH(3), 2, -1), /* [5] */
7220+
/* tag -> t: tag1, tag3 */
7221+
BTF_DECL_TAG_ENC(NAME_NTH(2), 3, -1), /* [6] */
7222+
BTF_DECL_TAG_ENC(NAME_NTH(4), 3, -1), /* [7] */
7223+
BTF_END_RAW,
7224+
},
7225+
BTF_STR_SEC("\0t\0tag1\0tag2\0tag3"),
7226+
},
7227+
.expect = {
7228+
.raw_types = {
7229+
BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
7230+
BTF_TYPEDEF_ENC(NAME_NTH(1), 1), /* [2] */
7231+
BTF_DECL_TAG_ENC(NAME_NTH(2), 2, -1), /* [3] */
7232+
BTF_DECL_TAG_ENC(NAME_NTH(3), 2, -1), /* [4] */
7233+
BTF_DECL_TAG_ENC(NAME_NTH(4), 2, -1), /* [5] */
7234+
BTF_END_RAW,
7235+
},
7236+
BTF_STR_SEC("\0t\0tag1\0tag2\0tag3"),
7237+
},
7238+
.opts = {
7239+
.dont_resolve_fwds = false,
7240+
},
7241+
},
72077242

72087243
};
72097244

0 commit comments

Comments
 (0)