diff mbox series

selftests: net: rds: fix module not found

Message ID 20241008082259.243476-1-alessandro.zanni87@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series selftests: net: rds: fix module not found | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 5 this patch: 5
netdev/build_tools success Errors and warnings before: 0 (+2) this patch: 0 (+2)
netdev/cc_maintainers warning 1 maintainers not CCed: rds-devel@oss.oracle.com
netdev/build_clang success Errors and warnings before: 5 this patch: 5
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 3 this patch: 3
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 10 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-10-08--15-00 (tests: 773)

Commit Message

Alessandro Zanni Oct. 8, 2024, 8:22 a.m. UTC
This fix solves this error, when calling kselftest with targets "net/rds":

selftests: net/rds: test.py
Traceback (most recent call last):
  File "tools/testing/selftests/net/rds/./test.py", line 17, in <module>
    from lib.py import ip
ModuleNotFoundError: No module named 'lib'

Signed-off-by: Alessandro Zanni <alessandro.zanni87@gmail.com>
---
 tools/testing/selftests/net/rds/test.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Jakub Kicinski Oct. 10, 2024, 2:40 a.m. UTC | #1
On Tue,  8 Oct 2024 10:22:53 +0200 Alessandro Zanni wrote:
> This fix solves this error, when calling kselftest with targets "net/rds":
> 
> selftests: net/rds: test.py
> Traceback (most recent call last):
>   File "tools/testing/selftests/net/rds/./test.py", line 17, in <module>
>     from lib.py import ip
> ModuleNotFoundError: No module named 'lib'
> 
> Signed-off-by: Alessandro Zanni <alessandro.zanni87@gmail.com>
> ---
>  tools/testing/selftests/net/rds/test.py | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/net/rds/test.py b/tools/testing/selftests/net/rds/test.py
> index e6bb109bcead..112a8059c030 100755
> --- a/tools/testing/selftests/net/rds/test.py
> +++ b/tools/testing/selftests/net/rds/test.py
> @@ -14,8 +14,9 @@ import sys
>  import atexit
>  from pwd import getpwuid
>  from os import stat
> -from lib.py import ip
>  
> +sys.path.append("..")
> +from lib.py.utils import ip
>  
>  libc = ctypes.cdll.LoadLibrary('libc.so.6')
>  setns = libc.setns

Does this work regardless of where we try to run the script from?
In other cross-imports we try to build the path based on __file__,
see: tools/testing/selftests/drivers/net/lib/py/__init__.py

Would be good to keep consistency.
Alessandro Zanni Oct. 10, 2024, 7:11 p.m. UTC | #2
On 24/10/09 07:40, Jakub Kicinski wrote:
> On Tue,  8 Oct 2024 10:22:53 +0200 Alessandro Zanni wrote:
> > This fix solves this error, when calling kselftest with targets "net/rds":
> > 
> > selftests: net/rds: test.py
> > Traceback (most recent call last):
> >   File "tools/testing/selftests/net/rds/./test.py", line 17, in <module>
> >     from lib.py import ip
> > ModuleNotFoundError: No module named 'lib'
> > 
> > Signed-off-by: Alessandro Zanni <alessandro.zanni87@gmail.com>
> > ---
> >  tools/testing/selftests/net/rds/test.py | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/tools/testing/selftests/net/rds/test.py b/tools/testing/selftests/net/rds/test.py
> > index e6bb109bcead..112a8059c030 100755
> > --- a/tools/testing/selftests/net/rds/test.py
> > +++ b/tools/testing/selftests/net/rds/test.py
> > @@ -14,8 +14,9 @@ import sys
> >  import atexit
> >  from pwd import getpwuid
> >  from os import stat
> > -from lib.py import ip
> >  
> > +sys.path.append("..")
> > +from lib.py.utils import ip
> >  
> >  libc = ctypes.cdll.LoadLibrary('libc.so.6')
> >  setns = libc.setns
> 
> Does this work regardless of where we try to run the script from?
> In other cross-imports we try to build the path based on __file__,
> see: tools/testing/selftests/drivers/net/lib/py/__init__.py

Yes, it works regardeless where we run the script from but I agree
with you to keep the same style used in other files.
Thanks for pointing out.

> Would be good to keep consistency.

Definitely. I'm sending a v2 patch with this in mind.

> -- 
> pw-bot: cr
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/rds/test.py b/tools/testing/selftests/net/rds/test.py
index e6bb109bcead..112a8059c030 100755
--- a/tools/testing/selftests/net/rds/test.py
+++ b/tools/testing/selftests/net/rds/test.py
@@ -14,8 +14,9 @@  import sys
 import atexit
 from pwd import getpwuid
 from os import stat
-from lib.py import ip
 
+sys.path.append("..")
+from lib.py.utils import ip
 
 libc = ctypes.cdll.LoadLibrary('libc.so.6')
 setns = libc.setns