Skip to content

Commit 5712e32

Browse files
committed
selftests: net-drv: stats: sanity check netlink dumps
Sanity check netlink dumps, to make sure dumps don't have repeated entries or gaps in IDs. Reviewed-by: Petr Machata <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 1234810 commit 5712e32

File tree

1 file changed

+18
-1
lines changed
  • tools/testing/selftests/drivers/net

1 file changed

+18
-1
lines changed

tools/testing/selftests/drivers/net/stats.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,23 @@ def qstat_by_ifindex(cfg) -> None:
110110
ksft_ge(triple[1][key], triple[0][key], comment="bad key: " + key)
111111
ksft_ge(triple[2][key], triple[1][key], comment="bad key: " + key)
112112

113+
# Sanity check the dumps
114+
queues = NetdevFamily(recv_size=4096).qstats_get({"scope": "queue"}, dump=True)
115+
# Reformat the output into {ifindex: {rx: [id, id, ...], tx: [id, id, ...]}}
116+
parsed = {}
117+
for entry in queues:
118+
ifindex = entry["ifindex"]
119+
if ifindex not in parsed:
120+
parsed[ifindex] = {"rx":[], "tx": []}
121+
parsed[ifindex][entry["queue-type"]].append(entry['queue-id'])
122+
# Now, validate
123+
for ifindex, queues in parsed.items():
124+
for qtype in ['rx', 'tx']:
125+
ksft_eq(len(queues[qtype]), len(set(queues[qtype])),
126+
comment="repeated queue keys")
127+
ksft_eq(len(queues[qtype]), max(queues[qtype]) + 1,
128+
comment="missing queue keys")
129+
113130
# Test invalid dumps
114131
# 0 is invalid
115132
with ksft_raises(NlError) as cm:
@@ -158,7 +175,7 @@ def check_down(cfg) -> None:
158175

159176

160177
def main() -> None:
161-
with NetDrvEnv(__file__) as cfg:
178+
with NetDrvEnv(__file__, queue_count=100) as cfg:
162179
ksft_run([check_pause, check_fec, pkt_byte_sum, qstat_by_ifindex,
163180
check_down],
164181
args=(cfg, ))

0 commit comments

Comments
 (0)