OSDN Git Service

selftests/bpf: Add bpf_read_branch_records() selftest
authorDaniel Xu <dxu@dxuuu.xyz>
Tue, 18 Feb 2020 03:04:32 +0000 (19:04 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 19 Feb 2020 23:01:07 +0000 (15:01 -0800)
commit67306f84ca78c2ca5136f21791710c126a55a19b
tree9017e0f53548a512619ec8dc4ffd13f2c5a37540
parentfff7b64355eac6e29b50229ad1512315bc04b44e
selftests/bpf: Add bpf_read_branch_records() selftest

Add a selftest to test:

* default bpf_read_branch_records() behavior
* BPF_F_GET_BRANCH_RECORDS_SIZE flag behavior
* error path on non branch record perf events
* using helper to write to stack
* using helper to write to global

On host with hardware counter support:

    # ./test_progs -t perf_branches
    #27/1 perf_branches_hw:OK
    #27/2 perf_branches_no_hw:OK
    #27 perf_branches:OK
    Summary: 1/2 PASSED, 0 SKIPPED, 0 FAILED

On host without hardware counter support (VM):

    # ./test_progs -t perf_branches
    #27/1 perf_branches_hw:OK
    #27/2 perf_branches_no_hw:OK
    #27 perf_branches:OK
    Summary: 1/2 PASSED, 1 SKIPPED, 0 FAILED

Also sync tools/include/uapi/linux/bpf.h.

Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/20200218030432.4600-3-dxu@dxuuu.xyz
tools/include/uapi/linux/bpf.h
tools/testing/selftests/bpf/prog_tests/perf_branches.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/test_perf_branches.c [new file with mode: 0644]