Subject: Re: [PATCH RFC net-next v4 2/2] selftests/dpll: add DPLL system integration selftests

From: Jakub Kicinski <[email-masked]>
Date: Fri, 1 Dec 2023 12:03:13 -0800

On Thu, 23 Nov 2023 05:52:43 -0500 Michal Michalik wrote:
> +++ b/tools/testing/selftests/drivers/net/netdevsim/dpll/ynlfamilyhandler.py
> @@ -0,0 +1,49 @@
> +# SPDX-License-Identifier: GPL-2.0
> +#
> +# Wrapper for the YNL library used to interact with the netlink interface.
> +#
> +# Copyright (c) 2023, Intel Corporation.
> +# Author: Michal Michalik <[email-masked]>
> +
> +import sys
> +from pathlib import Path
> +from dataclasses import dataclass
> +
> +from .consts import KSRC, YNLSPEC, YNLPATH
> +
> +
> +try:
> +    ynl_full_path = Path(KSRC) / YNLPATH
> +    sys.path.append(ynl_full_path.as_posix())
> +    from lib import YnlFamily
> +except ModuleNotFoundError:
> +    print("Failed importing `ynl` library from kernel sources, please set KSRC")
> +    sys.exit(1)

Do you have any suggestions on how we could build up a common Python
library for selftests? Can we create a directory for "library" code
somewhere under tools/testing/ ? Adding a wrapper like this for every
test is going to hurt.

Calling out to YNL, manipulating network namespaces, manipulating
netdevsim instances, etc - will be fairly common for a lot of networking
tests.

There's already some code in tools/testing/selftests/bpf/test_offload.py
which is likely Python-incompetent cause I wrote it. But much like YNL
it'd be nice if it was available for new tests for reuse.

Can we somehow "add to python's library search path" or some such?