• Martin KaFai Lau's avatar
    bpf: Refactor and bug fix in test_func_type in test_btf.c · 05687352
    Martin KaFai Lau authored
    1) bpf_load_program_xattr() is absorbing the EBIG error
       which makes testing this case impossible.  It is replaced
       with a direct syscall(__NR_bpf, BPF_PROG_LOAD,...).
    2) The test_func_type() is renamed to test_info_raw() to
       prepare for the new line_info test in the next patch.
    3) The bpf_obj_get_info_by_fd() testing for func_info
       is refactored to test_get_finfo().  A new
       test_get_linfo() will be added in the next patch
       for testing line_info purpose.
    4) The test->func_info_cnt is checked instead of
       a static value "2".
    5) Remove unnecessary "\n" in error message.
    6) Adding back info_raw_test_num to the cmd arg such
       that a specific test case can be tested, like
       all other existing tests.
    
    7) Fix a bug in handling expected_prog_load_failure.
       A test could pass even if prog_fd != -1 while
       expected_prog_load_failure is true.
    8) The min rec_size check should be < 8 instead of < 4.
    
    Fixes: 4798c4ba ("tools/bpf: extends test_btf to test load/retrieve func_type info")
    Signed-off-by: default avatarMartin KaFai Lau <kafai@fb.com>
    Acked-by: default avatarYonghong Song <yhs@fb.com>
    Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    05687352
test_btf.c 85.9 KB