Skip to content

Commit 0350264

Browse files
Xu KuohaiNobody
authored andcommitted
selftests/bpf: Update btf_dump case for conflict FWD and STRUCT name
Update btf_dump test case for conflict FWD and STRUCT name. Signed-off-by: Xu Kuohai <[email protected]>
1 parent 9b89fc5 commit 0350264

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ static void test_btf_dump_incremental(void)
150150
*
151151
* enum { VAL = 1 };
152152
*
153+
* struct s;
154+
*
153155
* struct s { int x; };
154156
*
155157
*/
@@ -161,8 +163,11 @@ static void test_btf_dump_incremental(void)
161163
id = btf__add_int(btf, "int", 4, BTF_INT_SIGNED);
162164
ASSERT_EQ(id, 2, "int_id");
163165

166+
id = btf__add_fwd(btf, "s", BTF_FWD_STRUCT);
167+
ASSERT_EQ(id, 3, "fwd_id");
168+
164169
id = btf__add_struct(btf, "s", 4);
165-
ASSERT_EQ(id, 3, "struct_id");
170+
ASSERT_EQ(id, 4, "struct_id");
166171
err = btf__add_field(btf, "x", 2, 0, 0);
167172
ASSERT_OK(err, "field_ok");
168173

@@ -178,6 +183,8 @@ static void test_btf_dump_incremental(void)
178183
" VAL = 1,\n"
179184
"};\n"
180185
"\n"
186+
"struct s;\n"
187+
"\n"
181188
"struct s {\n"
182189
" int x;\n"
183190
"};\n\n", "c_dump1");
@@ -199,7 +206,7 @@ static void test_btf_dump_incremental(void)
199206
fseek(dump_buf_file, 0, SEEK_SET);
200207

201208
id = btf__add_struct(btf, "s", 4);
202-
ASSERT_EQ(id, 4, "struct_id");
209+
ASSERT_EQ(id, 5, "struct_id");
203210
err = btf__add_field(btf, "x", 1, 0, 0);
204211
ASSERT_OK(err, "field_ok");
205212
err = btf__add_field(btf, "s", 3, 32, 0);

0 commit comments

Comments
 (0)