mirror of https://gitee.com/openkylin/linux.git
selftests: bpf: Make reuseport test output more legible
Include the name of the mismatching result in human readable format when reporting an error. The new output looks like the following: unexpected result result: [1, 0, 0, 0, 0, 0] expected: [0, 0, 0, 0, 0, 0] mismatch on DROP_ERR_INNER_MAP (bpf_prog_linum:153) check_results:FAIL:382 Signed-off-by: Lorenz Bauer <lmb@cloudflare.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Reviewed-by: Jakub Sitnicki <jakub@cloudflare.com> Acked-by: Martin KaFai Lau <kafai@fb.com> Acked-by: John Fastabend <john.fastabend@gmail.com> Link: https://lore.kernel.org/bpf/20200124112754.19664-4-lmb@cloudflare.com
This commit is contained in:
parent
8bec4f665e
commit
603fba9dfd
|
@ -316,6 +316,26 @@ static void check_data(int type, sa_family_t family, const struct cmd *cmd,
|
|||
expected.len, result.len, get_linum());
|
||||
}
|
||||
|
||||
static const char *result_to_str(enum result res)
|
||||
{
|
||||
switch (res) {
|
||||
case DROP_ERR_INNER_MAP:
|
||||
return "DROP_ERR_INNER_MAP";
|
||||
case DROP_ERR_SKB_DATA:
|
||||
return "DROP_ERR_SKB_DATA";
|
||||
case DROP_ERR_SK_SELECT_REUSEPORT:
|
||||
return "DROP_ERR_SK_SELECT_REUSEPORT";
|
||||
case DROP_MISC:
|
||||
return "DROP_MISC";
|
||||
case PASS:
|
||||
return "PASS";
|
||||
case PASS_ERR_SK_SELECT_REUSEPORT:
|
||||
return "PASS_ERR_SK_SELECT_REUSEPORT";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
static void check_results(void)
|
||||
{
|
||||
__u32 results[NR_RESULTS];
|
||||
|
@ -351,10 +371,10 @@ static void check_results(void)
|
|||
printf(", %u", expected_results[i]);
|
||||
printf("]\n");
|
||||
|
||||
RET_IF(expected_results[broken] != results[broken],
|
||||
"unexpected result",
|
||||
"expected_results[%u] != results[%u] bpf_prog_linum:%ld\n",
|
||||
broken, broken, get_linum());
|
||||
printf("mismatch on %s (bpf_prog_linum:%ld)\n", result_to_str(broken),
|
||||
get_linum());
|
||||
|
||||
CHECK_FAIL(true);
|
||||
}
|
||||
|
||||
static int send_data(int type, sa_family_t family, void *data, size_t len,
|
||||
|
|
Loading…
Reference in New Issue