Commit Graph

13 Commits

Author SHA1 Message Date
Viktor Malik ddeedc820d
selftests/bpf: Replaces the usage of CHECK calls for ASSERTs in bpf_obj_id
JIRA: https://issues.redhat.com/browse/RHEL-23644

commit f125d09b99fc0ee43f865810390f10b8f23a2c98
Author: Yuran Pereira <yuran.pereira@hotmail.com>
Date:   Tue Nov 21 05:39:25 2023 +0530

    selftests/bpf: Replaces the usage of CHECK calls for ASSERTs in bpf_obj_id
    
    bpf_obj_id uses the `CHECK` calls even though the use of
    ASSERT_ series of macros is preferred in the bpf selftests.
    
    This patch replaces all `CHECK` calls for equivalent `ASSERT_`
    macro calls.
    
    Signed-off-by: Yuran Pereira <yuran.pereira@hotmail.com>
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/bpf/GV1PR10MB65639AA3A10B4BBAA79952C7E8BBA@GV1PR10MB6563.EURPRD10.PROD.OUTLOOK.COM

Signed-off-by: Viktor Malik <vmalik@redhat.com>
2024-06-25 10:51:55 +02:00
Viktor Malik 7a4a8ac4be selftests/bpf: Use bpf_{btf,link,map,prog}_get_info_by_fd()
Bugzilla: https://bugzilla.redhat.com/2178930

commit c5a237a4db21ca7a28518c994def39d7bd62a0d1
Author: Ilya Leoshkevich <iii@linux.ibm.com>
Date:   Wed Feb 15 00:12:18 2023 +0100

    selftests/bpf: Use bpf_{btf,link,map,prog}_get_info_by_fd()
    
    Use the new type-safe wrappers around bpf_obj_get_info_by_fd().
    Fix a prog/map mixup in prog_holds_map().
    
    Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/bpf/20230214231221.249277-6-iii@linux.ibm.com

Signed-off-by: Viktor Malik <vmalik@redhat.com>
2023-06-13 22:45:39 +02:00
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
Artem Savkov 4e70663590 selftests/bpf: Stop using bpf_object__find_program_by_title API.
Bugzilla: https://bugzilla.redhat.com/2069046

Upstream Status: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

commit a393ea80a22a9beffdc9a527bd2f9f270e7a0c6e
Author: Kui-Feng Lee <kuifeng@fb.com>
Date:   Mon Dec 13 19:59:28 2021 -0800

    selftests/bpf: Stop using bpf_object__find_program_by_title API.

    bpf_object__find_program_by_title is going to be deprecated.  Replace
    all use cases in tools/testing/selftests/bpf with
    bpf_object__find_program_by_name or bpf_object__for_each_program.

    Signed-off-by: Kui-Feng Lee <kuifeng@fb.com>
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/bpf/20211214035931.1148209-2-kuifeng@fb.com

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2022-08-24 12:53:48 +02:00
Artem Savkov 15a59583f8 selftests/bpf: Use explicit bpf_prog_test_load() calls everywhere
Bugzilla: https://bugzilla.redhat.com/2069046

Upstream Status: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

commit cbdb1461dcf45765a036e9f6975ffe19e69bdc33
Author: Andrii Nakryiko <andrii@kernel.org>
Date:   Wed Nov 3 15:08:44 2021 -0700

    selftests/bpf: Use explicit bpf_prog_test_load() calls everywhere

    -Dbpf_prog_load_deprecated=bpf_prog_test_load trick is both ugly and
    breaks when deprecation goes into effect due to macro magic. Convert all
    the uses to explicit bpf_prog_test_load() calls which avoid deprecation
    errors and makes everything less magical.

    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Acked-by: Dave Marchevsky <davemarchevsky@fb.com>
    Link: https://lore.kernel.org/bpf/20211103220845.2676888-12-andrii@kernel.org

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2022-08-24 12:53:33 +02:00
Yauheni Kaliuta 5db2ed5228 selfetest/bpf: Make some tests serial
Bugzilla: http://bugzilla.redhat.com/2069045

commit d3f7b1664d3ebd69751327f45f5cd4adfb29f620
Author: Yucong Sun <sunyucong@gmail.com>
Date:   Wed Oct 6 11:56:19 2021 -0700

    selfetest/bpf: Make some tests serial
    
    Change tests that often fails in parallel execution mode to serial.
    
    Signed-off-by: Yucong Sun <sunyucong@gmail.com>
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/bpf/20211006185619.364369-15-fallentree@fb.com

Signed-off-by: Yauheni Kaliuta <ykaliuta@redhat.com>
2022-06-03 17:23:41 +03:00
Andrii Nakryiko 9028bbcc3e selftest/bpf: Fix compilation warnings in 32-bit mode
Fix compilation warnings emitted when compiling selftests for 32-bit platform
(x86 in my case).

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200813204945.1020225-3-andriin@fb.com
2020-08-13 16:45:41 -07:00
Andrii Nakryiko 2c2837b09e selftests/bpf: Test bpf_link's get_next_id, get_fd_by_id, and get_obj_info
Extend bpf_obj_id selftest to verify bpf_link's observability APIs.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200429001614.1544-7-andriin@fb.com
2020-04-28 17:27:08 -07:00
Stanislav Fomichev 62d69f24fe selftests/bpf: test_progs: remove asserts from subtests
Otherwise they can bring the whole process down.

Cc: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Stanislav Fomichev <sdf@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2019-08-28 00:35:40 +02:00
Stanislav Fomichev d38835b75f selftests/bpf: test_progs: remove global fail/success counts
Now that we have a global per-test/per-environment state, there
is no longer need to have global fail/success counters (and there
is no need to save/get the diff before/after the test).

Introduce CHECK_FAIL macro (suggested by Andrii) and covert existing tests
to it. CHECK_FAIL uses new test__fail() to record the failure.

Cc: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Stanislav Fomichev <sdf@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2019-08-28 00:35:40 +02:00
Andrii Nakryiko 0ff97e56c0 selftests/bpf: abstract away test log output
This patch changes how test output is printed out. By default, if test
had no errors, the only output will be a single line with test number,
name, and verdict at the end, e.g.:

  #31 xdp:OK

If test had any errors, all log output captured during test execution
will be output after test completes.

It's possible to force output of log with `-v` (`--verbose`) option, in
which case output won't be buffered and will be output immediately.

To support this, individual tests are required to use helper methods for
logging: `test__printf()` and `test__vprintf()`.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2019-07-27 22:36:19 -07:00
Stanislav Fomichev a918b03e8c selftests: bpf: fix -Wformat-invalid-specifier for bpf_obj_id.c
Use standard C99 %zu for sizeof, not GCC's custom %Zu:
bpf_obj_id.c:76:48: warning: invalid conversion specifier 'Z'

Signed-off-by: Stanislav Fomichev <sdf@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2019-04-02 23:17:18 +02:00
Stanislav Fomichev 886225bb08 selftests: bpf: break up test_progs - misc
Move the rest of prog tests into separate files.

Signed-off-by: Stanislav Fomichev <sdf@google.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2019-03-02 11:10:40 -08:00