Commit 0be740fb authored by Jakub Kicinski's avatar Jakub Kicinski Committed by Paolo Abeni
Browse files

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: default avatarSimon Horman <horms@kernel.org>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Reviewed-by: default avatarJacob Keller <jacob.e.keller@intel.com>
Link: https://patch.msgid.link/20251007232653.2099376-8-kuba@kernel.org


Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 2eecd3a4
Loading
Loading
Loading
Loading
+14 −6
Original line number Diff line number Diff line
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0

"""
Test driver resilience vs page pool allocation failures.
"""

import errno
import time
import os
@@ -13,7 +17,8 @@ from lib.py import cmd, tool, GenerateTraffic

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


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

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

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

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

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


def test_pp_alloc(cfg, netdevnl):
    """
    Configure page pool allocation fail injection while traffic is running.
    """

    def get_stats():
        return netdevnl.qstats_get({"ifindex": cfg.ifindex}, dump=True)[0]

@@ -119,6 +126,7 @@ def test_pp_alloc(cfg, netdevnl):


def main() -> None:
    """ Ksft boiler plate main """
    netdevnl = NetdevFamily()
    with NetDrvEpEnv(__file__, nsim_test=False) as cfg: