Skip to content

Commit b9670b9

Browse files
anakryikoAlexei Starovoitov
authored andcommitted
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>
1 parent 10b1b3f commit b9670b9

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

tools/testing/selftests/bpf/veristat.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,11 @@ static int cmp_prog_stats(const void *v1, const void *v2)
723723
return cmp;
724724
}
725725

726-
return 0;
726+
/* always disambiguate with file+prog, which are unique */
727+
cmp = strcmp(s1->file_name, s2->file_name);
728+
if (cmp != 0)
729+
return cmp;
730+
return strcmp(s1->prog_name, s2->prog_name);
727731
}
728732

729733
#define HEADER_CHAR '-'

0 commit comments

Comments
 (0)