On Fri, Mar 5, 2021 at 9:12 AM Ilya Leoshkevich <iii@xxxxxxxxxxxxx> wrote: > > Verify that bpf_core_field_size() is working correctly with floats. > Also document the required clang version. > > Suggested-by: John Fastabend <john.fastabend@xxxxxxxxx> > Signed-off-by: Ilya Leoshkevich <iii@xxxxxxxxxxxxx> > --- > tools/testing/selftests/bpf/README.rst | 9 +++++++++ > tools/testing/selftests/bpf/prog_tests/core_reloc.c | 1 + > tools/testing/selftests/bpf/progs/core_reloc_types.h | 5 +++++ > tools/testing/selftests/bpf/progs/test_core_reloc_size.c | 3 +++ > 4 files changed, 18 insertions(+) > [...] > diff --git a/tools/testing/selftests/bpf/progs/core_reloc_types.h b/tools/testing/selftests/bpf/progs/core_reloc_types.h > index 9a2850850121..3a2149c5863c 100644 > --- a/tools/testing/selftests/bpf/progs/core_reloc_types.h > +++ b/tools/testing/selftests/bpf/progs/core_reloc_types.h > @@ -807,6 +807,7 @@ struct core_reloc_size_output { > int arr_elem_sz; > int ptr_sz; > int enum_sz; > + int float_sz; > }; > > struct core_reloc_size { > @@ -816,6 +817,7 @@ struct core_reloc_size { > int arr_field[4]; > void *ptr_field; > enum { VALUE = 123 } enum_field; > + float float_field; > }; > > struct core_reloc_size___diff_sz { > @@ -825,6 +827,7 @@ struct core_reloc_size___diff_sz { > char arr_field[10]; > void *ptr_field; > enum { OTHER_VALUE = 0xFFFFFFFFFFFFFFFF } enum_field; > + float float_field; here the point is to test differently sized field, so it would be good to have `double float_field;` instead > }; > > /* Error case of two candidates with the fields (int_field) at the same > @@ -839,6 +842,7 @@ struct core_reloc_size___err_ambiguous1 { > int arr_field[4]; > void *ptr_field; > enum { VALUE___1 = 123 } enum_field; > + float float_field; > }; > > struct core_reloc_size___err_ambiguous2 { > @@ -850,6 +854,7 @@ struct core_reloc_size___err_ambiguous2 { > int arr_field[4]; > void *ptr_field; > enum { VALUE___2 = 123 } enum_field; > + float float_field; > }; > > /* [...]