summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/veristat.c
diff options
context:
space:
mode:
authorAndrii Nakryiko <andrii@kernel.org>2022-11-03 08:52:58 +0300
committerAlexei Starovoitov <ast@kernel.org>2022-11-04 07:54:13 +0300
commitb9670b904a59808ef4222179a255978384bcc119 (patch)
tree4f62c019ed7bc938ad918b6bb495f5e2600029c7 /tools/testing/selftests/bpf/veristat.c
parent10b1b3f3e56a6a3586356bf8cc77d7753ba8fcc9 (diff)
downloadlinux-b9670b904a59808ef4222179a255978384bcc119.tar.xz
selftests/bpf: ensure we always have non-ambiguous sorting in veristat
Always fall back to unique file/prog comparison if user's custom order specs are ambiguous. This ensures stable output no matter what. Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/r/20221103055304.2904589-5-andrii@kernel.org Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/testing/selftests/bpf/veristat.c')
-rw-r--r--tools/testing/selftests/bpf/veristat.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/tools/testing/selftests/bpf/veristat.c b/tools/testing/selftests/bpf/veristat.c
index f6f6a2490489..0da3ecf6ed52 100644
--- a/tools/testing/selftests/bpf/veristat.c
+++ b/tools/testing/selftests/bpf/veristat.c
@@ -723,7 +723,11 @@ static int cmp_prog_stats(const void *v1, const void *v2)
return cmp;
}
- return 0;
+ /* always disambiguate with file+prog, which are unique */
+ cmp = strcmp(s1->file_name, s2->file_name);
+ if (cmp != 0)
+ return cmp;
+ return strcmp(s1->prog_name, s2->prog_name);
}
#define HEADER_CHAR '-'