mbox series

[net-next,0/6] selftests: net: exercise page pool reporting via netlink

Message ID 20240411012815.174400-1-kuba@kernel.org
Headers show
Series selftests: net: exercise page pool reporting via netlink | expand

Message

Jakub Kicinski April 11, 2024, 1:28 a.m. UTC
Add a basic test for page pool netlink reporting.

Jakub Kicinski (6):
  net: netdevsim: add some fake page pool use
  tools: ynl: don't return None for dumps
  selftests: net: print report check location in python tests
  selftests: net: print full exception on failure
  selftests: net: support use of NetdevSimDev under "with" in python
  selftests: net: exercise page pool reporting via netlink

 drivers/net/netdevsim/netdev.c             | 93 ++++++++++++++++++++++
 drivers/net/netdevsim/netdevsim.h          |  4 +
 tools/net/ynl/lib/ynl.py                   |  4 +-
 tools/testing/selftests/net/lib/py/ksft.py | 29 ++++---
 tools/testing/selftests/net/lib/py/nsim.py | 22 ++++-
 tools/testing/selftests/net/nl_netdev.py   | 79 +++++++++++++++++-
 6 files changed, 215 insertions(+), 16 deletions(-)

Comments

Petr Machata April 12, 2024, 7:45 a.m. UTC | #1
Jakub Kicinski <kuba@kernel.org> writes:

> Developing Python tests is a bit annoying because when test fails
> we only print the fail message and no info about which exact check
> led to it. Print the location (the first line of this example is new):
>
>   # At /root/ksft-net-drv/./net/nl_netdev.py line 38:
>   # Check failed 0 != 10
>   not ok 3 nl_netdev.page_pool_check
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Reviewed-by: Petr Machata <petrm@nvidia.com>

> +def _fail(*args):
> +    global KSFT_RESULT
> +    KSFT_RESULT = False
> +
> +    frame = inspect.stack()[2]
> +    ksft_pr("At " + frame.filename + " line " + str(frame.lineno) + ":")
> +    ksft_pr(" ".join([str(a) for a in args]))

I think this could have just been ksft_pr(*args) like before, but
whatever.

> +
>  def ksft_eq(a, b, comment=""):
>      global KSFT_RESULT
>      if a != b:
> -        KSFT_RESULT = False
> -        ksft_pr("Check failed", a, "!=", b, comment)
> +        _fail("Check failed", a, "!=", b, comment)
Petr Machata April 12, 2024, 8:07 a.m. UTC | #2
Jakub Kicinski <kuba@kernel.org> writes:

> Using "with" on an entire driver test env is supported already,
> but it's also useful to use "with" on an individual nsim.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Reviewed-by: Petr Machata <petrm@nvidia.com>