mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 02:40:52 +07:00
selftests/bpf: Fix core_reloc test runner
[ Upstream commit bede0ebf0be87e9678103486a77f39e0334c6791 ]
Fix failed tests checks in core_reloc test runner, which allowed failing tests
to pass quietly. Also add extra check to make sure that expected to fail test cases with
invalid names are caught as test failure anyway, as this is not an expected
failure mode. Also fix mislabeled probed vs direct bitfield test cases.
Fixes: 124a892d1c
("selftests/bpf: Test TYPE_EXISTS and TYPE_SIZE CO-RE relocations")
Reported-by: Lorenz Bauer <lmb@cloudflare.com>
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-6-andrii@kernel.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
0257a0a5ff
commit
183d9ebd44
@ -192,7 +192,7 @@ static int duration = 0;
|
||||
|
||||
#define BITFIELDS_CASE(name, ...) { \
|
||||
BITFIELDS_CASE_COMMON("test_core_reloc_bitfields_probed.o", \
|
||||
"direct:", name), \
|
||||
"probed:", name), \
|
||||
.input = STRUCT_TO_CHAR_PTR(core_reloc_##name) __VA_ARGS__, \
|
||||
.input_len = sizeof(struct core_reloc_##name), \
|
||||
.output = STRUCT_TO_CHAR_PTR(core_reloc_bitfields_output) \
|
||||
@ -200,7 +200,7 @@ static int duration = 0;
|
||||
.output_len = sizeof(struct core_reloc_bitfields_output), \
|
||||
}, { \
|
||||
BITFIELDS_CASE_COMMON("test_core_reloc_bitfields_direct.o", \
|
||||
"probed:", name), \
|
||||
"direct:", name), \
|
||||
.input = STRUCT_TO_CHAR_PTR(core_reloc_##name) __VA_ARGS__, \
|
||||
.input_len = sizeof(struct core_reloc_##name), \
|
||||
.output = STRUCT_TO_CHAR_PTR(core_reloc_bitfields_output) \
|
||||
@ -495,8 +495,7 @@ static struct core_reloc_test_case test_cases[] = {
|
||||
ARRAYS_ERR_CASE(arrays___err_too_small),
|
||||
ARRAYS_ERR_CASE(arrays___err_too_shallow),
|
||||
ARRAYS_ERR_CASE(arrays___err_non_array),
|
||||
ARRAYS_ERR_CASE(arrays___err_wrong_val_type1),
|
||||
ARRAYS_ERR_CASE(arrays___err_wrong_val_type2),
|
||||
ARRAYS_ERR_CASE(arrays___err_wrong_val_type),
|
||||
ARRAYS_ERR_CASE(arrays___err_bad_zero_sz_arr),
|
||||
|
||||
/* enum/ptr/int handling scenarios */
|
||||
@ -811,13 +810,20 @@ void test_core_reloc(void)
|
||||
"prog '%s' not found\n", probe_name))
|
||||
goto cleanup;
|
||||
|
||||
|
||||
if (test_case->btf_src_file) {
|
||||
err = access(test_case->btf_src_file, R_OK);
|
||||
if (!ASSERT_OK(err, "btf_src_file"))
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
load_attr.obj = obj;
|
||||
load_attr.log_level = 0;
|
||||
load_attr.target_btf_path = test_case->btf_src_file;
|
||||
err = bpf_object__load_xattr(&load_attr);
|
||||
if (err) {
|
||||
if (!test_case->fails)
|
||||
CHECK(false, "obj_load", "failed to load prog '%s': %d\n", probe_name, err);
|
||||
ASSERT_OK(err, "obj_load");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -851,10 +857,8 @@ void test_core_reloc(void)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (test_case->fails) {
|
||||
CHECK(false, "obj_load_fail", "should fail to load prog '%s'\n", probe_name);
|
||||
if (!ASSERT_FALSE(test_case->fails, "obj_load_should_fail"))
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
equal = memcmp(data->out, test_case->output,
|
||||
test_case->output_len) == 0;
|
||||
|
Loading…
Reference in New Issue
Block a user