Skip to content

Commit

Permalink
selftests/bpf: fix btf_dedup testing code
Browse files Browse the repository at this point in the history
btf_dedup testing code doesn't account for length of struct btf_header
when calculating the start of a string section. This patch fixes this
problem.

Fixes: 49b57e0 ("tools/bpf: remove btf__get_strings() superseded by raw data API")
Signed-off-by: Andrii Nakryiko <[email protected]>
Acked-by: Song Liu <[email protected]>
Acked-by: Yonghong Song <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
  • Loading branch information
anakryiko authored and borkmann committed Mar 1, 2019
1 parent 3d8669e commit 8054d51
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions tools/testing/selftests/bpf/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ feature
test_libbpf_open
test_sock
test_sock_addr
test_sock_fields
urandom_read
test_btf
test_sockmap
Expand Down
4 changes: 2 additions & 2 deletions tools/testing/selftests/bpf/test_btf.c
Original file line number Diff line number Diff line change
Expand Up @@ -5936,9 +5936,9 @@ static int do_test_dedup(unsigned int test_num)
}

test_hdr = test_btf_data;
test_strs = test_btf_data + test_hdr->str_off;
test_strs = test_btf_data + sizeof(*test_hdr) + test_hdr->str_off;
expect_hdr = expect_btf_data;
expect_strs = expect_btf_data + expect_hdr->str_off;
expect_strs = expect_btf_data + sizeof(*test_hdr) + expect_hdr->str_off;
if (CHECK(test_hdr->str_len != expect_hdr->str_len,
"test_hdr->str_len:%u != expect_hdr->str_len:%u",
test_hdr->str_len, expect_hdr->str_len)) {
Expand Down

0 comments on commit 8054d51

Please sign in to comment.