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.

selftests: drv-net: assume stats refresh is 0 if no ethtool -c support

Tests using HW stats wait for them to stabilize, using data from
ethtool -c as the delay. Not all drivers implement ethtool -c
so handle the errors gracefully.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/20241220003116.1458863-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+11 -4
+7 -2
tools/testing/selftests/drivers/net/lib/py/env.py
··· 5 5 from pathlib import Path 6 6 from lib.py import KsftSkipEx, KsftXfailEx 7 7 from lib.py import ksft_setup 8 - from lib.py import cmd, ethtool, ip 8 + from lib.py import cmd, ethtool, ip, CmdExitFailure 9 9 from lib.py import NetNS, NetdevSimDev 10 10 from .remote import Remote 11 11 ··· 234 234 Good drivers will tell us via ethtool what their sync period is. 235 235 """ 236 236 if self._stats_settle_time is None: 237 - data = ethtool("-c " + self.ifname, json=True)[0] 237 + data = {} 238 + try: 239 + data = ethtool("-c " + self.ifname, json=True)[0] 240 + except CmdExitFailure as e: 241 + if "Operation not supported" not in e.cmd.stderr: 242 + raise 238 243 239 244 self._stats_settle_time = 0.025 + \ 240 245 data.get('stats-block-usecs', 0) / 1000 / 1000
+4 -2
tools/testing/selftests/net/lib/py/utils.py
··· 10 10 11 11 12 12 class CmdExitFailure(Exception): 13 - pass 13 + def __init__(self, msg, cmd_obj): 14 + super().__init__(msg) 15 + self.cmd = cmd_obj 14 16 15 17 16 18 class cmd: ··· 50 48 if len(stderr) > 0 and stderr[-1] == "\n": 51 49 stderr = stderr[:-1] 52 50 raise CmdExitFailure("Command failed: %s\nSTDOUT: %s\nSTDERR: %s" % 53 - (self.proc.args, stdout, stderr)) 51 + (self.proc.args, stdout, stderr), self) 54 52 55 53 56 54 class bkg(cmd):