Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'selftests-drv-net-stats-use-skip-instead-of-xfail'

Jakub Kicinski says:

====================
selftests: drv-net: stats: use skip instead of xfail

Alex posted support for configuring pause frames in fbnic. This flipped
the pause stats test from xfail to fail. Because CI considered xfail as
pass it now flags the test as failing. This shouldn't happen. Also we
currently report pause and FEC tests as passing on virtio which doesn't
make sense.
====================

Link: https://patch.msgid.link/20250620161109.2146242-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+30 -15
+30 -15
tools/testing/selftests/drivers/net/stats.py
··· 1 1 #!/usr/bin/env python3 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 4 + """ 5 + Tests related to standard netdevice statistics. 6 + """ 7 + 4 8 import errno 5 9 import subprocess 6 10 import time 7 11 from lib.py import ksft_run, ksft_exit, ksft_pr 8 12 from lib.py import ksft_ge, ksft_eq, ksft_is, ksft_in, ksft_lt, ksft_true, ksft_raises 9 - from lib.py import KsftSkipEx, KsftXfailEx 13 + from lib.py import KsftSkipEx, KsftFailEx 10 14 from lib.py import ksft_disruptive 11 15 from lib.py import EthtoolFamily, NetdevFamily, RtnlFamily, NlError 12 16 from lib.py import NetDrvEnv ··· 22 18 23 19 24 20 def check_pause(cfg) -> None: 25 - global ethnl 21 + """ 22 + Check that drivers which support Pause config also report standard 23 + pause stats. 24 + """ 26 25 27 26 try: 28 27 ethnl.pause_get({"header": {"dev-index": cfg.ifindex}}) 29 28 except NlError as e: 30 29 if e.error == errno.EOPNOTSUPP: 31 - raise KsftXfailEx("pause not supported by the device") 30 + raise KsftSkipEx("pause not supported by the device") from e 32 31 raise 33 32 34 33 data = ethnl.pause_get({"header": {"dev-index": cfg.ifindex, ··· 40 33 41 34 42 35 def check_fec(cfg) -> None: 43 - global ethnl 36 + """ 37 + Check that drivers which support FEC config also report standard 38 + FEC stats. 39 + """ 44 40 45 41 try: 46 42 ethnl.fec_get({"header": {"dev-index": cfg.ifindex}}) 47 43 except NlError as e: 48 44 if e.error == errno.EOPNOTSUPP: 49 - raise KsftXfailEx("FEC not supported by the device") 45 + raise KsftSkipEx("FEC not supported by the device") from e 50 46 raise 51 47 52 48 data = ethnl.fec_get({"header": {"dev-index": cfg.ifindex, ··· 58 48 59 49 60 50 def pkt_byte_sum(cfg) -> None: 61 - global netfam, rtnl 51 + """ 52 + Check that qstat and interface stats match in value. 53 + """ 62 54 63 55 def get_qstat(test): 64 - global netfam 65 56 stats = netfam.qstats_get({}, dump=True) 66 57 if stats: 67 58 for qs in stats: 68 59 if qs["ifindex"]== test.ifindex: 69 60 return qs 61 + return None 70 62 71 63 qstat = get_qstat(cfg) 72 64 if qstat is None: ··· 89 77 for _ in range(10): 90 78 rtstat = rtnl.getlink({"ifi-index": cfg.ifindex})['stats64'] 91 79 if stat_cmp(rtstat, qstat) < 0: 92 - raise Exception("RTNL stats are lower, fetched later") 80 + raise KsftFailEx("RTNL stats are lower, fetched later") 93 81 qstat = get_qstat(cfg) 94 82 if stat_cmp(rtstat, qstat) > 0: 95 - raise Exception("Qstats are lower, fetched later") 83 + raise KsftFailEx("Qstats are lower, fetched later") 96 84 97 85 98 86 def qstat_by_ifindex(cfg) -> None: 99 - global netfam 100 - global rtnl 87 + """ Qstats Netlink API tests - querying by ifindex. """ 101 88 102 89 # Construct a map ifindex -> [dump, by-index, dump] 103 90 ifindexes = {} ··· 104 93 for entry in stats: 105 94 ifindexes[entry['ifindex']] = [entry, None, None] 106 95 107 - for ifindex in ifindexes.keys(): 96 + for ifindex in ifindexes: 108 97 entry = netfam.qstats_get({"ifindex": ifindex}, dump=True) 109 98 ksft_eq(len(entry), 1) 110 99 ifindexes[entry[0]['ifindex']][1] = entry[0] ··· 156 145 157 146 # Try to get stats for lowest unused ifindex but not 0 158 147 devs = rtnl.getlink({}, dump=True) 159 - all_ifindexes = set([dev["ifi-index"] for dev in devs]) 148 + all_ifindexes = set(dev["ifi-index"] for dev in devs) 160 149 lowest = 2 161 150 while lowest in all_ifindexes: 162 151 lowest += 1 ··· 169 158 170 159 @ksft_disruptive 171 160 def check_down(cfg) -> None: 161 + """ Test statistics (interface and qstat) are not impacted by ifdown """ 162 + 172 163 try: 173 164 qstat = netfam.qstats_get({"ifindex": cfg.ifindex}, dump=True)[0] 174 165 except NlError as e: 175 166 if e.error == errno.EOPNOTSUPP: 176 - raise KsftSkipEx("qstats not supported by the device") 167 + raise KsftSkipEx("qstats not supported by the device") from e 177 168 raise 178 169 179 170 ip(f"link set dev {cfg.dev['ifname']} down") 180 171 defer(ip, f"link set dev {cfg.dev['ifname']} up") 181 172 182 173 qstat2 = netfam.qstats_get({"ifindex": cfg.ifindex}, dump=True)[0] 183 - for k, v in qstat.items(): 174 + for k in qstat: 184 175 ksft_ge(qstat2[k], qstat[k], comment=f"{k} went backwards on device down") 185 176 186 177 # exercise per-queue API to make sure that "device down" state ··· 276 263 277 264 278 265 def main() -> None: 266 + """ Ksft boiler plate main """ 267 + 279 268 with NetDrvEnv(__file__, queue_count=100) as cfg: 280 269 ksft_run([check_pause, check_fec, pkt_byte_sum, qstat_by_ifindex, 281 270 check_down, procfs_hammer, procfs_downup_hammer],