[Devel] [PATCH vz10 3/3] selftests: drv-net: read the channel count over netlink
Konstantin Khorenko
khorenko at virtuozzo.com
Thu Sep 24 14:53:20 MSK 2026
> napi_threaded needs the number of combined channels of the device and
> asks ethtool to print it as JSON. Not every ethtool prints that one:
> ethtool 6.11 does it for -k, -a, -c, -g and -x, but not for -l, and
> the test ends in the first case:
>
> CmdExitFailure: Command failed: ethtool --json -l eth4
> STDERR: b'ethtool: bad command line argument(s)
> JSON output not available for this subcommand
>
> not ok 1 napi_threaded.napi_init
>
> Ask the kernel for the count over netlink, which is where ethtool reads
> it too, so the test no longer depends on the ethtool version installed.
> Changing the count stays with ethtool -L, which needs no JSON. No other
> test in the group asks ethtool for something it cannot print, so this is
> the only one that needs it.
>
> https://virtuozzo.atlassian.net/browse/VSTOR-139651
> Feature: fix selftests
> Signed-off-by: Eva Kurchatova <eva.kurchatova at virtuozzo.com>
>
> diff --git a/tools/testing/selftests/drivers/net/napi_threaded.py b/tools/testing/selftests/drivers/net/napi_threaded.py
> index ed66efa481b0f..73c81a319b49f 100755
> --- a/tools/testing/selftests/drivers/net/napi_threaded.py
> +++ b/tools/testing/selftests/drivers/net/napi_threaded.py
> @@ -7,7 +7,7 @@ Test napi threaded states.
>
> from lib.py import ksft_run, ksft_exit
> from lib.py import ksft_eq, ksft_ne, ksft_ge
> -from lib.py import NetDrvEnv, NetdevFamily
> +from lib.py import EthtoolFamily, NetDrvEnv, NetdevFamily
> from lib.py import cmd, defer, ethtool
>
>
> @@ -28,7 +28,13 @@ from lib.py import cmd, defer, ethtool
>
>
> def _setup_deferred_cleanup(cfg) -> None:
> - combined = ethtool(f"-l {cfg.ifname}", json=True)[0].get("combined", 0)
> + # Not every ethtool prints the channel counts as JSON, the one on
> + # the test machine here does not:
> + # ethtool: bad command line argument(s)
> + # JSON output not available for this subcommand
> + # Ask the kernel for them instead, it is the same number.
The long description with error messages examples should be in the commit
message, not in the code comment. A short comment like
"not every ethtool prints -l as JSON, ask the kernel"
should be enough.
--
Konstantin Khorenko <khorenko at virtuozzo.com>
More information about the Devel
mailing list