Skip to content

Commit 0be740f

Browse files
kuba-mooPaolo Abeni
authored andcommitted
selftests: drv-net: fix linter warnings in pp_alloc_fail
Fix linter warnings, it's a bit hard to check for new ones otherwise. W0311: Bad indentation. Found 16 spaces, expected 12 (bad-indentation) C0114: Missing module docstring (missing-module-docstring) W1514: Using open without explicitly specifying an encoding (unspecified-encoding) C0116: Missing function or method docstring (missing-function-docstring) Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: Jakub Kicinski <kuba@kernel.org> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Link: https://patch.msgid.link/20251007232653.2099376-8-kuba@kernel.org Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 2eecd3a commit 0be740f

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

tools/testing/selftests/drivers/net/hw/pp_alloc_fail.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#!/usr/bin/env python3
22
# SPDX-License-Identifier: GPL-2.0
33

4+
"""
5+
Test driver resilience vs page pool allocation failures.
6+
"""
7+
48
import errno
59
import time
610
import os
@@ -13,7 +17,8 @@
1317

1418
def _write_fail_config(config):
1519
for key, value in config.items():
16-
with open("/sys/kernel/debug/fail_function/" + key, "w") as fp:
20+
path = "/sys/kernel/debug/fail_function/"
21+
with open(path + key, "w", encoding='ascii') as fp:
1722
fp.write(str(value) + "\n")
1823

1924

@@ -22,8 +27,7 @@ def _enable_pp_allocation_fail():
2227
raise KsftSkipEx("Kernel built without function error injection (or DebugFS)")
2328

2429
if not os.path.exists("/sys/kernel/debug/fail_function/page_pool_alloc_netmems"):
25-
with open("/sys/kernel/debug/fail_function/inject", "w") as fp:
26-
fp.write("page_pool_alloc_netmems\n")
30+
_write_fail_config({"inject": "page_pool_alloc_netmems"})
2731

2832
_write_fail_config({
2933
"verbose": 0,
@@ -38,8 +42,7 @@ def _disable_pp_allocation_fail():
3842
return
3943

4044
if os.path.exists("/sys/kernel/debug/fail_function/page_pool_alloc_netmems"):
41-
with open("/sys/kernel/debug/fail_function/inject", "w") as fp:
42-
fp.write("\n")
45+
_write_fail_config({"inject": ""})
4346

4447
_write_fail_config({
4548
"probability": 0,
@@ -48,6 +51,10 @@ def _disable_pp_allocation_fail():
4851

4952

5053
def test_pp_alloc(cfg, netdevnl):
54+
"""
55+
Configure page pool allocation fail injection while traffic is running.
56+
"""
57+
5158
def get_stats():
5259
return netdevnl.qstats_get({"ifindex": cfg.ifindex}, dump=True)[0]
5360

@@ -105,7 +112,7 @@ def check_traffic_flowing():
105112
else:
106113
ksft_pr("ethtool -G change retval: did not succeed", new_g)
107114
else:
108-
ksft_pr("ethtool -G change retval: did not try")
115+
ksft_pr("ethtool -G change retval: did not try")
109116

110117
time.sleep(0.1)
111118
check_traffic_flowing()
@@ -119,6 +126,7 @@ def check_traffic_flowing():
119126

120127

121128
def main() -> None:
129+
""" Ksft boiler plate main """
122130
netdevnl = NetdevFamily()
123131
with NetDrvEpEnv(__file__, nsim_test=False) as cfg:
124132

0 commit comments

Comments
 (0)