Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/bpf: Remove too strict field offset relo test cases

As libbpf is going to gain support for more field relocations, including field
size, some restrictions about exact size match are going to be lifted. Remove
test cases that explicitly test such failures.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20191101222810.1246166-2-andriin@fb.com

authored by

Andrii Nakryiko and committed by
Daniel Borkmann
42765ede 1574cf83

+4 -90
+3
tools/testing/selftests/bpf/progs/btf__core_reloc_arrays___err_wrong_val_type.c
··· 1 + #include "core_reloc_types.h" 2 + 3 + void f(struct core_reloc_arrays___err_wrong_val_type x) {}
-3
tools/testing/selftests/bpf/progs/btf__core_reloc_arrays___err_wrong_val_type1.c
··· 1 - #include "core_reloc_types.h" 2 - 3 - void f(struct core_reloc_arrays___err_wrong_val_type1 x) {}
-3
tools/testing/selftests/bpf/progs/btf__core_reloc_arrays___err_wrong_val_type2.c
··· 1 - #include "core_reloc_types.h" 2 - 3 - void f(struct core_reloc_arrays___err_wrong_val_type2 x) {}
-3
tools/testing/selftests/bpf/progs/btf__core_reloc_ints___err_bitfield.c
··· 1 - #include "core_reloc_types.h" 2 - 3 - void f(struct core_reloc_ints___err_bitfield x) {}
-3
tools/testing/selftests/bpf/progs/btf__core_reloc_ints___err_wrong_sz_16.c
··· 1 - #include "core_reloc_types.h" 2 - 3 - void f(struct core_reloc_ints___err_wrong_sz_16 x) {}
-3
tools/testing/selftests/bpf/progs/btf__core_reloc_ints___err_wrong_sz_32.c
··· 1 - #include "core_reloc_types.h" 2 - 3 - void f(struct core_reloc_ints___err_wrong_sz_32 x) {}
-3
tools/testing/selftests/bpf/progs/btf__core_reloc_ints___err_wrong_sz_64.c
··· 1 - #include "core_reloc_types.h" 2 - 3 - void f(struct core_reloc_ints___err_wrong_sz_64 x) {}
-3
tools/testing/selftests/bpf/progs/btf__core_reloc_ints___err_wrong_sz_8.c
··· 1 - #include "core_reloc_types.h" 2 - 3 - void f(struct core_reloc_ints___err_wrong_sz_8 x) {}
+1 -69
tools/testing/selftests/bpf/progs/core_reloc_types.h
··· 386 386 struct core_reloc_arrays_substruct d[1][2]; 387 387 }; 388 388 389 - struct core_reloc_arrays___err_wrong_val_type1 { 390 - char a[5]; /* char instead of int */ 391 - char b[2][3][4]; 392 - struct core_reloc_arrays_substruct c[3]; 393 - struct core_reloc_arrays_substruct d[1][2]; 394 - }; 395 - 396 - struct core_reloc_arrays___err_wrong_val_type2 { 389 + struct core_reloc_arrays___err_wrong_val_type { 397 390 int a[5]; 398 391 char b[2][3][4]; 399 392 int c[3]; /* value is not a struct */ ··· 580 587 int32_t s32_field; 581 588 uint64_t u64_field; 582 589 int64_t s64_field; 583 - }; 584 - 585 - struct core_reloc_ints___err_bitfield { 586 - uint8_t u8_field; 587 - int8_t s8_field; 588 - uint16_t u16_field; 589 - int16_t s16_field; 590 - uint32_t u32_field: 32; /* bitfields are not supported */ 591 - int32_t s32_field; 592 - uint64_t u64_field; 593 - int64_t s64_field; 594 - }; 595 - 596 - struct core_reloc_ints___err_wrong_sz_8 { 597 - uint16_t u8_field; /* not 8-bit anymore */ 598 - int16_t s8_field; /* not 8-bit anymore */ 599 - 600 - uint16_t u16_field; 601 - int16_t s16_field; 602 - uint32_t u32_field; 603 - int32_t s32_field; 604 - uint64_t u64_field; 605 - int64_t s64_field; 606 - }; 607 - 608 - struct core_reloc_ints___err_wrong_sz_16 { 609 - uint8_t u8_field; 610 - int8_t s8_field; 611 - 612 - uint32_t u16_field; /* not 16-bit anymore */ 613 - int32_t s16_field; /* not 16-bit anymore */ 614 - 615 - uint32_t u32_field; 616 - int32_t s32_field; 617 - uint64_t u64_field; 618 - int64_t s64_field; 619 - }; 620 - 621 - struct core_reloc_ints___err_wrong_sz_32 { 622 - uint8_t u8_field; 623 - int8_t s8_field; 624 - uint16_t u16_field; 625 - int16_t s16_field; 626 - 627 - uint64_t u32_field; /* not 32-bit anymore */ 628 - int64_t s32_field; /* not 32-bit anymore */ 629 - 630 - uint64_t u64_field; 631 - int64_t s64_field; 632 - }; 633 - 634 - struct core_reloc_ints___err_wrong_sz_64 { 635 - uint8_t u8_field; 636 - int8_t s8_field; 637 - uint16_t u16_field; 638 - int16_t s16_field; 639 - uint32_t u32_field; 640 - int32_t s32_field; 641 - 642 - uint32_t u64_field; /* not 64-bit anymore */ 643 - int32_t s64_field; /* not 64-bit anymore */ 644 590 }; 645 591 646 592 /*