Skip to content

Commit 46c61cb

Browse files
mykyta5anakryiko
authored andcommitted
selftests/bpf: Handle prog/attach type comparison in veristat
Implemented handling of prog type and attach type stats comparison in veristat. To test this change: ``` ./veristat pyperf600.bpf.o -o csv > base1.csv ./veristat pyperf600.bpf.o -o csv > base2.csv ./veristat -C base2.csv base1.csv -o csv ...,raw_tracepoint,raw_tracepoint,MATCH, ...,cgroup_inet_ingress,cgroup_inet_ingress,MATCH ``` Signed-off-by: Mykyta Yatsenko <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Tested-by: Eduard Zingerman <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent f44275e commit 46c61cb

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

tools/testing/selftests/bpf/veristat.c

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1688,9 +1688,42 @@ static int parse_stat_value(const char *str, enum stat_id id, struct verif_stats
16881688
st->stats[id] = val;
16891689
break;
16901690
}
1691-
case PROG_TYPE:
1692-
case ATTACH_TYPE:
1691+
case PROG_TYPE: {
1692+
enum bpf_prog_type prog_type = 0;
1693+
const char *type;
1694+
1695+
while ((type = libbpf_bpf_prog_type_str(prog_type))) {
1696+
if (strcmp(type, str) == 0) {
1697+
st->stats[id] = prog_type;
1698+
break;
1699+
}
1700+
prog_type++;
1701+
}
1702+
1703+
if (!type) {
1704+
fprintf(stderr, "Unrecognized prog type %s\n", str);
1705+
return -EINVAL;
1706+
}
16931707
break;
1708+
}
1709+
case ATTACH_TYPE: {
1710+
enum bpf_attach_type attach_type = 0;
1711+
const char *type;
1712+
1713+
while ((type = libbpf_bpf_attach_type_str(attach_type))) {
1714+
if (strcmp(type, str) == 0) {
1715+
st->stats[id] = attach_type;
1716+
break;
1717+
}
1718+
attach_type++;
1719+
}
1720+
1721+
if (!type) {
1722+
fprintf(stderr, "Unrecognized attach type %s\n", str);
1723+
return -EINVAL;
1724+
}
1725+
break;
1726+
}
16941727
default:
16951728
fprintf(stderr, "Unrecognized stat #%d\n", id);
16961729
return -EINVAL;

0 commit comments

Comments
 (0)