Commit Graph

5 Commits

Author SHA1 Message Date
Artem Savkov fbd9cfcd5b selftests/bpf: Store BPF object files with .bpf.o extension
Bugzilla: https://bugzilla.redhat.com/2166911

commit afef88e65554c3e8691513b8350d6445e292560e
Author: Daniel Müller <deso@posteo.net>
Date:   Thu Sep 1 22:22:53 2022 +0000

    selftests/bpf: Store BPF object files with .bpf.o extension
    
    BPF object files are, in a way, the final artifact produced as part of
    the ahead-of-time compilation process. That makes them somewhat special
    compared to "regular" object files, which are a intermediate build
    artifacts that can typically be removed safely. As such, it can make
    sense to name them differently to make it easier to spot this difference
    at a glance.
    
    Among others, libbpf-bootstrap [0] has established the extension .bpf.o
    for BPF object files. It seems reasonable to follow this example and
    establish the same denomination for selftest build artifacts. To that
    end, this change adjusts the corresponding part of the build system and
    the test programs loading BPF object files to work with .bpf.o files.
    
      [0] https://github.com/libbpf/libbpf-bootstrap
    
    Suggested-by: Andrii Nakryiko <andrii@kernel.org>
    Signed-off-by: Daniel Müller <deso@posteo.net>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Link: https://lore.kernel.org/bpf/20220901222253.1199242-1-deso@posteo.net

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2023-03-06 14:54:06 +01:00
Yauheni Kaliuta c0db35c594 selftests/bpf: Use __BYTE_ORDER__
Bugzilla: http://bugzilla.redhat.com/2069045

commit 06fca841fb64c9ed499a3575a530014268d0251a
Author: Ilya Leoshkevich <iii@linux.ibm.com>
Date:   Tue Oct 26 03:08:28 2021 +0200

    selftests/bpf: Use __BYTE_ORDER__
    
    Use the compiler-defined __BYTE_ORDER__ instead of the libc-defined
    __BYTE_ORDER for consistency.
    
    Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/bpf/20211026010831.748682-4-iii@linux.ibm.com

Signed-off-by: Yauheni Kaliuta <ykaliuta@redhat.com>
2022-06-03 17:23:47 +03:00
Yauheni Kaliuta 0946d363ca selftests/bpf: Switch to new btf__type_cnt/btf__raw_data APIs
Bugzilla: http://bugzilla.redhat.com/2069045

commit 487ef148cf17730442444c07a4c56f16578ec73e
Author: Hengqi Chen <hengqi.chen@gmail.com>
Date:   Fri Oct 22 21:06:23 2021 +0800

    selftests/bpf: Switch to new btf__type_cnt/btf__raw_data APIs
    
    Replace the calls to btf__get_nr_types/btf__get_raw_data in
    selftests with new APIs btf__type_cnt/btf__raw_data. The old
    APIs will be deprecated in libbpf v0.7+.
    
    Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com>
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/bpf/20211022130623.1548429-6-hengqi.chen@gmail.com

Signed-off-by: Yauheni Kaliuta <ykaliuta@redhat.com>
2022-06-03 17:23:45 +03:00
Andrii Nakryiko 7a2fa70aaf selftests/bpf: Add remaining ASSERT_xxx() variants
Add ASSERT_TRUE/ASSERT_FALSE for conditions calculated with custom logic to
true/false. Also add remaining arithmetical assertions:
  - ASSERT_LE -- less than or equal;
  - ASSERT_GT -- greater than;
  - ASSERT_GE -- greater than or equal.
This should cover most scenarios where people fall back to error-prone
CHECK()s.

Also extend ASSERT_ERR() to print out errno, in addition to direct error.

Also convert few CHECK() instances to ensure new ASSERT_xxx() variants work as
expected. Subsequent patch will also use ASSERT_TRUE/ASSERT_FALSE more
extensively.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Lorenz Bauer <lmb@cloudflare.com>
Link: https://lore.kernel.org/bpf/20210426192949.416837-2-andrii@kernel.org
2021-04-26 18:37:13 -07:00
Andrii Nakryiko ed9cf248b9 selftests/bpf: Test BTF's handling of endianness
Add selftests juggling endianness back and forth to validate BTF's handling of
endianness convertions internally.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200929043046.1324350-4-andriin@fb.com
2020-09-29 12:21:23 -07:00