Skip to content

Commit 2c1e7f7

Browse files
committed
selftests/bpf: Fix testing BTF dump of struct data on 32-bit
Allow the test dumping BTF of 'struct file_operations' to succeed on 32-bit targets by accounting for varying pointer size in the expected dump output. This avoids failures in test_progs like: [...] test_btf_dump_struct_data:FAIL:file_operations unexpected file_operations: actual '(struct file_operations){ .owner = (struct module *)0xffffffff, .fop_flags = (fop_flags_t)4294967295, .llsee' != expected '(struct file_operations){ .owner = (struct module *)0xffffffffffffffff, .fop_flags = (fop_flags_t)4294967295,' [...] torvalds#31/15 btf_dump/btf_dump: struct_data:FAIL Fixes: 70a9241 ("selftests/bpf: Add dump type data tests to btf dump tests") Signed-off-by: Tony Ambardar <[email protected]>
1 parent 8568bad commit 2c1e7f7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,9 +721,15 @@ static void test_btf_dump_struct_data(struct btf *btf, struct btf_dump *d,
721721
ret = btf_dump__dump_type_data(d, type_id, fops, type_sz, &opts);
722722
ASSERT_EQ(ret, type_sz,
723723
"unexpected return value dumping file_operations");
724+
725+
/* account for host word-size in expected string*/
724726
cmpstr =
725727
"(struct file_operations){\n"
728+
#if __SIZEOF_LONG__ == 8
726729
" .owner = (struct module *)0xffffffffffffffff,\n"
730+
#else
731+
" .owner = (struct module *)0xffffffff,\n"
732+
#endif
727733
" .fop_flags = (fop_flags_t)4294967295,";
728734

729735
ASSERT_STRNEQ(str, cmpstr, strlen(cmpstr), "file_operations");

0 commit comments

Comments
 (0)