Skip to content

Commit f288c7a

Browse files
committed
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 <[email protected]> Reviewed-by: Willem de Bruijn <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 85101bd commit f288c7a

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

tools/testing/selftests/drivers/net/lib/py/env.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from pathlib import Path
66
from lib.py import KsftSkipEx, KsftXfailEx
77
from lib.py import ksft_setup
8-
from lib.py import cmd, ethtool, ip
8+
from lib.py import cmd, ethtool, ip, CmdExitFailure
99
from lib.py import NetNS, NetdevSimDev
1010
from .remote import Remote
1111

@@ -234,7 +234,12 @@ def wait_hw_stats_settle(self):
234234
Good drivers will tell us via ethtool what their sync period is.
235235
"""
236236
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
238243

239244
self._stats_settle_time = 0.025 + \
240245
data.get('stats-block-usecs', 0) / 1000 / 1000

tools/testing/selftests/net/lib/py/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010

1111

1212
class CmdExitFailure(Exception):
13-
pass
13+
def __init__(self, msg, cmd_obj):
14+
super().__init__(msg)
15+
self.cmd = cmd_obj
1416

1517

1618
class cmd:
@@ -48,7 +50,7 @@ def process(self, terminate=True, fail=None, timeout=5):
4850
if len(stderr) > 0 and stderr[-1] == "\n":
4951
stderr = stderr[:-1]
5052
raise CmdExitFailure("Command failed: %s\nSTDOUT: %s\nSTDERR: %s" %
51-
(self.proc.args, stdout, stderr))
53+
(self.proc.args, stdout, stderr), self)
5254

5355

5456
class bkg(cmd):

0 commit comments

Comments
 (0)