* [PATCH v1 0/2] python gitignore and line length
@ 2022-11-03 13:29 Juraj Linkeš
2022-11-03 13:29 ` [PATCH v1 1/2] git: ignore standard python files Juraj Linkeš
` (2 more replies)
0 siblings, 3 replies; 36+ messages in thread
From: Juraj Linkeš @ 2022-11-03 13:29 UTC (permalink / raw)
Cc: dev, Juraj Linkeš
These two config options/preferences are relevant to DTS, but not only
to DTS and need to be discussed separately, as they affect all Python
code in DPDK.
Juraj Linkeš (2):
git: ignore standard python files
doc: increase python max line to 88
.editorconfig | 2 +-
.gitignore | 6 ++++--
doc/doc_build/meson-private/meson.lock | 0
doc/guides/contributing/coding_style.rst | 8 +++++++-
4 files changed, 12 insertions(+), 4 deletions(-)
create mode 100644 doc/doc_build/meson-private/meson.lock
--
2.30.2
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v1 1/2] git: ignore standard python files
2022-11-03 13:29 [PATCH v1 0/2] python gitignore and line length Juraj Linkeš
@ 2022-11-03 13:29 ` Juraj Linkeš
2022-11-04 9:16 ` Juraj Linkeš
` (2 more replies)
2022-11-03 13:29 ` [PATCH v1 2/2] doc: increase python max line to 88 Juraj Linkeš
2022-11-04 9:15 ` [PATCH v1 0/2] python gitignore and line length Juraj Linkeš
2 siblings, 3 replies; 36+ messages in thread
From: Juraj Linkeš @ 2022-11-03 13:29 UTC (permalink / raw)
Cc: dev, Juraj Linkeš
These are python byte-compiled/optimized/dll files and IDE files.
Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
.gitignore | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/.gitignore b/.gitignore
index 212c7aa28e..fbec0ce441 100644
--- a/.gitignore
+++ b/.gitignore
@@ -33,8 +33,10 @@ GRTAGS
tags
TAGS
-# ignore python bytecode files
-*.pyc
+# python byte-compiled/optimized/dll files
+__pycache__/
+*.py[cod]
+*$py.class
# ignore default build directory, and directories from test-meson-builds.sh
build
--
2.30.2
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v1 2/2] doc: increase python max line to 88
2022-11-03 13:29 [PATCH v1 0/2] python gitignore and line length Juraj Linkeš
2022-11-03 13:29 ` [PATCH v1 1/2] git: ignore standard python files Juraj Linkeš
@ 2022-11-03 13:29 ` Juraj Linkeš
2022-11-04 9:16 ` Juraj Linkeš
2023-09-26 12:10 ` [PATCH v2 1/2] doc: increase python max line length to 100 Juraj Linkeš
2022-11-04 9:15 ` [PATCH v1 0/2] python gitignore and line length Juraj Linkeš
2 siblings, 2 replies; 36+ messages in thread
From: Juraj Linkeš @ 2022-11-03 13:29 UTC (permalink / raw)
Cc: dev, Juraj Linkeš
88 is a good compromise between shorter files,
readability and other considerations. More in [0].
[0] https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length
Signed-off-by: Owen Hilyard <ohilyard@iol.unh.edu>
Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
.editorconfig | 2 +-
doc/doc_build/meson-private/meson.lock | 0
doc/guides/contributing/coding_style.rst | 8 +++++++-
3 files changed, 8 insertions(+), 2 deletions(-)
create mode 100644 doc/doc_build/meson-private/meson.lock
diff --git a/.editorconfig b/.editorconfig
index ab41c95085..f20996f329 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -16,7 +16,7 @@ max_line_length = 100
[*.py]
indent_style = space
indent_size = 4
-max_line_length = 79
+max_line_length = 88 # https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length
[meson.build]
indent_style = space
diff --git a/doc/doc_build/meson-private/meson.lock b/doc/doc_build/meson-private/meson.lock
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/doc/guides/contributing/coding_style.rst b/doc/guides/contributing/coding_style.rst
index 89db6260cf..7620268dc7 100644
--- a/doc/guides/contributing/coding_style.rst
+++ b/doc/guides/contributing/coding_style.rst
@@ -851,7 +851,13 @@ Python Code
All Python code should be compliant with
`PEP8 (Style Guide for Python Code) <https://www.python.org/dev/peps/pep-0008/>`_.
-The ``pep8`` tool can be used for testing compliance with the guidelines.
+The ``pep8`` tool can be used for testing compliance with the guidelines. Note that the
+maximum line length is 88, as that is a good compromise between shorter files, usability
+with other tools (side-by-side diffs, docs, presentations) and disability accommodation.
+More in `Black's documentation
+<https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length>`_.
+
+..
Integrating with the Build System
---------------------------------
--
2.30.2
^ permalink raw reply [flat|nested] 36+ messages in thread
* RE: [PATCH v1 0/2] python gitignore and line length
2022-11-03 13:29 [PATCH v1 0/2] python gitignore and line length Juraj Linkeš
2022-11-03 13:29 ` [PATCH v1 1/2] git: ignore standard python files Juraj Linkeš
2022-11-03 13:29 ` [PATCH v1 2/2] doc: increase python max line to 88 Juraj Linkeš
@ 2022-11-04 9:15 ` Juraj Linkeš
2 siblings, 0 replies; 36+ messages in thread
From: Juraj Linkeš @ 2022-11-04 9:15 UTC (permalink / raw)
To: Honnappa Nagarahalli, Owen Hilyard, thomas, Lijuan Tu, Richardson, Bruce
Cc: dev
Adding folks I forgot to add.
> -----Original Message-----
> From: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Sent: Thursday, November 3, 2022 2:29 PM
> Cc: dev@dpdk.org; Juraj Linkeš <juraj.linkes@pantheon.tech>
> Subject: [PATCH v1 0/2] python gitignore and line length
>
> These two config options/preferences are relevant to DTS, but not only to
> DTS and need to be discussed separately, as they affect all Python code in
> DPDK.
>
> Juraj Linkeš (2):
> git: ignore standard python files
> doc: increase python max line to 88
>
> .editorconfig | 2 +-
> .gitignore | 6 ++++--
> doc/doc_build/meson-private/meson.lock | 0
> doc/guides/contributing/coding_style.rst | 8 +++++++-
> 4 files changed, 12 insertions(+), 4 deletions(-) create mode 100644
> doc/doc_build/meson-private/meson.lock
>
> --
> 2.30.2
^ permalink raw reply [flat|nested] 36+ messages in thread
* RE: [PATCH v1 1/2] git: ignore standard python files
2022-11-03 13:29 ` [PATCH v1 1/2] git: ignore standard python files Juraj Linkeš
@ 2022-11-04 9:16 ` Juraj Linkeš
2022-11-04 9:26 ` Bruce Richardson
2023-07-16 18:11 ` [PATCH] doc: fix description of runtime directories Stephen Hemminger
2 siblings, 0 replies; 36+ messages in thread
From: Juraj Linkeš @ 2022-11-04 9:16 UTC (permalink / raw)
To: Honnappa Nagarahalli, Owen Hilyard, thomas, Lijuan Tu, Richardson, Bruce
Cc: dev
Adding folks I forgot to add
> -----Original Message-----
> From: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Sent: Thursday, November 3, 2022 2:29 PM
> Cc: dev@dpdk.org; Juraj Linkeš <juraj.linkes@pantheon.tech>
> Subject: [PATCH v1 1/2] git: ignore standard python files
>
> These are python byte-compiled/optimized/dll files and IDE files.
>
> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> ---
> .gitignore | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/.gitignore b/.gitignore
> index 212c7aa28e..fbec0ce441 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -33,8 +33,10 @@ GRTAGS
> tags
> TAGS
>
> -# ignore python bytecode files
> -*.pyc
> +# python byte-compiled/optimized/dll files __pycache__/ *.py[cod]
> +*$py.class
>
> # ignore default build directory, and directories from test-meson-builds.sh
> build
> --
> 2.30.2
^ permalink raw reply [flat|nested] 36+ messages in thread
* RE: [PATCH v1 2/2] doc: increase python max line to 88
2022-11-03 13:29 ` [PATCH v1 2/2] doc: increase python max line to 88 Juraj Linkeš
@ 2022-11-04 9:16 ` Juraj Linkeš
2022-11-04 9:28 ` Bruce Richardson
2022-11-04 16:57 ` Stephen Hemminger
2023-09-26 12:10 ` [PATCH v2 1/2] doc: increase python max line length to 100 Juraj Linkeš
1 sibling, 2 replies; 36+ messages in thread
From: Juraj Linkeš @ 2022-11-04 9:16 UTC (permalink / raw)
To: Honnappa Nagarahalli, Owen Hilyard, thomas, Lijuan Tu, Richardson, Bruce
Cc: dev
Adding folks I forgot to add.
> -----Original Message-----
> From: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Sent: Thursday, November 3, 2022 2:29 PM
> Cc: dev@dpdk.org; Juraj Linkeš <juraj.linkes@pantheon.tech>
> Subject: [PATCH v1 2/2] doc: increase python max line to 88
>
> 88 is a good compromise between shorter files, readability and other
> considerations. More in [0].
>
> [0]
> https://black.readthedocs.io/en/stable/the_black_code_style/current_style
> .html#line-length
>
> Signed-off-by: Owen Hilyard <ohilyard@iol.unh.edu>
> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> ---
> .editorconfig | 2 +-
> doc/doc_build/meson-private/meson.lock | 0
> doc/guides/contributing/coding_style.rst | 8 +++++++-
> 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644
> doc/doc_build/meson-private/meson.lock
>
> diff --git a/.editorconfig b/.editorconfig index ab41c95085..f20996f329 100644
> --- a/.editorconfig
> +++ b/.editorconfig
> @@ -16,7 +16,7 @@ max_line_length = 100
> [*.py]
> indent_style = space
> indent_size = 4
> -max_line_length = 79
> +max_line_length = 88 #
> +https://black.readthedocs.io/en/stable/the_black_code_style/current_sty
> +le.html#line-length
>
> [meson.build]
> indent_style = space
> diff --git a/doc/doc_build/meson-private/meson.lock
> b/doc/doc_build/meson-private/meson.lock
> new file mode 100644
> index 0000000000..e69de29bb2
> diff --git a/doc/guides/contributing/coding_style.rst
> b/doc/guides/contributing/coding_style.rst
> index 89db6260cf..7620268dc7 100644
> --- a/doc/guides/contributing/coding_style.rst
> +++ b/doc/guides/contributing/coding_style.rst
> @@ -851,7 +851,13 @@ Python Code
> All Python code should be compliant with
> `PEP8 (Style Guide for Python Code)
> <https://www.python.org/dev/peps/pep-0008/>`_.
>
> -The ``pep8`` tool can be used for testing compliance with the guidelines.
> +The ``pep8`` tool can be used for testing compliance with the
> +guidelines. Note that the maximum line length is 88, as that is a good
> +compromise between shorter files, usability with other tools (side-by-side
> diffs, docs, presentations) and disability accommodation.
> +More in `Black's documentation
> +<https://black.readthedocs.io/en/stable/the_black_code_style/current_st
> yle.html#line-length>`_.
> +
> +..
>
> Integrating with the Build System
> ---------------------------------
> --
> 2.30.2
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v1 1/2] git: ignore standard python files
2022-11-03 13:29 ` [PATCH v1 1/2] git: ignore standard python files Juraj Linkeš
2022-11-04 9:16 ` Juraj Linkeš
@ 2022-11-04 9:26 ` Bruce Richardson
2023-07-16 18:11 ` [PATCH] doc: fix description of runtime directories Stephen Hemminger
2 siblings, 0 replies; 36+ messages in thread
From: Bruce Richardson @ 2022-11-04 9:26 UTC (permalink / raw)
To: Juraj Linkeš; +Cc: dev
On Thu, Nov 03, 2022 at 01:29:25PM +0000, Juraj Linkeš wrote:
> These are python byte-compiled/optimized/dll files and IDE files.
>
> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> ---
> .gitignore | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/.gitignore b/.gitignore
> index 212c7aa28e..fbec0ce441 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -33,8 +33,10 @@ GRTAGS
> tags
> TAGS
>
> -# ignore python bytecode files
> -*.pyc
> +# python byte-compiled/optimized/dll files
> +__pycache__/
> +*.py[cod]
> +*$py.class
>
Looks harmless :-)
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v1 2/2] doc: increase python max line to 88
2022-11-04 9:16 ` Juraj Linkeš
@ 2022-11-04 9:28 ` Bruce Richardson
2022-11-04 16:57 ` Stephen Hemminger
1 sibling, 0 replies; 36+ messages in thread
From: Bruce Richardson @ 2022-11-04 9:28 UTC (permalink / raw)
To: Juraj Linkeš
Cc: Honnappa Nagarahalli, Owen Hilyard, thomas, Lijuan Tu, dev
On Fri, Nov 04, 2022 at 09:16:13AM +0000, Juraj Linkeš wrote:
> Adding folks I forgot to add.
>
> > -----Original Message-----
> > From: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > Sent: Thursday, November 3, 2022 2:29 PM
> > Cc: dev@dpdk.org; Juraj Linkeš <juraj.linkes@pantheon.tech>
> > Subject: [PATCH v1 2/2] doc: increase python max line to 88
> >
> > 88 is a good compromise between shorter files, readability and other
> > considerations. More in [0].
> >
> > [0]
> > https://black.readthedocs.io/en/stable/the_black_code_style/current_style
> > .html#line-length
> >
> > Signed-off-by: Owen Hilyard <ohilyard@iol.unh.edu>
> > Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > ---
Personally, if we move beyond 80 chars, I'd prefer to go all the way to
100, but I'm not going to argue about it. Happy enough to go with 88 for
now.
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v1 2/2] doc: increase python max line to 88
2022-11-04 9:16 ` Juraj Linkeš
2022-11-04 9:28 ` Bruce Richardson
@ 2022-11-04 16:57 ` Stephen Hemminger
2022-11-10 9:15 ` Juraj Linkeš
1 sibling, 1 reply; 36+ messages in thread
From: Stephen Hemminger @ 2022-11-04 16:57 UTC (permalink / raw)
To: Juraj Linkeš
Cc: Honnappa Nagarahalli, Owen Hilyard, thomas, Lijuan Tu,
Richardson, Bruce, dev
On Fri, 4 Nov 2022 09:16:13 +0000
Juraj Linkeš <juraj.linkes@pantheon.tech> wrote:
> > +max_line_length = 88 #
> > +https://black.readthedocs.io/en/stable/the_black_code_style/current_sty
> > +le.html#li
Skip the comment, it caused your line break!
^ permalink raw reply [flat|nested] 36+ messages in thread
* RE: [PATCH v1 2/2] doc: increase python max line to 88
2022-11-04 16:57 ` Stephen Hemminger
@ 2022-11-10 9:15 ` Juraj Linkeš
2022-11-10 16:27 ` Stephen Hemminger
0 siblings, 1 reply; 36+ messages in thread
From: Juraj Linkeš @ 2022-11-10 9:15 UTC (permalink / raw)
To: Stephen Hemminger
Cc: Honnappa Nagarahalli, Owen Hilyard, thomas, Lijuan Tu,
Richardson, Bruce, dev
> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Friday, November 4, 2022 5:58 PM
> To: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Cc: Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>; Owen Hilyard
> <ohilyard@iol.unh.edu>; thomas@monjalon.net; Lijuan Tu
> <lijuan.tu@intel.com>; Richardson, Bruce <bruce.richardson@intel.com>;
> dev@dpdk.org
> Subject: Re: [PATCH v1 2/2] doc: increase python max line to 88
>
> On Fri, 4 Nov 2022 09:16:13 +0000
> Juraj Linkeš <juraj.linkes@pantheon.tech> wrote:
>
> > > +max_line_length = 88 #
> > >
> +https://black.readthedocs.io/en/stable/the_black_code_style/current_sty
> > > +le.html#li
>
> Skip the comment, it caused your line break!
The fact that the line is a bit longer does not make the line less readable, as the link is there to be copy-pasted (and I don't think anyone reads the full hyperlinks - the knowledge of domain is enough). As such I think it's better to include the link as it serves as self-documentation (that we're deviating from the standard).
We could move the comment before or after the max_line_length option and that would result in lines below 100 characters (which is what .editorconfig prescribes). I used that in my one of my local versions, but it was less readable in my opinion. I'd rather break the rule and have it be more readable.
Of course, not having the comment is fine, since we document it in the coding style guide. I just think there's no (or very little) downside and some upside (more than downside) in adding the comment.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v1 2/2] doc: increase python max line to 88
2022-11-10 9:15 ` Juraj Linkeš
@ 2022-11-10 16:27 ` Stephen Hemminger
0 siblings, 0 replies; 36+ messages in thread
From: Stephen Hemminger @ 2022-11-10 16:27 UTC (permalink / raw)
To: Juraj Linkeš
Cc: Honnappa Nagarahalli, Owen Hilyard, thomas, Lijuan Tu,
Richardson, Bruce, dev
On Thu, 10 Nov 2022 09:15:16 +0000
Juraj Linkeš <juraj.linkes@pantheon.tech> wrote:
> > -----Original Message-----
> > From: Stephen Hemminger <stephen@networkplumber.org>
> > Sent: Friday, November 4, 2022 5:58 PM
> > To: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > Cc: Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>; Owen Hilyard
> > <ohilyard@iol.unh.edu>; thomas@monjalon.net; Lijuan Tu
> > <lijuan.tu@intel.com>; Richardson, Bruce <bruce.richardson@intel.com>;
> > dev@dpdk.org
> > Subject: Re: [PATCH v1 2/2] doc: increase python max line to 88
> >
> > On Fri, 4 Nov 2022 09:16:13 +0000
> > Juraj Linkeš <juraj.linkes@pantheon.tech> wrote:
> >
> > > > +max_line_length = 88 #
> > > >
> > +https://black.readthedocs.io/en/stable/the_black_code_style/current_sty
> > > > +le.html#li
> >
> > Skip the comment, it caused your line break!
>
> The fact that the line is a bit longer does not make the line less readable, as the link is there to be copy-pasted (and I don't think anyone reads the full hyperlinks - the knowledge of domain is enough). As such I think it's better to include the link as it serves as self-documentation (that we're deviating from the standard).
>
> We could move the comment before or after the max_line_length option and that would result in lines below 100 characters (which is what .editorconfig prescribes). I used that in my one of my local versions, but it was less readable in my opinion. I'd rather break the rule and have it be more readable.
>
> Of course, not having the comment is fine, since we document it in the coding style guide. I just think there's no (or very little) downside and some upside (more than downside) in adding the comment.
The choice of max line length is project specific. Referencing some other style guide
doesn't seem necessary. My choice would be to use 100 like the other C code.
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH] doc: fix description of runtime directories
2022-11-03 13:29 ` [PATCH v1 1/2] git: ignore standard python files Juraj Linkeš
2022-11-04 9:16 ` Juraj Linkeš
2022-11-04 9:26 ` Bruce Richardson
@ 2023-07-16 18:11 ` Stephen Hemminger
2023-07-20 3:26 ` Thomas Monjalon
2 siblings, 1 reply; 36+ messages in thread
From: Stephen Hemminger @ 2023-07-16 18:11 UTC (permalink / raw)
To: dev; +Cc: Muhammad Jawad Hussain, Stephen Hemminger
The documentation was never updated when the DPDK EAL
was modified to follow standard runtime conventions.
Fixes: 1835a22f342f ("support systemd service convention for runtime directory")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
doc/guides/prog_guide/multi_proc_support.rst | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/doc/guides/prog_guide/multi_proc_support.rst b/doc/guides/prog_guide/multi_proc_support.rst
index 815e8bdc4332..cdebfa8d05bb 100644
--- a/doc/guides/prog_guide/multi_proc_support.rst
+++ b/doc/guides/prog_guide/multi_proc_support.rst
@@ -107,15 +107,18 @@ Running Multiple Independent DPDK Applications
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In addition to the above scenarios involving multiple DPDK processes working together,
-it is possible to run multiple DPDK processes side-by-side,
+it is possible to run multiple DPDK processes concurrently,
where those processes are all working independently.
Support for this usage scenario is provided using the ``--file-prefix`` parameter to the EAL.
-By default, the EAL creates hugepage files on each hugetlbfs filesystem using the rtemap_X filename,
+The EAL puts shared runtime files in a directory based on standard conventions.
+If ``$RUNTIME_DIRECTORY'' is defined in the environment it is used (as ``$RUNTIME_DIRECTORY/dpdk'').
+Otherwise, if DPDK is run as root user, it uses /var/run/dpdk
+or if run as non-root user then the /tmp/dpdk (or $XDG_RUNTIME_DIRECTORY/dpdk) is used.
+Hugepage files on each hugetlbfs filesystem using the rtemap_X filename,
where X is in the range 0 to the maximum number of hugepages -1.
-Similarly, it creates shared configuration files, memory mapped in each process, using the /var/run/.rte_config filename,
-when run as root (or $HOME/.rte_config when run as a non-root user;
-if filesystem and device permissions are set up to allow this).
+Similarly, it creates shared configuration files, memory mapped in each process,
+using the .rte_config filename.
The rte part of the filenames of each of the above is configurable using the file-prefix parameter.
In addition to specifying the file-prefix parameter,
--
2.39.2
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH] doc: fix description of runtime directories
2023-07-16 18:11 ` [PATCH] doc: fix description of runtime directories Stephen Hemminger
@ 2023-07-20 3:26 ` Thomas Monjalon
0 siblings, 0 replies; 36+ messages in thread
From: Thomas Monjalon @ 2023-07-20 3:26 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: dev, Muhammad Jawad Hussain
16/07/2023 20:11, Stephen Hemminger:
> The documentation was never updated when the DPDK EAL
> was modified to follow standard runtime conventions.
>
> Fixes: 1835a22f342f ("support systemd service convention for runtime directory")
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Applied, thanks.
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 1/2] doc: increase python max line length to 100
2022-11-03 13:29 ` [PATCH v1 2/2] doc: increase python max line to 88 Juraj Linkeš
2022-11-04 9:16 ` Juraj Linkeš
@ 2023-09-26 12:10 ` Juraj Linkeš
2023-09-26 12:10 ` [PATCH v2 2/2] dts: reformat to 100 line length Juraj Linkeš
` (2 more replies)
1 sibling, 3 replies; 36+ messages in thread
From: Juraj Linkeš @ 2023-09-26 12:10 UTC (permalink / raw)
To: thomas, Honnappa.Nagarahalli, bruce.richardson, jspewock, probb, stephen
Cc: dev, Juraj Linkeš
Unify with C recommendations which allow line length of up to 100
characters.
Signed-off-by: Owen Hilyard <ohilyard@iol.unh.edu>
Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
.editorconfig | 2 +-
doc/doc_build/meson-private/meson.lock | 0
doc/guides/contributing/coding_style.rst | 3 +++
3 files changed, 4 insertions(+), 1 deletion(-)
create mode 100644 doc/doc_build/meson-private/meson.lock
diff --git a/.editorconfig b/.editorconfig
index ab41c95085..1e7d74213f 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -16,7 +16,7 @@ max_line_length = 100
[*.py]
indent_style = space
indent_size = 4
-max_line_length = 79
+max_line_length = 100
[meson.build]
indent_style = space
diff --git a/doc/doc_build/meson-private/meson.lock b/doc/doc_build/meson-private/meson.lock
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/doc/guides/contributing/coding_style.rst b/doc/guides/contributing/coding_style.rst
index 648849899d..a42cd3d58d 100644
--- a/doc/guides/contributing/coding_style.rst
+++ b/doc/guides/contributing/coding_style.rst
@@ -880,6 +880,9 @@ All Python code should be compliant with
`PEP8 (Style Guide for Python Code) <https://www.python.org/dev/peps/pep-0008/>`_.
The ``pep8`` tool can be used for testing compliance with the guidelines.
+Note that line lengths are acceptable up to 100 characters, which is in line with C recommendations.
+
+..
Integrating with the Build System
---------------------------------
--
2.34.1
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 2/2] dts: reformat to 100 line length
2023-09-26 12:10 ` [PATCH v2 1/2] doc: increase python max line length to 100 Juraj Linkeš
@ 2023-09-26 12:10 ` Juraj Linkeš
2023-09-26 21:52 ` Jeremy Spewock
2023-09-27 8:08 ` Bruce Richardson
2023-09-26 13:00 ` [PATCH v2 1/2] doc: increase python max line length to 100 Bruce Richardson
2023-09-28 12:18 ` [PATCH v3 " Juraj Linkeš
2 siblings, 2 replies; 36+ messages in thread
From: Juraj Linkeš @ 2023-09-26 12:10 UTC (permalink / raw)
To: thomas, Honnappa.Nagarahalli, bruce.richardson, jspewock, probb, stephen
Cc: dev, Juraj Linkeš
Reformat to 100 from the previous 88 to unify with C recommendations.
Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
dts/framework/config/__init__.py | 20 ++-----
dts/framework/dts.py | 12 +---
dts/framework/exception.py | 3 +-
dts/framework/remote_session/__init__.py | 4 +-
dts/framework/remote_session/linux_session.py | 39 ++++---------
dts/framework/remote_session/posix_session.py | 30 +++-------
.../remote/interactive_remote_session.py | 7 +--
.../remote/interactive_shell.py | 4 +-
.../remote_session/remote/remote_session.py | 8 +--
.../remote_session/remote/ssh_session.py | 16 ++----
.../remote_session/remote/testpmd_shell.py | 8 +--
dts/framework/settings.py | 4 +-
dts/framework/test_result.py | 16 ++----
dts/framework/test_suite.py | 57 +++++--------------
.../capturing_traffic_generator.py | 4 +-
dts/framework/testbed_model/hw/cpu.py | 20 ++-----
dts/framework/testbed_model/node.py | 8 +--
dts/framework/testbed_model/scapy.py | 16 ++----
dts/framework/testbed_model/sut_node.py | 38 ++++---------
dts/framework/testbed_model/tg_node.py | 7 +--
dts/framework/utils.py | 20 ++-----
dts/pyproject.toml | 4 +-
dts/tests/TestSuite_hello_world.py | 4 +-
dts/tests/TestSuite_smoke_tests.py | 11 +---
24 files changed, 93 insertions(+), 267 deletions(-)
diff --git a/dts/framework/config/__init__.py b/dts/framework/config/__init__.py
index cb7e00ba34..9b32cf0532 100644
--- a/dts/framework/config/__init__.py
+++ b/dts/framework/config/__init__.py
@@ -140,9 +140,7 @@ def from_dict(d: dict) -> Union["SutNodeConfiguration", "TGNodeConfiguration"]:
if "traffic_generator" in d:
return TGNodeConfiguration(
- traffic_generator=TrafficGeneratorConfig.from_dict(
- d["traffic_generator"]
- ),
+ traffic_generator=TrafficGeneratorConfig.from_dict(d["traffic_generator"]),
**common_config,
)
else:
@@ -249,9 +247,7 @@ def from_dict(
build_targets: list[BuildTargetConfiguration] = list(
map(BuildTargetConfiguration.from_dict, d["build_targets"])
)
- test_suites: list[TestSuiteConfig] = list(
- map(TestSuiteConfig.from_dict, d["test_suites"])
- )
+ test_suites: list[TestSuiteConfig] = list(map(TestSuiteConfig.from_dict, d["test_suites"]))
sut_name = d["system_under_test_node"]["node_name"]
skip_smoke_tests = d.get("skip_smoke_tests", False)
assert sut_name in node_map, f"Unknown SUT {sut_name} in execution {d}"
@@ -268,9 +264,7 @@ def from_dict(
), f"Invalid TG configuration {traffic_generator_node}"
vdevs = (
- d["system_under_test_node"]["vdevs"]
- if "vdevs" in d["system_under_test_node"]
- else []
+ d["system_under_test_node"]["vdevs"] if "vdevs" in d["system_under_test_node"] else []
)
return ExecutionConfiguration(
build_targets=build_targets,
@@ -299,9 +293,7 @@ def from_dict(d: dict) -> "Configuration":
assert len(nodes) == len(node_map), "Duplicate node names are not allowed"
executions: list[ExecutionConfiguration] = list(
- map(
- ExecutionConfiguration.from_dict, d["executions"], [node_map for _ in d]
- )
+ map(ExecutionConfiguration.from_dict, d["executions"], [node_map for _ in d])
)
return Configuration(executions=executions)
@@ -315,9 +307,7 @@ def load_config() -> Configuration:
with open(SETTINGS.config_file_path, "r") as f:
config_data = yaml.safe_load(f)
- schema_path = os.path.join(
- pathlib.Path(__file__).parent.resolve(), "conf_yaml_schema.json"
- )
+ schema_path = os.path.join(pathlib.Path(__file__).parent.resolve(), "conf_yaml_schema.json")
with open(schema_path, "r") as f:
schema = json.load(f)
diff --git a/dts/framework/dts.py b/dts/framework/dts.py
index f773f0c38d..e2aada5a23 100644
--- a/dts/framework/dts.py
+++ b/dts/framework/dts.py
@@ -92,9 +92,7 @@ def _run_execution(
Run the given execution. This involves running the execution setup as well as
running all build targets in the given execution.
"""
- dts_logger.info(
- f"Running execution with SUT '{execution.system_under_test_node.name}'."
- )
+ dts_logger.info(f"Running execution with SUT '{execution.system_under_test_node.name}'.")
execution_result = result.add_execution(sut_node.config)
execution_result.add_sut_info(sut_node.node_info)
@@ -107,9 +105,7 @@ def _run_execution(
else:
for build_target in execution.build_targets:
- _run_build_target(
- sut_node, tg_node, build_target, execution, execution_result
- )
+ _run_build_target(sut_node, tg_node, build_target, execution, execution_result)
finally:
try:
@@ -170,9 +166,7 @@ def _run_all_suites(
execution.test_suites[:0] = [TestSuiteConfig.from_dict("smoke_tests")]
for test_suite_config in execution.test_suites:
try:
- _run_single_suite(
- sut_node, tg_node, execution, build_target_result, test_suite_config
- )
+ _run_single_suite(sut_node, tg_node, execution, build_target_result, test_suite_config)
except BlockingTestSuiteError as e:
dts_logger.exception(
f"An error occurred within {test_suite_config.test_suite}. "
diff --git a/dts/framework/exception.py b/dts/framework/exception.py
index 001a5a5496..59cf9fd12a 100644
--- a/dts/framework/exception.py
+++ b/dts/framework/exception.py
@@ -117,8 +117,7 @@ def __init__(self, command: str, command_return_code: int):
def __str__(self) -> str:
return (
- f"Command {self.command} returned a non-zero exit code: "
- f"{self.command_return_code}"
+ f"Command {self.command} returned a non-zero exit code: " f"{self.command_return_code}"
)
diff --git a/dts/framework/remote_session/__init__.py b/dts/framework/remote_session/__init__.py
index 00b6d1f03a..6124417bd7 100644
--- a/dts/framework/remote_session/__init__.py
+++ b/dts/framework/remote_session/__init__.py
@@ -30,9 +30,7 @@
)
-def create_session(
- node_config: NodeConfiguration, name: str, logger: DTSLOG
-) -> OSSession:
+def create_session(node_config: NodeConfiguration, name: str, logger: DTSLOG) -> OSSession:
match node_config.os:
case OS.linux:
return LinuxSession(node_config, name, logger)
diff --git a/dts/framework/remote_session/linux_session.py b/dts/framework/remote_session/linux_session.py
index a3f1a6bf3b..aa76e25436 100644
--- a/dts/framework/remote_session/linux_session.py
+++ b/dts/framework/remote_session/linux_session.py
@@ -82,9 +82,7 @@ def setup_hugepages(self, hugepage_amount: int, force_first_numa: bool) -> None:
self._mount_huge_pages()
def _get_hugepage_size(self) -> int:
- hugepage_size = self.send_command(
- "awk '/Hugepagesize/ {print $2}' /proc/meminfo"
- ).stdout
+ hugepage_size = self.send_command("awk '/Hugepagesize/ {print $2}' /proc/meminfo").stdout
return int(hugepage_size)
def _get_hugepages_total(self) -> int:
@@ -120,13 +118,9 @@ def _supports_numa(self) -> bool:
# there's no reason to do any numa specific configuration)
return len(self._numa_nodes) > 1
- def _configure_huge_pages(
- self, amount: int, size: int, force_first_numa: bool
- ) -> None:
+ def _configure_huge_pages(self, amount: int, size: int, force_first_numa: bool) -> None:
self._logger.info("Configuring Hugepages.")
- hugepage_config_path = (
- f"/sys/kernel/mm/hugepages/hugepages-{size}kB/nr_hugepages"
- )
+ hugepage_config_path = f"/sys/kernel/mm/hugepages/hugepages-{size}kB/nr_hugepages"
if force_first_numa and self._supports_numa():
# clear non-numa hugepages
self.send_command(f"echo 0 | tee {hugepage_config_path}", privileged=True)
@@ -135,24 +129,18 @@ def _configure_huge_pages(
f"/hugepages-{size}kB/nr_hugepages"
)
- self.send_command(
- f"echo {amount} | tee {hugepage_config_path}", privileged=True
- )
+ self.send_command(f"echo {amount} | tee {hugepage_config_path}", privileged=True)
def update_ports(self, ports: list[Port]) -> None:
self._logger.debug("Gathering port info.")
for port in ports:
- assert (
- port.node == self.name
- ), "Attempted to gather port info on the wrong node"
+ assert port.node == self.name, "Attempted to gather port info on the wrong node"
port_info_list = self._get_lshw_info()
for port in ports:
for port_info in port_info_list:
if f"pci@{port.pci}" == port_info.get("businfo"):
- self._update_port_attr(
- port, port_info.get("logicalname"), "logical_name"
- )
+ self._update_port_attr(port, port_info.get("logicalname"), "logical_name")
self._update_port_attr(port, port_info.get("serial"), "mac_address")
port_info_list.remove(port_info)
break
@@ -163,25 +151,18 @@ def _get_lshw_info(self) -> list[LshwOutput]:
output = self.send_command("lshw -quiet -json -C network", verify=True)
return json.loads(output.stdout)
- def _update_port_attr(
- self, port: Port, attr_value: str | None, attr_name: str
- ) -> None:
+ def _update_port_attr(self, port: Port, attr_value: str | None, attr_name: str) -> None:
if attr_value:
setattr(port, attr_name, attr_value)
- self._logger.debug(
- f"Found '{attr_name}' of port {port.pci}: '{attr_value}'."
- )
+ self._logger.debug(f"Found '{attr_name}' of port {port.pci}: '{attr_value}'.")
else:
self._logger.warning(
- f"Attempted to get '{attr_name}' of port {port.pci}, "
- f"but it doesn't exist."
+ f"Attempted to get '{attr_name}' of port {port.pci}, " f"but it doesn't exist."
)
def configure_port_state(self, port: Port, enable: bool) -> None:
state = "up" if enable else "down"
- self.send_command(
- f"ip link set dev {port.logical_name} {state}", privileged=True
- )
+ self.send_command(f"ip link set dev {port.logical_name} {state}", privileged=True)
def configure_port_ip_address(
self,
diff --git a/dts/framework/remote_session/posix_session.py b/dts/framework/remote_session/posix_session.py
index 5da0516e05..eb59252dd1 100644
--- a/dts/framework/remote_session/posix_session.py
+++ b/dts/framework/remote_session/posix_session.py
@@ -94,8 +94,7 @@ def extract_remote_tarball(
expected_dir: str | PurePath | None = None,
) -> None:
self.send_command(
- f"tar xfm {remote_tarball_path} "
- f"-C {PurePosixPath(remote_tarball_path).parent}",
+ f"tar xfm {remote_tarball_path} " f"-C {PurePosixPath(remote_tarball_path).parent}",
60,
)
if expected_dir:
@@ -125,8 +124,7 @@ def build_dpdk(
self._logger.info("Configuring DPDK build from scratch.")
self.remove_remote_dir(remote_dpdk_build_dir)
self.send_command(
- f"meson setup "
- f"{meson_args} {remote_dpdk_dir} {remote_dpdk_build_dir}",
+ f"meson setup " f"{meson_args} {remote_dpdk_dir} {remote_dpdk_build_dir}",
timeout,
verify=True,
env=env_vars,
@@ -140,9 +138,7 @@ def build_dpdk(
raise DPDKBuildError(f"DPDK build failed when doing '{e.command}'.")
def get_dpdk_version(self, build_dir: str | PurePath) -> str:
- out = self.send_command(
- f"cat {self.join_remote_path(build_dir, 'VERSION')}", verify=True
- )
+ out = self.send_command(f"cat {self.join_remote_path(build_dir, 'VERSION')}", verify=True)
return out.stdout
def kill_cleanup_dpdk_apps(self, dpdk_prefix_list: Iterable[str]) -> None:
@@ -156,9 +152,7 @@ def kill_cleanup_dpdk_apps(self, dpdk_prefix_list: Iterable[str]) -> None:
self._check_dpdk_hugepages(dpdk_runtime_dirs)
self._remove_dpdk_runtime_dirs(dpdk_runtime_dirs)
- def _get_dpdk_runtime_dirs(
- self, dpdk_prefix_list: Iterable[str]
- ) -> list[PurePosixPath]:
+ def _get_dpdk_runtime_dirs(self, dpdk_prefix_list: Iterable[str]) -> list[PurePosixPath]:
prefix = PurePosixPath("/var", "run", "dpdk")
if not dpdk_prefix_list:
remote_prefixes = self._list_remote_dirs(prefix)
@@ -174,9 +168,7 @@ def _list_remote_dirs(self, remote_path: str | PurePath) -> list[str] | None:
Return a list of directories of the remote_dir.
If remote_path doesn't exist, return None.
"""
- out = self.send_command(
- f"ls -l {remote_path} | awk '/^d/ {{print $NF}}'"
- ).stdout
+ out = self.send_command(f"ls -l {remote_path} | awk '/^d/ {{print $NF}}'").stdout
if "No such file or directory" in out:
return None
else:
@@ -200,9 +192,7 @@ def _remote_files_exists(self, remote_path: PurePath) -> bool:
result = self.send_command(f"test -e {remote_path}")
return not result.return_code
- def _check_dpdk_hugepages(
- self, dpdk_runtime_dirs: Iterable[str | PurePath]
- ) -> None:
+ def _check_dpdk_hugepages(self, dpdk_runtime_dirs: Iterable[str | PurePath]) -> None:
for dpdk_runtime_dir in dpdk_runtime_dirs:
hugepage_info = PurePosixPath(dpdk_runtime_dir, "hugepage_info")
if self._remote_files_exists(hugepage_info):
@@ -213,9 +203,7 @@ def _check_dpdk_hugepages(
self._logger.warning(out)
self._logger.warning("*******************************************")
- def _remove_dpdk_runtime_dirs(
- self, dpdk_runtime_dirs: Iterable[str | PurePath]
- ) -> None:
+ def _remove_dpdk_runtime_dirs(self, dpdk_runtime_dirs: Iterable[str | PurePath]) -> None:
for dpdk_runtime_dir in dpdk_runtime_dirs:
self.remove_remote_dir(dpdk_runtime_dir)
@@ -245,6 +233,4 @@ def get_node_info(self) -> NodeInfo:
SETTINGS.timeout,
).stdout.split("\n")
kernel_version = self.send_command("uname -r", SETTINGS.timeout).stdout
- return NodeInfo(
- os_release_info[0].strip(), os_release_info[1].strip(), kernel_version
- )
+ return NodeInfo(os_release_info[0].strip(), os_release_info[1].strip(), kernel_version)
diff --git a/dts/framework/remote_session/remote/interactive_remote_session.py b/dts/framework/remote_session/remote/interactive_remote_session.py
index 9085a668e8..42c99b2525 100644
--- a/dts/framework/remote_session/remote/interactive_remote_session.py
+++ b/dts/framework/remote_session/remote/interactive_remote_session.py
@@ -73,9 +73,7 @@ def __init__(self, node_config: NodeConfiguration, _logger: DTSLOG) -> None:
f"Initializing interactive connection for {self.username}@{self.hostname}"
)
self._connect()
- self._logger.info(
- f"Interactive connection successful for {self.username}@{self.hostname}"
- )
+ self._logger.info(f"Interactive connection successful for {self.username}@{self.hostname}")
def _connect(self) -> None:
"""Establish a connection to the node.
@@ -108,8 +106,7 @@ def _connect(self) -> None:
self._logger.debug(traceback.format_exc())
self._logger.warning(e)
self._logger.info(
- "Retrying interactive session connection: "
- f"retry number {retry_attempt +1}"
+ "Retrying interactive session connection: " f"retry number {retry_attempt +1}"
)
else:
break
diff --git a/dts/framework/remote_session/remote/interactive_shell.py b/dts/framework/remote_session/remote/interactive_shell.py
index c24376b2a8..4db19fb9b3 100644
--- a/dts/framework/remote_session/remote/interactive_shell.py
+++ b/dts/framework/remote_session/remote/interactive_shell.py
@@ -85,9 +85,7 @@ def __init__(
self._app_args = app_args
self._start_application(get_privileged_command)
- def _start_application(
- self, get_privileged_command: Callable[[str], str] | None
- ) -> None:
+ def _start_application(self, get_privileged_command: Callable[[str], str] | None) -> None:
"""Starts a new interactive application based on the path to the app.
This method is often overridden by subclasses as their process for
diff --git a/dts/framework/remote_session/remote/remote_session.py b/dts/framework/remote_session/remote/remote_session.py
index 0647d93de4..719f7d1ef7 100644
--- a/dts/framework/remote_session/remote/remote_session.py
+++ b/dts/framework/remote_session/remote/remote_session.py
@@ -96,9 +96,7 @@ def send_command(
If verify is True, check the return code of the executed command
and raise a RemoteCommandExecutionError if the command failed.
"""
- self._logger.info(
- f"Sending: '{command}'" + (f" with env vars: '{env}'" if env else "")
- )
+ self._logger.info(f"Sending: '{command}'" + (f" with env vars: '{env}'" if env else ""))
result = self._send_command(command, timeout, env)
if verify and result.return_code:
self._logger.debug(
@@ -112,9 +110,7 @@ def send_command(
return result
@abstractmethod
- def _send_command(
- self, command: str, timeout: float, env: dict | None
- ) -> CommandResult:
+ def _send_command(self, command: str, timeout: float, env: dict | None) -> CommandResult:
"""
Use the underlying protocol to execute the command using optional env vars
and return CommandResult.
diff --git a/dts/framework/remote_session/remote/ssh_session.py b/dts/framework/remote_session/remote/ssh_session.py
index 8d127f1601..1a7ee649ab 100644
--- a/dts/framework/remote_session/remote/ssh_session.py
+++ b/dts/framework/remote_session/remote/ssh_session.py
@@ -80,9 +80,7 @@ def _connect(self) -> None:
if error not in errors:
errors.append(error)
- self._logger.info(
- f"Retrying connection: retry number {retry_attempt + 1}."
- )
+ self._logger.info(f"Retrying connection: retry number {retry_attempt + 1}.")
else:
break
@@ -92,9 +90,7 @@ def _connect(self) -> None:
def is_alive(self) -> bool:
return self.session.is_connected
- def _send_command(
- self, command: str, timeout: float, env: dict | None
- ) -> CommandResult:
+ def _send_command(self, command: str, timeout: float, env: dict | None) -> CommandResult:
"""Send a command and return the result of the execution.
Args:
@@ -107,9 +103,7 @@ def _send_command(
SSHTimeoutError: The command execution timed out.
"""
try:
- output = self.session.run(
- command, env=env, warn=True, hide=True, timeout=timeout
- )
+ output = self.session.run(command, env=env, warn=True, hide=True, timeout=timeout)
except (UnexpectedExit, ThreadException) as e:
self._logger.exception(e)
@@ -119,9 +113,7 @@ def _send_command(
self._logger.exception(e)
raise SSHTimeoutError(command, e.result.stderr) from e
- return CommandResult(
- self.name, command, output.stdout, output.stderr, output.return_code
- )
+ return CommandResult(self.name, command, output.stdout, output.stderr, output.return_code)
def copy_from(
self,
diff --git a/dts/framework/remote_session/remote/testpmd_shell.py b/dts/framework/remote_session/remote/testpmd_shell.py
index 1455b5a199..08ac311016 100644
--- a/dts/framework/remote_session/remote/testpmd_shell.py
+++ b/dts/framework/remote_session/remote/testpmd_shell.py
@@ -21,13 +21,9 @@ class TestPmdShell(InteractiveShell):
path: PurePath = PurePath("app", "dpdk-testpmd")
dpdk_app: bool = True
_default_prompt: str = "testpmd>"
- _command_extra_chars: str = (
- "\n" # We want to append an extra newline to every command
- )
+ _command_extra_chars: str = "\n" # We want to append an extra newline to every command
- def _start_application(
- self, get_privileged_command: Callable[[str], str] | None
- ) -> None:
+ def _start_application(self, get_privileged_command: Callable[[str], str] | None) -> None:
"""See "_start_application" in InteractiveShell."""
self._app_args += " -- -i"
super()._start_application(get_privileged_command)
diff --git a/dts/framework/settings.py b/dts/framework/settings.py
index cfa39d011b..aad444e99c 100644
--- a/dts/framework/settings.py
+++ b/dts/framework/settings.py
@@ -170,9 +170,7 @@ def _get_settings() -> _Settings:
timeout=parsed_args.timeout,
verbose=(parsed_args.verbose == "Y"),
skip_setup=(parsed_args.skip_setup == "Y"),
- dpdk_tarball_path=Path(
- DPDKGitTarball(parsed_args.tarball, parsed_args.output_dir)
- )
+ dpdk_tarball_path=Path(DPDKGitTarball(parsed_args.tarball, parsed_args.output_dir))
if not os.path.exists(parsed_args.tarball)
else Path(parsed_args.tarball),
compile_timeout=parsed_args.compile_timeout,
diff --git a/dts/framework/test_result.py b/dts/framework/test_result.py
index f0fbe80f6f..4c2e7e2418 100644
--- a/dts/framework/test_result.py
+++ b/dts/framework/test_result.py
@@ -83,9 +83,7 @@ def __iadd__(self, other: Result) -> "Statistics":
"""
self[other.name] += 1
self["PASS RATE"] = (
- float(self[Result.PASS.name])
- * 100
- / sum(self[result.name] for result in Result)
+ float(self[Result.PASS.name]) * 100 / sum(self[result.name] for result in Result)
)
return self
@@ -135,9 +133,7 @@ def _get_setup_teardown_errors(self) -> list[Exception]:
def _get_inner_errors(self) -> list[Exception]:
return [
- error
- for inner_result in self._inner_results
- for error in inner_result.get_errors()
+ error for inner_result in self._inner_results for error in inner_result.get_errors()
]
def get_errors(self) -> list[Exception]:
@@ -174,9 +170,7 @@ def add_stats(self, statistics: Statistics) -> None:
statistics += self.result
def __bool__(self) -> bool:
- return (
- bool(self.setup_result) and bool(self.teardown_result) and bool(self.result)
- )
+ return bool(self.setup_result) and bool(self.teardown_result) and bool(self.result)
class TestSuiteResult(BaseResult):
@@ -247,9 +241,7 @@ def __init__(self, sut_node: NodeConfiguration):
super(ExecutionResult, self).__init__()
self.sut_node = sut_node
- def add_build_target(
- self, build_target: BuildTargetConfiguration
- ) -> BuildTargetResult:
+ def add_build_target(self, build_target: BuildTargetConfiguration) -> BuildTargetResult:
build_target_result = BuildTargetResult(build_target)
self._inner_results.append(build_target_result)
return build_target_result
diff --git a/dts/framework/test_suite.py b/dts/framework/test_suite.py
index 3b890c0451..46d3de4944 100644
--- a/dts/framework/test_suite.py
+++ b/dts/framework/test_suite.py
@@ -102,9 +102,7 @@ def _process_links(self) -> None:
tg_port.peer,
tg_port.identifier,
):
- self._port_links.append(
- PortLink(sut_port=sut_port, tg_port=tg_port)
- )
+ self._port_links.append(PortLink(sut_port=sut_port, tg_port=tg_port))
def set_up_suite(self) -> None:
"""
@@ -151,9 +149,7 @@ def configure_testbed_ipv4(self, restore: bool = False) -> None:
def _configure_ipv4_forwarding(self, enable: bool) -> None:
self.sut_node.configure_ipv4_forwarding(enable)
- def send_packet_and_capture(
- self, packet: Packet, duration: float = 1
- ) -> list[Packet]:
+ def send_packet_and_capture(self, packet: Packet, duration: float = 1) -> list[Packet]:
"""
Send a packet through the appropriate interface and
receive on the appropriate interface.
@@ -202,21 +198,15 @@ def verify(self, condition: bool, failure_description: str) -> None:
self._fail_test_case_verify(failure_description)
def _fail_test_case_verify(self, failure_description: str) -> None:
- self._logger.debug(
- "A test case failed, showing the last 10 commands executed on SUT:"
- )
+ self._logger.debug("A test case failed, showing the last 10 commands executed on SUT:")
for command_res in self.sut_node.main_session.remote_session.history[-10:]:
self._logger.debug(command_res.command)
- self._logger.debug(
- "A test case failed, showing the last 10 commands executed on TG:"
- )
+ self._logger.debug("A test case failed, showing the last 10 commands executed on TG:")
for command_res in self.tg_node.main_session.remote_session.history[-10:]:
self._logger.debug(command_res.command)
raise TestCaseVerifyError(failure_description)
- def verify_packets(
- self, expected_packet: Packet, received_packets: list[Packet]
- ) -> None:
+ def verify_packets(self, expected_packet: Packet, received_packets: list[Packet]) -> None:
for received_packet in received_packets:
if self._compare_packets(expected_packet, received_packet):
break
@@ -225,17 +215,11 @@ def verify_packets(
f"The expected packet {get_packet_summaries(expected_packet)} "
f"not found among received {get_packet_summaries(received_packets)}"
)
- self._fail_test_case_verify(
- "An expected packet not found among received packets."
- )
+ self._fail_test_case_verify("An expected packet not found among received packets.")
- def _compare_packets(
- self, expected_packet: Packet, received_packet: Packet
- ) -> bool:
+ def _compare_packets(self, expected_packet: Packet, received_packet: Packet) -> bool:
self._logger.debug(
- "Comparing packets: \n"
- f"{expected_packet.summary()}\n"
- f"{received_packet.summary()}"
+ "Comparing packets: \n" f"{expected_packet.summary()}\n" f"{received_packet.summary()}"
)
l3 = IP in expected_packet.layers()
@@ -262,14 +246,10 @@ def _compare_packets(
expected_payload = expected_payload.payload
if expected_payload:
- self._logger.debug(
- f"The expected packet did not contain {expected_payload}."
- )
+ self._logger.debug(f"The expected packet did not contain {expected_payload}.")
return False
if received_payload and received_payload.__class__ != Padding:
- self._logger.debug(
- "The received payload had extra layers which were not padding."
- )
+ self._logger.debug("The received payload had extra layers which were not padding.")
return False
return True
@@ -296,10 +276,7 @@ def _verify_l2_frame(self, received_packet: Ether, l3: bool) -> bool:
def _verify_l3_packet(self, received_packet: IP, expected_packet: IP) -> bool:
self._logger.debug("Looking at the IP layer.")
- if (
- received_packet.src != expected_packet.src
- or received_packet.dst != expected_packet.dst
- ):
+ if received_packet.src != expected_packet.src or received_packet.dst != expected_packet.dst:
return False
return True
@@ -373,9 +350,7 @@ def _get_test_cases(self, test_case_regex: str) -> list[MethodType]:
if self._should_be_executed(test_case_name, test_case_regex):
filtered_test_cases.append(test_case)
cases_str = ", ".join((x.__name__ for x in filtered_test_cases))
- self._logger.debug(
- f"Found test cases '{cases_str}' in {self.__class__.__name__}."
- )
+ self._logger.debug(f"Found test cases '{cases_str}' in {self.__class__.__name__}.")
return filtered_test_cases
def _should_be_executed(self, test_case_name: str, test_case_regex: str) -> bool:
@@ -445,9 +420,7 @@ def _execute_test_case(
self._logger.exception(f"Test case execution ERROR: {test_case_name}")
test_case_result.update(Result.ERROR, e)
except KeyboardInterrupt:
- self._logger.error(
- f"Test case execution INTERRUPTED by user: {test_case_name}"
- )
+ self._logger.error(f"Test case execution INTERRUPTED by user: {test_case_name}")
test_case_result.update(Result.SKIP)
raise KeyboardInterrupt("Stop DTS")
@@ -464,9 +437,7 @@ def is_test_suite(object) -> bool:
try:
testcase_module = importlib.import_module(testsuite_module_path)
except ModuleNotFoundError as e:
- raise ConfigurationError(
- f"Test suite '{testsuite_module_path}' not found."
- ) from e
+ raise ConfigurationError(f"Test suite '{testsuite_module_path}' not found.") from e
return [
test_suite_class
for _, test_suite_class in inspect.getmembers(testcase_module, is_test_suite)
diff --git a/dts/framework/testbed_model/capturing_traffic_generator.py b/dts/framework/testbed_model/capturing_traffic_generator.py
index ab98987f8e..48d019ab21 100644
--- a/dts/framework/testbed_model/capturing_traffic_generator.py
+++ b/dts/framework/testbed_model/capturing_traffic_generator.py
@@ -110,9 +110,7 @@ def send_packets_and_capture(
duration,
)
- self._logger.debug(
- f"Received packets: {get_packet_summaries(received_packets)}"
- )
+ self._logger.debug(f"Received packets: {get_packet_summaries(received_packets)}")
self._write_capture_from_packets(capture_name, received_packets)
return received_packets
diff --git a/dts/framework/testbed_model/hw/cpu.py b/dts/framework/testbed_model/hw/cpu.py
index d1918a12dc..cbc5fe7fff 100644
--- a/dts/framework/testbed_model/hw/cpu.py
+++ b/dts/framework/testbed_model/hw/cpu.py
@@ -54,9 +54,7 @@ def __init__(self, lcore_list: list[int] | list[str] | list[LogicalCore] | str):
# the input lcores may not be sorted
self._lcore_list.sort()
- self._lcore_str = (
- f'{",".join(self._get_consecutive_lcores_range(self._lcore_list))}'
- )
+ self._lcore_str = f'{",".join(self._get_consecutive_lcores_range(self._lcore_list))}'
@property
def lcore_list(self) -> list[int]:
@@ -70,15 +68,11 @@ def _get_consecutive_lcores_range(self, lcore_ids_list: list[int]) -> list[str]:
segment.append(lcore_id)
else:
formatted_core_list.append(
- f"{segment[0]}-{segment[-1]}"
- if len(segment) > 1
- else f"{segment[0]}"
+ f"{segment[0]}-{segment[-1]}" if len(segment) > 1 else f"{segment[0]}"
)
current_core_index = lcore_ids_list.index(lcore_id)
formatted_core_list.extend(
- self._get_consecutive_lcores_range(
- lcore_ids_list[current_core_index:]
- )
+ self._get_consecutive_lcores_range(lcore_ids_list[current_core_index:])
)
segment.clear()
break
@@ -125,9 +119,7 @@ def __init__(
self._filter_specifier = filter_specifier
# sorting by core is needed in case hyperthreading is enabled
- self._lcores_to_filter = sorted(
- lcore_list, key=lambda x: x.core, reverse=not ascending
- )
+ self._lcores_to_filter = sorted(lcore_list, key=lambda x: x.core, reverse=not ascending)
self.filter()
@abstractmethod
@@ -220,9 +212,7 @@ def _filter_cores_from_socket(
else:
# we have enough lcores per this core
continue
- elif self._filter_specifier.cores_per_socket > len(
- lcore_count_per_core_map
- ):
+ elif self._filter_specifier.cores_per_socket > len(lcore_count_per_core_map):
# only add cores if we need more
lcore_count_per_core_map[lcore.core] = 1
filtered_lcores.append(lcore)
diff --git a/dts/framework/testbed_model/node.py b/dts/framework/testbed_model/node.py
index fc01e0bf8e..ef700d8114 100644
--- a/dts/framework/testbed_model/node.py
+++ b/dts/framework/testbed_model/node.py
@@ -103,18 +103,14 @@ def _tear_down_execution(self) -> None:
is not decorated so that the derived class doesn't have to use the decorator.
"""
- def set_up_build_target(
- self, build_target_config: BuildTargetConfiguration
- ) -> None:
+ def set_up_build_target(self, build_target_config: BuildTargetConfiguration) -> None:
"""
Perform the build target setup that will be done for each build target
tested on this node.
"""
self._set_up_build_target(build_target_config)
- def _set_up_build_target(
- self, build_target_config: BuildTargetConfiguration
- ) -> None:
+ def _set_up_build_target(self, build_target_config: BuildTargetConfiguration) -> None:
"""
This method exists to be optionally overwritten by derived classes and
is not decorated so that the derived class doesn't have to use the decorator.
diff --git a/dts/framework/testbed_model/scapy.py b/dts/framework/testbed_model/scapy.py
index af0d4dbb25..7948424951 100644
--- a/dts/framework/testbed_model/scapy.py
+++ b/dts/framework/testbed_model/scapy.py
@@ -96,9 +96,7 @@ def scapy_send_packets_and_capture(
return [scapy_packet.build() for scapy_packet in sniffer.stop(join=True)]
-def scapy_send_packets(
- xmlrpc_packets: list[xmlrpc.client.Binary], send_iface: str
-) -> None:
+def scapy_send_packets(xmlrpc_packets: list[xmlrpc.client.Binary], send_iface: str) -> None:
"""RPC function to send packets.
The function is meant to be executed on the remote TG node.
@@ -197,9 +195,7 @@ class ScapyTrafficGenerator(CapturingTrafficGenerator):
def __init__(self, tg_node: TGNode, config: ScapyTrafficGeneratorConfig):
self._config = config
self._tg_node = tg_node
- self._logger = getLogger(
- f"{self._tg_node.name} {self._config.traffic_generator_type}"
- )
+ self._logger = getLogger(f"{self._tg_node.name} {self._config.traffic_generator_type}")
assert (
self._tg_node.config.os == OS.linux
@@ -218,9 +214,7 @@ def __init__(self, tg_node: TGNode, config: ScapyTrafficGeneratorConfig):
self._start_xmlrpc_server_in_remote_python(xmlrpc_server_listen_port)
# connect to the server
- server_url = (
- f"http://{self._tg_node.config.hostname}:{xmlrpc_server_listen_port}"
- )
+ server_url = f"http://{self._tg_node.config.hostname}:{xmlrpc_server_listen_port}"
self.rpc_server_proxy = xmlrpc.client.ServerProxy(
server_url, allow_none=True, verbose=SETTINGS.verbose
)
@@ -240,9 +234,7 @@ def _start_xmlrpc_server_in_remote_python(self, listen_port: int):
src = inspect.getsource(QuittableXMLRPCServer)
# Lines with only whitespace break the repl if in the middle of a function
# or class, so strip all lines containing only whitespace
- src = "\n".join(
- [line for line in src.splitlines() if not line.isspace() and line != ""]
- )
+ src = "\n".join([line for line in src.splitlines() if not line.isspace() and line != ""])
spacing = "\n" * 4
diff --git a/dts/framework/testbed_model/sut_node.py b/dts/framework/testbed_model/sut_node.py
index 202aebfd06..dfd8c755b4 100644
--- a/dts/framework/testbed_model/sut_node.py
+++ b/dts/framework/testbed_model/sut_node.py
@@ -129,9 +129,7 @@ def remote_dpdk_build_dir(self) -> PurePath:
@property
def dpdk_version(self) -> str:
if self._dpdk_version is None:
- self._dpdk_version = self.main_session.get_dpdk_version(
- self._remote_dpdk_dir
- )
+ self._dpdk_version = self.main_session.get_dpdk_version(self._remote_dpdk_dir)
return self._dpdk_version
@property
@@ -149,8 +147,7 @@ def compiler_version(self) -> str:
)
else:
self._logger.warning(
- "Failed to get compiler version because"
- "_build_target_config is None."
+ "Failed to get compiler version because" "_build_target_config is None."
)
return ""
return self._compiler_version
@@ -163,9 +160,7 @@ def get_build_target_info(self) -> BuildTargetInfo:
def _guess_dpdk_remote_dir(self) -> PurePath:
return self.main_session.guess_dpdk_remote_dir(self._remote_tmp_dir)
- def _set_up_build_target(
- self, build_target_config: BuildTargetConfiguration
- ) -> None:
+ def _set_up_build_target(self, build_target_config: BuildTargetConfiguration) -> None:
"""
Setup DPDK on the SUT node.
"""
@@ -177,22 +172,17 @@ def _set_up_build_target(
self._copy_dpdk_tarball()
self._build_dpdk()
- def _configure_build_target(
- self, build_target_config: BuildTargetConfiguration
- ) -> None:
+ def _configure_build_target(self, build_target_config: BuildTargetConfiguration) -> None:
"""
Populate common environment variables and set build target config.
"""
self._env_vars = {}
self._build_target_config = build_target_config
- self._env_vars.update(
- self.main_session.get_dpdk_build_env_vars(build_target_config.arch)
- )
+ self._env_vars.update(self.main_session.get_dpdk_build_env_vars(build_target_config.arch))
self._env_vars["CC"] = build_target_config.compiler.name
if build_target_config.compiler_wrapper:
self._env_vars["CC"] = (
- f"'{build_target_config.compiler_wrapper} "
- f"{build_target_config.compiler.name}'"
+ f"'{build_target_config.compiler_wrapper} " f"{build_target_config.compiler.name}'"
)
@Node.skip_setup
@@ -224,9 +214,7 @@ def _copy_dpdk_tarball(self) -> None:
self.main_session.remove_remote_dir(self._remote_dpdk_dir)
# then extract to remote path
- self.main_session.extract_remote_tarball(
- remote_tarball_path, self._remote_dpdk_dir
- )
+ self.main_session.extract_remote_tarball(remote_tarball_path, self._remote_dpdk_dir)
@Node.skip_setup
def _build_dpdk(self) -> None:
@@ -263,9 +251,7 @@ def build_dpdk_app(self, app_name: str, **meson_dpdk_args: str | bool) -> PurePa
)
if app_name == "all":
- return self.main_session.join_remote_path(
- self.remote_dpdk_build_dir, "examples"
- )
+ return self.main_session.join_remote_path(self.remote_dpdk_build_dir, "examples")
return self.main_session.join_remote_path(
self.remote_dpdk_build_dir, "examples", f"dpdk-{app_name}"
)
@@ -319,9 +305,7 @@ def create_eal_parameters(
'-c 0xf -a 0000:88:00.0 --file-prefix=dpdk_1112_20190809143420';
"""
- lcore_list = LogicalCoreList(
- self.filter_lcores(lcore_filter_specifier, ascending_cores)
- )
+ lcore_list = LogicalCoreList(self.filter_lcores(lcore_filter_specifier, ascending_cores))
if append_prefix_timestamp:
prefix = f"{prefix}_{self._dpdk_timestamp}"
@@ -386,6 +370,4 @@ def create_interactive_shell(
self.remote_dpdk_build_dir, shell_cls.path
)
- return super().create_interactive_shell(
- shell_cls, timeout, privileged, str(eal_parameters)
- )
+ return super().create_interactive_shell(shell_cls, timeout, privileged, str(eal_parameters))
diff --git a/dts/framework/testbed_model/tg_node.py b/dts/framework/testbed_model/tg_node.py
index 27025cfa31..dca4ec0849 100644
--- a/dts/framework/testbed_model/tg_node.py
+++ b/dts/framework/testbed_model/tg_node.py
@@ -45,9 +45,7 @@ class TGNode(Node):
def __init__(self, node_config: TGNodeConfiguration):
super(TGNode, self).__init__(node_config)
- self.traffic_generator = create_traffic_generator(
- self, node_config.traffic_generator
- )
+ self.traffic_generator = create_traffic_generator(self, node_config.traffic_generator)
self._logger.info(f"Created node: {self.name}")
def send_packet_and_capture(
@@ -94,6 +92,5 @@ def create_traffic_generator(
return ScapyTrafficGenerator(tg_node, traffic_generator_config)
case _:
raise ConfigurationError(
- "Unknown traffic generator: "
- f"{traffic_generator_config.traffic_generator_type}"
+ "Unknown traffic generator: " f"{traffic_generator_config.traffic_generator_type}"
)
diff --git a/dts/framework/utils.py b/dts/framework/utils.py
index d27c2c5b5f..d098d364ff 100644
--- a/dts/framework/utils.py
+++ b/dts/framework/utils.py
@@ -19,9 +19,7 @@
class StrEnum(Enum):
@staticmethod
- def _generate_next_value_(
- name: str, start: int, count: int, last_values: object
- ) -> str:
+ def _generate_next_value_(name: str, start: int, count: int, last_values: object) -> str:
return name
def __str__(self) -> str:
@@ -32,9 +30,7 @@ def __str__(self) -> str:
def check_dts_python_version() -> None:
- if sys.version_info.major < 3 or (
- sys.version_info.major == 3 and sys.version_info.minor < 10
- ):
+ if sys.version_info.major < 3 or (sys.version_info.major == 3 and sys.version_info.minor < 10):
print(
RED(
(
@@ -60,9 +56,7 @@ def expand_range(range_str: str) -> list[int]:
range_boundaries = range_str.split("-")
# will throw an exception when items in range_boundaries can't be converted,
# serving as type check
- expanded_range.extend(
- range(int(range_boundaries[0]), int(range_boundaries[-1]) + 1)
- )
+ expanded_range.extend(range(int(range_boundaries[0]), int(range_boundaries[-1]) + 1))
return expanded_range
@@ -71,9 +65,7 @@ def get_packet_summaries(packets: list[Packet]):
if len(packets) == 1:
packet_summaries = packets[0].summary()
else:
- packet_summaries = json.dumps(
- list(map(lambda pkt: pkt.summary(), packets)), indent=4
- )
+ packet_summaries = json.dumps(list(map(lambda pkt: pkt.summary(), packets)), indent=4)
return f"Packet contents: \n{packet_summaries}"
@@ -94,9 +86,7 @@ class MesonArgs(object):
_default_library: str
def __init__(self, default_library: str | None = None, **dpdk_args: str | bool):
- self._default_library = (
- f"--default-library={default_library}" if default_library else ""
- )
+ self._default_library = f"--default-library={default_library}" if default_library else ""
self._dpdk_args = " ".join(
(
f"-D{dpdk_arg_name}={dpdk_arg_value}"
diff --git a/dts/pyproject.toml b/dts/pyproject.toml
index 6762edfa6b..980ac3c7db 100644
--- a/dts/pyproject.toml
+++ b/dts/pyproject.toml
@@ -41,7 +41,7 @@ build-backend = "poetry.core.masonry.api"
[tool.pylama]
linters = "mccabe,pycodestyle,pyflakes"
format = "pylint"
-max_line_length = 88 # https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length
+max_line_length = 100
[tool.mypy]
python_version = "3.10"
@@ -55,4 +55,4 @@ profile = "black"
[tool.black]
target-version = ['py310']
include = '\.pyi?$'
-line-length = 88 # https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length
+line-length = 100
diff --git a/dts/tests/TestSuite_hello_world.py b/dts/tests/TestSuite_hello_world.py
index 7e3d95c0cf..768ba1cfa8 100644
--- a/dts/tests/TestSuite_hello_world.py
+++ b/dts/tests/TestSuite_hello_world.py
@@ -34,9 +34,7 @@ def test_hello_world_single_core(self) -> None:
# get the first usable core
lcore_amount = LogicalCoreCount(1, 1, 1)
lcores = LogicalCoreCountFilter(self.sut_node.lcores, lcore_amount).filter()
- eal_para = self.sut_node.create_eal_parameters(
- lcore_filter_specifier=lcore_amount
- )
+ eal_para = self.sut_node.create_eal_parameters(lcore_filter_specifier=lcore_amount)
result = self.sut_node.run_dpdk_app(self.app_helloworld_path, eal_para)
self.verify(
f"hello from core {int(lcores[0])}" in result.stdout,
diff --git a/dts/tests/TestSuite_smoke_tests.py b/dts/tests/TestSuite_smoke_tests.py
index 4a269df75b..36119e6469 100644
--- a/dts/tests/TestSuite_smoke_tests.py
+++ b/dts/tests/TestSuite_smoke_tests.py
@@ -45,13 +45,10 @@ def test_driver_tests(self) -> None:
for dev in self.sut_node.virtual_devices:
vdev_args += f"--vdev {dev} "
vdev_args = vdev_args[:-1]
- driver_tests_command = (
- f"meson test -C {self.dpdk_build_dir_path} --suite driver-tests"
- )
+ driver_tests_command = f"meson test -C {self.dpdk_build_dir_path} --suite driver-tests"
if vdev_args:
self._logger.info(
- "Running driver tests with the following virtual "
- f"devices: {vdev_args}"
+ "Running driver tests with the following virtual " f"devices: {vdev_args}"
)
driver_tests_command += f' --test-args "{vdev_args}"'
@@ -67,9 +64,7 @@ def test_devices_listed_in_testpmd(self) -> None:
Test:
Uses testpmd driver to verify that devices have been found by testpmd.
"""
- testpmd_driver = self.sut_node.create_interactive_shell(
- TestPmdShell, privileged=True
- )
+ testpmd_driver = self.sut_node.create_interactive_shell(TestPmdShell, privileged=True)
dev_list = [str(x) for x in testpmd_driver.get_devices()]
for nic in self.nics_in_node:
self.verify(
--
2.34.1
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v2 1/2] doc: increase python max line length to 100
2023-09-26 12:10 ` [PATCH v2 1/2] doc: increase python max line length to 100 Juraj Linkeš
2023-09-26 12:10 ` [PATCH v2 2/2] dts: reformat to 100 line length Juraj Linkeš
@ 2023-09-26 13:00 ` Bruce Richardson
2023-09-28 12:18 ` [PATCH v3 " Juraj Linkeš
2 siblings, 0 replies; 36+ messages in thread
From: Bruce Richardson @ 2023-09-26 13:00 UTC (permalink / raw)
To: Juraj Linkeš
Cc: thomas, Honnappa.Nagarahalli, jspewock, probb, stephen, dev
On Tue, Sep 26, 2023 at 02:10:12PM +0200, Juraj Linkeš wrote:
> Unify with C recommendations which allow line length of up to 100
> characters.
>
> Signed-off-by: Owen Hilyard <ohilyard@iol.unh.edu>
> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> ---
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v2 2/2] dts: reformat to 100 line length
2023-09-26 12:10 ` [PATCH v2 2/2] dts: reformat to 100 line length Juraj Linkeš
@ 2023-09-26 21:52 ` Jeremy Spewock
2023-09-28 7:27 ` Juraj Linkeš
2023-09-27 8:08 ` Bruce Richardson
1 sibling, 1 reply; 36+ messages in thread
From: Jeremy Spewock @ 2023-09-26 21:52 UTC (permalink / raw)
To: Juraj Linkeš
Cc: thomas, Honnappa.Nagarahalli, bruce.richardson, probb, stephen, dev
[-- Attachment #1: Type: text/plain, Size: 52997 bytes --]
I think this is a good idea because of all the weird places we had to break
things up with the 88 character cap. I do however also notice that in some
cases where these multi-line strings were combined back into one line it
would just have two string literals on the same line rather than them being
just oen string. I tried to point out everywhere I found this behavoir
below as it looks a little awkward in the code.
It looks good to me otherwise though.
On Tue, Sep 26, 2023 at 8:10 AM Juraj Linkeš <juraj.linkes@pantheon.tech>
wrote:
> Reformat to 100 from the previous 88 to unify with C recommendations.
>
> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> ---
> dts/framework/config/__init__.py | 20 ++-----
> dts/framework/dts.py | 12 +---
> dts/framework/exception.py | 3 +-
> dts/framework/remote_session/__init__.py | 4 +-
> dts/framework/remote_session/linux_session.py | 39 ++++---------
> dts/framework/remote_session/posix_session.py | 30 +++-------
> .../remote/interactive_remote_session.py | 7 +--
> .../remote/interactive_shell.py | 4 +-
> .../remote_session/remote/remote_session.py | 8 +--
> .../remote_session/remote/ssh_session.py | 16 ++----
> .../remote_session/remote/testpmd_shell.py | 8 +--
> dts/framework/settings.py | 4 +-
> dts/framework/test_result.py | 16 ++----
> dts/framework/test_suite.py | 57 +++++--------------
> .../capturing_traffic_generator.py | 4 +-
> dts/framework/testbed_model/hw/cpu.py | 20 ++-----
> dts/framework/testbed_model/node.py | 8 +--
> dts/framework/testbed_model/scapy.py | 16 ++----
> dts/framework/testbed_model/sut_node.py | 38 ++++---------
> dts/framework/testbed_model/tg_node.py | 7 +--
> dts/framework/utils.py | 20 ++-----
> dts/pyproject.toml | 4 +-
> dts/tests/TestSuite_hello_world.py | 4 +-
> dts/tests/TestSuite_smoke_tests.py | 11 +---
> 24 files changed, 93 insertions(+), 267 deletions(-)
>
> diff --git a/dts/framework/config/__init__.py
> b/dts/framework/config/__init__.py
> index cb7e00ba34..9b32cf0532 100644
> --- a/dts/framework/config/__init__.py
> +++ b/dts/framework/config/__init__.py
> @@ -140,9 +140,7 @@ def from_dict(d: dict) ->
> Union["SutNodeConfiguration", "TGNodeConfiguration"]:
>
> if "traffic_generator" in d:
> return TGNodeConfiguration(
> - traffic_generator=TrafficGeneratorConfig.from_dict(
> - d["traffic_generator"]
> - ),
> +
> traffic_generator=TrafficGeneratorConfig.from_dict(d["traffic_generator"]),
> **common_config,
> )
> else:
> @@ -249,9 +247,7 @@ def from_dict(
> build_targets: list[BuildTargetConfiguration] = list(
> map(BuildTargetConfiguration.from_dict, d["build_targets"])
> )
> - test_suites: list[TestSuiteConfig] = list(
> - map(TestSuiteConfig.from_dict, d["test_suites"])
> - )
> + test_suites: list[TestSuiteConfig] =
> list(map(TestSuiteConfig.from_dict, d["test_suites"]))
> sut_name = d["system_under_test_node"]["node_name"]
> skip_smoke_tests = d.get("skip_smoke_tests", False)
> assert sut_name in node_map, f"Unknown SUT {sut_name} in
> execution {d}"
> @@ -268,9 +264,7 @@ def from_dict(
> ), f"Invalid TG configuration {traffic_generator_node}"
>
> vdevs = (
> - d["system_under_test_node"]["vdevs"]
> - if "vdevs" in d["system_under_test_node"]
> - else []
> + d["system_under_test_node"]["vdevs"] if "vdevs" in
> d["system_under_test_node"] else []
> )
> return ExecutionConfiguration(
> build_targets=build_targets,
> @@ -299,9 +293,7 @@ def from_dict(d: dict) -> "Configuration":
> assert len(nodes) == len(node_map), "Duplicate node names are not
> allowed"
>
> executions: list[ExecutionConfiguration] = list(
> - map(
> - ExecutionConfiguration.from_dict, d["executions"],
> [node_map for _ in d]
> - )
> + map(ExecutionConfiguration.from_dict, d["executions"],
> [node_map for _ in d])
> )
>
> return Configuration(executions=executions)
> @@ -315,9 +307,7 @@ def load_config() -> Configuration:
> with open(SETTINGS.config_file_path, "r") as f:
> config_data = yaml.safe_load(f)
>
> - schema_path = os.path.join(
> - pathlib.Path(__file__).parent.resolve(), "conf_yaml_schema.json"
> - )
> + schema_path = os.path.join(pathlib.Path(__file__).parent.resolve(),
> "conf_yaml_schema.json")
>
> with open(schema_path, "r") as f:
> schema = json.load(f)
> diff --git a/dts/framework/dts.py b/dts/framework/dts.py
> index f773f0c38d..e2aada5a23 100644
> --- a/dts/framework/dts.py
> +++ b/dts/framework/dts.py
> @@ -92,9 +92,7 @@ def _run_execution(
> Run the given execution. This involves running the execution setup as
> well as
> running all build targets in the given execution.
> """
> - dts_logger.info(
> - f"Running execution with SUT '{
> execution.system_under_test_node.name}'."
> - )
> + dts_logger.info(f"Running execution with SUT '{
> execution.system_under_test_node.name}'.")
> execution_result = result.add_execution(sut_node.config)
> execution_result.add_sut_info(sut_node.node_info)
>
> @@ -107,9 +105,7 @@ def _run_execution(
>
> else:
> for build_target in execution.build_targets:
> - _run_build_target(
> - sut_node, tg_node, build_target, execution,
> execution_result
> - )
> + _run_build_target(sut_node, tg_node, build_target, execution,
> execution_result)
>
> finally:
> try:
> @@ -170,9 +166,7 @@ def _run_all_suites(
> execution.test_suites[:0] =
> [TestSuiteConfig.from_dict("smoke_tests")]
> for test_suite_config in execution.test_suites:
> try:
> - _run_single_suite(
> - sut_node, tg_node, execution, build_target_result,
> test_suite_config
> - )
> + _run_single_suite(sut_node, tg_node, execution,
> build_target_result, test_suite_config)
> except BlockingTestSuiteError as e:
> dts_logger.exception(
> f"An error occurred within
> {test_suite_config.test_suite}. "
> diff --git a/dts/framework/exception.py b/dts/framework/exception.py
> index 001a5a5496..59cf9fd12a 100644
> --- a/dts/framework/exception.py
> +++ b/dts/framework/exception.py
> @@ -117,8 +117,7 @@ def __init__(self, command: str, command_return_code:
> int):
>
> def __str__(self) -> str:
> return (
> - f"Command {self.command} returned a non-zero exit code: "
> - f"{self.command_return_code}"
> + f"Command {self.command} returned a non-zero exit code: "
> f"{self.command_return_code}"
>
If you modify this to be on the same line you actually don't need the
separate string on this line. The line could instead be the following:
f"Command {self.command} returned a non-zero exit code:
{self.command_return_code}"
> )
>
>
> diff --git a/dts/framework/remote_session/__init__.py
> b/dts/framework/remote_session/__init__.py
> index 00b6d1f03a..6124417bd7 100644
> --- a/dts/framework/remote_session/__init__.py
> +++ b/dts/framework/remote_session/__init__.py
> @@ -30,9 +30,7 @@
> )
>
>
> -def create_session(
> - node_config: NodeConfiguration, name: str, logger: DTSLOG
> -) -> OSSession:
> +def create_session(node_config: NodeConfiguration, name: str, logger:
> DTSLOG) -> OSSession:
> match node_config.os:
> case OS.linux:
> return LinuxSession(node_config, name, logger)
> diff --git a/dts/framework/remote_session/linux_session.py
> b/dts/framework/remote_session/linux_session.py
> index a3f1a6bf3b..aa76e25436 100644
> --- a/dts/framework/remote_session/linux_session.py
> +++ b/dts/framework/remote_session/linux_session.py
> @@ -82,9 +82,7 @@ def setup_hugepages(self, hugepage_amount: int,
> force_first_numa: bool) -> None:
> self._mount_huge_pages()
>
> def _get_hugepage_size(self) -> int:
> - hugepage_size = self.send_command(
> - "awk '/Hugepagesize/ {print $2}' /proc/meminfo"
> - ).stdout
> + hugepage_size = self.send_command("awk '/Hugepagesize/ {print
> $2}' /proc/meminfo").stdout
> return int(hugepage_size)
>
> def _get_hugepages_total(self) -> int:
> @@ -120,13 +118,9 @@ def _supports_numa(self) -> bool:
> # there's no reason to do any numa specific configuration)
> return len(self._numa_nodes) > 1
>
> - def _configure_huge_pages(
> - self, amount: int, size: int, force_first_numa: bool
> - ) -> None:
> + def _configure_huge_pages(self, amount: int, size: int,
> force_first_numa: bool) -> None:
> self._logger.info("Configuring Hugepages.")
> - hugepage_config_path = (
> - f"/sys/kernel/mm/hugepages/hugepages-{size}kB/nr_hugepages"
> - )
> + hugepage_config_path =
> f"/sys/kernel/mm/hugepages/hugepages-{size}kB/nr_hugepages"
> if force_first_numa and self._supports_numa():
> # clear non-numa hugepages
> self.send_command(f"echo 0 | tee {hugepage_config_path}",
> privileged=True)
> @@ -135,24 +129,18 @@ def _configure_huge_pages(
> f"/hugepages-{size}kB/nr_hugepages"
> )
>
> - self.send_command(
> - f"echo {amount} | tee {hugepage_config_path}", privileged=True
> - )
> + self.send_command(f"echo {amount} | tee {hugepage_config_path}",
> privileged=True)
>
> def update_ports(self, ports: list[Port]) -> None:
> self._logger.debug("Gathering port info.")
> for port in ports:
> - assert (
> - port.node == self.name
> - ), "Attempted to gather port info on the wrong node"
> + assert port.node == self.name, "Attempted to gather port
> info on the wrong node"
>
> port_info_list = self._get_lshw_info()
> for port in ports:
> for port_info in port_info_list:
> if f"pci@{port.pci}" == port_info.get("businfo"):
> - self._update_port_attr(
> - port, port_info.get("logicalname"), "logical_name"
> - )
> + self._update_port_attr(port,
> port_info.get("logicalname"), "logical_name")
> self._update_port_attr(port, port_info.get("serial"),
> "mac_address")
> port_info_list.remove(port_info)
> break
> @@ -163,25 +151,18 @@ def _get_lshw_info(self) -> list[LshwOutput]:
> output = self.send_command("lshw -quiet -json -C network",
> verify=True)
> return json.loads(output.stdout)
>
> - def _update_port_attr(
> - self, port: Port, attr_value: str | None, attr_name: str
> - ) -> None:
> + def _update_port_attr(self, port: Port, attr_value: str | None,
> attr_name: str) -> None:
> if attr_value:
> setattr(port, attr_name, attr_value)
> - self._logger.debug(
> - f"Found '{attr_name}' of port {port.pci}: '{attr_value}'."
> - )
> + self._logger.debug(f"Found '{attr_name}' of port {port.pci}:
> '{attr_value}'.")
> else:
> self._logger.warning(
> - f"Attempted to get '{attr_name}' of port {port.pci}, "
> - f"but it doesn't exist."
> + f"Attempted to get '{attr_name}' of port {port.pci}, "
> f"but it doesn't exist."
>
This is another case where the two different strings aren't needed
> )
>
> def configure_port_state(self, port: Port, enable: bool) -> None:
> state = "up" if enable else "down"
> - self.send_command(
> - f"ip link set dev {port.logical_name} {state}",
> privileged=True
> - )
> + self.send_command(f"ip link set dev {port.logical_name} {state}",
> privileged=True)
>
> def configure_port_ip_address(
> self,
> diff --git a/dts/framework/remote_session/posix_session.py
> b/dts/framework/remote_session/posix_session.py
> index 5da0516e05..eb59252dd1 100644
> --- a/dts/framework/remote_session/posix_session.py
> +++ b/dts/framework/remote_session/posix_session.py
> @@ -94,8 +94,7 @@ def extract_remote_tarball(
> expected_dir: str | PurePath | None = None,
> ) -> None:
> self.send_command(
> - f"tar xfm {remote_tarball_path} "
> - f"-C {PurePosixPath(remote_tarball_path).parent}",
> + f"tar xfm {remote_tarball_path} " f"-C
> {PurePosixPath(remote_tarball_path).parent}",
>
Double string here as well.
> 60,
> )
> if expected_dir:
> @@ -125,8 +124,7 @@ def build_dpdk(
> self._logger.info("Configuring DPDK build from scratch.")
> self.remove_remote_dir(remote_dpdk_build_dir)
> self.send_command(
> - f"meson setup "
> - f"{meson_args} {remote_dpdk_dir}
> {remote_dpdk_build_dir}",
> + f"meson setup " f"{meson_args} {remote_dpdk_dir}
> {remote_dpdk_build_dir}",
>
Double string.
> timeout,
> verify=True,
> env=env_vars,
> @@ -140,9 +138,7 @@ def build_dpdk(
> raise DPDKBuildError(f"DPDK build failed when doing
> '{e.command}'.")
>
> def get_dpdk_version(self, build_dir: str | PurePath) -> str:
> - out = self.send_command(
> - f"cat {self.join_remote_path(build_dir, 'VERSION')}",
> verify=True
> - )
> + out = self.send_command(f"cat {self.join_remote_path(build_dir,
> 'VERSION')}", verify=True)
> return out.stdout
>
> def kill_cleanup_dpdk_apps(self, dpdk_prefix_list: Iterable[str]) ->
> None:
> @@ -156,9 +152,7 @@ def kill_cleanup_dpdk_apps(self, dpdk_prefix_list:
> Iterable[str]) -> None:
> self._check_dpdk_hugepages(dpdk_runtime_dirs)
> self._remove_dpdk_runtime_dirs(dpdk_runtime_dirs)
>
> - def _get_dpdk_runtime_dirs(
> - self, dpdk_prefix_list: Iterable[str]
> - ) -> list[PurePosixPath]:
> + def _get_dpdk_runtime_dirs(self, dpdk_prefix_list: Iterable[str]) ->
> list[PurePosixPath]:
> prefix = PurePosixPath("/var", "run", "dpdk")
> if not dpdk_prefix_list:
> remote_prefixes = self._list_remote_dirs(prefix)
> @@ -174,9 +168,7 @@ def _list_remote_dirs(self, remote_path: str |
> PurePath) -> list[str] | None:
> Return a list of directories of the remote_dir.
> If remote_path doesn't exist, return None.
> """
> - out = self.send_command(
> - f"ls -l {remote_path} | awk '/^d/ {{print $NF}}'"
> - ).stdout
> + out = self.send_command(f"ls -l {remote_path} | awk '/^d/ {{print
> $NF}}'").stdout
> if "No such file or directory" in out:
> return None
> else:
> @@ -200,9 +192,7 @@ def _remote_files_exists(self, remote_path: PurePath)
> -> bool:
> result = self.send_command(f"test -e {remote_path}")
> return not result.return_code
>
> - def _check_dpdk_hugepages(
> - self, dpdk_runtime_dirs: Iterable[str | PurePath]
> - ) -> None:
> + def _check_dpdk_hugepages(self, dpdk_runtime_dirs: Iterable[str |
> PurePath]) -> None:
> for dpdk_runtime_dir in dpdk_runtime_dirs:
> hugepage_info = PurePosixPath(dpdk_runtime_dir,
> "hugepage_info")
> if self._remote_files_exists(hugepage_info):
> @@ -213,9 +203,7 @@ def _check_dpdk_hugepages(
> self._logger.warning(out)
>
> self._logger.warning("*******************************************")
>
> - def _remove_dpdk_runtime_dirs(
> - self, dpdk_runtime_dirs: Iterable[str | PurePath]
> - ) -> None:
> + def _remove_dpdk_runtime_dirs(self, dpdk_runtime_dirs: Iterable[str |
> PurePath]) -> None:
> for dpdk_runtime_dir in dpdk_runtime_dirs:
> self.remove_remote_dir(dpdk_runtime_dir)
>
> @@ -245,6 +233,4 @@ def get_node_info(self) -> NodeInfo:
> SETTINGS.timeout,
> ).stdout.split("\n")
> kernel_version = self.send_command("uname -r",
> SETTINGS.timeout).stdout
> - return NodeInfo(
> - os_release_info[0].strip(), os_release_info[1].strip(),
> kernel_version
> - )
> + return NodeInfo(os_release_info[0].strip(),
> os_release_info[1].strip(), kernel_version)
> diff --git
> a/dts/framework/remote_session/remote/interactive_remote_session.py
> b/dts/framework/remote_session/remote/interactive_remote_session.py
> index 9085a668e8..42c99b2525 100644
> --- a/dts/framework/remote_session/remote/interactive_remote_session.py
> +++ b/dts/framework/remote_session/remote/interactive_remote_session.py
> @@ -73,9 +73,7 @@ def __init__(self, node_config: NodeConfiguration,
> _logger: DTSLOG) -> None:
> f"Initializing interactive connection for {self.username}@
> {self.hostname}"
> )
> self._connect()
> - self._logger.info(
> - f"Interactive connection successful for {self.username}@
> {self.hostname}"
> - )
> + self._logger.info(f"Interactive connection successful for
> {self.username}@{self.hostname}")
>
> def _connect(self) -> None:
> """Establish a connection to the node.
> @@ -108,8 +106,7 @@ def _connect(self) -> None:
> self._logger.debug(traceback.format_exc())
> self._logger.warning(e)
> self._logger.info(
> - "Retrying interactive session connection: "
> - f"retry number {retry_attempt +1}"
> + "Retrying interactive session connection: " f"retry
> number {retry_attempt +1}"
>
Here you can get rid of the double string, but you would have to make sure
to add the f to the start to make the whole thing and f-string.
> )
> else:
> break
> diff --git a/dts/framework/remote_session/remote/interactive_shell.py
> b/dts/framework/remote_session/remote/interactive_shell.py
> index c24376b2a8..4db19fb9b3 100644
> --- a/dts/framework/remote_session/remote/interactive_shell.py
> +++ b/dts/framework/remote_session/remote/interactive_shell.py
> @@ -85,9 +85,7 @@ def __init__(
> self._app_args = app_args
> self._start_application(get_privileged_command)
>
> - def _start_application(
> - self, get_privileged_command: Callable[[str], str] | None
> - ) -> None:
> + def _start_application(self, get_privileged_command: Callable[[str],
> str] | None) -> None:
> """Starts a new interactive application based on the path to the
> app.
>
> This method is often overridden by subclasses as their process for
> diff --git a/dts/framework/remote_session/remote/remote_session.py
> b/dts/framework/remote_session/remote/remote_session.py
> index 0647d93de4..719f7d1ef7 100644
> --- a/dts/framework/remote_session/remote/remote_session.py
> +++ b/dts/framework/remote_session/remote/remote_session.py
> @@ -96,9 +96,7 @@ def send_command(
> If verify is True, check the return code of the executed command
> and raise a RemoteCommandExecutionError if the command failed.
> """
> - self._logger.info(
> - f"Sending: '{command}'" + (f" with env vars: '{env}'" if env
> else "")
> - )
> + self._logger.info(f"Sending: '{command}'" + (f" with env vars:
> '{env}'" if env else ""))
> result = self._send_command(command, timeout, env)
> if verify and result.return_code:
> self._logger.debug(
> @@ -112,9 +110,7 @@ def send_command(
> return result
>
> @abstractmethod
> - def _send_command(
> - self, command: str, timeout: float, env: dict | None
> - ) -> CommandResult:
> + def _send_command(self, command: str, timeout: float, env: dict |
> None) -> CommandResult:
> """
> Use the underlying protocol to execute the command using optional
> env vars
> and return CommandResult.
> diff --git a/dts/framework/remote_session/remote/ssh_session.py
> b/dts/framework/remote_session/remote/ssh_session.py
> index 8d127f1601..1a7ee649ab 100644
> --- a/dts/framework/remote_session/remote/ssh_session.py
> +++ b/dts/framework/remote_session/remote/ssh_session.py
> @@ -80,9 +80,7 @@ def _connect(self) -> None:
> if error not in errors:
> errors.append(error)
>
> - self._logger.info(
> - f"Retrying connection: retry number {retry_attempt +
> 1}."
> - )
> + self._logger.info(f"Retrying connection: retry number
> {retry_attempt + 1}.")
>
> else:
> break
> @@ -92,9 +90,7 @@ def _connect(self) -> None:
> def is_alive(self) -> bool:
> return self.session.is_connected
>
> - def _send_command(
> - self, command: str, timeout: float, env: dict | None
> - ) -> CommandResult:
> + def _send_command(self, command: str, timeout: float, env: dict |
> None) -> CommandResult:
> """Send a command and return the result of the execution.
>
> Args:
> @@ -107,9 +103,7 @@ def _send_command(
> SSHTimeoutError: The command execution timed out.
> """
> try:
> - output = self.session.run(
> - command, env=env, warn=True, hide=True, timeout=timeout
> - )
> + output = self.session.run(command, env=env, warn=True,
> hide=True, timeout=timeout)
>
> except (UnexpectedExit, ThreadException) as e:
> self._logger.exception(e)
> @@ -119,9 +113,7 @@ def _send_command(
> self._logger.exception(e)
> raise SSHTimeoutError(command, e.result.stderr) from e
>
> - return CommandResult(
> - self.name, command, output.stdout, output.stderr,
> output.return_code
> - )
> + return CommandResult(self.name, command, output.stdout,
> output.stderr, output.return_code)
>
> def copy_from(
> self,
> diff --git a/dts/framework/remote_session/remote/testpmd_shell.py
> b/dts/framework/remote_session/remote/testpmd_shell.py
> index 1455b5a199..08ac311016 100644
> --- a/dts/framework/remote_session/remote/testpmd_shell.py
> +++ b/dts/framework/remote_session/remote/testpmd_shell.py
> @@ -21,13 +21,9 @@ class TestPmdShell(InteractiveShell):
> path: PurePath = PurePath("app", "dpdk-testpmd")
> dpdk_app: bool = True
> _default_prompt: str = "testpmd>"
> - _command_extra_chars: str = (
> - "\n" # We want to append an extra newline to every command
> - )
> + _command_extra_chars: str = "\n" # We want to append an extra
> newline to every command
>
> - def _start_application(
> - self, get_privileged_command: Callable[[str], str] | None
> - ) -> None:
> + def _start_application(self, get_privileged_command: Callable[[str],
> str] | None) -> None:
> """See "_start_application" in InteractiveShell."""
> self._app_args += " -- -i"
> super()._start_application(get_privileged_command)
> diff --git a/dts/framework/settings.py b/dts/framework/settings.py
> index cfa39d011b..aad444e99c 100644
> --- a/dts/framework/settings.py
> +++ b/dts/framework/settings.py
> @@ -170,9 +170,7 @@ def _get_settings() -> _Settings:
> timeout=parsed_args.timeout,
> verbose=(parsed_args.verbose == "Y"),
> skip_setup=(parsed_args.skip_setup == "Y"),
> - dpdk_tarball_path=Path(
> - DPDKGitTarball(parsed_args.tarball, parsed_args.output_dir)
> - )
> + dpdk_tarball_path=Path(DPDKGitTarball(parsed_args.tarball,
> parsed_args.output_dir))
> if not os.path.exists(parsed_args.tarball)
> else Path(parsed_args.tarball),
> compile_timeout=parsed_args.compile_timeout,
> diff --git a/dts/framework/test_result.py b/dts/framework/test_result.py
> index f0fbe80f6f..4c2e7e2418 100644
> --- a/dts/framework/test_result.py
> +++ b/dts/framework/test_result.py
> @@ -83,9 +83,7 @@ def __iadd__(self, other: Result) -> "Statistics":
> """
> self[other.name] += 1
> self["PASS RATE"] = (
> - float(self[Result.PASS.name])
> - * 100
> - / sum(self[result.name] for result in Result)
> + float(self[Result.PASS.name]) * 100 / sum(self[result.name]
> for result in Result)
> )
> return self
>
> @@ -135,9 +133,7 @@ def _get_setup_teardown_errors(self) ->
> list[Exception]:
>
> def _get_inner_errors(self) -> list[Exception]:
> return [
> - error
> - for inner_result in self._inner_results
> - for error in inner_result.get_errors()
> + error for inner_result in self._inner_results for error in
> inner_result.get_errors()
> ]
>
> def get_errors(self) -> list[Exception]:
> @@ -174,9 +170,7 @@ def add_stats(self, statistics: Statistics) -> None:
> statistics += self.result
>
> def __bool__(self) -> bool:
> - return (
> - bool(self.setup_result) and bool(self.teardown_result) and
> bool(self.result)
> - )
> + return bool(self.setup_result) and bool(self.teardown_result) and
> bool(self.result)
>
>
> class TestSuiteResult(BaseResult):
> @@ -247,9 +241,7 @@ def __init__(self, sut_node: NodeConfiguration):
> super(ExecutionResult, self).__init__()
> self.sut_node = sut_node
>
> - def add_build_target(
> - self, build_target: BuildTargetConfiguration
> - ) -> BuildTargetResult:
> + def add_build_target(self, build_target: BuildTargetConfiguration) ->
> BuildTargetResult:
> build_target_result = BuildTargetResult(build_target)
> self._inner_results.append(build_target_result)
> return build_target_result
> diff --git a/dts/framework/test_suite.py b/dts/framework/test_suite.py
> index 3b890c0451..46d3de4944 100644
> --- a/dts/framework/test_suite.py
> +++ b/dts/framework/test_suite.py
> @@ -102,9 +102,7 @@ def _process_links(self) -> None:
> tg_port.peer,
> tg_port.identifier,
> ):
> - self._port_links.append(
> - PortLink(sut_port=sut_port, tg_port=tg_port)
> - )
> + self._port_links.append(PortLink(sut_port=sut_port,
> tg_port=tg_port))
>
> def set_up_suite(self) -> None:
> """
> @@ -151,9 +149,7 @@ def configure_testbed_ipv4(self, restore: bool =
> False) -> None:
> def _configure_ipv4_forwarding(self, enable: bool) -> None:
> self.sut_node.configure_ipv4_forwarding(enable)
>
> - def send_packet_and_capture(
> - self, packet: Packet, duration: float = 1
> - ) -> list[Packet]:
> + def send_packet_and_capture(self, packet: Packet, duration: float =
> 1) -> list[Packet]:
> """
> Send a packet through the appropriate interface and
> receive on the appropriate interface.
> @@ -202,21 +198,15 @@ def verify(self, condition: bool,
> failure_description: str) -> None:
> self._fail_test_case_verify(failure_description)
>
> def _fail_test_case_verify(self, failure_description: str) -> None:
> - self._logger.debug(
> - "A test case failed, showing the last 10 commands executed on
> SUT:"
> - )
> + self._logger.debug("A test case failed, showing the last 10
> commands executed on SUT:")
> for command_res in
> self.sut_node.main_session.remote_session.history[-10:]:
> self._logger.debug(command_res.command)
> - self._logger.debug(
> - "A test case failed, showing the last 10 commands executed on
> TG:"
> - )
> + self._logger.debug("A test case failed, showing the last 10
> commands executed on TG:")
> for command_res in
> self.tg_node.main_session.remote_session.history[-10:]:
> self._logger.debug(command_res.command)
> raise TestCaseVerifyError(failure_description)
>
> - def verify_packets(
> - self, expected_packet: Packet, received_packets: list[Packet]
> - ) -> None:
> + def verify_packets(self, expected_packet: Packet, received_packets:
> list[Packet]) -> None:
> for received_packet in received_packets:
> if self._compare_packets(expected_packet, received_packet):
> break
> @@ -225,17 +215,11 @@ def verify_packets(
> f"The expected packet
> {get_packet_summaries(expected_packet)} "
> f"not found among received
> {get_packet_summaries(received_packets)}"
> )
> - self._fail_test_case_verify(
> - "An expected packet not found among received packets."
> - )
> + self._fail_test_case_verify("An expected packet not found
> among received packets.")
>
> - def _compare_packets(
> - self, expected_packet: Packet, received_packet: Packet
> - ) -> bool:
> + def _compare_packets(self, expected_packet: Packet, received_packet:
> Packet) -> bool:
> self._logger.debug(
> - "Comparing packets: \n"
> - f"{expected_packet.summary()}\n"
> - f"{received_packet.summary()}"
> + "Comparing packets: \n" f"{expected_packet.summary()}\n"
> f"{received_packet.summary()}"
>
Same situation as above where you would want to make sure to put the f at
the start.
> )
>
> l3 = IP in expected_packet.layers()
> @@ -262,14 +246,10 @@ def _compare_packets(
> expected_payload = expected_payload.payload
>
> if expected_payload:
> - self._logger.debug(
> - f"The expected packet did not contain {expected_payload}."
> - )
> + self._logger.debug(f"The expected packet did not contain
> {expected_payload}.")
> return False
> if received_payload and received_payload.__class__ != Padding:
> - self._logger.debug(
> - "The received payload had extra layers which were not
> padding."
> - )
> + self._logger.debug("The received payload had extra layers
> which were not padding.")
> return False
> return True
>
> @@ -296,10 +276,7 @@ def _verify_l2_frame(self, received_packet: Ether,
> l3: bool) -> bool:
>
> def _verify_l3_packet(self, received_packet: IP, expected_packet: IP)
> -> bool:
> self._logger.debug("Looking at the IP layer.")
> - if (
> - received_packet.src != expected_packet.src
> - or received_packet.dst != expected_packet.dst
> - ):
> + if received_packet.src != expected_packet.src or
> received_packet.dst != expected_packet.dst:
> return False
> return True
>
> @@ -373,9 +350,7 @@ def _get_test_cases(self, test_case_regex: str) ->
> list[MethodType]:
> if self._should_be_executed(test_case_name, test_case_regex):
> filtered_test_cases.append(test_case)
> cases_str = ", ".join((x.__name__ for x in filtered_test_cases))
> - self._logger.debug(
> - f"Found test cases '{cases_str}' in
> {self.__class__.__name__}."
> - )
> + self._logger.debug(f"Found test cases '{cases_str}' in
> {self.__class__.__name__}.")
> return filtered_test_cases
>
> def _should_be_executed(self, test_case_name: str, test_case_regex:
> str) -> bool:
> @@ -445,9 +420,7 @@ def _execute_test_case(
> self._logger.exception(f"Test case execution ERROR:
> {test_case_name}")
> test_case_result.update(Result.ERROR, e)
> except KeyboardInterrupt:
> - self._logger.error(
> - f"Test case execution INTERRUPTED by user:
> {test_case_name}"
> - )
> + self._logger.error(f"Test case execution INTERRUPTED by user:
> {test_case_name}")
> test_case_result.update(Result.SKIP)
> raise KeyboardInterrupt("Stop DTS")
>
> @@ -464,9 +437,7 @@ def is_test_suite(object) -> bool:
> try:
> testcase_module = importlib.import_module(testsuite_module_path)
> except ModuleNotFoundError as e:
> - raise ConfigurationError(
> - f"Test suite '{testsuite_module_path}' not found."
> - ) from e
> + raise ConfigurationError(f"Test suite '{testsuite_module_path}'
> not found.") from e
> return [
> test_suite_class
> for _, test_suite_class in inspect.getmembers(testcase_module,
> is_test_suite)
> diff --git a/dts/framework/testbed_model/capturing_traffic_generator.py
> b/dts/framework/testbed_model/capturing_traffic_generator.py
> index ab98987f8e..48d019ab21 100644
> --- a/dts/framework/testbed_model/capturing_traffic_generator.py
> +++ b/dts/framework/testbed_model/capturing_traffic_generator.py
> @@ -110,9 +110,7 @@ def send_packets_and_capture(
> duration,
> )
>
> - self._logger.debug(
> - f"Received packets: {get_packet_summaries(received_packets)}"
> - )
> + self._logger.debug(f"Received packets:
> {get_packet_summaries(received_packets)}")
> self._write_capture_from_packets(capture_name, received_packets)
> return received_packets
>
> diff --git a/dts/framework/testbed_model/hw/cpu.py
> b/dts/framework/testbed_model/hw/cpu.py
> index d1918a12dc..cbc5fe7fff 100644
> --- a/dts/framework/testbed_model/hw/cpu.py
> +++ b/dts/framework/testbed_model/hw/cpu.py
> @@ -54,9 +54,7 @@ def __init__(self, lcore_list: list[int] | list[str] |
> list[LogicalCore] | str):
>
> # the input lcores may not be sorted
> self._lcore_list.sort()
> - self._lcore_str = (
> -
> f'{",".join(self._get_consecutive_lcores_range(self._lcore_list))}'
> - )
> + self._lcore_str =
> f'{",".join(self._get_consecutive_lcores_range(self._lcore_list))}'
>
> @property
> def lcore_list(self) -> list[int]:
> @@ -70,15 +68,11 @@ def _get_consecutive_lcores_range(self,
> lcore_ids_list: list[int]) -> list[str]:
> segment.append(lcore_id)
> else:
> formatted_core_list.append(
> - f"{segment[0]}-{segment[-1]}"
> - if len(segment) > 1
> - else f"{segment[0]}"
> + f"{segment[0]}-{segment[-1]}" if len(segment) > 1
> else f"{segment[0]}"
> )
> current_core_index = lcore_ids_list.index(lcore_id)
> formatted_core_list.extend(
> - self._get_consecutive_lcores_range(
> - lcore_ids_list[current_core_index:]
> - )
> +
> self._get_consecutive_lcores_range(lcore_ids_list[current_core_index:])
> )
> segment.clear()
> break
> @@ -125,9 +119,7 @@ def __init__(
> self._filter_specifier = filter_specifier
>
> # sorting by core is needed in case hyperthreading is enabled
> - self._lcores_to_filter = sorted(
> - lcore_list, key=lambda x: x.core, reverse=not ascending
> - )
> + self._lcores_to_filter = sorted(lcore_list, key=lambda x: x.core,
> reverse=not ascending)
> self.filter()
>
> @abstractmethod
> @@ -220,9 +212,7 @@ def _filter_cores_from_socket(
> else:
> # we have enough lcores per this core
> continue
> - elif self._filter_specifier.cores_per_socket > len(
> - lcore_count_per_core_map
> - ):
> + elif self._filter_specifier.cores_per_socket >
> len(lcore_count_per_core_map):
> # only add cores if we need more
> lcore_count_per_core_map[lcore.core] = 1
> filtered_lcores.append(lcore)
> diff --git a/dts/framework/testbed_model/node.py
> b/dts/framework/testbed_model/node.py
> index fc01e0bf8e..ef700d8114 100644
> --- a/dts/framework/testbed_model/node.py
> +++ b/dts/framework/testbed_model/node.py
> @@ -103,18 +103,14 @@ def _tear_down_execution(self) -> None:
> is not decorated so that the derived class doesn't have to use
> the decorator.
> """
>
> - def set_up_build_target(
> - self, build_target_config: BuildTargetConfiguration
> - ) -> None:
> + def set_up_build_target(self, build_target_config:
> BuildTargetConfiguration) -> None:
> """
> Perform the build target setup that will be done for each build
> target
> tested on this node.
> """
> self._set_up_build_target(build_target_config)
>
> - def _set_up_build_target(
> - self, build_target_config: BuildTargetConfiguration
> - ) -> None:
> + def _set_up_build_target(self, build_target_config:
> BuildTargetConfiguration) -> None:
> """
> This method exists to be optionally overwritten by derived
> classes and
> is not decorated so that the derived class doesn't have to use
> the decorator.
> diff --git a/dts/framework/testbed_model/scapy.py
> b/dts/framework/testbed_model/scapy.py
> index af0d4dbb25..7948424951 100644
> --- a/dts/framework/testbed_model/scapy.py
> +++ b/dts/framework/testbed_model/scapy.py
> @@ -96,9 +96,7 @@ def scapy_send_packets_and_capture(
> return [scapy_packet.build() for scapy_packet in
> sniffer.stop(join=True)]
>
>
> -def scapy_send_packets(
> - xmlrpc_packets: list[xmlrpc.client.Binary], send_iface: str
> -) -> None:
> +def scapy_send_packets(xmlrpc_packets: list[xmlrpc.client.Binary],
> send_iface: str) -> None:
> """RPC function to send packets.
>
> The function is meant to be executed on the remote TG node.
> @@ -197,9 +195,7 @@ class ScapyTrafficGenerator(CapturingTrafficGenerator):
> def __init__(self, tg_node: TGNode, config:
> ScapyTrafficGeneratorConfig):
> self._config = config
> self._tg_node = tg_node
> - self._logger = getLogger(
> - f"{self._tg_node.name} {self._config.traffic_generator_type}"
> - )
> + self._logger = getLogger(f"{self._tg_node.name}
> {self._config.traffic_generator_type}")
>
> assert (
> self._tg_node.config.os == OS.linux
> @@ -218,9 +214,7 @@ def __init__(self, tg_node: TGNode, config:
> ScapyTrafficGeneratorConfig):
>
> self._start_xmlrpc_server_in_remote_python(xmlrpc_server_listen_port)
>
> # connect to the server
> - server_url = (
> - f"http://
> {self._tg_node.config.hostname}:{xmlrpc_server_listen_port}"
> - )
> + server_url = f"http://
> {self._tg_node.config.hostname}:{xmlrpc_server_listen_port}"
> self.rpc_server_proxy = xmlrpc.client.ServerProxy(
> server_url, allow_none=True, verbose=SETTINGS.verbose
> )
> @@ -240,9 +234,7 @@ def _start_xmlrpc_server_in_remote_python(self,
> listen_port: int):
> src = inspect.getsource(QuittableXMLRPCServer)
> # Lines with only whitespace break the repl if in the middle of a
> function
> # or class, so strip all lines containing only whitespace
> - src = "\n".join(
> - [line for line in src.splitlines() if not line.isspace() and
> line != ""]
> - )
> + src = "\n".join([line for line in src.splitlines() if not
> line.isspace() and line != ""])
>
> spacing = "\n" * 4
>
> diff --git a/dts/framework/testbed_model/sut_node.py
> b/dts/framework/testbed_model/sut_node.py
> index 202aebfd06..dfd8c755b4 100644
> --- a/dts/framework/testbed_model/sut_node.py
> +++ b/dts/framework/testbed_model/sut_node.py
> @@ -129,9 +129,7 @@ def remote_dpdk_build_dir(self) -> PurePath:
> @property
> def dpdk_version(self) -> str:
> if self._dpdk_version is None:
> - self._dpdk_version = self.main_session.get_dpdk_version(
> - self._remote_dpdk_dir
> - )
> + self._dpdk_version =
> self.main_session.get_dpdk_version(self._remote_dpdk_dir)
> return self._dpdk_version
>
> @property
> @@ -149,8 +147,7 @@ def compiler_version(self) -> str:
> )
> else:
> self._logger.warning(
> - "Failed to get compiler version because"
> - "_build_target_config is None."
> + "Failed to get compiler version because"
> "_build_target_config is None."
>
Double string here.
> )
> return ""
> return self._compiler_version
> @@ -163,9 +160,7 @@ def get_build_target_info(self) -> BuildTargetInfo:
> def _guess_dpdk_remote_dir(self) -> PurePath:
> return
> self.main_session.guess_dpdk_remote_dir(self._remote_tmp_dir)
>
> - def _set_up_build_target(
> - self, build_target_config: BuildTargetConfiguration
> - ) -> None:
> + def _set_up_build_target(self, build_target_config:
> BuildTargetConfiguration) -> None:
> """
> Setup DPDK on the SUT node.
> """
> @@ -177,22 +172,17 @@ def _set_up_build_target(
> self._copy_dpdk_tarball()
> self._build_dpdk()
>
> - def _configure_build_target(
> - self, build_target_config: BuildTargetConfiguration
> - ) -> None:
> + def _configure_build_target(self, build_target_config:
> BuildTargetConfiguration) -> None:
> """
> Populate common environment variables and set build target config.
> """
> self._env_vars = {}
> self._build_target_config = build_target_config
> - self._env_vars.update(
> -
> self.main_session.get_dpdk_build_env_vars(build_target_config.arch)
> - )
> +
> self._env_vars.update(self.main_session.get_dpdk_build_env_vars(build_target_config.arch))
> self._env_vars["CC"] = build_target_config.compiler.name
> if build_target_config.compiler_wrapper:
> self._env_vars["CC"] = (
> - f"'{build_target_config.compiler_wrapper} "
> - f"{build_target_config.compiler.name}'"
> + f"'{build_target_config.compiler_wrapper} " f"{
> build_target_config.compiler.name}'"
>
Double string here.
> )
>
> @Node.skip_setup
> @@ -224,9 +214,7 @@ def _copy_dpdk_tarball(self) -> None:
> self.main_session.remove_remote_dir(self._remote_dpdk_dir)
>
> # then extract to remote path
> - self.main_session.extract_remote_tarball(
> - remote_tarball_path, self._remote_dpdk_dir
> - )
> + self.main_session.extract_remote_tarball(remote_tarball_path,
> self._remote_dpdk_dir)
>
> @Node.skip_setup
> def _build_dpdk(self) -> None:
> @@ -263,9 +251,7 @@ def build_dpdk_app(self, app_name: str,
> **meson_dpdk_args: str | bool) -> PurePa
> )
>
> if app_name == "all":
> - return self.main_session.join_remote_path(
> - self.remote_dpdk_build_dir, "examples"
> - )
> + return
> self.main_session.join_remote_path(self.remote_dpdk_build_dir, "examples")
> return self.main_session.join_remote_path(
> self.remote_dpdk_build_dir, "examples", f"dpdk-{app_name}"
> )
> @@ -319,9 +305,7 @@ def create_eal_parameters(
> '-c 0xf -a 0000:88:00.0
> --file-prefix=dpdk_1112_20190809143420';
> """
>
> - lcore_list = LogicalCoreList(
> - self.filter_lcores(lcore_filter_specifier, ascending_cores)
> - )
> + lcore_list =
> LogicalCoreList(self.filter_lcores(lcore_filter_specifier, ascending_cores))
>
> if append_prefix_timestamp:
> prefix = f"{prefix}_{self._dpdk_timestamp}"
> @@ -386,6 +370,4 @@ def create_interactive_shell(
> self.remote_dpdk_build_dir, shell_cls.path
> )
>
> - return super().create_interactive_shell(
> - shell_cls, timeout, privileged, str(eal_parameters)
> - )
> + return super().create_interactive_shell(shell_cls, timeout,
> privileged, str(eal_parameters))
> diff --git a/dts/framework/testbed_model/tg_node.py
> b/dts/framework/testbed_model/tg_node.py
> index 27025cfa31..dca4ec0849 100644
> --- a/dts/framework/testbed_model/tg_node.py
> +++ b/dts/framework/testbed_model/tg_node.py
> @@ -45,9 +45,7 @@ class TGNode(Node):
>
> def __init__(self, node_config: TGNodeConfiguration):
> super(TGNode, self).__init__(node_config)
> - self.traffic_generator = create_traffic_generator(
> - self, node_config.traffic_generator
> - )
> + self.traffic_generator = create_traffic_generator(self,
> node_config.traffic_generator)
> self._logger.info(f"Created node: {self.name}")
>
> def send_packet_and_capture(
> @@ -94,6 +92,5 @@ def create_traffic_generator(
> return ScapyTrafficGenerator(tg_node,
> traffic_generator_config)
> case _:
> raise ConfigurationError(
> - "Unknown traffic generator: "
> - f"{traffic_generator_config.traffic_generator_type}"
> + "Unknown traffic generator: "
> f"{traffic_generator_config.traffic_generator_type}"
>
Double string but one that needs the whole thing to be an f-string.
> )
> diff --git a/dts/framework/utils.py b/dts/framework/utils.py
> index d27c2c5b5f..d098d364ff 100644
> --- a/dts/framework/utils.py
> +++ b/dts/framework/utils.py
> @@ -19,9 +19,7 @@
>
> class StrEnum(Enum):
> @staticmethod
> - def _generate_next_value_(
> - name: str, start: int, count: int, last_values: object
> - ) -> str:
> + def _generate_next_value_(name: str, start: int, count: int,
> last_values: object) -> str:
> return name
>
> def __str__(self) -> str:
> @@ -32,9 +30,7 @@ def __str__(self) -> str:
>
>
> def check_dts_python_version() -> None:
> - if sys.version_info.major < 3 or (
> - sys.version_info.major == 3 and sys.version_info.minor < 10
> - ):
> + if sys.version_info.major < 3 or (sys.version_info.major == 3 and
> sys.version_info.minor < 10):
> print(
> RED(
> (
> @@ -60,9 +56,7 @@ def expand_range(range_str: str) -> list[int]:
> range_boundaries = range_str.split("-")
> # will throw an exception when items in range_boundaries can't be
> converted,
> # serving as type check
> - expanded_range.extend(
> - range(int(range_boundaries[0]), int(range_boundaries[-1]) + 1)
> - )
> + expanded_range.extend(range(int(range_boundaries[0]),
> int(range_boundaries[-1]) + 1))
>
> return expanded_range
>
> @@ -71,9 +65,7 @@ def get_packet_summaries(packets: list[Packet]):
> if len(packets) == 1:
> packet_summaries = packets[0].summary()
> else:
> - packet_summaries = json.dumps(
> - list(map(lambda pkt: pkt.summary(), packets)), indent=4
> - )
> + packet_summaries = json.dumps(list(map(lambda pkt: pkt.summary(),
> packets)), indent=4)
> return f"Packet contents: \n{packet_summaries}"
>
>
> @@ -94,9 +86,7 @@ class MesonArgs(object):
> _default_library: str
>
> def __init__(self, default_library: str | None = None, **dpdk_args:
> str | bool):
> - self._default_library = (
> - f"--default-library={default_library}" if default_library
> else ""
> - )
> + self._default_library = f"--default-library={default_library}" if
> default_library else ""
> self._dpdk_args = " ".join(
> (
> f"-D{dpdk_arg_name}={dpdk_arg_value}"
> diff --git a/dts/pyproject.toml b/dts/pyproject.toml
> index 6762edfa6b..980ac3c7db 100644
> --- a/dts/pyproject.toml
> +++ b/dts/pyproject.toml
> @@ -41,7 +41,7 @@ build-backend = "poetry.core.masonry.api"
> [tool.pylama]
> linters = "mccabe,pycodestyle,pyflakes"
> format = "pylint"
> -max_line_length = 88 #
> https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length
> +max_line_length = 100
>
> [tool.mypy]
> python_version = "3.10"
> @@ -55,4 +55,4 @@ profile = "black"
> [tool.black]
> target-version = ['py310']
> include = '\.pyi?$'
> -line-length = 88 #
> https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length
> +line-length
> <https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length+line-length>
> = 100
> diff --git a/dts/tests/TestSuite_hello_world.py
> b/dts/tests/TestSuite_hello_world.py
> index 7e3d95c0cf..768ba1cfa8 100644
> --- a/dts/tests/TestSuite_hello_world.py
> +++ b/dts/tests/TestSuite_hello_world.py
> @@ -34,9 +34,7 @@ def test_hello_world_single_core(self) -> None:
> # get the first usable core
> lcore_amount = LogicalCoreCount(1, 1, 1)
> lcores = LogicalCoreCountFilter(self.sut_node.lcores,
> lcore_amount).filter()
> - eal_para = self.sut_node.create_eal_parameters(
> - lcore_filter_specifier=lcore_amount
> - )
> + eal_para =
> self.sut_node.create_eal_parameters(lcore_filter_specifier=lcore_amount)
> result = self.sut_node.run_dpdk_app(self.app_helloworld_path,
> eal_para)
> self.verify(
> f"hello from core {int(lcores[0])}" in result.stdout,
> diff --git a/dts/tests/TestSuite_smoke_tests.py
> b/dts/tests/TestSuite_smoke_tests.py
> index 4a269df75b..36119e6469 100644
> --- a/dts/tests/TestSuite_smoke_tests.py
> +++ b/dts/tests/TestSuite_smoke_tests.py
> @@ -45,13 +45,10 @@ def test_driver_tests(self) -> None:
> for dev in self.sut_node.virtual_devices:
> vdev_args += f"--vdev {dev} "
> vdev_args = vdev_args[:-1]
> - driver_tests_command = (
> - f"meson test -C {self.dpdk_build_dir_path} --suite
> driver-tests"
> - )
> + driver_tests_command = f"meson test -C {self.dpdk_build_dir_path}
> --suite driver-tests"
> if vdev_args:
> self._logger.info(
> - "Running driver tests with the following virtual "
> - f"devices: {vdev_args}"
> + "Running driver tests with the following virtual "
> f"devices: {vdev_args}"
>
Double string that should be an f-string.
> )
> driver_tests_command += f' --test-args "{vdev_args}"'
>
> @@ -67,9 +64,7 @@ def test_devices_listed_in_testpmd(self) -> None:
> Test:
> Uses testpmd driver to verify that devices have been found by
> testpmd.
> """
> - testpmd_driver = self.sut_node.create_interactive_shell(
> - TestPmdShell, privileged=True
> - )
> + testpmd_driver =
> self.sut_node.create_interactive_shell(TestPmdShell, privileged=True)
> dev_list = [str(x) for x in testpmd_driver.get_devices()]
> for nic in self.nics_in_node:
> self.verify(
> --
> 2.34.1
>
>
[-- Attachment #2: Type: text/html, Size: 67422 bytes --]
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v2 2/2] dts: reformat to 100 line length
2023-09-26 12:10 ` [PATCH v2 2/2] dts: reformat to 100 line length Juraj Linkeš
2023-09-26 21:52 ` Jeremy Spewock
@ 2023-09-27 8:08 ` Bruce Richardson
2023-09-28 7:33 ` Juraj Linkeš
1 sibling, 1 reply; 36+ messages in thread
From: Bruce Richardson @ 2023-09-27 8:08 UTC (permalink / raw)
To: Juraj Linkeš
Cc: thomas, Honnappa.Nagarahalli, jspewock, probb, stephen, dev
On Tue, Sep 26, 2023 at 02:10:13PM +0200, Juraj Linkeš wrote:
> Reformat to 100 from the previous 88 to unify with C recommendations.
>
> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
Generally for something like this we wouldn't reformat the existing code,
because it confuses the git history e.g. for those looking for "fixlines"
for bug fixes. However, given that DTS is so new in the repo, it's probably
ok and worthwhile doing.
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v2 2/2] dts: reformat to 100 line length
2023-09-26 21:52 ` Jeremy Spewock
@ 2023-09-28 7:27 ` Juraj Linkeš
0 siblings, 0 replies; 36+ messages in thread
From: Juraj Linkeš @ 2023-09-28 7:27 UTC (permalink / raw)
To: Jeremy Spewock
Cc: thomas, Honnappa.Nagarahalli, bruce.richardson, probb, stephen, dev
[-- Attachment #1: Type: text/plain, Size: 54591 bytes --]
Thanks, Jeremy. I skimmed the changes before submitting them, but I didn't
catch this. I'll submit a new version.
On Tue, Sep 26, 2023 at 11:52 PM Jeremy Spewock <jspewock@iol.unh.edu>
wrote:
>
>
> I think this is a good idea because of all the weird places we had to
> break things up with the 88 character cap. I do however also notice that in
> some cases where these multi-line strings were combined back into one line
> it would just have two string literals on the same line rather than them
> being just oen string. I tried to point out everywhere I found this
> behavoir below as it looks a little awkward in the code.
>
> It looks good to me otherwise though.
>
>
> On Tue, Sep 26, 2023 at 8:10 AM Juraj Linkeš <juraj.linkes@pantheon.tech>
> wrote:
>
>> Reformat to 100 from the previous 88 to unify with C recommendations.
>>
>> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
>> ---
>> dts/framework/config/__init__.py | 20 ++-----
>> dts/framework/dts.py | 12 +---
>> dts/framework/exception.py | 3 +-
>> dts/framework/remote_session/__init__.py | 4 +-
>> dts/framework/remote_session/linux_session.py | 39 ++++---------
>> dts/framework/remote_session/posix_session.py | 30 +++-------
>> .../remote/interactive_remote_session.py | 7 +--
>> .../remote/interactive_shell.py | 4 +-
>> .../remote_session/remote/remote_session.py | 8 +--
>> .../remote_session/remote/ssh_session.py | 16 ++----
>> .../remote_session/remote/testpmd_shell.py | 8 +--
>> dts/framework/settings.py | 4 +-
>> dts/framework/test_result.py | 16 ++----
>> dts/framework/test_suite.py | 57 +++++--------------
>> .../capturing_traffic_generator.py | 4 +-
>> dts/framework/testbed_model/hw/cpu.py | 20 ++-----
>> dts/framework/testbed_model/node.py | 8 +--
>> dts/framework/testbed_model/scapy.py | 16 ++----
>> dts/framework/testbed_model/sut_node.py | 38 ++++---------
>> dts/framework/testbed_model/tg_node.py | 7 +--
>> dts/framework/utils.py | 20 ++-----
>> dts/pyproject.toml | 4 +-
>> dts/tests/TestSuite_hello_world.py | 4 +-
>> dts/tests/TestSuite_smoke_tests.py | 11 +---
>> 24 files changed, 93 insertions(+), 267 deletions(-)
>>
>> diff --git a/dts/framework/config/__init__.py
>> b/dts/framework/config/__init__.py
>> index cb7e00ba34..9b32cf0532 100644
>> --- a/dts/framework/config/__init__.py
>> +++ b/dts/framework/config/__init__.py
>> @@ -140,9 +140,7 @@ def from_dict(d: dict) ->
>> Union["SutNodeConfiguration", "TGNodeConfiguration"]:
>>
>> if "traffic_generator" in d:
>> return TGNodeConfiguration(
>> - traffic_generator=TrafficGeneratorConfig.from_dict(
>> - d["traffic_generator"]
>> - ),
>> +
>> traffic_generator=TrafficGeneratorConfig.from_dict(d["traffic_generator"]),
>> **common_config,
>> )
>> else:
>> @@ -249,9 +247,7 @@ def from_dict(
>> build_targets: list[BuildTargetConfiguration] = list(
>> map(BuildTargetConfiguration.from_dict, d["build_targets"])
>> )
>> - test_suites: list[TestSuiteConfig] = list(
>> - map(TestSuiteConfig.from_dict, d["test_suites"])
>> - )
>> + test_suites: list[TestSuiteConfig] =
>> list(map(TestSuiteConfig.from_dict, d["test_suites"]))
>> sut_name = d["system_under_test_node"]["node_name"]
>> skip_smoke_tests = d.get("skip_smoke_tests", False)
>> assert sut_name in node_map, f"Unknown SUT {sut_name} in
>> execution {d}"
>> @@ -268,9 +264,7 @@ def from_dict(
>> ), f"Invalid TG configuration {traffic_generator_node}"
>>
>> vdevs = (
>> - d["system_under_test_node"]["vdevs"]
>> - if "vdevs" in d["system_under_test_node"]
>> - else []
>> + d["system_under_test_node"]["vdevs"] if "vdevs" in
>> d["system_under_test_node"] else []
>> )
>> return ExecutionConfiguration(
>> build_targets=build_targets,
>> @@ -299,9 +293,7 @@ def from_dict(d: dict) -> "Configuration":
>> assert len(nodes) == len(node_map), "Duplicate node names are
>> not allowed"
>>
>> executions: list[ExecutionConfiguration] = list(
>> - map(
>> - ExecutionConfiguration.from_dict, d["executions"],
>> [node_map for _ in d]
>> - )
>> + map(ExecutionConfiguration.from_dict, d["executions"],
>> [node_map for _ in d])
>> )
>>
>> return Configuration(executions=executions)
>> @@ -315,9 +307,7 @@ def load_config() -> Configuration:
>> with open(SETTINGS.config_file_path, "r") as f:
>> config_data = yaml.safe_load(f)
>>
>> - schema_path = os.path.join(
>> - pathlib.Path(__file__).parent.resolve(), "conf_yaml_schema.json"
>> - )
>> + schema_path = os.path.join(pathlib.Path(__file__).parent.resolve(),
>> "conf_yaml_schema.json")
>>
>> with open(schema_path, "r") as f:
>> schema = json.load(f)
>> diff --git a/dts/framework/dts.py b/dts/framework/dts.py
>> index f773f0c38d..e2aada5a23 100644
>> --- a/dts/framework/dts.py
>> +++ b/dts/framework/dts.py
>> @@ -92,9 +92,7 @@ def _run_execution(
>> Run the given execution. This involves running the execution setup
>> as well as
>> running all build targets in the given execution.
>> """
>> - dts_logger.info(
>> - f"Running execution with SUT '{
>> execution.system_under_test_node.name}'."
>> - )
>> + dts_logger.info(f"Running execution with SUT '{
>> execution.system_under_test_node.name}'.")
>> execution_result = result.add_execution(sut_node.config)
>> execution_result.add_sut_info(sut_node.node_info)
>>
>> @@ -107,9 +105,7 @@ def _run_execution(
>>
>> else:
>> for build_target in execution.build_targets:
>> - _run_build_target(
>> - sut_node, tg_node, build_target, execution,
>> execution_result
>> - )
>> + _run_build_target(sut_node, tg_node, build_target,
>> execution, execution_result)
>>
>> finally:
>> try:
>> @@ -170,9 +166,7 @@ def _run_all_suites(
>> execution.test_suites[:0] =
>> [TestSuiteConfig.from_dict("smoke_tests")]
>> for test_suite_config in execution.test_suites:
>> try:
>> - _run_single_suite(
>> - sut_node, tg_node, execution, build_target_result,
>> test_suite_config
>> - )
>> + _run_single_suite(sut_node, tg_node, execution,
>> build_target_result, test_suite_config)
>> except BlockingTestSuiteError as e:
>> dts_logger.exception(
>> f"An error occurred within
>> {test_suite_config.test_suite}. "
>> diff --git a/dts/framework/exception.py b/dts/framework/exception.py
>> index 001a5a5496..59cf9fd12a 100644
>> --- a/dts/framework/exception.py
>> +++ b/dts/framework/exception.py
>> @@ -117,8 +117,7 @@ def __init__(self, command: str, command_return_code:
>> int):
>>
>> def __str__(self) -> str:
>> return (
>> - f"Command {self.command} returned a non-zero exit code: "
>> - f"{self.command_return_code}"
>> + f"Command {self.command} returned a non-zero exit code: "
>> f"{self.command_return_code}"
>>
>
> If you modify this to be on the same line you actually don't need the
> separate string on this line. The line could instead be the following:
>
> f"Command {self.command} returned a non-zero exit code:
> {self.command_return_code}"
>
>
>> )
>>
>>
>> diff --git a/dts/framework/remote_session/__init__.py
>> b/dts/framework/remote_session/__init__.py
>> index 00b6d1f03a..6124417bd7 100644
>> --- a/dts/framework/remote_session/__init__.py
>> +++ b/dts/framework/remote_session/__init__.py
>> @@ -30,9 +30,7 @@
>> )
>>
>>
>> -def create_session(
>> - node_config: NodeConfiguration, name: str, logger: DTSLOG
>> -) -> OSSession:
>> +def create_session(node_config: NodeConfiguration, name: str, logger:
>> DTSLOG) -> OSSession:
>> match node_config.os:
>> case OS.linux:
>> return LinuxSession(node_config, name, logger)
>> diff --git a/dts/framework/remote_session/linux_session.py
>> b/dts/framework/remote_session/linux_session.py
>> index a3f1a6bf3b..aa76e25436 100644
>> --- a/dts/framework/remote_session/linux_session.py
>> +++ b/dts/framework/remote_session/linux_session.py
>> @@ -82,9 +82,7 @@ def setup_hugepages(self, hugepage_amount: int,
>> force_first_numa: bool) -> None:
>> self._mount_huge_pages()
>>
>> def _get_hugepage_size(self) -> int:
>> - hugepage_size = self.send_command(
>> - "awk '/Hugepagesize/ {print $2}' /proc/meminfo"
>> - ).stdout
>> + hugepage_size = self.send_command("awk '/Hugepagesize/ {print
>> $2}' /proc/meminfo").stdout
>> return int(hugepage_size)
>>
>> def _get_hugepages_total(self) -> int:
>> @@ -120,13 +118,9 @@ def _supports_numa(self) -> bool:
>> # there's no reason to do any numa specific configuration)
>> return len(self._numa_nodes) > 1
>>
>> - def _configure_huge_pages(
>> - self, amount: int, size: int, force_first_numa: bool
>> - ) -> None:
>> + def _configure_huge_pages(self, amount: int, size: int,
>> force_first_numa: bool) -> None:
>> self._logger.info("Configuring Hugepages.")
>> - hugepage_config_path = (
>> - f"/sys/kernel/mm/hugepages/hugepages-{size}kB/nr_hugepages"
>> - )
>> + hugepage_config_path =
>> f"/sys/kernel/mm/hugepages/hugepages-{size}kB/nr_hugepages"
>> if force_first_numa and self._supports_numa():
>> # clear non-numa hugepages
>> self.send_command(f"echo 0 | tee {hugepage_config_path}",
>> privileged=True)
>> @@ -135,24 +129,18 @@ def _configure_huge_pages(
>> f"/hugepages-{size}kB/nr_hugepages"
>> )
>>
>> - self.send_command(
>> - f"echo {amount} | tee {hugepage_config_path}",
>> privileged=True
>> - )
>> + self.send_command(f"echo {amount} | tee {hugepage_config_path}",
>> privileged=True)
>>
>> def update_ports(self, ports: list[Port]) -> None:
>> self._logger.debug("Gathering port info.")
>> for port in ports:
>> - assert (
>> - port.node == self.name
>> - ), "Attempted to gather port info on the wrong node"
>> + assert port.node == self.name, "Attempted to gather port
>> info on the wrong node"
>>
>> port_info_list = self._get_lshw_info()
>> for port in ports:
>> for port_info in port_info_list:
>> if f"pci@{port.pci}" == port_info.get("businfo"):
>> - self._update_port_attr(
>> - port, port_info.get("logicalname"),
>> "logical_name"
>> - )
>> + self._update_port_attr(port,
>> port_info.get("logicalname"), "logical_name")
>> self._update_port_attr(port,
>> port_info.get("serial"), "mac_address")
>> port_info_list.remove(port_info)
>> break
>> @@ -163,25 +151,18 @@ def _get_lshw_info(self) -> list[LshwOutput]:
>> output = self.send_command("lshw -quiet -json -C network",
>> verify=True)
>> return json.loads(output.stdout)
>>
>> - def _update_port_attr(
>> - self, port: Port, attr_value: str | None, attr_name: str
>> - ) -> None:
>> + def _update_port_attr(self, port: Port, attr_value: str | None,
>> attr_name: str) -> None:
>> if attr_value:
>> setattr(port, attr_name, attr_value)
>> - self._logger.debug(
>> - f"Found '{attr_name}' of port {port.pci}:
>> '{attr_value}'."
>> - )
>> + self._logger.debug(f"Found '{attr_name}' of port {port.pci}:
>> '{attr_value}'.")
>> else:
>> self._logger.warning(
>> - f"Attempted to get '{attr_name}' of port {port.pci}, "
>> - f"but it doesn't exist."
>> + f"Attempted to get '{attr_name}' of port {port.pci}, "
>> f"but it doesn't exist."
>>
>
> This is another case where the two different strings aren't needed
>
>
>> )
>>
>> def configure_port_state(self, port: Port, enable: bool) -> None:
>> state = "up" if enable else "down"
>> - self.send_command(
>> - f"ip link set dev {port.logical_name} {state}",
>> privileged=True
>> - )
>> + self.send_command(f"ip link set dev {port.logical_name}
>> {state}", privileged=True)
>>
>> def configure_port_ip_address(
>> self,
>> diff --git a/dts/framework/remote_session/posix_session.py
>> b/dts/framework/remote_session/posix_session.py
>> index 5da0516e05..eb59252dd1 100644
>> --- a/dts/framework/remote_session/posix_session.py
>> +++ b/dts/framework/remote_session/posix_session.py
>> @@ -94,8 +94,7 @@ def extract_remote_tarball(
>> expected_dir: str | PurePath | None = None,
>> ) -> None:
>> self.send_command(
>> - f"tar xfm {remote_tarball_path} "
>> - f"-C {PurePosixPath(remote_tarball_path).parent}",
>> + f"tar xfm {remote_tarball_path} " f"-C
>> {PurePosixPath(remote_tarball_path).parent}",
>>
>
> Double string here as well.
>
>
>> 60,
>> )
>> if expected_dir:
>> @@ -125,8 +124,7 @@ def build_dpdk(
>> self._logger.info("Configuring DPDK build from
>> scratch.")
>> self.remove_remote_dir(remote_dpdk_build_dir)
>> self.send_command(
>> - f"meson setup "
>> - f"{meson_args} {remote_dpdk_dir}
>> {remote_dpdk_build_dir}",
>> + f"meson setup " f"{meson_args} {remote_dpdk_dir}
>> {remote_dpdk_build_dir}",
>>
>
> Double string.
>
>
>> timeout,
>> verify=True,
>> env=env_vars,
>> @@ -140,9 +138,7 @@ def build_dpdk(
>> raise DPDKBuildError(f"DPDK build failed when doing
>> '{e.command}'.")
>>
>> def get_dpdk_version(self, build_dir: str | PurePath) -> str:
>> - out = self.send_command(
>> - f"cat {self.join_remote_path(build_dir, 'VERSION')}",
>> verify=True
>> - )
>> + out = self.send_command(f"cat {self.join_remote_path(build_dir,
>> 'VERSION')}", verify=True)
>> return out.stdout
>>
>> def kill_cleanup_dpdk_apps(self, dpdk_prefix_list: Iterable[str]) ->
>> None:
>> @@ -156,9 +152,7 @@ def kill_cleanup_dpdk_apps(self, dpdk_prefix_list:
>> Iterable[str]) -> None:
>> self._check_dpdk_hugepages(dpdk_runtime_dirs)
>> self._remove_dpdk_runtime_dirs(dpdk_runtime_dirs)
>>
>> - def _get_dpdk_runtime_dirs(
>> - self, dpdk_prefix_list: Iterable[str]
>> - ) -> list[PurePosixPath]:
>> + def _get_dpdk_runtime_dirs(self, dpdk_prefix_list: Iterable[str]) ->
>> list[PurePosixPath]:
>> prefix = PurePosixPath("/var", "run", "dpdk")
>> if not dpdk_prefix_list:
>> remote_prefixes = self._list_remote_dirs(prefix)
>> @@ -174,9 +168,7 @@ def _list_remote_dirs(self, remote_path: str |
>> PurePath) -> list[str] | None:
>> Return a list of directories of the remote_dir.
>> If remote_path doesn't exist, return None.
>> """
>> - out = self.send_command(
>> - f"ls -l {remote_path} | awk '/^d/ {{print $NF}}'"
>> - ).stdout
>> + out = self.send_command(f"ls -l {remote_path} | awk '/^d/
>> {{print $NF}}'").stdout
>> if "No such file or directory" in out:
>> return None
>> else:
>> @@ -200,9 +192,7 @@ def _remote_files_exists(self, remote_path: PurePath)
>> -> bool:
>> result = self.send_command(f"test -e {remote_path}")
>> return not result.return_code
>>
>> - def _check_dpdk_hugepages(
>> - self, dpdk_runtime_dirs: Iterable[str | PurePath]
>> - ) -> None:
>> + def _check_dpdk_hugepages(self, dpdk_runtime_dirs: Iterable[str |
>> PurePath]) -> None:
>> for dpdk_runtime_dir in dpdk_runtime_dirs:
>> hugepage_info = PurePosixPath(dpdk_runtime_dir,
>> "hugepage_info")
>> if self._remote_files_exists(hugepage_info):
>> @@ -213,9 +203,7 @@ def _check_dpdk_hugepages(
>> self._logger.warning(out)
>>
>> self._logger.warning("*******************************************")
>>
>> - def _remove_dpdk_runtime_dirs(
>> - self, dpdk_runtime_dirs: Iterable[str | PurePath]
>> - ) -> None:
>> + def _remove_dpdk_runtime_dirs(self, dpdk_runtime_dirs: Iterable[str
>> | PurePath]) -> None:
>> for dpdk_runtime_dir in dpdk_runtime_dirs:
>> self.remove_remote_dir(dpdk_runtime_dir)
>>
>> @@ -245,6 +233,4 @@ def get_node_info(self) -> NodeInfo:
>> SETTINGS.timeout,
>> ).stdout.split("\n")
>> kernel_version = self.send_command("uname -r",
>> SETTINGS.timeout).stdout
>> - return NodeInfo(
>> - os_release_info[0].strip(), os_release_info[1].strip(),
>> kernel_version
>> - )
>> + return NodeInfo(os_release_info[0].strip(),
>> os_release_info[1].strip(), kernel_version)
>> diff --git
>> a/dts/framework/remote_session/remote/interactive_remote_session.py
>> b/dts/framework/remote_session/remote/interactive_remote_session.py
>> index 9085a668e8..42c99b2525 100644
>> --- a/dts/framework/remote_session/remote/interactive_remote_session.py
>> +++ b/dts/framework/remote_session/remote/interactive_remote_session.py
>> @@ -73,9 +73,7 @@ def __init__(self, node_config: NodeConfiguration,
>> _logger: DTSLOG) -> None:
>> f"Initializing interactive connection for {self.username}@
>> {self.hostname}"
>> )
>> self._connect()
>> - self._logger.info(
>> - f"Interactive connection successful for {self.username}@
>> {self.hostname}"
>> - )
>> + self._logger.info(f"Interactive connection successful for
>> {self.username}@{self.hostname}")
>>
>> def _connect(self) -> None:
>> """Establish a connection to the node.
>> @@ -108,8 +106,7 @@ def _connect(self) -> None:
>> self._logger.debug(traceback.format_exc())
>> self._logger.warning(e)
>> self._logger.info(
>> - "Retrying interactive session connection: "
>> - f"retry number {retry_attempt +1}"
>> + "Retrying interactive session connection: " f"retry
>> number {retry_attempt +1}"
>>
>
> Here you can get rid of the double string, but you would have to make sure
> to add the f to the start to make the whole thing and f-string.
>
>
>> )
>> else:
>> break
>> diff --git a/dts/framework/remote_session/remote/interactive_shell.py
>> b/dts/framework/remote_session/remote/interactive_shell.py
>> index c24376b2a8..4db19fb9b3 100644
>> --- a/dts/framework/remote_session/remote/interactive_shell.py
>> +++ b/dts/framework/remote_session/remote/interactive_shell.py
>> @@ -85,9 +85,7 @@ def __init__(
>> self._app_args = app_args
>> self._start_application(get_privileged_command)
>>
>> - def _start_application(
>> - self, get_privileged_command: Callable[[str], str] | None
>> - ) -> None:
>> + def _start_application(self, get_privileged_command: Callable[[str],
>> str] | None) -> None:
>> """Starts a new interactive application based on the path to the
>> app.
>>
>> This method is often overridden by subclasses as their process
>> for
>> diff --git a/dts/framework/remote_session/remote/remote_session.py
>> b/dts/framework/remote_session/remote/remote_session.py
>> index 0647d93de4..719f7d1ef7 100644
>> --- a/dts/framework/remote_session/remote/remote_session.py
>> +++ b/dts/framework/remote_session/remote/remote_session.py
>> @@ -96,9 +96,7 @@ def send_command(
>> If verify is True, check the return code of the executed command
>> and raise a RemoteCommandExecutionError if the command failed.
>> """
>> - self._logger.info(
>> - f"Sending: '{command}'" + (f" with env vars: '{env}'" if env
>> else "")
>> - )
>> + self._logger.info(f"Sending: '{command}'" + (f" with env vars:
>> '{env}'" if env else ""))
>> result = self._send_command(command, timeout, env)
>> if verify and result.return_code:
>> self._logger.debug(
>> @@ -112,9 +110,7 @@ def send_command(
>> return result
>>
>> @abstractmethod
>> - def _send_command(
>> - self, command: str, timeout: float, env: dict | None
>> - ) -> CommandResult:
>> + def _send_command(self, command: str, timeout: float, env: dict |
>> None) -> CommandResult:
>> """
>> Use the underlying protocol to execute the command using
>> optional env vars
>> and return CommandResult.
>> diff --git a/dts/framework/remote_session/remote/ssh_session.py
>> b/dts/framework/remote_session/remote/ssh_session.py
>> index 8d127f1601..1a7ee649ab 100644
>> --- a/dts/framework/remote_session/remote/ssh_session.py
>> +++ b/dts/framework/remote_session/remote/ssh_session.py
>> @@ -80,9 +80,7 @@ def _connect(self) -> None:
>> if error not in errors:
>> errors.append(error)
>>
>> - self._logger.info(
>> - f"Retrying connection: retry number {retry_attempt +
>> 1}."
>> - )
>> + self._logger.info(f"Retrying connection: retry number
>> {retry_attempt + 1}.")
>>
>> else:
>> break
>> @@ -92,9 +90,7 @@ def _connect(self) -> None:
>> def is_alive(self) -> bool:
>> return self.session.is_connected
>>
>> - def _send_command(
>> - self, command: str, timeout: float, env: dict | None
>> - ) -> CommandResult:
>> + def _send_command(self, command: str, timeout: float, env: dict |
>> None) -> CommandResult:
>> """Send a command and return the result of the execution.
>>
>> Args:
>> @@ -107,9 +103,7 @@ def _send_command(
>> SSHTimeoutError: The command execution timed out.
>> """
>> try:
>> - output = self.session.run(
>> - command, env=env, warn=True, hide=True, timeout=timeout
>> - )
>> + output = self.session.run(command, env=env, warn=True,
>> hide=True, timeout=timeout)
>>
>> except (UnexpectedExit, ThreadException) as e:
>> self._logger.exception(e)
>> @@ -119,9 +113,7 @@ def _send_command(
>> self._logger.exception(e)
>> raise SSHTimeoutError(command, e.result.stderr) from e
>>
>> - return CommandResult(
>> - self.name, command, output.stdout, output.stderr,
>> output.return_code
>> - )
>> + return CommandResult(self.name, command, output.stdout,
>> output.stderr, output.return_code)
>>
>> def copy_from(
>> self,
>> diff --git a/dts/framework/remote_session/remote/testpmd_shell.py
>> b/dts/framework/remote_session/remote/testpmd_shell.py
>> index 1455b5a199..08ac311016 100644
>> --- a/dts/framework/remote_session/remote/testpmd_shell.py
>> +++ b/dts/framework/remote_session/remote/testpmd_shell.py
>> @@ -21,13 +21,9 @@ class TestPmdShell(InteractiveShell):
>> path: PurePath = PurePath("app", "dpdk-testpmd")
>> dpdk_app: bool = True
>> _default_prompt: str = "testpmd>"
>> - _command_extra_chars: str = (
>> - "\n" # We want to append an extra newline to every command
>> - )
>> + _command_extra_chars: str = "\n" # We want to append an extra
>> newline to every command
>>
>> - def _start_application(
>> - self, get_privileged_command: Callable[[str], str] | None
>> - ) -> None:
>> + def _start_application(self, get_privileged_command: Callable[[str],
>> str] | None) -> None:
>> """See "_start_application" in InteractiveShell."""
>> self._app_args += " -- -i"
>> super()._start_application(get_privileged_command)
>> diff --git a/dts/framework/settings.py b/dts/framework/settings.py
>> index cfa39d011b..aad444e99c 100644
>> --- a/dts/framework/settings.py
>> +++ b/dts/framework/settings.py
>> @@ -170,9 +170,7 @@ def _get_settings() -> _Settings:
>> timeout=parsed_args.timeout,
>> verbose=(parsed_args.verbose == "Y"),
>> skip_setup=(parsed_args.skip_setup == "Y"),
>> - dpdk_tarball_path=Path(
>> - DPDKGitTarball(parsed_args.tarball, parsed_args.output_dir)
>> - )
>> + dpdk_tarball_path=Path(DPDKGitTarball(parsed_args.tarball,
>> parsed_args.output_dir))
>> if not os.path.exists(parsed_args.tarball)
>> else Path(parsed_args.tarball),
>> compile_timeout=parsed_args.compile_timeout,
>> diff --git a/dts/framework/test_result.py b/dts/framework/test_result.py
>> index f0fbe80f6f..4c2e7e2418 100644
>> --- a/dts/framework/test_result.py
>> +++ b/dts/framework/test_result.py
>> @@ -83,9 +83,7 @@ def __iadd__(self, other: Result) -> "Statistics":
>> """
>> self[other.name] += 1
>> self["PASS RATE"] = (
>> - float(self[Result.PASS.name])
>> - * 100
>> - / sum(self[result.name] for result in Result)
>> + float(self[Result.PASS.name]) * 100 / sum(self[result.name]
>> for result in Result)
>> )
>> return self
>>
>> @@ -135,9 +133,7 @@ def _get_setup_teardown_errors(self) ->
>> list[Exception]:
>>
>> def _get_inner_errors(self) -> list[Exception]:
>> return [
>> - error
>> - for inner_result in self._inner_results
>> - for error in inner_result.get_errors()
>> + error for inner_result in self._inner_results for error in
>> inner_result.get_errors()
>> ]
>>
>> def get_errors(self) -> list[Exception]:
>> @@ -174,9 +170,7 @@ def add_stats(self, statistics: Statistics) -> None:
>> statistics += self.result
>>
>> def __bool__(self) -> bool:
>> - return (
>> - bool(self.setup_result) and bool(self.teardown_result) and
>> bool(self.result)
>> - )
>> + return bool(self.setup_result) and bool(self.teardown_result)
>> and bool(self.result)
>>
>>
>> class TestSuiteResult(BaseResult):
>> @@ -247,9 +241,7 @@ def __init__(self, sut_node: NodeConfiguration):
>> super(ExecutionResult, self).__init__()
>> self.sut_node = sut_node
>>
>> - def add_build_target(
>> - self, build_target: BuildTargetConfiguration
>> - ) -> BuildTargetResult:
>> + def add_build_target(self, build_target: BuildTargetConfiguration)
>> -> BuildTargetResult:
>> build_target_result = BuildTargetResult(build_target)
>> self._inner_results.append(build_target_result)
>> return build_target_result
>> diff --git a/dts/framework/test_suite.py b/dts/framework/test_suite.py
>> index 3b890c0451..46d3de4944 100644
>> --- a/dts/framework/test_suite.py
>> +++ b/dts/framework/test_suite.py
>> @@ -102,9 +102,7 @@ def _process_links(self) -> None:
>> tg_port.peer,
>> tg_port.identifier,
>> ):
>> - self._port_links.append(
>> - PortLink(sut_port=sut_port, tg_port=tg_port)
>> - )
>> + self._port_links.append(PortLink(sut_port=sut_port,
>> tg_port=tg_port))
>>
>> def set_up_suite(self) -> None:
>> """
>> @@ -151,9 +149,7 @@ def configure_testbed_ipv4(self, restore: bool =
>> False) -> None:
>> def _configure_ipv4_forwarding(self, enable: bool) -> None:
>> self.sut_node.configure_ipv4_forwarding(enable)
>>
>> - def send_packet_and_capture(
>> - self, packet: Packet, duration: float = 1
>> - ) -> list[Packet]:
>> + def send_packet_and_capture(self, packet: Packet, duration: float =
>> 1) -> list[Packet]:
>> """
>> Send a packet through the appropriate interface and
>> receive on the appropriate interface.
>> @@ -202,21 +198,15 @@ def verify(self, condition: bool,
>> failure_description: str) -> None:
>> self._fail_test_case_verify(failure_description)
>>
>> def _fail_test_case_verify(self, failure_description: str) -> None:
>> - self._logger.debug(
>> - "A test case failed, showing the last 10 commands executed
>> on SUT:"
>> - )
>> + self._logger.debug("A test case failed, showing the last 10
>> commands executed on SUT:")
>> for command_res in
>> self.sut_node.main_session.remote_session.history[-10:]:
>> self._logger.debug(command_res.command)
>> - self._logger.debug(
>> - "A test case failed, showing the last 10 commands executed
>> on TG:"
>> - )
>> + self._logger.debug("A test case failed, showing the last 10
>> commands executed on TG:")
>> for command_res in
>> self.tg_node.main_session.remote_session.history[-10:]:
>> self._logger.debug(command_res.command)
>> raise TestCaseVerifyError(failure_description)
>>
>> - def verify_packets(
>> - self, expected_packet: Packet, received_packets: list[Packet]
>> - ) -> None:
>> + def verify_packets(self, expected_packet: Packet, received_packets:
>> list[Packet]) -> None:
>> for received_packet in received_packets:
>> if self._compare_packets(expected_packet, received_packet):
>> break
>> @@ -225,17 +215,11 @@ def verify_packets(
>> f"The expected packet
>> {get_packet_summaries(expected_packet)} "
>> f"not found among received
>> {get_packet_summaries(received_packets)}"
>> )
>> - self._fail_test_case_verify(
>> - "An expected packet not found among received packets."
>> - )
>> + self._fail_test_case_verify("An expected packet not found
>> among received packets.")
>>
>> - def _compare_packets(
>> - self, expected_packet: Packet, received_packet: Packet
>> - ) -> bool:
>> + def _compare_packets(self, expected_packet: Packet, received_packet:
>> Packet) -> bool:
>> self._logger.debug(
>> - "Comparing packets: \n"
>> - f"{expected_packet.summary()}\n"
>> - f"{received_packet.summary()}"
>> + "Comparing packets: \n" f"{expected_packet.summary()}\n"
>> f"{received_packet.summary()}"
>>
>
> Same situation as above where you would want to make sure to put the f at
> the start.
>
>
>> )
>>
>> l3 = IP in expected_packet.layers()
>> @@ -262,14 +246,10 @@ def _compare_packets(
>> expected_payload = expected_payload.payload
>>
>> if expected_payload:
>> - self._logger.debug(
>> - f"The expected packet did not contain
>> {expected_payload}."
>> - )
>> + self._logger.debug(f"The expected packet did not contain
>> {expected_payload}.")
>> return False
>> if received_payload and received_payload.__class__ != Padding:
>> - self._logger.debug(
>> - "The received payload had extra layers which were not
>> padding."
>> - )
>> + self._logger.debug("The received payload had extra layers
>> which were not padding.")
>> return False
>> return True
>>
>> @@ -296,10 +276,7 @@ def _verify_l2_frame(self, received_packet: Ether,
>> l3: bool) -> bool:
>>
>> def _verify_l3_packet(self, received_packet: IP, expected_packet:
>> IP) -> bool:
>> self._logger.debug("Looking at the IP layer.")
>> - if (
>> - received_packet.src != expected_packet.src
>> - or received_packet.dst != expected_packet.dst
>> - ):
>> + if received_packet.src != expected_packet.src or
>> received_packet.dst != expected_packet.dst:
>> return False
>> return True
>>
>> @@ -373,9 +350,7 @@ def _get_test_cases(self, test_case_regex: str) ->
>> list[MethodType]:
>> if self._should_be_executed(test_case_name, test_case_regex):
>> filtered_test_cases.append(test_case)
>> cases_str = ", ".join((x.__name__ for x in filtered_test_cases))
>> - self._logger.debug(
>> - f"Found test cases '{cases_str}' in
>> {self.__class__.__name__}."
>> - )
>> + self._logger.debug(f"Found test cases '{cases_str}' in
>> {self.__class__.__name__}.")
>> return filtered_test_cases
>>
>> def _should_be_executed(self, test_case_name: str, test_case_regex:
>> str) -> bool:
>> @@ -445,9 +420,7 @@ def _execute_test_case(
>> self._logger.exception(f"Test case execution ERROR:
>> {test_case_name}")
>> test_case_result.update(Result.ERROR, e)
>> except KeyboardInterrupt:
>> - self._logger.error(
>> - f"Test case execution INTERRUPTED by user:
>> {test_case_name}"
>> - )
>> + self._logger.error(f"Test case execution INTERRUPTED by
>> user: {test_case_name}")
>> test_case_result.update(Result.SKIP)
>> raise KeyboardInterrupt("Stop DTS")
>>
>> @@ -464,9 +437,7 @@ def is_test_suite(object) -> bool:
>> try:
>> testcase_module = importlib.import_module(testsuite_module_path)
>> except ModuleNotFoundError as e:
>> - raise ConfigurationError(
>> - f"Test suite '{testsuite_module_path}' not found."
>> - ) from e
>> + raise ConfigurationError(f"Test suite '{testsuite_module_path}'
>> not found.") from e
>> return [
>> test_suite_class
>> for _, test_suite_class in inspect.getmembers(testcase_module,
>> is_test_suite)
>> diff --git a/dts/framework/testbed_model/capturing_traffic_generator.py
>> b/dts/framework/testbed_model/capturing_traffic_generator.py
>> index ab98987f8e..48d019ab21 100644
>> --- a/dts/framework/testbed_model/capturing_traffic_generator.py
>> +++ b/dts/framework/testbed_model/capturing_traffic_generator.py
>> @@ -110,9 +110,7 @@ def send_packets_and_capture(
>> duration,
>> )
>>
>> - self._logger.debug(
>> - f"Received packets: {get_packet_summaries(received_packets)}"
>> - )
>> + self._logger.debug(f"Received packets:
>> {get_packet_summaries(received_packets)}")
>> self._write_capture_from_packets(capture_name, received_packets)
>> return received_packets
>>
>> diff --git a/dts/framework/testbed_model/hw/cpu.py
>> b/dts/framework/testbed_model/hw/cpu.py
>> index d1918a12dc..cbc5fe7fff 100644
>> --- a/dts/framework/testbed_model/hw/cpu.py
>> +++ b/dts/framework/testbed_model/hw/cpu.py
>> @@ -54,9 +54,7 @@ def __init__(self, lcore_list: list[int] | list[str] |
>> list[LogicalCore] | str):
>>
>> # the input lcores may not be sorted
>> self._lcore_list.sort()
>> - self._lcore_str = (
>> -
>> f'{",".join(self._get_consecutive_lcores_range(self._lcore_list))}'
>> - )
>> + self._lcore_str =
>> f'{",".join(self._get_consecutive_lcores_range(self._lcore_list))}'
>>
>> @property
>> def lcore_list(self) -> list[int]:
>> @@ -70,15 +68,11 @@ def _get_consecutive_lcores_range(self,
>> lcore_ids_list: list[int]) -> list[str]:
>> segment.append(lcore_id)
>> else:
>> formatted_core_list.append(
>> - f"{segment[0]}-{segment[-1]}"
>> - if len(segment) > 1
>> - else f"{segment[0]}"
>> + f"{segment[0]}-{segment[-1]}" if len(segment) > 1
>> else f"{segment[0]}"
>> )
>> current_core_index = lcore_ids_list.index(lcore_id)
>> formatted_core_list.extend(
>> - self._get_consecutive_lcores_range(
>> - lcore_ids_list[current_core_index:]
>> - )
>> +
>> self._get_consecutive_lcores_range(lcore_ids_list[current_core_index:])
>> )
>> segment.clear()
>> break
>> @@ -125,9 +119,7 @@ def __init__(
>> self._filter_specifier = filter_specifier
>>
>> # sorting by core is needed in case hyperthreading is enabled
>> - self._lcores_to_filter = sorted(
>> - lcore_list, key=lambda x: x.core, reverse=not ascending
>> - )
>> + self._lcores_to_filter = sorted(lcore_list, key=lambda x:
>> x.core, reverse=not ascending)
>> self.filter()
>>
>> @abstractmethod
>> @@ -220,9 +212,7 @@ def _filter_cores_from_socket(
>> else:
>> # we have enough lcores per this core
>> continue
>> - elif self._filter_specifier.cores_per_socket > len(
>> - lcore_count_per_core_map
>> - ):
>> + elif self._filter_specifier.cores_per_socket >
>> len(lcore_count_per_core_map):
>> # only add cores if we need more
>> lcore_count_per_core_map[lcore.core] = 1
>> filtered_lcores.append(lcore)
>> diff --git a/dts/framework/testbed_model/node.py
>> b/dts/framework/testbed_model/node.py
>> index fc01e0bf8e..ef700d8114 100644
>> --- a/dts/framework/testbed_model/node.py
>> +++ b/dts/framework/testbed_model/node.py
>> @@ -103,18 +103,14 @@ def _tear_down_execution(self) -> None:
>> is not decorated so that the derived class doesn't have to use
>> the decorator.
>> """
>>
>> - def set_up_build_target(
>> - self, build_target_config: BuildTargetConfiguration
>> - ) -> None:
>> + def set_up_build_target(self, build_target_config:
>> BuildTargetConfiguration) -> None:
>> """
>> Perform the build target setup that will be done for each build
>> target
>> tested on this node.
>> """
>> self._set_up_build_target(build_target_config)
>>
>> - def _set_up_build_target(
>> - self, build_target_config: BuildTargetConfiguration
>> - ) -> None:
>> + def _set_up_build_target(self, build_target_config:
>> BuildTargetConfiguration) -> None:
>> """
>> This method exists to be optionally overwritten by derived
>> classes and
>> is not decorated so that the derived class doesn't have to use
>> the decorator.
>> diff --git a/dts/framework/testbed_model/scapy.py
>> b/dts/framework/testbed_model/scapy.py
>> index af0d4dbb25..7948424951 100644
>> --- a/dts/framework/testbed_model/scapy.py
>> +++ b/dts/framework/testbed_model/scapy.py
>> @@ -96,9 +96,7 @@ def scapy_send_packets_and_capture(
>> return [scapy_packet.build() for scapy_packet in
>> sniffer.stop(join=True)]
>>
>>
>> -def scapy_send_packets(
>> - xmlrpc_packets: list[xmlrpc.client.Binary], send_iface: str
>> -) -> None:
>> +def scapy_send_packets(xmlrpc_packets: list[xmlrpc.client.Binary],
>> send_iface: str) -> None:
>> """RPC function to send packets.
>>
>> The function is meant to be executed on the remote TG node.
>> @@ -197,9 +195,7 @@ class
>> ScapyTrafficGenerator(CapturingTrafficGenerator):
>> def __init__(self, tg_node: TGNode, config:
>> ScapyTrafficGeneratorConfig):
>> self._config = config
>> self._tg_node = tg_node
>> - self._logger = getLogger(
>> - f"{self._tg_node.name}
>> {self._config.traffic_generator_type}"
>> - )
>> + self._logger = getLogger(f"{self._tg_node.name}
>> {self._config.traffic_generator_type}")
>>
>> assert (
>> self._tg_node.config.os == OS.linux
>> @@ -218,9 +214,7 @@ def __init__(self, tg_node: TGNode, config:
>> ScapyTrafficGeneratorConfig):
>>
>> self._start_xmlrpc_server_in_remote_python(xmlrpc_server_listen_port)
>>
>> # connect to the server
>> - server_url = (
>> - f"http://
>> {self._tg_node.config.hostname}:{xmlrpc_server_listen_port}"
>> - )
>> + server_url = f"http://
>> {self._tg_node.config.hostname}:{xmlrpc_server_listen_port}"
>> self.rpc_server_proxy = xmlrpc.client.ServerProxy(
>> server_url, allow_none=True, verbose=SETTINGS.verbose
>> )
>> @@ -240,9 +234,7 @@ def _start_xmlrpc_server_in_remote_python(self,
>> listen_port: int):
>> src = inspect.getsource(QuittableXMLRPCServer)
>> # Lines with only whitespace break the repl if in the middle of
>> a function
>> # or class, so strip all lines containing only whitespace
>> - src = "\n".join(
>> - [line for line in src.splitlines() if not line.isspace() and
>> line != ""]
>> - )
>> + src = "\n".join([line for line in src.splitlines() if not
>> line.isspace() and line != ""])
>>
>> spacing = "\n" * 4
>>
>> diff --git a/dts/framework/testbed_model/sut_node.py
>> b/dts/framework/testbed_model/sut_node.py
>> index 202aebfd06..dfd8c755b4 100644
>> --- a/dts/framework/testbed_model/sut_node.py
>> +++ b/dts/framework/testbed_model/sut_node.py
>> @@ -129,9 +129,7 @@ def remote_dpdk_build_dir(self) -> PurePath:
>> @property
>> def dpdk_version(self) -> str:
>> if self._dpdk_version is None:
>> - self._dpdk_version = self.main_session.get_dpdk_version(
>> - self._remote_dpdk_dir
>> - )
>> + self._dpdk_version =
>> self.main_session.get_dpdk_version(self._remote_dpdk_dir)
>> return self._dpdk_version
>>
>> @property
>> @@ -149,8 +147,7 @@ def compiler_version(self) -> str:
>> )
>> else:
>> self._logger.warning(
>> - "Failed to get compiler version because"
>> - "_build_target_config is None."
>> + "Failed to get compiler version because"
>> "_build_target_config is None."
>>
>
> Double string here.
>
>
>> )
>> return ""
>> return self._compiler_version
>> @@ -163,9 +160,7 @@ def get_build_target_info(self) -> BuildTargetInfo:
>> def _guess_dpdk_remote_dir(self) -> PurePath:
>> return
>> self.main_session.guess_dpdk_remote_dir(self._remote_tmp_dir)
>>
>> - def _set_up_build_target(
>> - self, build_target_config: BuildTargetConfiguration
>> - ) -> None:
>> + def _set_up_build_target(self, build_target_config:
>> BuildTargetConfiguration) -> None:
>> """
>> Setup DPDK on the SUT node.
>> """
>> @@ -177,22 +172,17 @@ def _set_up_build_target(
>> self._copy_dpdk_tarball()
>> self._build_dpdk()
>>
>> - def _configure_build_target(
>> - self, build_target_config: BuildTargetConfiguration
>> - ) -> None:
>> + def _configure_build_target(self, build_target_config:
>> BuildTargetConfiguration) -> None:
>> """
>> Populate common environment variables and set build target
>> config.
>> """
>> self._env_vars = {}
>> self._build_target_config = build_target_config
>> - self._env_vars.update(
>> -
>> self.main_session.get_dpdk_build_env_vars(build_target_config.arch)
>> - )
>> +
>> self._env_vars.update(self.main_session.get_dpdk_build_env_vars(build_target_config.arch))
>> self._env_vars["CC"] = build_target_config.compiler.name
>> if build_target_config.compiler_wrapper:
>> self._env_vars["CC"] = (
>> - f"'{build_target_config.compiler_wrapper} "
>> - f"{build_target_config.compiler.name}'"
>> + f"'{build_target_config.compiler_wrapper} " f"{
>> build_target_config.compiler.name}'"
>>
>
> Double string here.
>
>
>> )
>>
>> @Node.skip_setup
>> @@ -224,9 +214,7 @@ def _copy_dpdk_tarball(self) -> None:
>> self.main_session.remove_remote_dir(self._remote_dpdk_dir)
>>
>> # then extract to remote path
>> - self.main_session.extract_remote_tarball(
>> - remote_tarball_path, self._remote_dpdk_dir
>> - )
>> + self.main_session.extract_remote_tarball(remote_tarball_path,
>> self._remote_dpdk_dir)
>>
>> @Node.skip_setup
>> def _build_dpdk(self) -> None:
>> @@ -263,9 +251,7 @@ def build_dpdk_app(self, app_name: str,
>> **meson_dpdk_args: str | bool) -> PurePa
>> )
>>
>> if app_name == "all":
>> - return self.main_session.join_remote_path(
>> - self.remote_dpdk_build_dir, "examples"
>> - )
>> + return
>> self.main_session.join_remote_path(self.remote_dpdk_build_dir, "examples")
>> return self.main_session.join_remote_path(
>> self.remote_dpdk_build_dir, "examples", f"dpdk-{app_name}"
>> )
>> @@ -319,9 +305,7 @@ def create_eal_parameters(
>> '-c 0xf -a 0000:88:00.0
>> --file-prefix=dpdk_1112_20190809143420';
>> """
>>
>> - lcore_list = LogicalCoreList(
>> - self.filter_lcores(lcore_filter_specifier, ascending_cores)
>> - )
>> + lcore_list =
>> LogicalCoreList(self.filter_lcores(lcore_filter_specifier, ascending_cores))
>>
>> if append_prefix_timestamp:
>> prefix = f"{prefix}_{self._dpdk_timestamp}"
>> @@ -386,6 +370,4 @@ def create_interactive_shell(
>> self.remote_dpdk_build_dir, shell_cls.path
>> )
>>
>> - return super().create_interactive_shell(
>> - shell_cls, timeout, privileged, str(eal_parameters)
>> - )
>> + return super().create_interactive_shell(shell_cls, timeout,
>> privileged, str(eal_parameters))
>> diff --git a/dts/framework/testbed_model/tg_node.py
>> b/dts/framework/testbed_model/tg_node.py
>> index 27025cfa31..dca4ec0849 100644
>> --- a/dts/framework/testbed_model/tg_node.py
>> +++ b/dts/framework/testbed_model/tg_node.py
>> @@ -45,9 +45,7 @@ class TGNode(Node):
>>
>> def __init__(self, node_config: TGNodeConfiguration):
>> super(TGNode, self).__init__(node_config)
>> - self.traffic_generator = create_traffic_generator(
>> - self, node_config.traffic_generator
>> - )
>> + self.traffic_generator = create_traffic_generator(self,
>> node_config.traffic_generator)
>> self._logger.info(f"Created node: {self.name}")
>>
>> def send_packet_and_capture(
>> @@ -94,6 +92,5 @@ def create_traffic_generator(
>> return ScapyTrafficGenerator(tg_node,
>> traffic_generator_config)
>> case _:
>> raise ConfigurationError(
>> - "Unknown traffic generator: "
>> - f"{traffic_generator_config.traffic_generator_type}"
>> + "Unknown traffic generator: "
>> f"{traffic_generator_config.traffic_generator_type}"
>>
>
> Double string but one that needs the whole thing to be an f-string.
>
>
>> )
>> diff --git a/dts/framework/utils.py b/dts/framework/utils.py
>> index d27c2c5b5f..d098d364ff 100644
>> --- a/dts/framework/utils.py
>> +++ b/dts/framework/utils.py
>> @@ -19,9 +19,7 @@
>>
>> class StrEnum(Enum):
>> @staticmethod
>> - def _generate_next_value_(
>> - name: str, start: int, count: int, last_values: object
>> - ) -> str:
>> + def _generate_next_value_(name: str, start: int, count: int,
>> last_values: object) -> str:
>> return name
>>
>> def __str__(self) -> str:
>> @@ -32,9 +30,7 @@ def __str__(self) -> str:
>>
>>
>> def check_dts_python_version() -> None:
>> - if sys.version_info.major < 3 or (
>> - sys.version_info.major == 3 and sys.version_info.minor < 10
>> - ):
>> + if sys.version_info.major < 3 or (sys.version_info.major == 3 and
>> sys.version_info.minor < 10):
>> print(
>> RED(
>> (
>> @@ -60,9 +56,7 @@ def expand_range(range_str: str) -> list[int]:
>> range_boundaries = range_str.split("-")
>> # will throw an exception when items in range_boundaries can't
>> be converted,
>> # serving as type check
>> - expanded_range.extend(
>> - range(int(range_boundaries[0]), int(range_boundaries[-1]) +
>> 1)
>> - )
>> + expanded_range.extend(range(int(range_boundaries[0]),
>> int(range_boundaries[-1]) + 1))
>>
>> return expanded_range
>>
>> @@ -71,9 +65,7 @@ def get_packet_summaries(packets: list[Packet]):
>> if len(packets) == 1:
>> packet_summaries = packets[0].summary()
>> else:
>> - packet_summaries = json.dumps(
>> - list(map(lambda pkt: pkt.summary(), packets)), indent=4
>> - )
>> + packet_summaries = json.dumps(list(map(lambda pkt:
>> pkt.summary(), packets)), indent=4)
>> return f"Packet contents: \n{packet_summaries}"
>>
>>
>> @@ -94,9 +86,7 @@ class MesonArgs(object):
>> _default_library: str
>>
>> def __init__(self, default_library: str | None = None, **dpdk_args:
>> str | bool):
>> - self._default_library = (
>> - f"--default-library={default_library}" if default_library
>> else ""
>> - )
>> + self._default_library = f"--default-library={default_library}"
>> if default_library else ""
>> self._dpdk_args = " ".join(
>> (
>> f"-D{dpdk_arg_name}={dpdk_arg_value}"
>> diff --git a/dts/pyproject.toml b/dts/pyproject.toml
>> index 6762edfa6b..980ac3c7db 100644
>> --- a/dts/pyproject.toml
>> +++ b/dts/pyproject.toml
>> @@ -41,7 +41,7 @@ build-backend = "poetry.core.masonry.api"
>> [tool.pylama]
>> linters = "mccabe,pycodestyle,pyflakes"
>> format = "pylint"
>> -max_line_length = 88 #
>> https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length
>> +max_line_length = 100
>>
>> [tool.mypy]
>> python_version = "3.10"
>> @@ -55,4 +55,4 @@ profile = "black"
>> [tool.black]
>> target-version = ['py310']
>> include = '\.pyi?$'
>> -line-length = 88 #
>> https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length
>> +line-length
>> <https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length+line-length>
>> = 100
>> diff --git a/dts/tests/TestSuite_hello_world.py
>> b/dts/tests/TestSuite_hello_world.py
>> index 7e3d95c0cf..768ba1cfa8 100644
>> --- a/dts/tests/TestSuite_hello_world.py
>> +++ b/dts/tests/TestSuite_hello_world.py
>> @@ -34,9 +34,7 @@ def test_hello_world_single_core(self) -> None:
>> # get the first usable core
>> lcore_amount = LogicalCoreCount(1, 1, 1)
>> lcores = LogicalCoreCountFilter(self.sut_node.lcores,
>> lcore_amount).filter()
>> - eal_para = self.sut_node.create_eal_parameters(
>> - lcore_filter_specifier=lcore_amount
>> - )
>> + eal_para =
>> self.sut_node.create_eal_parameters(lcore_filter_specifier=lcore_amount)
>> result = self.sut_node.run_dpdk_app(self.app_helloworld_path,
>> eal_para)
>> self.verify(
>> f"hello from core {int(lcores[0])}" in result.stdout,
>> diff --git a/dts/tests/TestSuite_smoke_tests.py
>> b/dts/tests/TestSuite_smoke_tests.py
>> index 4a269df75b..36119e6469 100644
>> --- a/dts/tests/TestSuite_smoke_tests.py
>> +++ b/dts/tests/TestSuite_smoke_tests.py
>> @@ -45,13 +45,10 @@ def test_driver_tests(self) -> None:
>> for dev in self.sut_node.virtual_devices:
>> vdev_args += f"--vdev {dev} "
>> vdev_args = vdev_args[:-1]
>> - driver_tests_command = (
>> - f"meson test -C {self.dpdk_build_dir_path} --suite
>> driver-tests"
>> - )
>> + driver_tests_command = f"meson test -C
>> {self.dpdk_build_dir_path} --suite driver-tests"
>> if vdev_args:
>> self._logger.info(
>> - "Running driver tests with the following virtual "
>> - f"devices: {vdev_args}"
>> + "Running driver tests with the following virtual "
>> f"devices: {vdev_args}"
>>
>
> Double string that should be an f-string.
>
>
>> )
>> driver_tests_command += f' --test-args "{vdev_args}"'
>>
>> @@ -67,9 +64,7 @@ def test_devices_listed_in_testpmd(self) -> None:
>> Test:
>> Uses testpmd driver to verify that devices have been found
>> by testpmd.
>> """
>> - testpmd_driver = self.sut_node.create_interactive_shell(
>> - TestPmdShell, privileged=True
>> - )
>> + testpmd_driver =
>> self.sut_node.create_interactive_shell(TestPmdShell, privileged=True)
>> dev_list = [str(x) for x in testpmd_driver.get_devices()]
>> for nic in self.nics_in_node:
>> self.verify(
>> --
>> 2.34.1
>>
>>
[-- Attachment #2: Type: text/html, Size: 67906 bytes --]
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v2 2/2] dts: reformat to 100 line length
2023-09-27 8:08 ` Bruce Richardson
@ 2023-09-28 7:33 ` Juraj Linkeš
2023-09-28 8:42 ` Bruce Richardson
0 siblings, 1 reply; 36+ messages in thread
From: Juraj Linkeš @ 2023-09-28 7:33 UTC (permalink / raw)
To: Bruce Richardson
Cc: thomas, Honnappa.Nagarahalli, jspewock, probb, stephen, dev
On Wed, Sep 27, 2023 at 10:08 AM Bruce Richardson
<bruce.richardson@intel.com> wrote:
>
> On Tue, Sep 26, 2023 at 02:10:13PM +0200, Juraj Linkeš wrote:
> > Reformat to 100 from the previous 88 to unify with C recommendations.
> >
> > Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
>
> Generally for something like this we wouldn't reformat the existing code,
> because it confuses the git history e.g. for those looking for "fixlines"
> for bug fixes. However, given that DTS is so new in the repo, it's probably
> ok and worthwhile doing.
>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Thanks for pointing this out, Bruce, I'll keep it in mind for the
future. For now, it's kinda necessary we do this because our reformat
tool, Black, reformats the whole codebase so I think the pros outweigh
the cons.
One more thing: I originally wanted to put this config part into the
first patch (I wanted this patch to be only code changes) which I plan
on fixing in the next version:
diff --git a/dts/pyproject.toml b/dts/pyproject.toml
index 6762edfa6b..980ac3c7db 100644
--- a/dts/pyproject.toml
+++ b/dts/pyproject.toml
@@ -41,7 +41,7 @@ build-backend = "poetry.core.masonry.api"
[tool.pylama]
linters = "mccabe,pycodestyle,pyflakes"
format = "pylint"
-max_line_length = 88 #
https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length
+max_line_length = 100
[tool.mypy]
python_version = "3.10"
@@ -55,4 +55,4 @@ profile = "black"
[tool.black]
target-version = ['py310']
include = '\.pyi?$'
-line-length = 88 #
https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length
+line-length
<https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length+line-length>
= 100
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v2 2/2] dts: reformat to 100 line length
2023-09-28 7:33 ` Juraj Linkeš
@ 2023-09-28 8:42 ` Bruce Richardson
0 siblings, 0 replies; 36+ messages in thread
From: Bruce Richardson @ 2023-09-28 8:42 UTC (permalink / raw)
To: Juraj Linkeš
Cc: thomas, Honnappa.Nagarahalli, jspewock, probb, stephen, dev
On Thu, Sep 28, 2023 at 09:33:55AM +0200, Juraj Linkeš wrote:
> On Wed, Sep 27, 2023 at 10:08 AM Bruce Richardson
> <bruce.richardson@intel.com> wrote:
> >
> > On Tue, Sep 26, 2023 at 02:10:13PM +0200, Juraj Linkeš wrote:
> > > Reformat to 100 from the previous 88 to unify with C recommendations.
> > >
> > > Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> >
> > Generally for something like this we wouldn't reformat the existing code,
> > because it confuses the git history e.g. for those looking for "fixlines"
> > for bug fixes. However, given that DTS is so new in the repo, it's probably
> > ok and worthwhile doing.
> >
> > Acked-by: Bruce Richardson <bruce.richardson@intel.com>
>
> Thanks for pointing this out, Bruce, I'll keep it in mind for the
> future. For now, it's kinda necessary we do this because our reformat
> tool, Black, reformats the whole codebase so I think the pros outweigh
> the cons.
>
Agreed
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v3 1/2] doc: increase python max line length to 100
2023-09-26 12:10 ` [PATCH v2 1/2] doc: increase python max line length to 100 Juraj Linkeš
2023-09-26 12:10 ` [PATCH v2 2/2] dts: reformat to 100 line length Juraj Linkeš
2023-09-26 13:00 ` [PATCH v2 1/2] doc: increase python max line length to 100 Bruce Richardson
@ 2023-09-28 12:18 ` Juraj Linkeš
2023-09-28 12:18 ` [PATCH v3 2/2] dts: reformat to 100 line length Juraj Linkeš
2023-10-12 12:52 ` [PATCH v3 " Paul Szczepanek
2 siblings, 2 replies; 36+ messages in thread
From: Juraj Linkeš @ 2023-09-28 12:18 UTC (permalink / raw)
To: thomas, Honnappa.Nagarahalli, bruce.richardson, jspewock, probb, stephen
Cc: dev, Juraj Linkeš
Unify with C recommendations which allow line length of up to 100
characters.
Signed-off-by: Owen Hilyard <ohilyard@iol.unh.edu>
Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
.editorconfig | 2 +-
doc/doc_build/meson-private/meson.lock | 0
doc/guides/contributing/coding_style.rst | 3 +++
dts/pyproject.toml | 4 ++--
4 files changed, 6 insertions(+), 3 deletions(-)
create mode 100644 doc/doc_build/meson-private/meson.lock
diff --git a/.editorconfig b/.editorconfig
index ab41c95085..1e7d74213f 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -16,7 +16,7 @@ max_line_length = 100
[*.py]
indent_style = space
indent_size = 4
-max_line_length = 79
+max_line_length = 100
[meson.build]
indent_style = space
diff --git a/doc/doc_build/meson-private/meson.lock b/doc/doc_build/meson-private/meson.lock
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/doc/guides/contributing/coding_style.rst b/doc/guides/contributing/coding_style.rst
index 648849899d..a42cd3d58d 100644
--- a/doc/guides/contributing/coding_style.rst
+++ b/doc/guides/contributing/coding_style.rst
@@ -880,6 +880,9 @@ All Python code should be compliant with
`PEP8 (Style Guide for Python Code) <https://www.python.org/dev/peps/pep-0008/>`_.
The ``pep8`` tool can be used for testing compliance with the guidelines.
+Note that line lengths are acceptable up to 100 characters, which is in line with C recommendations.
+
+..
Integrating with the Build System
---------------------------------
diff --git a/dts/pyproject.toml b/dts/pyproject.toml
index 6762edfa6b..980ac3c7db 100644
--- a/dts/pyproject.toml
+++ b/dts/pyproject.toml
@@ -41,7 +41,7 @@ build-backend = "poetry.core.masonry.api"
[tool.pylama]
linters = "mccabe,pycodestyle,pyflakes"
format = "pylint"
-max_line_length = 88 # https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length
+max_line_length = 100
[tool.mypy]
python_version = "3.10"
@@ -55,4 +55,4 @@ profile = "black"
[tool.black]
target-version = ['py310']
include = '\.pyi?$'
-line-length = 88 # https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length
+line-length = 100
--
2.34.1
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v3 2/2] dts: reformat to 100 line length
2023-09-28 12:18 ` [PATCH v3 " Juraj Linkeš
@ 2023-09-28 12:18 ` Juraj Linkeš
2023-09-29 16:53 ` Jeremy Spewock
2023-10-13 7:58 ` [PATCH v4 1/2] doc: increase python max line length to 100 Juraj Linkeš
2023-10-12 12:52 ` [PATCH v3 " Paul Szczepanek
1 sibling, 2 replies; 36+ messages in thread
From: Juraj Linkeš @ 2023-09-28 12:18 UTC (permalink / raw)
To: thomas, Honnappa.Nagarahalli, bruce.richardson, jspewock, probb, stephen
Cc: dev, Juraj Linkeš
Reformat to 100 from the previous 88 to unify with C recommendations.
Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
dts/framework/config/__init__.py | 20 ++-----
dts/framework/dts.py | 15 ++---
dts/framework/exception.py | 5 +-
dts/framework/remote_session/__init__.py | 4 +-
dts/framework/remote_session/linux_session.py | 39 ++++---------
dts/framework/remote_session/posix_session.py | 30 +++-------
.../remote/interactive_remote_session.py | 7 +--
.../remote/interactive_shell.py | 4 +-
.../remote_session/remote/remote_session.py | 8 +--
.../remote_session/remote/ssh_session.py | 16 ++----
.../remote_session/remote/testpmd_shell.py | 8 +--
dts/framework/settings.py | 15 ++---
dts/framework/test_result.py | 16 ++----
dts/framework/test_suite.py | 57 +++++--------------
.../capturing_traffic_generator.py | 7 +--
dts/framework/testbed_model/hw/cpu.py | 20 ++-----
dts/framework/testbed_model/node.py | 8 +--
dts/framework/testbed_model/scapy.py | 19 ++-----
dts/framework/testbed_model/sut_node.py | 40 ++++---------
dts/framework/testbed_model/tg_node.py | 7 +--
dts/framework/utils.py | 20 ++-----
dts/tests/TestSuite_hello_world.py | 4 +-
dts/tests/TestSuite_smoke_tests.py | 11 +---
23 files changed, 99 insertions(+), 281 deletions(-)
diff --git a/dts/framework/config/__init__.py b/dts/framework/config/__init__.py
index cb7e00ba34..9b32cf0532 100644
--- a/dts/framework/config/__init__.py
+++ b/dts/framework/config/__init__.py
@@ -140,9 +140,7 @@ def from_dict(d: dict) -> Union["SutNodeConfiguration", "TGNodeConfiguration"]:
if "traffic_generator" in d:
return TGNodeConfiguration(
- traffic_generator=TrafficGeneratorConfig.from_dict(
- d["traffic_generator"]
- ),
+ traffic_generator=TrafficGeneratorConfig.from_dict(d["traffic_generator"]),
**common_config,
)
else:
@@ -249,9 +247,7 @@ def from_dict(
build_targets: list[BuildTargetConfiguration] = list(
map(BuildTargetConfiguration.from_dict, d["build_targets"])
)
- test_suites: list[TestSuiteConfig] = list(
- map(TestSuiteConfig.from_dict, d["test_suites"])
- )
+ test_suites: list[TestSuiteConfig] = list(map(TestSuiteConfig.from_dict, d["test_suites"]))
sut_name = d["system_under_test_node"]["node_name"]
skip_smoke_tests = d.get("skip_smoke_tests", False)
assert sut_name in node_map, f"Unknown SUT {sut_name} in execution {d}"
@@ -268,9 +264,7 @@ def from_dict(
), f"Invalid TG configuration {traffic_generator_node}"
vdevs = (
- d["system_under_test_node"]["vdevs"]
- if "vdevs" in d["system_under_test_node"]
- else []
+ d["system_under_test_node"]["vdevs"] if "vdevs" in d["system_under_test_node"] else []
)
return ExecutionConfiguration(
build_targets=build_targets,
@@ -299,9 +293,7 @@ def from_dict(d: dict) -> "Configuration":
assert len(nodes) == len(node_map), "Duplicate node names are not allowed"
executions: list[ExecutionConfiguration] = list(
- map(
- ExecutionConfiguration.from_dict, d["executions"], [node_map for _ in d]
- )
+ map(ExecutionConfiguration.from_dict, d["executions"], [node_map for _ in d])
)
return Configuration(executions=executions)
@@ -315,9 +307,7 @@ def load_config() -> Configuration:
with open(SETTINGS.config_file_path, "r") as f:
config_data = yaml.safe_load(f)
- schema_path = os.path.join(
- pathlib.Path(__file__).parent.resolve(), "conf_yaml_schema.json"
- )
+ schema_path = os.path.join(pathlib.Path(__file__).parent.resolve(), "conf_yaml_schema.json")
with open(schema_path, "r") as f:
schema = json.load(f)
diff --git a/dts/framework/dts.py b/dts/framework/dts.py
index f773f0c38d..25d6942d81 100644
--- a/dts/framework/dts.py
+++ b/dts/framework/dts.py
@@ -92,9 +92,7 @@ def _run_execution(
Run the given execution. This involves running the execution setup as well as
running all build targets in the given execution.
"""
- dts_logger.info(
- f"Running execution with SUT '{execution.system_under_test_node.name}'."
- )
+ dts_logger.info(f"Running execution with SUT '{execution.system_under_test_node.name}'.")
execution_result = result.add_execution(sut_node.config)
execution_result.add_sut_info(sut_node.node_info)
@@ -107,9 +105,7 @@ def _run_execution(
else:
for build_target in execution.build_targets:
- _run_build_target(
- sut_node, tg_node, build_target, execution, execution_result
- )
+ _run_build_target(sut_node, tg_node, build_target, execution, execution_result)
finally:
try:
@@ -170,13 +166,10 @@ def _run_all_suites(
execution.test_suites[:0] = [TestSuiteConfig.from_dict("smoke_tests")]
for test_suite_config in execution.test_suites:
try:
- _run_single_suite(
- sut_node, tg_node, execution, build_target_result, test_suite_config
- )
+ _run_single_suite(sut_node, tg_node, execution, build_target_result, test_suite_config)
except BlockingTestSuiteError as e:
dts_logger.exception(
- f"An error occurred within {test_suite_config.test_suite}. "
- "Skipping build target..."
+ f"An error occurred within {test_suite_config.test_suite}. Skipping build target."
)
result.add_error(e)
end_build_target = True
diff --git a/dts/framework/exception.py b/dts/framework/exception.py
index 001a5a5496..b362e42924 100644
--- a/dts/framework/exception.py
+++ b/dts/framework/exception.py
@@ -116,10 +116,7 @@ def __init__(self, command: str, command_return_code: int):
self.command_return_code = command_return_code
def __str__(self) -> str:
- return (
- f"Command {self.command} returned a non-zero exit code: "
- f"{self.command_return_code}"
- )
+ return f"Command {self.command} returned a non-zero exit code: {self.command_return_code}"
class RemoteDirectoryExistsError(DTSError):
diff --git a/dts/framework/remote_session/__init__.py b/dts/framework/remote_session/__init__.py
index 00b6d1f03a..6124417bd7 100644
--- a/dts/framework/remote_session/__init__.py
+++ b/dts/framework/remote_session/__init__.py
@@ -30,9 +30,7 @@
)
-def create_session(
- node_config: NodeConfiguration, name: str, logger: DTSLOG
-) -> OSSession:
+def create_session(node_config: NodeConfiguration, name: str, logger: DTSLOG) -> OSSession:
match node_config.os:
case OS.linux:
return LinuxSession(node_config, name, logger)
diff --git a/dts/framework/remote_session/linux_session.py b/dts/framework/remote_session/linux_session.py
index a3f1a6bf3b..fd877fbfae 100644
--- a/dts/framework/remote_session/linux_session.py
+++ b/dts/framework/remote_session/linux_session.py
@@ -82,9 +82,7 @@ def setup_hugepages(self, hugepage_amount: int, force_first_numa: bool) -> None:
self._mount_huge_pages()
def _get_hugepage_size(self) -> int:
- hugepage_size = self.send_command(
- "awk '/Hugepagesize/ {print $2}' /proc/meminfo"
- ).stdout
+ hugepage_size = self.send_command("awk '/Hugepagesize/ {print $2}' /proc/meminfo").stdout
return int(hugepage_size)
def _get_hugepages_total(self) -> int:
@@ -120,13 +118,9 @@ def _supports_numa(self) -> bool:
# there's no reason to do any numa specific configuration)
return len(self._numa_nodes) > 1
- def _configure_huge_pages(
- self, amount: int, size: int, force_first_numa: bool
- ) -> None:
+ def _configure_huge_pages(self, amount: int, size: int, force_first_numa: bool) -> None:
self._logger.info("Configuring Hugepages.")
- hugepage_config_path = (
- f"/sys/kernel/mm/hugepages/hugepages-{size}kB/nr_hugepages"
- )
+ hugepage_config_path = f"/sys/kernel/mm/hugepages/hugepages-{size}kB/nr_hugepages"
if force_first_numa and self._supports_numa():
# clear non-numa hugepages
self.send_command(f"echo 0 | tee {hugepage_config_path}", privileged=True)
@@ -135,24 +129,18 @@ def _configure_huge_pages(
f"/hugepages-{size}kB/nr_hugepages"
)
- self.send_command(
- f"echo {amount} | tee {hugepage_config_path}", privileged=True
- )
+ self.send_command(f"echo {amount} | tee {hugepage_config_path}", privileged=True)
def update_ports(self, ports: list[Port]) -> None:
self._logger.debug("Gathering port info.")
for port in ports:
- assert (
- port.node == self.name
- ), "Attempted to gather port info on the wrong node"
+ assert port.node == self.name, "Attempted to gather port info on the wrong node"
port_info_list = self._get_lshw_info()
for port in ports:
for port_info in port_info_list:
if f"pci@{port.pci}" == port_info.get("businfo"):
- self._update_port_attr(
- port, port_info.get("logicalname"), "logical_name"
- )
+ self._update_port_attr(port, port_info.get("logicalname"), "logical_name")
self._update_port_attr(port, port_info.get("serial"), "mac_address")
port_info_list.remove(port_info)
break
@@ -163,25 +151,18 @@ def _get_lshw_info(self) -> list[LshwOutput]:
output = self.send_command("lshw -quiet -json -C network", verify=True)
return json.loads(output.stdout)
- def _update_port_attr(
- self, port: Port, attr_value: str | None, attr_name: str
- ) -> None:
+ def _update_port_attr(self, port: Port, attr_value: str | None, attr_name: str) -> None:
if attr_value:
setattr(port, attr_name, attr_value)
- self._logger.debug(
- f"Found '{attr_name}' of port {port.pci}: '{attr_value}'."
- )
+ self._logger.debug(f"Found '{attr_name}' of port {port.pci}: '{attr_value}'.")
else:
self._logger.warning(
- f"Attempted to get '{attr_name}' of port {port.pci}, "
- f"but it doesn't exist."
+ f"Attempted to get '{attr_name}' of port {port.pci}, but it doesn't exist."
)
def configure_port_state(self, port: Port, enable: bool) -> None:
state = "up" if enable else "down"
- self.send_command(
- f"ip link set dev {port.logical_name} {state}", privileged=True
- )
+ self.send_command(f"ip link set dev {port.logical_name} {state}", privileged=True)
def configure_port_ip_address(
self,
diff --git a/dts/framework/remote_session/posix_session.py b/dts/framework/remote_session/posix_session.py
index 5da0516e05..a29e2e8280 100644
--- a/dts/framework/remote_session/posix_session.py
+++ b/dts/framework/remote_session/posix_session.py
@@ -94,8 +94,7 @@ def extract_remote_tarball(
expected_dir: str | PurePath | None = None,
) -> None:
self.send_command(
- f"tar xfm {remote_tarball_path} "
- f"-C {PurePosixPath(remote_tarball_path).parent}",
+ f"tar xfm {remote_tarball_path} -C {PurePosixPath(remote_tarball_path).parent}",
60,
)
if expected_dir:
@@ -125,8 +124,7 @@ def build_dpdk(
self._logger.info("Configuring DPDK build from scratch.")
self.remove_remote_dir(remote_dpdk_build_dir)
self.send_command(
- f"meson setup "
- f"{meson_args} {remote_dpdk_dir} {remote_dpdk_build_dir}",
+ f"meson setup {meson_args} {remote_dpdk_dir} {remote_dpdk_build_dir}",
timeout,
verify=True,
env=env_vars,
@@ -140,9 +138,7 @@ def build_dpdk(
raise DPDKBuildError(f"DPDK build failed when doing '{e.command}'.")
def get_dpdk_version(self, build_dir: str | PurePath) -> str:
- out = self.send_command(
- f"cat {self.join_remote_path(build_dir, 'VERSION')}", verify=True
- )
+ out = self.send_command(f"cat {self.join_remote_path(build_dir, 'VERSION')}", verify=True)
return out.stdout
def kill_cleanup_dpdk_apps(self, dpdk_prefix_list: Iterable[str]) -> None:
@@ -156,9 +152,7 @@ def kill_cleanup_dpdk_apps(self, dpdk_prefix_list: Iterable[str]) -> None:
self._check_dpdk_hugepages(dpdk_runtime_dirs)
self._remove_dpdk_runtime_dirs(dpdk_runtime_dirs)
- def _get_dpdk_runtime_dirs(
- self, dpdk_prefix_list: Iterable[str]
- ) -> list[PurePosixPath]:
+ def _get_dpdk_runtime_dirs(self, dpdk_prefix_list: Iterable[str]) -> list[PurePosixPath]:
prefix = PurePosixPath("/var", "run", "dpdk")
if not dpdk_prefix_list:
remote_prefixes = self._list_remote_dirs(prefix)
@@ -174,9 +168,7 @@ def _list_remote_dirs(self, remote_path: str | PurePath) -> list[str] | None:
Return a list of directories of the remote_dir.
If remote_path doesn't exist, return None.
"""
- out = self.send_command(
- f"ls -l {remote_path} | awk '/^d/ {{print $NF}}'"
- ).stdout
+ out = self.send_command(f"ls -l {remote_path} | awk '/^d/ {{print $NF}}'").stdout
if "No such file or directory" in out:
return None
else:
@@ -200,9 +192,7 @@ def _remote_files_exists(self, remote_path: PurePath) -> bool:
result = self.send_command(f"test -e {remote_path}")
return not result.return_code
- def _check_dpdk_hugepages(
- self, dpdk_runtime_dirs: Iterable[str | PurePath]
- ) -> None:
+ def _check_dpdk_hugepages(self, dpdk_runtime_dirs: Iterable[str | PurePath]) -> None:
for dpdk_runtime_dir in dpdk_runtime_dirs:
hugepage_info = PurePosixPath(dpdk_runtime_dir, "hugepage_info")
if self._remote_files_exists(hugepage_info):
@@ -213,9 +203,7 @@ def _check_dpdk_hugepages(
self._logger.warning(out)
self._logger.warning("*******************************************")
- def _remove_dpdk_runtime_dirs(
- self, dpdk_runtime_dirs: Iterable[str | PurePath]
- ) -> None:
+ def _remove_dpdk_runtime_dirs(self, dpdk_runtime_dirs: Iterable[str | PurePath]) -> None:
for dpdk_runtime_dir in dpdk_runtime_dirs:
self.remove_remote_dir(dpdk_runtime_dir)
@@ -245,6 +233,4 @@ def get_node_info(self) -> NodeInfo:
SETTINGS.timeout,
).stdout.split("\n")
kernel_version = self.send_command("uname -r", SETTINGS.timeout).stdout
- return NodeInfo(
- os_release_info[0].strip(), os_release_info[1].strip(), kernel_version
- )
+ return NodeInfo(os_release_info[0].strip(), os_release_info[1].strip(), kernel_version)
diff --git a/dts/framework/remote_session/remote/interactive_remote_session.py b/dts/framework/remote_session/remote/interactive_remote_session.py
index 9085a668e8..098ded1bb0 100644
--- a/dts/framework/remote_session/remote/interactive_remote_session.py
+++ b/dts/framework/remote_session/remote/interactive_remote_session.py
@@ -73,9 +73,7 @@ def __init__(self, node_config: NodeConfiguration, _logger: DTSLOG) -> None:
f"Initializing interactive connection for {self.username}@{self.hostname}"
)
self._connect()
- self._logger.info(
- f"Interactive connection successful for {self.username}@{self.hostname}"
- )
+ self._logger.info(f"Interactive connection successful for {self.username}@{self.hostname}")
def _connect(self) -> None:
"""Establish a connection to the node.
@@ -108,8 +106,7 @@ def _connect(self) -> None:
self._logger.debug(traceback.format_exc())
self._logger.warning(e)
self._logger.info(
- "Retrying interactive session connection: "
- f"retry number {retry_attempt +1}"
+ f"Retrying interactive session connection: retry number {retry_attempt +1}"
)
else:
break
diff --git a/dts/framework/remote_session/remote/interactive_shell.py b/dts/framework/remote_session/remote/interactive_shell.py
index c24376b2a8..4db19fb9b3 100644
--- a/dts/framework/remote_session/remote/interactive_shell.py
+++ b/dts/framework/remote_session/remote/interactive_shell.py
@@ -85,9 +85,7 @@ def __init__(
self._app_args = app_args
self._start_application(get_privileged_command)
- def _start_application(
- self, get_privileged_command: Callable[[str], str] | None
- ) -> None:
+ def _start_application(self, get_privileged_command: Callable[[str], str] | None) -> None:
"""Starts a new interactive application based on the path to the app.
This method is often overridden by subclasses as their process for
diff --git a/dts/framework/remote_session/remote/remote_session.py b/dts/framework/remote_session/remote/remote_session.py
index 0647d93de4..719f7d1ef7 100644
--- a/dts/framework/remote_session/remote/remote_session.py
+++ b/dts/framework/remote_session/remote/remote_session.py
@@ -96,9 +96,7 @@ def send_command(
If verify is True, check the return code of the executed command
and raise a RemoteCommandExecutionError if the command failed.
"""
- self._logger.info(
- f"Sending: '{command}'" + (f" with env vars: '{env}'" if env else "")
- )
+ self._logger.info(f"Sending: '{command}'" + (f" with env vars: '{env}'" if env else ""))
result = self._send_command(command, timeout, env)
if verify and result.return_code:
self._logger.debug(
@@ -112,9 +110,7 @@ def send_command(
return result
@abstractmethod
- def _send_command(
- self, command: str, timeout: float, env: dict | None
- ) -> CommandResult:
+ def _send_command(self, command: str, timeout: float, env: dict | None) -> CommandResult:
"""
Use the underlying protocol to execute the command using optional env vars
and return CommandResult.
diff --git a/dts/framework/remote_session/remote/ssh_session.py b/dts/framework/remote_session/remote/ssh_session.py
index 8d127f1601..1a7ee649ab 100644
--- a/dts/framework/remote_session/remote/ssh_session.py
+++ b/dts/framework/remote_session/remote/ssh_session.py
@@ -80,9 +80,7 @@ def _connect(self) -> None:
if error not in errors:
errors.append(error)
- self._logger.info(
- f"Retrying connection: retry number {retry_attempt + 1}."
- )
+ self._logger.info(f"Retrying connection: retry number {retry_attempt + 1}.")
else:
break
@@ -92,9 +90,7 @@ def _connect(self) -> None:
def is_alive(self) -> bool:
return self.session.is_connected
- def _send_command(
- self, command: str, timeout: float, env: dict | None
- ) -> CommandResult:
+ def _send_command(self, command: str, timeout: float, env: dict | None) -> CommandResult:
"""Send a command and return the result of the execution.
Args:
@@ -107,9 +103,7 @@ def _send_command(
SSHTimeoutError: The command execution timed out.
"""
try:
- output = self.session.run(
- command, env=env, warn=True, hide=True, timeout=timeout
- )
+ output = self.session.run(command, env=env, warn=True, hide=True, timeout=timeout)
except (UnexpectedExit, ThreadException) as e:
self._logger.exception(e)
@@ -119,9 +113,7 @@ def _send_command(
self._logger.exception(e)
raise SSHTimeoutError(command, e.result.stderr) from e
- return CommandResult(
- self.name, command, output.stdout, output.stderr, output.return_code
- )
+ return CommandResult(self.name, command, output.stdout, output.stderr, output.return_code)
def copy_from(
self,
diff --git a/dts/framework/remote_session/remote/testpmd_shell.py b/dts/framework/remote_session/remote/testpmd_shell.py
index 1455b5a199..08ac311016 100644
--- a/dts/framework/remote_session/remote/testpmd_shell.py
+++ b/dts/framework/remote_session/remote/testpmd_shell.py
@@ -21,13 +21,9 @@ class TestPmdShell(InteractiveShell):
path: PurePath = PurePath("app", "dpdk-testpmd")
dpdk_app: bool = True
_default_prompt: str = "testpmd>"
- _command_extra_chars: str = (
- "\n" # We want to append an extra newline to every command
- )
+ _command_extra_chars: str = "\n" # We want to append an extra newline to every command
- def _start_application(
- self, get_privileged_command: Callable[[str], str] | None
- ) -> None:
+ def _start_application(self, get_privileged_command: Callable[[str], str] | None) -> None:
"""See "_start_application" in InteractiveShell."""
self._app_args += " -- -i"
super()._start_application(get_privileged_command)
diff --git a/dts/framework/settings.py b/dts/framework/settings.py
index cfa39d011b..974793a11a 100644
--- a/dts/framework/settings.py
+++ b/dts/framework/settings.py
@@ -72,9 +72,8 @@ class _Settings:
def _get_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(
- description="Run DPDK test suites. All options may be specified with "
- "the environment variables provided in brackets. "
- "Command line arguments have higher priority.",
+ description="Run DPDK test suites. All options may be specified with the environment "
+ "variables provided in brackets. Command line arguments have higher priority.",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
@@ -82,8 +81,7 @@ def _get_parser() -> argparse.ArgumentParser:
"--config-file",
action=_env_arg("DTS_CFG_FILE"),
default="conf.yaml",
- help="[DTS_CFG_FILE] configuration file that describes the test cases, SUTs "
- "and targets.",
+ help="[DTS_CFG_FILE] configuration file that describes the test cases, SUTs and targets.",
)
parser.add_argument(
@@ -100,8 +98,7 @@ def _get_parser() -> argparse.ArgumentParser:
action=_env_arg("DTS_TIMEOUT"),
default=15,
type=float,
- help="[DTS_TIMEOUT] The default timeout for all DTS operations except for "
- "compiling DPDK.",
+ help="[DTS_TIMEOUT] The default timeout for all DTS operations except for compiling DPDK.",
)
parser.add_argument(
@@ -170,9 +167,7 @@ def _get_settings() -> _Settings:
timeout=parsed_args.timeout,
verbose=(parsed_args.verbose == "Y"),
skip_setup=(parsed_args.skip_setup == "Y"),
- dpdk_tarball_path=Path(
- DPDKGitTarball(parsed_args.tarball, parsed_args.output_dir)
- )
+ dpdk_tarball_path=Path(DPDKGitTarball(parsed_args.tarball, parsed_args.output_dir))
if not os.path.exists(parsed_args.tarball)
else Path(parsed_args.tarball),
compile_timeout=parsed_args.compile_timeout,
diff --git a/dts/framework/test_result.py b/dts/framework/test_result.py
index f0fbe80f6f..4c2e7e2418 100644
--- a/dts/framework/test_result.py
+++ b/dts/framework/test_result.py
@@ -83,9 +83,7 @@ def __iadd__(self, other: Result) -> "Statistics":
"""
self[other.name] += 1
self["PASS RATE"] = (
- float(self[Result.PASS.name])
- * 100
- / sum(self[result.name] for result in Result)
+ float(self[Result.PASS.name]) * 100 / sum(self[result.name] for result in Result)
)
return self
@@ -135,9 +133,7 @@ def _get_setup_teardown_errors(self) -> list[Exception]:
def _get_inner_errors(self) -> list[Exception]:
return [
- error
- for inner_result in self._inner_results
- for error in inner_result.get_errors()
+ error for inner_result in self._inner_results for error in inner_result.get_errors()
]
def get_errors(self) -> list[Exception]:
@@ -174,9 +170,7 @@ def add_stats(self, statistics: Statistics) -> None:
statistics += self.result
def __bool__(self) -> bool:
- return (
- bool(self.setup_result) and bool(self.teardown_result) and bool(self.result)
- )
+ return bool(self.setup_result) and bool(self.teardown_result) and bool(self.result)
class TestSuiteResult(BaseResult):
@@ -247,9 +241,7 @@ def __init__(self, sut_node: NodeConfiguration):
super(ExecutionResult, self).__init__()
self.sut_node = sut_node
- def add_build_target(
- self, build_target: BuildTargetConfiguration
- ) -> BuildTargetResult:
+ def add_build_target(self, build_target: BuildTargetConfiguration) -> BuildTargetResult:
build_target_result = BuildTargetResult(build_target)
self._inner_results.append(build_target_result)
return build_target_result
diff --git a/dts/framework/test_suite.py b/dts/framework/test_suite.py
index 3b890c0451..4a7907ec33 100644
--- a/dts/framework/test_suite.py
+++ b/dts/framework/test_suite.py
@@ -102,9 +102,7 @@ def _process_links(self) -> None:
tg_port.peer,
tg_port.identifier,
):
- self._port_links.append(
- PortLink(sut_port=sut_port, tg_port=tg_port)
- )
+ self._port_links.append(PortLink(sut_port=sut_port, tg_port=tg_port))
def set_up_suite(self) -> None:
"""
@@ -151,9 +149,7 @@ def configure_testbed_ipv4(self, restore: bool = False) -> None:
def _configure_ipv4_forwarding(self, enable: bool) -> None:
self.sut_node.configure_ipv4_forwarding(enable)
- def send_packet_and_capture(
- self, packet: Packet, duration: float = 1
- ) -> list[Packet]:
+ def send_packet_and_capture(self, packet: Packet, duration: float = 1) -> list[Packet]:
"""
Send a packet through the appropriate interface and
receive on the appropriate interface.
@@ -202,21 +198,15 @@ def verify(self, condition: bool, failure_description: str) -> None:
self._fail_test_case_verify(failure_description)
def _fail_test_case_verify(self, failure_description: str) -> None:
- self._logger.debug(
- "A test case failed, showing the last 10 commands executed on SUT:"
- )
+ self._logger.debug("A test case failed, showing the last 10 commands executed on SUT:")
for command_res in self.sut_node.main_session.remote_session.history[-10:]:
self._logger.debug(command_res.command)
- self._logger.debug(
- "A test case failed, showing the last 10 commands executed on TG:"
- )
+ self._logger.debug("A test case failed, showing the last 10 commands executed on TG:")
for command_res in self.tg_node.main_session.remote_session.history[-10:]:
self._logger.debug(command_res.command)
raise TestCaseVerifyError(failure_description)
- def verify_packets(
- self, expected_packet: Packet, received_packets: list[Packet]
- ) -> None:
+ def verify_packets(self, expected_packet: Packet, received_packets: list[Packet]) -> None:
for received_packet in received_packets:
if self._compare_packets(expected_packet, received_packet):
break
@@ -225,17 +215,11 @@ def verify_packets(
f"The expected packet {get_packet_summaries(expected_packet)} "
f"not found among received {get_packet_summaries(received_packets)}"
)
- self._fail_test_case_verify(
- "An expected packet not found among received packets."
- )
+ self._fail_test_case_verify("An expected packet not found among received packets.")
- def _compare_packets(
- self, expected_packet: Packet, received_packet: Packet
- ) -> bool:
+ def _compare_packets(self, expected_packet: Packet, received_packet: Packet) -> bool:
self._logger.debug(
- "Comparing packets: \n"
- f"{expected_packet.summary()}\n"
- f"{received_packet.summary()}"
+ f"Comparing packets: \n{expected_packet.summary()}\n{received_packet.summary()}"
)
l3 = IP in expected_packet.layers()
@@ -262,14 +246,10 @@ def _compare_packets(
expected_payload = expected_payload.payload
if expected_payload:
- self._logger.debug(
- f"The expected packet did not contain {expected_payload}."
- )
+ self._logger.debug(f"The expected packet did not contain {expected_payload}.")
return False
if received_payload and received_payload.__class__ != Padding:
- self._logger.debug(
- "The received payload had extra layers which were not padding."
- )
+ self._logger.debug("The received payload had extra layers which were not padding.")
return False
return True
@@ -296,10 +276,7 @@ def _verify_l2_frame(self, received_packet: Ether, l3: bool) -> bool:
def _verify_l3_packet(self, received_packet: IP, expected_packet: IP) -> bool:
self._logger.debug("Looking at the IP layer.")
- if (
- received_packet.src != expected_packet.src
- or received_packet.dst != expected_packet.dst
- ):
+ if received_packet.src != expected_packet.src or received_packet.dst != expected_packet.dst:
return False
return True
@@ -373,9 +350,7 @@ def _get_test_cases(self, test_case_regex: str) -> list[MethodType]:
if self._should_be_executed(test_case_name, test_case_regex):
filtered_test_cases.append(test_case)
cases_str = ", ".join((x.__name__ for x in filtered_test_cases))
- self._logger.debug(
- f"Found test cases '{cases_str}' in {self.__class__.__name__}."
- )
+ self._logger.debug(f"Found test cases '{cases_str}' in {self.__class__.__name__}.")
return filtered_test_cases
def _should_be_executed(self, test_case_name: str, test_case_regex: str) -> bool:
@@ -445,9 +420,7 @@ def _execute_test_case(
self._logger.exception(f"Test case execution ERROR: {test_case_name}")
test_case_result.update(Result.ERROR, e)
except KeyboardInterrupt:
- self._logger.error(
- f"Test case execution INTERRUPTED by user: {test_case_name}"
- )
+ self._logger.error(f"Test case execution INTERRUPTED by user: {test_case_name}")
test_case_result.update(Result.SKIP)
raise KeyboardInterrupt("Stop DTS")
@@ -464,9 +437,7 @@ def is_test_suite(object) -> bool:
try:
testcase_module = importlib.import_module(testsuite_module_path)
except ModuleNotFoundError as e:
- raise ConfigurationError(
- f"Test suite '{testsuite_module_path}' not found."
- ) from e
+ raise ConfigurationError(f"Test suite '{testsuite_module_path}' not found.") from e
return [
test_suite_class
for _, test_suite_class in inspect.getmembers(testcase_module, is_test_suite)
diff --git a/dts/framework/testbed_model/capturing_traffic_generator.py b/dts/framework/testbed_model/capturing_traffic_generator.py
index ab98987f8e..e6512061d7 100644
--- a/dts/framework/testbed_model/capturing_traffic_generator.py
+++ b/dts/framework/testbed_model/capturing_traffic_generator.py
@@ -100,8 +100,7 @@ def send_packets_and_capture(
"""
self._logger.debug(get_packet_summaries(packets))
self._logger.debug(
- f"Sending packet on {send_port.logical_name}, "
- f"receiving on {receive_port.logical_name}."
+ f"Sending packet on {send_port.logical_name}, receiving on {receive_port.logical_name}."
)
received_packets = self._send_packets_and_capture(
packets,
@@ -110,9 +109,7 @@ def send_packets_and_capture(
duration,
)
- self._logger.debug(
- f"Received packets: {get_packet_summaries(received_packets)}"
- )
+ self._logger.debug(f"Received packets: {get_packet_summaries(received_packets)}")
self._write_capture_from_packets(capture_name, received_packets)
return received_packets
diff --git a/dts/framework/testbed_model/hw/cpu.py b/dts/framework/testbed_model/hw/cpu.py
index d1918a12dc..cbc5fe7fff 100644
--- a/dts/framework/testbed_model/hw/cpu.py
+++ b/dts/framework/testbed_model/hw/cpu.py
@@ -54,9 +54,7 @@ def __init__(self, lcore_list: list[int] | list[str] | list[LogicalCore] | str):
# the input lcores may not be sorted
self._lcore_list.sort()
- self._lcore_str = (
- f'{",".join(self._get_consecutive_lcores_range(self._lcore_list))}'
- )
+ self._lcore_str = f'{",".join(self._get_consecutive_lcores_range(self._lcore_list))}'
@property
def lcore_list(self) -> list[int]:
@@ -70,15 +68,11 @@ def _get_consecutive_lcores_range(self, lcore_ids_list: list[int]) -> list[str]:
segment.append(lcore_id)
else:
formatted_core_list.append(
- f"{segment[0]}-{segment[-1]}"
- if len(segment) > 1
- else f"{segment[0]}"
+ f"{segment[0]}-{segment[-1]}" if len(segment) > 1 else f"{segment[0]}"
)
current_core_index = lcore_ids_list.index(lcore_id)
formatted_core_list.extend(
- self._get_consecutive_lcores_range(
- lcore_ids_list[current_core_index:]
- )
+ self._get_consecutive_lcores_range(lcore_ids_list[current_core_index:])
)
segment.clear()
break
@@ -125,9 +119,7 @@ def __init__(
self._filter_specifier = filter_specifier
# sorting by core is needed in case hyperthreading is enabled
- self._lcores_to_filter = sorted(
- lcore_list, key=lambda x: x.core, reverse=not ascending
- )
+ self._lcores_to_filter = sorted(lcore_list, key=lambda x: x.core, reverse=not ascending)
self.filter()
@abstractmethod
@@ -220,9 +212,7 @@ def _filter_cores_from_socket(
else:
# we have enough lcores per this core
continue
- elif self._filter_specifier.cores_per_socket > len(
- lcore_count_per_core_map
- ):
+ elif self._filter_specifier.cores_per_socket > len(lcore_count_per_core_map):
# only add cores if we need more
lcore_count_per_core_map[lcore.core] = 1
filtered_lcores.append(lcore)
diff --git a/dts/framework/testbed_model/node.py b/dts/framework/testbed_model/node.py
index fc01e0bf8e..ef700d8114 100644
--- a/dts/framework/testbed_model/node.py
+++ b/dts/framework/testbed_model/node.py
@@ -103,18 +103,14 @@ def _tear_down_execution(self) -> None:
is not decorated so that the derived class doesn't have to use the decorator.
"""
- def set_up_build_target(
- self, build_target_config: BuildTargetConfiguration
- ) -> None:
+ def set_up_build_target(self, build_target_config: BuildTargetConfiguration) -> None:
"""
Perform the build target setup that will be done for each build target
tested on this node.
"""
self._set_up_build_target(build_target_config)
- def _set_up_build_target(
- self, build_target_config: BuildTargetConfiguration
- ) -> None:
+ def _set_up_build_target(self, build_target_config: BuildTargetConfiguration) -> None:
"""
This method exists to be optionally overwritten by derived classes and
is not decorated so that the derived class doesn't have to use the decorator.
diff --git a/dts/framework/testbed_model/scapy.py b/dts/framework/testbed_model/scapy.py
index af0d4dbb25..9083e92b3d 100644
--- a/dts/framework/testbed_model/scapy.py
+++ b/dts/framework/testbed_model/scapy.py
@@ -96,9 +96,7 @@ def scapy_send_packets_and_capture(
return [scapy_packet.build() for scapy_packet in sniffer.stop(join=True)]
-def scapy_send_packets(
- xmlrpc_packets: list[xmlrpc.client.Binary], send_iface: str
-) -> None:
+def scapy_send_packets(xmlrpc_packets: list[xmlrpc.client.Binary], send_iface: str) -> None:
"""RPC function to send packets.
The function is meant to be executed on the remote TG node.
@@ -197,9 +195,7 @@ class ScapyTrafficGenerator(CapturingTrafficGenerator):
def __init__(self, tg_node: TGNode, config: ScapyTrafficGeneratorConfig):
self._config = config
self._tg_node = tg_node
- self._logger = getLogger(
- f"{self._tg_node.name} {self._config.traffic_generator_type}"
- )
+ self._logger = getLogger(f"{self._tg_node.name} {self._config.traffic_generator_type}")
assert (
self._tg_node.config.os == OS.linux
@@ -218,9 +214,7 @@ def __init__(self, tg_node: TGNode, config: ScapyTrafficGeneratorConfig):
self._start_xmlrpc_server_in_remote_python(xmlrpc_server_listen_port)
# connect to the server
- server_url = (
- f"http://{self._tg_node.config.hostname}:{xmlrpc_server_listen_port}"
- )
+ server_url = f"http://{self._tg_node.config.hostname}:{xmlrpc_server_listen_port}"
self.rpc_server_proxy = xmlrpc.client.ServerProxy(
server_url, allow_none=True, verbose=SETTINGS.verbose
)
@@ -240,17 +234,14 @@ def _start_xmlrpc_server_in_remote_python(self, listen_port: int):
src = inspect.getsource(QuittableXMLRPCServer)
# Lines with only whitespace break the repl if in the middle of a function
# or class, so strip all lines containing only whitespace
- src = "\n".join(
- [line for line in src.splitlines() if not line.isspace() and line != ""]
- )
+ src = "\n".join([line for line in src.splitlines() if not line.isspace() and line != ""])
spacing = "\n" * 4
# execute it in the python terminal
self.session.send_command(spacing + src + spacing)
self.session.send_command(
- f"server = QuittableXMLRPCServer(('0.0.0.0', {listen_port}));"
- f"server.serve_forever()",
+ f"server = QuittableXMLRPCServer(('0.0.0.0', {listen_port}));server.serve_forever()",
"XMLRPC OK",
)
diff --git a/dts/framework/testbed_model/sut_node.py b/dts/framework/testbed_model/sut_node.py
index 202aebfd06..d5d8905be7 100644
--- a/dts/framework/testbed_model/sut_node.py
+++ b/dts/framework/testbed_model/sut_node.py
@@ -129,9 +129,7 @@ def remote_dpdk_build_dir(self) -> PurePath:
@property
def dpdk_version(self) -> str:
if self._dpdk_version is None:
- self._dpdk_version = self.main_session.get_dpdk_version(
- self._remote_dpdk_dir
- )
+ self._dpdk_version = self.main_session.get_dpdk_version(self._remote_dpdk_dir)
return self._dpdk_version
@property
@@ -149,8 +147,7 @@ def compiler_version(self) -> str:
)
else:
self._logger.warning(
- "Failed to get compiler version because"
- "_build_target_config is None."
+ "Failed to get compiler version because _build_target_config is None."
)
return ""
return self._compiler_version
@@ -163,9 +160,7 @@ def get_build_target_info(self) -> BuildTargetInfo:
def _guess_dpdk_remote_dir(self) -> PurePath:
return self.main_session.guess_dpdk_remote_dir(self._remote_tmp_dir)
- def _set_up_build_target(
- self, build_target_config: BuildTargetConfiguration
- ) -> None:
+ def _set_up_build_target(self, build_target_config: BuildTargetConfiguration) -> None:
"""
Setup DPDK on the SUT node.
"""
@@ -177,23 +172,18 @@ def _set_up_build_target(
self._copy_dpdk_tarball()
self._build_dpdk()
- def _configure_build_target(
- self, build_target_config: BuildTargetConfiguration
- ) -> None:
+ def _configure_build_target(self, build_target_config: BuildTargetConfiguration) -> None:
"""
Populate common environment variables and set build target config.
"""
self._env_vars = {}
self._build_target_config = build_target_config
- self._env_vars.update(
- self.main_session.get_dpdk_build_env_vars(build_target_config.arch)
- )
+ self._env_vars.update(self.main_session.get_dpdk_build_env_vars(build_target_config.arch))
self._env_vars["CC"] = build_target_config.compiler.name
if build_target_config.compiler_wrapper:
self._env_vars["CC"] = (
- f"'{build_target_config.compiler_wrapper} "
- f"{build_target_config.compiler.name}'"
- )
+ f"'{build_target_config.compiler_wrapper} {build_target_config.compiler.name}'"
+ ) # fmt: skip
@Node.skip_setup
def _copy_dpdk_tarball(self) -> None:
@@ -224,9 +214,7 @@ def _copy_dpdk_tarball(self) -> None:
self.main_session.remove_remote_dir(self._remote_dpdk_dir)
# then extract to remote path
- self.main_session.extract_remote_tarball(
- remote_tarball_path, self._remote_dpdk_dir
- )
+ self.main_session.extract_remote_tarball(remote_tarball_path, self._remote_dpdk_dir)
@Node.skip_setup
def _build_dpdk(self) -> None:
@@ -263,9 +251,7 @@ def build_dpdk_app(self, app_name: str, **meson_dpdk_args: str | bool) -> PurePa
)
if app_name == "all":
- return self.main_session.join_remote_path(
- self.remote_dpdk_build_dir, "examples"
- )
+ return self.main_session.join_remote_path(self.remote_dpdk_build_dir, "examples")
return self.main_session.join_remote_path(
self.remote_dpdk_build_dir, "examples", f"dpdk-{app_name}"
)
@@ -319,9 +305,7 @@ def create_eal_parameters(
'-c 0xf -a 0000:88:00.0 --file-prefix=dpdk_1112_20190809143420';
"""
- lcore_list = LogicalCoreList(
- self.filter_lcores(lcore_filter_specifier, ascending_cores)
- )
+ lcore_list = LogicalCoreList(self.filter_lcores(lcore_filter_specifier, ascending_cores))
if append_prefix_timestamp:
prefix = f"{prefix}_{self._dpdk_timestamp}"
@@ -386,6 +370,4 @@ def create_interactive_shell(
self.remote_dpdk_build_dir, shell_cls.path
)
- return super().create_interactive_shell(
- shell_cls, timeout, privileged, str(eal_parameters)
- )
+ return super().create_interactive_shell(shell_cls, timeout, privileged, str(eal_parameters))
diff --git a/dts/framework/testbed_model/tg_node.py b/dts/framework/testbed_model/tg_node.py
index 27025cfa31..79a55663b5 100644
--- a/dts/framework/testbed_model/tg_node.py
+++ b/dts/framework/testbed_model/tg_node.py
@@ -45,9 +45,7 @@ class TGNode(Node):
def __init__(self, node_config: TGNodeConfiguration):
super(TGNode, self).__init__(node_config)
- self.traffic_generator = create_traffic_generator(
- self, node_config.traffic_generator
- )
+ self.traffic_generator = create_traffic_generator(self, node_config.traffic_generator)
self._logger.info(f"Created node: {self.name}")
def send_packet_and_capture(
@@ -94,6 +92,5 @@ def create_traffic_generator(
return ScapyTrafficGenerator(tg_node, traffic_generator_config)
case _:
raise ConfigurationError(
- "Unknown traffic generator: "
- f"{traffic_generator_config.traffic_generator_type}"
+ f"Unknown traffic generator: {traffic_generator_config.traffic_generator_type}"
)
diff --git a/dts/framework/utils.py b/dts/framework/utils.py
index d27c2c5b5f..d098d364ff 100644
--- a/dts/framework/utils.py
+++ b/dts/framework/utils.py
@@ -19,9 +19,7 @@
class StrEnum(Enum):
@staticmethod
- def _generate_next_value_(
- name: str, start: int, count: int, last_values: object
- ) -> str:
+ def _generate_next_value_(name: str, start: int, count: int, last_values: object) -> str:
return name
def __str__(self) -> str:
@@ -32,9 +30,7 @@ def __str__(self) -> str:
def check_dts_python_version() -> None:
- if sys.version_info.major < 3 or (
- sys.version_info.major == 3 and sys.version_info.minor < 10
- ):
+ if sys.version_info.major < 3 or (sys.version_info.major == 3 and sys.version_info.minor < 10):
print(
RED(
(
@@ -60,9 +56,7 @@ def expand_range(range_str: str) -> list[int]:
range_boundaries = range_str.split("-")
# will throw an exception when items in range_boundaries can't be converted,
# serving as type check
- expanded_range.extend(
- range(int(range_boundaries[0]), int(range_boundaries[-1]) + 1)
- )
+ expanded_range.extend(range(int(range_boundaries[0]), int(range_boundaries[-1]) + 1))
return expanded_range
@@ -71,9 +65,7 @@ def get_packet_summaries(packets: list[Packet]):
if len(packets) == 1:
packet_summaries = packets[0].summary()
else:
- packet_summaries = json.dumps(
- list(map(lambda pkt: pkt.summary(), packets)), indent=4
- )
+ packet_summaries = json.dumps(list(map(lambda pkt: pkt.summary(), packets)), indent=4)
return f"Packet contents: \n{packet_summaries}"
@@ -94,9 +86,7 @@ class MesonArgs(object):
_default_library: str
def __init__(self, default_library: str | None = None, **dpdk_args: str | bool):
- self._default_library = (
- f"--default-library={default_library}" if default_library else ""
- )
+ self._default_library = f"--default-library={default_library}" if default_library else ""
self._dpdk_args = " ".join(
(
f"-D{dpdk_arg_name}={dpdk_arg_value}"
diff --git a/dts/tests/TestSuite_hello_world.py b/dts/tests/TestSuite_hello_world.py
index 7e3d95c0cf..768ba1cfa8 100644
--- a/dts/tests/TestSuite_hello_world.py
+++ b/dts/tests/TestSuite_hello_world.py
@@ -34,9 +34,7 @@ def test_hello_world_single_core(self) -> None:
# get the first usable core
lcore_amount = LogicalCoreCount(1, 1, 1)
lcores = LogicalCoreCountFilter(self.sut_node.lcores, lcore_amount).filter()
- eal_para = self.sut_node.create_eal_parameters(
- lcore_filter_specifier=lcore_amount
- )
+ eal_para = self.sut_node.create_eal_parameters(lcore_filter_specifier=lcore_amount)
result = self.sut_node.run_dpdk_app(self.app_helloworld_path, eal_para)
self.verify(
f"hello from core {int(lcores[0])}" in result.stdout,
diff --git a/dts/tests/TestSuite_smoke_tests.py b/dts/tests/TestSuite_smoke_tests.py
index 4a269df75b..670053c6a5 100644
--- a/dts/tests/TestSuite_smoke_tests.py
+++ b/dts/tests/TestSuite_smoke_tests.py
@@ -45,13 +45,10 @@ def test_driver_tests(self) -> None:
for dev in self.sut_node.virtual_devices:
vdev_args += f"--vdev {dev} "
vdev_args = vdev_args[:-1]
- driver_tests_command = (
- f"meson test -C {self.dpdk_build_dir_path} --suite driver-tests"
- )
+ driver_tests_command = f"meson test -C {self.dpdk_build_dir_path} --suite driver-tests"
if vdev_args:
self._logger.info(
- "Running driver tests with the following virtual "
- f"devices: {vdev_args}"
+ f"Running driver tests with the following virtual devices: {vdev_args}"
)
driver_tests_command += f' --test-args "{vdev_args}"'
@@ -67,9 +64,7 @@ def test_devices_listed_in_testpmd(self) -> None:
Test:
Uses testpmd driver to verify that devices have been found by testpmd.
"""
- testpmd_driver = self.sut_node.create_interactive_shell(
- TestPmdShell, privileged=True
- )
+ testpmd_driver = self.sut_node.create_interactive_shell(TestPmdShell, privileged=True)
dev_list = [str(x) for x in testpmd_driver.get_devices()]
for nic in self.nics_in_node:
self.verify(
--
2.34.1
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v3 2/2] dts: reformat to 100 line length
2023-09-28 12:18 ` [PATCH v3 2/2] dts: reformat to 100 line length Juraj Linkeš
@ 2023-09-29 16:53 ` Jeremy Spewock
2023-10-13 7:58 ` [PATCH v4 1/2] doc: increase python max line length to 100 Juraj Linkeš
1 sibling, 0 replies; 36+ messages in thread
From: Jeremy Spewock @ 2023-09-29 16:53 UTC (permalink / raw)
To: Juraj Linkeš
Cc: thomas, Honnappa.Nagarahalli, bruce.richardson, probb, stephen, dev
[-- Attachment #1: Type: text/plain, Size: 48 bytes --]
Acked-by: Jeremy Spewock <jspewock@iol.unh.edu>
[-- Attachment #2: Type: text/html, Size: 289 bytes --]
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v3 1/2] doc: increase python max line length to 100
2023-09-28 12:18 ` [PATCH v3 " Juraj Linkeš
2023-09-28 12:18 ` [PATCH v3 2/2] dts: reformat to 100 line length Juraj Linkeš
@ 2023-10-12 12:52 ` Paul Szczepanek
2023-10-13 7:56 ` Juraj Linkeš
1 sibling, 1 reply; 36+ messages in thread
From: Paul Szczepanek @ 2023-10-12 12:52 UTC (permalink / raw)
To: Juraj Linkeš,
thomas, Honnappa.Nagarahalli, bruce.richardson, jspewock, probb,
stephen
Cc: nd, dev
On 28/09/2023 13:18, Juraj Linkeš wrote:
> Unify with C recommendations which allow line length of up to 100
> characters.
>
> Signed-off-by: Owen Hilyard <ohilyard@iol.unh.edu>
> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> ---
> .editorconfig | 2 +-
> doc/doc_build/meson-private/meson.lock | 0
> doc/guides/contributing/coding_style.rst | 3 +++
> dts/pyproject.toml | 4 ++--
> 4 files changed, 6 insertions(+), 3 deletions(-)
> create mode 100644 doc/doc_build/meson-private/meson.lock
>
> diff --git a/.editorconfig b/.editorconfig
> index ab41c95085..1e7d74213f 100644
> --- a/.editorconfig
> +++ b/.editorconfig
> @@ -16,7 +16,7 @@ max_line_length = 100
> [*.py]
> indent_style = space
> indent_size = 4
> -max_line_length = 79
> +max_line_length = 100
>
> [meson.build]
> indent_style = space
> diff --git a/doc/doc_build/meson-private/meson.lock b/doc/doc_build/meson-private/meson.lock
> new file mode 100644
> index 0000000000..e69de29bb2
> diff --git a/doc/guides/contributing/coding_style.rst b/doc/guides/contributing/coding_style.rst
> index 648849899d..a42cd3d58d 100644
> --- a/doc/guides/contributing/coding_style.rst
> +++ b/doc/guides/contributing/coding_style.rst
> @@ -880,6 +880,9 @@ All Python code should be compliant with
> `PEP8 (Style Guide for Python Code) <https://www.python.org/dev/peps/pep-0008/>`_.
>
> The ``pep8`` tool can be used for testing compliance with the guidelines.
> +Note that line lengths are acceptable up to 100 characters, which is in line with C recommendations.
> +
> +..
Presumably the bare ".." is some accidental leftover markup.
>
> Integrating with the Build System
> ---------------------------------
> diff --git a/dts/pyproject.toml b/dts/pyproject.toml
> index 6762edfa6b..980ac3c7db 100644
> --- a/dts/pyproject.toml
> +++ b/dts/pyproject.toml
> @@ -41,7 +41,7 @@ build-backend = "poetry.core.masonry.api"
> [tool.pylama]
> linters = "mccabe,pycodestyle,pyflakes"
> format = "pylint"
> -max_line_length = 88 # https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length
> +max_line_length = 100
>
> [tool.mypy]
> python_version = "3.10"
> @@ -55,4 +55,4 @@ profile = "black"
> [tool.black]
> target-version = ['py310']
> include = '\.pyi?$'
> -line-length = 88 # https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length
> +line-length = 100
The rest looks good. Wholeheartedly support longer line length.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v3 1/2] doc: increase python max line length to 100
2023-10-12 12:52 ` [PATCH v3 " Paul Szczepanek
@ 2023-10-13 7:56 ` Juraj Linkeš
0 siblings, 0 replies; 36+ messages in thread
From: Juraj Linkeš @ 2023-10-13 7:56 UTC (permalink / raw)
To: Paul Szczepanek
Cc: thomas, Honnappa.Nagarahalli, bruce.richardson, jspewock, probb,
stephen, nd, dev
On Thu, Oct 12, 2023 at 2:52 PM Paul Szczepanek <paul.szczepanek@arm.com> wrote:
>
>
> On 28/09/2023 13:18, Juraj Linkeš wrote:
> > Unify with C recommendations which allow line length of up to 100
> > characters.
> >
> > Signed-off-by: Owen Hilyard <ohilyard@iol.unh.edu>
> > Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > ---
> > .editorconfig | 2 +-
> > doc/doc_build/meson-private/meson.lock | 0
> > doc/guides/contributing/coding_style.rst | 3 +++
> > dts/pyproject.toml | 4 ++--
> > 4 files changed, 6 insertions(+), 3 deletions(-)
> > create mode 100644 doc/doc_build/meson-private/meson.lock
> >
> > diff --git a/.editorconfig b/.editorconfig
> > index ab41c95085..1e7d74213f 100644
> > --- a/.editorconfig
> > +++ b/.editorconfig
> > @@ -16,7 +16,7 @@ max_line_length = 100
> > [*.py]
> > indent_style = space
> > indent_size = 4
> > -max_line_length = 79
> > +max_line_length = 100
> >
> > [meson.build]
> > indent_style = space
> > diff --git a/doc/doc_build/meson-private/meson.lock b/doc/doc_build/meson-private/meson.lock
> > new file mode 100644
> > index 0000000000..e69de29bb2
> > diff --git a/doc/guides/contributing/coding_style.rst b/doc/guides/contributing/coding_style.rst
> > index 648849899d..a42cd3d58d 100644
> > --- a/doc/guides/contributing/coding_style.rst
> > +++ b/doc/guides/contributing/coding_style.rst
> > @@ -880,6 +880,9 @@ All Python code should be compliant with
> > `PEP8 (Style Guide for Python Code) <https://www.python.org/dev/peps/pep-0008/>`_.
> >
> > The ``pep8`` tool can be used for testing compliance with the guidelines.
> > +Note that line lengths are acceptable up to 100 characters, which is in line with C recommendations.
> > +
> > +..
>
> Presumably the bare ".." is some accidental leftover markup.
>
I'll fix this in the next version.
>
> >
> > Integrating with the Build System
> > ---------------------------------
> > diff --git a/dts/pyproject.toml b/dts/pyproject.toml
> > index 6762edfa6b..980ac3c7db 100644
> > --- a/dts/pyproject.toml
> > +++ b/dts/pyproject.toml
> > @@ -41,7 +41,7 @@ build-backend = "poetry.core.masonry.api"
> > [tool.pylama]
> > linters = "mccabe,pycodestyle,pyflakes"
> > format = "pylint"
> > -max_line_length = 88 # https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length
> > +max_line_length = 100
> >
> > [tool.mypy]
> > python_version = "3.10"
> > @@ -55,4 +55,4 @@ profile = "black"
> > [tool.black]
> > target-version = ['py310']
> > include = '\.pyi?$'
> > -line-length = 88 # https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length
> > +line-length = 100
>
> The rest looks good. Wholeheartedly support longer line length.
>
Thanks, please send your ack's in the new version.
>
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v4 1/2] doc: increase python max line length to 100
2023-09-28 12:18 ` [PATCH v3 2/2] dts: reformat to 100 line length Juraj Linkeš
2023-09-29 16:53 ` Jeremy Spewock
@ 2023-10-13 7:58 ` Juraj Linkeš
2023-10-13 7:58 ` [PATCH v4 2/2] dts: reformat to 100 line length Juraj Linkeš
2023-10-13 16:09 ` [PATCH v4 1/2] doc: increase python max line length to 100 Stephen Hemminger
1 sibling, 2 replies; 36+ messages in thread
From: Juraj Linkeš @ 2023-10-13 7:58 UTC (permalink / raw)
To: thomas, Honnappa.Nagarahalli, bruce.richardson, jspewock, probb, stephen
Cc: dev, Juraj Linkeš
Unify with C recommendations which allow line length of up to 100
characters.
Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
.editorconfig | 2 +-
doc/doc_build/meson-private/meson.lock | 0
doc/guides/contributing/coding_style.rst | 1 +
dts/pyproject.toml | 4 ++--
4 files changed, 4 insertions(+), 3 deletions(-)
create mode 100644 doc/doc_build/meson-private/meson.lock
diff --git a/.editorconfig b/.editorconfig
index ab41c95085..1e7d74213f 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -16,7 +16,7 @@ max_line_length = 100
[*.py]
indent_style = space
indent_size = 4
-max_line_length = 79
+max_line_length = 100
[meson.build]
indent_style = space
diff --git a/doc/doc_build/meson-private/meson.lock b/doc/doc_build/meson-private/meson.lock
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/doc/guides/contributing/coding_style.rst b/doc/guides/contributing/coding_style.rst
index 648849899d..1ebc79ca3c 100644
--- a/doc/guides/contributing/coding_style.rst
+++ b/doc/guides/contributing/coding_style.rst
@@ -880,6 +880,7 @@ All Python code should be compliant with
`PEP8 (Style Guide for Python Code) <https://www.python.org/dev/peps/pep-0008/>`_.
The ``pep8`` tool can be used for testing compliance with the guidelines.
+Note that line lengths are acceptable up to 100 characters, which is in line with C recommendations.
Integrating with the Build System
---------------------------------
diff --git a/dts/pyproject.toml b/dts/pyproject.toml
index 6762edfa6b..980ac3c7db 100644
--- a/dts/pyproject.toml
+++ b/dts/pyproject.toml
@@ -41,7 +41,7 @@ build-backend = "poetry.core.masonry.api"
[tool.pylama]
linters = "mccabe,pycodestyle,pyflakes"
format = "pylint"
-max_line_length = 88 # https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length
+max_line_length = 100
[tool.mypy]
python_version = "3.10"
@@ -55,4 +55,4 @@ profile = "black"
[tool.black]
target-version = ['py310']
include = '\.pyi?$'
-line-length = 88 # https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length
+line-length = 100
--
2.34.1
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v4 2/2] dts: reformat to 100 line length
2023-10-13 7:58 ` [PATCH v4 1/2] doc: increase python max line length to 100 Juraj Linkeš
@ 2023-10-13 7:58 ` Juraj Linkeš
2023-10-16 6:45 ` [PATCH v5 1/2] doc: increase python max line length to 100 Juraj Linkeš
2023-10-13 16:09 ` [PATCH v4 1/2] doc: increase python max line length to 100 Stephen Hemminger
1 sibling, 1 reply; 36+ messages in thread
From: Juraj Linkeš @ 2023-10-13 7:58 UTC (permalink / raw)
To: thomas, Honnappa.Nagarahalli, bruce.richardson, jspewock, probb, stephen
Cc: dev, Juraj Linkeš
Reformat to 100 from the previous 88 to unify with C recommendations.
Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
Acked-by: Jeremy Spewock <jspewock@iol.unh.edu>
---
dts/framework/config/__init__.py | 20 ++-----
dts/framework/dts.py | 15 ++---
dts/framework/exception.py | 5 +-
dts/framework/remote_session/__init__.py | 4 +-
dts/framework/remote_session/linux_session.py | 39 ++++---------
dts/framework/remote_session/posix_session.py | 30 +++-------
.../remote/interactive_remote_session.py | 7 +--
.../remote/interactive_shell.py | 4 +-
.../remote_session/remote/remote_session.py | 8 +--
.../remote_session/remote/ssh_session.py | 16 ++----
.../remote_session/remote/testpmd_shell.py | 8 +--
dts/framework/settings.py | 15 ++---
dts/framework/test_result.py | 16 ++----
dts/framework/test_suite.py | 57 +++++--------------
.../capturing_traffic_generator.py | 7 +--
dts/framework/testbed_model/hw/cpu.py | 20 ++-----
dts/framework/testbed_model/node.py | 8 +--
dts/framework/testbed_model/scapy.py | 19 ++-----
dts/framework/testbed_model/sut_node.py | 40 ++++---------
dts/framework/testbed_model/tg_node.py | 7 +--
dts/framework/utils.py | 20 ++-----
dts/tests/TestSuite_hello_world.py | 4 +-
dts/tests/TestSuite_smoke_tests.py | 11 +---
23 files changed, 99 insertions(+), 281 deletions(-)
diff --git a/dts/framework/config/__init__.py b/dts/framework/config/__init__.py
index cb7e00ba34..9b32cf0532 100644
--- a/dts/framework/config/__init__.py
+++ b/dts/framework/config/__init__.py
@@ -140,9 +140,7 @@ def from_dict(d: dict) -> Union["SutNodeConfiguration", "TGNodeConfiguration"]:
if "traffic_generator" in d:
return TGNodeConfiguration(
- traffic_generator=TrafficGeneratorConfig.from_dict(
- d["traffic_generator"]
- ),
+ traffic_generator=TrafficGeneratorConfig.from_dict(d["traffic_generator"]),
**common_config,
)
else:
@@ -249,9 +247,7 @@ def from_dict(
build_targets: list[BuildTargetConfiguration] = list(
map(BuildTargetConfiguration.from_dict, d["build_targets"])
)
- test_suites: list[TestSuiteConfig] = list(
- map(TestSuiteConfig.from_dict, d["test_suites"])
- )
+ test_suites: list[TestSuiteConfig] = list(map(TestSuiteConfig.from_dict, d["test_suites"]))
sut_name = d["system_under_test_node"]["node_name"]
skip_smoke_tests = d.get("skip_smoke_tests", False)
assert sut_name in node_map, f"Unknown SUT {sut_name} in execution {d}"
@@ -268,9 +264,7 @@ def from_dict(
), f"Invalid TG configuration {traffic_generator_node}"
vdevs = (
- d["system_under_test_node"]["vdevs"]
- if "vdevs" in d["system_under_test_node"]
- else []
+ d["system_under_test_node"]["vdevs"] if "vdevs" in d["system_under_test_node"] else []
)
return ExecutionConfiguration(
build_targets=build_targets,
@@ -299,9 +293,7 @@ def from_dict(d: dict) -> "Configuration":
assert len(nodes) == len(node_map), "Duplicate node names are not allowed"
executions: list[ExecutionConfiguration] = list(
- map(
- ExecutionConfiguration.from_dict, d["executions"], [node_map for _ in d]
- )
+ map(ExecutionConfiguration.from_dict, d["executions"], [node_map for _ in d])
)
return Configuration(executions=executions)
@@ -315,9 +307,7 @@ def load_config() -> Configuration:
with open(SETTINGS.config_file_path, "r") as f:
config_data = yaml.safe_load(f)
- schema_path = os.path.join(
- pathlib.Path(__file__).parent.resolve(), "conf_yaml_schema.json"
- )
+ schema_path = os.path.join(pathlib.Path(__file__).parent.resolve(), "conf_yaml_schema.json")
with open(schema_path, "r") as f:
schema = json.load(f)
diff --git a/dts/framework/dts.py b/dts/framework/dts.py
index f773f0c38d..25d6942d81 100644
--- a/dts/framework/dts.py
+++ b/dts/framework/dts.py
@@ -92,9 +92,7 @@ def _run_execution(
Run the given execution. This involves running the execution setup as well as
running all build targets in the given execution.
"""
- dts_logger.info(
- f"Running execution with SUT '{execution.system_under_test_node.name}'."
- )
+ dts_logger.info(f"Running execution with SUT '{execution.system_under_test_node.name}'.")
execution_result = result.add_execution(sut_node.config)
execution_result.add_sut_info(sut_node.node_info)
@@ -107,9 +105,7 @@ def _run_execution(
else:
for build_target in execution.build_targets:
- _run_build_target(
- sut_node, tg_node, build_target, execution, execution_result
- )
+ _run_build_target(sut_node, tg_node, build_target, execution, execution_result)
finally:
try:
@@ -170,13 +166,10 @@ def _run_all_suites(
execution.test_suites[:0] = [TestSuiteConfig.from_dict("smoke_tests")]
for test_suite_config in execution.test_suites:
try:
- _run_single_suite(
- sut_node, tg_node, execution, build_target_result, test_suite_config
- )
+ _run_single_suite(sut_node, tg_node, execution, build_target_result, test_suite_config)
except BlockingTestSuiteError as e:
dts_logger.exception(
- f"An error occurred within {test_suite_config.test_suite}. "
- "Skipping build target..."
+ f"An error occurred within {test_suite_config.test_suite}. Skipping build target."
)
result.add_error(e)
end_build_target = True
diff --git a/dts/framework/exception.py b/dts/framework/exception.py
index 001a5a5496..b362e42924 100644
--- a/dts/framework/exception.py
+++ b/dts/framework/exception.py
@@ -116,10 +116,7 @@ def __init__(self, command: str, command_return_code: int):
self.command_return_code = command_return_code
def __str__(self) -> str:
- return (
- f"Command {self.command} returned a non-zero exit code: "
- f"{self.command_return_code}"
- )
+ return f"Command {self.command} returned a non-zero exit code: {self.command_return_code}"
class RemoteDirectoryExistsError(DTSError):
diff --git a/dts/framework/remote_session/__init__.py b/dts/framework/remote_session/__init__.py
index 00b6d1f03a..6124417bd7 100644
--- a/dts/framework/remote_session/__init__.py
+++ b/dts/framework/remote_session/__init__.py
@@ -30,9 +30,7 @@
)
-def create_session(
- node_config: NodeConfiguration, name: str, logger: DTSLOG
-) -> OSSession:
+def create_session(node_config: NodeConfiguration, name: str, logger: DTSLOG) -> OSSession:
match node_config.os:
case OS.linux:
return LinuxSession(node_config, name, logger)
diff --git a/dts/framework/remote_session/linux_session.py b/dts/framework/remote_session/linux_session.py
index a3f1a6bf3b..fd877fbfae 100644
--- a/dts/framework/remote_session/linux_session.py
+++ b/dts/framework/remote_session/linux_session.py
@@ -82,9 +82,7 @@ def setup_hugepages(self, hugepage_amount: int, force_first_numa: bool) -> None:
self._mount_huge_pages()
def _get_hugepage_size(self) -> int:
- hugepage_size = self.send_command(
- "awk '/Hugepagesize/ {print $2}' /proc/meminfo"
- ).stdout
+ hugepage_size = self.send_command("awk '/Hugepagesize/ {print $2}' /proc/meminfo").stdout
return int(hugepage_size)
def _get_hugepages_total(self) -> int:
@@ -120,13 +118,9 @@ def _supports_numa(self) -> bool:
# there's no reason to do any numa specific configuration)
return len(self._numa_nodes) > 1
- def _configure_huge_pages(
- self, amount: int, size: int, force_first_numa: bool
- ) -> None:
+ def _configure_huge_pages(self, amount: int, size: int, force_first_numa: bool) -> None:
self._logger.info("Configuring Hugepages.")
- hugepage_config_path = (
- f"/sys/kernel/mm/hugepages/hugepages-{size}kB/nr_hugepages"
- )
+ hugepage_config_path = f"/sys/kernel/mm/hugepages/hugepages-{size}kB/nr_hugepages"
if force_first_numa and self._supports_numa():
# clear non-numa hugepages
self.send_command(f"echo 0 | tee {hugepage_config_path}", privileged=True)
@@ -135,24 +129,18 @@ def _configure_huge_pages(
f"/hugepages-{size}kB/nr_hugepages"
)
- self.send_command(
- f"echo {amount} | tee {hugepage_config_path}", privileged=True
- )
+ self.send_command(f"echo {amount} | tee {hugepage_config_path}", privileged=True)
def update_ports(self, ports: list[Port]) -> None:
self._logger.debug("Gathering port info.")
for port in ports:
- assert (
- port.node == self.name
- ), "Attempted to gather port info on the wrong node"
+ assert port.node == self.name, "Attempted to gather port info on the wrong node"
port_info_list = self._get_lshw_info()
for port in ports:
for port_info in port_info_list:
if f"pci@{port.pci}" == port_info.get("businfo"):
- self._update_port_attr(
- port, port_info.get("logicalname"), "logical_name"
- )
+ self._update_port_attr(port, port_info.get("logicalname"), "logical_name")
self._update_port_attr(port, port_info.get("serial"), "mac_address")
port_info_list.remove(port_info)
break
@@ -163,25 +151,18 @@ def _get_lshw_info(self) -> list[LshwOutput]:
output = self.send_command("lshw -quiet -json -C network", verify=True)
return json.loads(output.stdout)
- def _update_port_attr(
- self, port: Port, attr_value: str | None, attr_name: str
- ) -> None:
+ def _update_port_attr(self, port: Port, attr_value: str | None, attr_name: str) -> None:
if attr_value:
setattr(port, attr_name, attr_value)
- self._logger.debug(
- f"Found '{attr_name}' of port {port.pci}: '{attr_value}'."
- )
+ self._logger.debug(f"Found '{attr_name}' of port {port.pci}: '{attr_value}'.")
else:
self._logger.warning(
- f"Attempted to get '{attr_name}' of port {port.pci}, "
- f"but it doesn't exist."
+ f"Attempted to get '{attr_name}' of port {port.pci}, but it doesn't exist."
)
def configure_port_state(self, port: Port, enable: bool) -> None:
state = "up" if enable else "down"
- self.send_command(
- f"ip link set dev {port.logical_name} {state}", privileged=True
- )
+ self.send_command(f"ip link set dev {port.logical_name} {state}", privileged=True)
def configure_port_ip_address(
self,
diff --git a/dts/framework/remote_session/posix_session.py b/dts/framework/remote_session/posix_session.py
index 5da0516e05..a29e2e8280 100644
--- a/dts/framework/remote_session/posix_session.py
+++ b/dts/framework/remote_session/posix_session.py
@@ -94,8 +94,7 @@ def extract_remote_tarball(
expected_dir: str | PurePath | None = None,
) -> None:
self.send_command(
- f"tar xfm {remote_tarball_path} "
- f"-C {PurePosixPath(remote_tarball_path).parent}",
+ f"tar xfm {remote_tarball_path} -C {PurePosixPath(remote_tarball_path).parent}",
60,
)
if expected_dir:
@@ -125,8 +124,7 @@ def build_dpdk(
self._logger.info("Configuring DPDK build from scratch.")
self.remove_remote_dir(remote_dpdk_build_dir)
self.send_command(
- f"meson setup "
- f"{meson_args} {remote_dpdk_dir} {remote_dpdk_build_dir}",
+ f"meson setup {meson_args} {remote_dpdk_dir} {remote_dpdk_build_dir}",
timeout,
verify=True,
env=env_vars,
@@ -140,9 +138,7 @@ def build_dpdk(
raise DPDKBuildError(f"DPDK build failed when doing '{e.command}'.")
def get_dpdk_version(self, build_dir: str | PurePath) -> str:
- out = self.send_command(
- f"cat {self.join_remote_path(build_dir, 'VERSION')}", verify=True
- )
+ out = self.send_command(f"cat {self.join_remote_path(build_dir, 'VERSION')}", verify=True)
return out.stdout
def kill_cleanup_dpdk_apps(self, dpdk_prefix_list: Iterable[str]) -> None:
@@ -156,9 +152,7 @@ def kill_cleanup_dpdk_apps(self, dpdk_prefix_list: Iterable[str]) -> None:
self._check_dpdk_hugepages(dpdk_runtime_dirs)
self._remove_dpdk_runtime_dirs(dpdk_runtime_dirs)
- def _get_dpdk_runtime_dirs(
- self, dpdk_prefix_list: Iterable[str]
- ) -> list[PurePosixPath]:
+ def _get_dpdk_runtime_dirs(self, dpdk_prefix_list: Iterable[str]) -> list[PurePosixPath]:
prefix = PurePosixPath("/var", "run", "dpdk")
if not dpdk_prefix_list:
remote_prefixes = self._list_remote_dirs(prefix)
@@ -174,9 +168,7 @@ def _list_remote_dirs(self, remote_path: str | PurePath) -> list[str] | None:
Return a list of directories of the remote_dir.
If remote_path doesn't exist, return None.
"""
- out = self.send_command(
- f"ls -l {remote_path} | awk '/^d/ {{print $NF}}'"
- ).stdout
+ out = self.send_command(f"ls -l {remote_path} | awk '/^d/ {{print $NF}}'").stdout
if "No such file or directory" in out:
return None
else:
@@ -200,9 +192,7 @@ def _remote_files_exists(self, remote_path: PurePath) -> bool:
result = self.send_command(f"test -e {remote_path}")
return not result.return_code
- def _check_dpdk_hugepages(
- self, dpdk_runtime_dirs: Iterable[str | PurePath]
- ) -> None:
+ def _check_dpdk_hugepages(self, dpdk_runtime_dirs: Iterable[str | PurePath]) -> None:
for dpdk_runtime_dir in dpdk_runtime_dirs:
hugepage_info = PurePosixPath(dpdk_runtime_dir, "hugepage_info")
if self._remote_files_exists(hugepage_info):
@@ -213,9 +203,7 @@ def _check_dpdk_hugepages(
self._logger.warning(out)
self._logger.warning("*******************************************")
- def _remove_dpdk_runtime_dirs(
- self, dpdk_runtime_dirs: Iterable[str | PurePath]
- ) -> None:
+ def _remove_dpdk_runtime_dirs(self, dpdk_runtime_dirs: Iterable[str | PurePath]) -> None:
for dpdk_runtime_dir in dpdk_runtime_dirs:
self.remove_remote_dir(dpdk_runtime_dir)
@@ -245,6 +233,4 @@ def get_node_info(self) -> NodeInfo:
SETTINGS.timeout,
).stdout.split("\n")
kernel_version = self.send_command("uname -r", SETTINGS.timeout).stdout
- return NodeInfo(
- os_release_info[0].strip(), os_release_info[1].strip(), kernel_version
- )
+ return NodeInfo(os_release_info[0].strip(), os_release_info[1].strip(), kernel_version)
diff --git a/dts/framework/remote_session/remote/interactive_remote_session.py b/dts/framework/remote_session/remote/interactive_remote_session.py
index 9085a668e8..098ded1bb0 100644
--- a/dts/framework/remote_session/remote/interactive_remote_session.py
+++ b/dts/framework/remote_session/remote/interactive_remote_session.py
@@ -73,9 +73,7 @@ def __init__(self, node_config: NodeConfiguration, _logger: DTSLOG) -> None:
f"Initializing interactive connection for {self.username}@{self.hostname}"
)
self._connect()
- self._logger.info(
- f"Interactive connection successful for {self.username}@{self.hostname}"
- )
+ self._logger.info(f"Interactive connection successful for {self.username}@{self.hostname}")
def _connect(self) -> None:
"""Establish a connection to the node.
@@ -108,8 +106,7 @@ def _connect(self) -> None:
self._logger.debug(traceback.format_exc())
self._logger.warning(e)
self._logger.info(
- "Retrying interactive session connection: "
- f"retry number {retry_attempt +1}"
+ f"Retrying interactive session connection: retry number {retry_attempt +1}"
)
else:
break
diff --git a/dts/framework/remote_session/remote/interactive_shell.py b/dts/framework/remote_session/remote/interactive_shell.py
index c24376b2a8..4db19fb9b3 100644
--- a/dts/framework/remote_session/remote/interactive_shell.py
+++ b/dts/framework/remote_session/remote/interactive_shell.py
@@ -85,9 +85,7 @@ def __init__(
self._app_args = app_args
self._start_application(get_privileged_command)
- def _start_application(
- self, get_privileged_command: Callable[[str], str] | None
- ) -> None:
+ def _start_application(self, get_privileged_command: Callable[[str], str] | None) -> None:
"""Starts a new interactive application based on the path to the app.
This method is often overridden by subclasses as their process for
diff --git a/dts/framework/remote_session/remote/remote_session.py b/dts/framework/remote_session/remote/remote_session.py
index 0647d93de4..719f7d1ef7 100644
--- a/dts/framework/remote_session/remote/remote_session.py
+++ b/dts/framework/remote_session/remote/remote_session.py
@@ -96,9 +96,7 @@ def send_command(
If verify is True, check the return code of the executed command
and raise a RemoteCommandExecutionError if the command failed.
"""
- self._logger.info(
- f"Sending: '{command}'" + (f" with env vars: '{env}'" if env else "")
- )
+ self._logger.info(f"Sending: '{command}'" + (f" with env vars: '{env}'" if env else ""))
result = self._send_command(command, timeout, env)
if verify and result.return_code:
self._logger.debug(
@@ -112,9 +110,7 @@ def send_command(
return result
@abstractmethod
- def _send_command(
- self, command: str, timeout: float, env: dict | None
- ) -> CommandResult:
+ def _send_command(self, command: str, timeout: float, env: dict | None) -> CommandResult:
"""
Use the underlying protocol to execute the command using optional env vars
and return CommandResult.
diff --git a/dts/framework/remote_session/remote/ssh_session.py b/dts/framework/remote_session/remote/ssh_session.py
index 8d127f1601..1a7ee649ab 100644
--- a/dts/framework/remote_session/remote/ssh_session.py
+++ b/dts/framework/remote_session/remote/ssh_session.py
@@ -80,9 +80,7 @@ def _connect(self) -> None:
if error not in errors:
errors.append(error)
- self._logger.info(
- f"Retrying connection: retry number {retry_attempt + 1}."
- )
+ self._logger.info(f"Retrying connection: retry number {retry_attempt + 1}.")
else:
break
@@ -92,9 +90,7 @@ def _connect(self) -> None:
def is_alive(self) -> bool:
return self.session.is_connected
- def _send_command(
- self, command: str, timeout: float, env: dict | None
- ) -> CommandResult:
+ def _send_command(self, command: str, timeout: float, env: dict | None) -> CommandResult:
"""Send a command and return the result of the execution.
Args:
@@ -107,9 +103,7 @@ def _send_command(
SSHTimeoutError: The command execution timed out.
"""
try:
- output = self.session.run(
- command, env=env, warn=True, hide=True, timeout=timeout
- )
+ output = self.session.run(command, env=env, warn=True, hide=True, timeout=timeout)
except (UnexpectedExit, ThreadException) as e:
self._logger.exception(e)
@@ -119,9 +113,7 @@ def _send_command(
self._logger.exception(e)
raise SSHTimeoutError(command, e.result.stderr) from e
- return CommandResult(
- self.name, command, output.stdout, output.stderr, output.return_code
- )
+ return CommandResult(self.name, command, output.stdout, output.stderr, output.return_code)
def copy_from(
self,
diff --git a/dts/framework/remote_session/remote/testpmd_shell.py b/dts/framework/remote_session/remote/testpmd_shell.py
index 1455b5a199..08ac311016 100644
--- a/dts/framework/remote_session/remote/testpmd_shell.py
+++ b/dts/framework/remote_session/remote/testpmd_shell.py
@@ -21,13 +21,9 @@ class TestPmdShell(InteractiveShell):
path: PurePath = PurePath("app", "dpdk-testpmd")
dpdk_app: bool = True
_default_prompt: str = "testpmd>"
- _command_extra_chars: str = (
- "\n" # We want to append an extra newline to every command
- )
+ _command_extra_chars: str = "\n" # We want to append an extra newline to every command
- def _start_application(
- self, get_privileged_command: Callable[[str], str] | None
- ) -> None:
+ def _start_application(self, get_privileged_command: Callable[[str], str] | None) -> None:
"""See "_start_application" in InteractiveShell."""
self._app_args += " -- -i"
super()._start_application(get_privileged_command)
diff --git a/dts/framework/settings.py b/dts/framework/settings.py
index cfa39d011b..974793a11a 100644
--- a/dts/framework/settings.py
+++ b/dts/framework/settings.py
@@ -72,9 +72,8 @@ class _Settings:
def _get_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(
- description="Run DPDK test suites. All options may be specified with "
- "the environment variables provided in brackets. "
- "Command line arguments have higher priority.",
+ description="Run DPDK test suites. All options may be specified with the environment "
+ "variables provided in brackets. Command line arguments have higher priority.",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
@@ -82,8 +81,7 @@ def _get_parser() -> argparse.ArgumentParser:
"--config-file",
action=_env_arg("DTS_CFG_FILE"),
default="conf.yaml",
- help="[DTS_CFG_FILE] configuration file that describes the test cases, SUTs "
- "and targets.",
+ help="[DTS_CFG_FILE] configuration file that describes the test cases, SUTs and targets.",
)
parser.add_argument(
@@ -100,8 +98,7 @@ def _get_parser() -> argparse.ArgumentParser:
action=_env_arg("DTS_TIMEOUT"),
default=15,
type=float,
- help="[DTS_TIMEOUT] The default timeout for all DTS operations except for "
- "compiling DPDK.",
+ help="[DTS_TIMEOUT] The default timeout for all DTS operations except for compiling DPDK.",
)
parser.add_argument(
@@ -170,9 +167,7 @@ def _get_settings() -> _Settings:
timeout=parsed_args.timeout,
verbose=(parsed_args.verbose == "Y"),
skip_setup=(parsed_args.skip_setup == "Y"),
- dpdk_tarball_path=Path(
- DPDKGitTarball(parsed_args.tarball, parsed_args.output_dir)
- )
+ dpdk_tarball_path=Path(DPDKGitTarball(parsed_args.tarball, parsed_args.output_dir))
if not os.path.exists(parsed_args.tarball)
else Path(parsed_args.tarball),
compile_timeout=parsed_args.compile_timeout,
diff --git a/dts/framework/test_result.py b/dts/framework/test_result.py
index f0fbe80f6f..4c2e7e2418 100644
--- a/dts/framework/test_result.py
+++ b/dts/framework/test_result.py
@@ -83,9 +83,7 @@ def __iadd__(self, other: Result) -> "Statistics":
"""
self[other.name] += 1
self["PASS RATE"] = (
- float(self[Result.PASS.name])
- * 100
- / sum(self[result.name] for result in Result)
+ float(self[Result.PASS.name]) * 100 / sum(self[result.name] for result in Result)
)
return self
@@ -135,9 +133,7 @@ def _get_setup_teardown_errors(self) -> list[Exception]:
def _get_inner_errors(self) -> list[Exception]:
return [
- error
- for inner_result in self._inner_results
- for error in inner_result.get_errors()
+ error for inner_result in self._inner_results for error in inner_result.get_errors()
]
def get_errors(self) -> list[Exception]:
@@ -174,9 +170,7 @@ def add_stats(self, statistics: Statistics) -> None:
statistics += self.result
def __bool__(self) -> bool:
- return (
- bool(self.setup_result) and bool(self.teardown_result) and bool(self.result)
- )
+ return bool(self.setup_result) and bool(self.teardown_result) and bool(self.result)
class TestSuiteResult(BaseResult):
@@ -247,9 +241,7 @@ def __init__(self, sut_node: NodeConfiguration):
super(ExecutionResult, self).__init__()
self.sut_node = sut_node
- def add_build_target(
- self, build_target: BuildTargetConfiguration
- ) -> BuildTargetResult:
+ def add_build_target(self, build_target: BuildTargetConfiguration) -> BuildTargetResult:
build_target_result = BuildTargetResult(build_target)
self._inner_results.append(build_target_result)
return build_target_result
diff --git a/dts/framework/test_suite.py b/dts/framework/test_suite.py
index 3b890c0451..4a7907ec33 100644
--- a/dts/framework/test_suite.py
+++ b/dts/framework/test_suite.py
@@ -102,9 +102,7 @@ def _process_links(self) -> None:
tg_port.peer,
tg_port.identifier,
):
- self._port_links.append(
- PortLink(sut_port=sut_port, tg_port=tg_port)
- )
+ self._port_links.append(PortLink(sut_port=sut_port, tg_port=tg_port))
def set_up_suite(self) -> None:
"""
@@ -151,9 +149,7 @@ def configure_testbed_ipv4(self, restore: bool = False) -> None:
def _configure_ipv4_forwarding(self, enable: bool) -> None:
self.sut_node.configure_ipv4_forwarding(enable)
- def send_packet_and_capture(
- self, packet: Packet, duration: float = 1
- ) -> list[Packet]:
+ def send_packet_and_capture(self, packet: Packet, duration: float = 1) -> list[Packet]:
"""
Send a packet through the appropriate interface and
receive on the appropriate interface.
@@ -202,21 +198,15 @@ def verify(self, condition: bool, failure_description: str) -> None:
self._fail_test_case_verify(failure_description)
def _fail_test_case_verify(self, failure_description: str) -> None:
- self._logger.debug(
- "A test case failed, showing the last 10 commands executed on SUT:"
- )
+ self._logger.debug("A test case failed, showing the last 10 commands executed on SUT:")
for command_res in self.sut_node.main_session.remote_session.history[-10:]:
self._logger.debug(command_res.command)
- self._logger.debug(
- "A test case failed, showing the last 10 commands executed on TG:"
- )
+ self._logger.debug("A test case failed, showing the last 10 commands executed on TG:")
for command_res in self.tg_node.main_session.remote_session.history[-10:]:
self._logger.debug(command_res.command)
raise TestCaseVerifyError(failure_description)
- def verify_packets(
- self, expected_packet: Packet, received_packets: list[Packet]
- ) -> None:
+ def verify_packets(self, expected_packet: Packet, received_packets: list[Packet]) -> None:
for received_packet in received_packets:
if self._compare_packets(expected_packet, received_packet):
break
@@ -225,17 +215,11 @@ def verify_packets(
f"The expected packet {get_packet_summaries(expected_packet)} "
f"not found among received {get_packet_summaries(received_packets)}"
)
- self._fail_test_case_verify(
- "An expected packet not found among received packets."
- )
+ self._fail_test_case_verify("An expected packet not found among received packets.")
- def _compare_packets(
- self, expected_packet: Packet, received_packet: Packet
- ) -> bool:
+ def _compare_packets(self, expected_packet: Packet, received_packet: Packet) -> bool:
self._logger.debug(
- "Comparing packets: \n"
- f"{expected_packet.summary()}\n"
- f"{received_packet.summary()}"
+ f"Comparing packets: \n{expected_packet.summary()}\n{received_packet.summary()}"
)
l3 = IP in expected_packet.layers()
@@ -262,14 +246,10 @@ def _compare_packets(
expected_payload = expected_payload.payload
if expected_payload:
- self._logger.debug(
- f"The expected packet did not contain {expected_payload}."
- )
+ self._logger.debug(f"The expected packet did not contain {expected_payload}.")
return False
if received_payload and received_payload.__class__ != Padding:
- self._logger.debug(
- "The received payload had extra layers which were not padding."
- )
+ self._logger.debug("The received payload had extra layers which were not padding.")
return False
return True
@@ -296,10 +276,7 @@ def _verify_l2_frame(self, received_packet: Ether, l3: bool) -> bool:
def _verify_l3_packet(self, received_packet: IP, expected_packet: IP) -> bool:
self._logger.debug("Looking at the IP layer.")
- if (
- received_packet.src != expected_packet.src
- or received_packet.dst != expected_packet.dst
- ):
+ if received_packet.src != expected_packet.src or received_packet.dst != expected_packet.dst:
return False
return True
@@ -373,9 +350,7 @@ def _get_test_cases(self, test_case_regex: str) -> list[MethodType]:
if self._should_be_executed(test_case_name, test_case_regex):
filtered_test_cases.append(test_case)
cases_str = ", ".join((x.__name__ for x in filtered_test_cases))
- self._logger.debug(
- f"Found test cases '{cases_str}' in {self.__class__.__name__}."
- )
+ self._logger.debug(f"Found test cases '{cases_str}' in {self.__class__.__name__}.")
return filtered_test_cases
def _should_be_executed(self, test_case_name: str, test_case_regex: str) -> bool:
@@ -445,9 +420,7 @@ def _execute_test_case(
self._logger.exception(f"Test case execution ERROR: {test_case_name}")
test_case_result.update(Result.ERROR, e)
except KeyboardInterrupt:
- self._logger.error(
- f"Test case execution INTERRUPTED by user: {test_case_name}"
- )
+ self._logger.error(f"Test case execution INTERRUPTED by user: {test_case_name}")
test_case_result.update(Result.SKIP)
raise KeyboardInterrupt("Stop DTS")
@@ -464,9 +437,7 @@ def is_test_suite(object) -> bool:
try:
testcase_module = importlib.import_module(testsuite_module_path)
except ModuleNotFoundError as e:
- raise ConfigurationError(
- f"Test suite '{testsuite_module_path}' not found."
- ) from e
+ raise ConfigurationError(f"Test suite '{testsuite_module_path}' not found.") from e
return [
test_suite_class
for _, test_suite_class in inspect.getmembers(testcase_module, is_test_suite)
diff --git a/dts/framework/testbed_model/capturing_traffic_generator.py b/dts/framework/testbed_model/capturing_traffic_generator.py
index ab98987f8e..e6512061d7 100644
--- a/dts/framework/testbed_model/capturing_traffic_generator.py
+++ b/dts/framework/testbed_model/capturing_traffic_generator.py
@@ -100,8 +100,7 @@ def send_packets_and_capture(
"""
self._logger.debug(get_packet_summaries(packets))
self._logger.debug(
- f"Sending packet on {send_port.logical_name}, "
- f"receiving on {receive_port.logical_name}."
+ f"Sending packet on {send_port.logical_name}, receiving on {receive_port.logical_name}."
)
received_packets = self._send_packets_and_capture(
packets,
@@ -110,9 +109,7 @@ def send_packets_and_capture(
duration,
)
- self._logger.debug(
- f"Received packets: {get_packet_summaries(received_packets)}"
- )
+ self._logger.debug(f"Received packets: {get_packet_summaries(received_packets)}")
self._write_capture_from_packets(capture_name, received_packets)
return received_packets
diff --git a/dts/framework/testbed_model/hw/cpu.py b/dts/framework/testbed_model/hw/cpu.py
index d1918a12dc..cbc5fe7fff 100644
--- a/dts/framework/testbed_model/hw/cpu.py
+++ b/dts/framework/testbed_model/hw/cpu.py
@@ -54,9 +54,7 @@ def __init__(self, lcore_list: list[int] | list[str] | list[LogicalCore] | str):
# the input lcores may not be sorted
self._lcore_list.sort()
- self._lcore_str = (
- f'{",".join(self._get_consecutive_lcores_range(self._lcore_list))}'
- )
+ self._lcore_str = f'{",".join(self._get_consecutive_lcores_range(self._lcore_list))}'
@property
def lcore_list(self) -> list[int]:
@@ -70,15 +68,11 @@ def _get_consecutive_lcores_range(self, lcore_ids_list: list[int]) -> list[str]:
segment.append(lcore_id)
else:
formatted_core_list.append(
- f"{segment[0]}-{segment[-1]}"
- if len(segment) > 1
- else f"{segment[0]}"
+ f"{segment[0]}-{segment[-1]}" if len(segment) > 1 else f"{segment[0]}"
)
current_core_index = lcore_ids_list.index(lcore_id)
formatted_core_list.extend(
- self._get_consecutive_lcores_range(
- lcore_ids_list[current_core_index:]
- )
+ self._get_consecutive_lcores_range(lcore_ids_list[current_core_index:])
)
segment.clear()
break
@@ -125,9 +119,7 @@ def __init__(
self._filter_specifier = filter_specifier
# sorting by core is needed in case hyperthreading is enabled
- self._lcores_to_filter = sorted(
- lcore_list, key=lambda x: x.core, reverse=not ascending
- )
+ self._lcores_to_filter = sorted(lcore_list, key=lambda x: x.core, reverse=not ascending)
self.filter()
@abstractmethod
@@ -220,9 +212,7 @@ def _filter_cores_from_socket(
else:
# we have enough lcores per this core
continue
- elif self._filter_specifier.cores_per_socket > len(
- lcore_count_per_core_map
- ):
+ elif self._filter_specifier.cores_per_socket > len(lcore_count_per_core_map):
# only add cores if we need more
lcore_count_per_core_map[lcore.core] = 1
filtered_lcores.append(lcore)
diff --git a/dts/framework/testbed_model/node.py b/dts/framework/testbed_model/node.py
index fc01e0bf8e..ef700d8114 100644
--- a/dts/framework/testbed_model/node.py
+++ b/dts/framework/testbed_model/node.py
@@ -103,18 +103,14 @@ def _tear_down_execution(self) -> None:
is not decorated so that the derived class doesn't have to use the decorator.
"""
- def set_up_build_target(
- self, build_target_config: BuildTargetConfiguration
- ) -> None:
+ def set_up_build_target(self, build_target_config: BuildTargetConfiguration) -> None:
"""
Perform the build target setup that will be done for each build target
tested on this node.
"""
self._set_up_build_target(build_target_config)
- def _set_up_build_target(
- self, build_target_config: BuildTargetConfiguration
- ) -> None:
+ def _set_up_build_target(self, build_target_config: BuildTargetConfiguration) -> None:
"""
This method exists to be optionally overwritten by derived classes and
is not decorated so that the derived class doesn't have to use the decorator.
diff --git a/dts/framework/testbed_model/scapy.py b/dts/framework/testbed_model/scapy.py
index af0d4dbb25..9083e92b3d 100644
--- a/dts/framework/testbed_model/scapy.py
+++ b/dts/framework/testbed_model/scapy.py
@@ -96,9 +96,7 @@ def scapy_send_packets_and_capture(
return [scapy_packet.build() for scapy_packet in sniffer.stop(join=True)]
-def scapy_send_packets(
- xmlrpc_packets: list[xmlrpc.client.Binary], send_iface: str
-) -> None:
+def scapy_send_packets(xmlrpc_packets: list[xmlrpc.client.Binary], send_iface: str) -> None:
"""RPC function to send packets.
The function is meant to be executed on the remote TG node.
@@ -197,9 +195,7 @@ class ScapyTrafficGenerator(CapturingTrafficGenerator):
def __init__(self, tg_node: TGNode, config: ScapyTrafficGeneratorConfig):
self._config = config
self._tg_node = tg_node
- self._logger = getLogger(
- f"{self._tg_node.name} {self._config.traffic_generator_type}"
- )
+ self._logger = getLogger(f"{self._tg_node.name} {self._config.traffic_generator_type}")
assert (
self._tg_node.config.os == OS.linux
@@ -218,9 +214,7 @@ def __init__(self, tg_node: TGNode, config: ScapyTrafficGeneratorConfig):
self._start_xmlrpc_server_in_remote_python(xmlrpc_server_listen_port)
# connect to the server
- server_url = (
- f"http://{self._tg_node.config.hostname}:{xmlrpc_server_listen_port}"
- )
+ server_url = f"http://{self._tg_node.config.hostname}:{xmlrpc_server_listen_port}"
self.rpc_server_proxy = xmlrpc.client.ServerProxy(
server_url, allow_none=True, verbose=SETTINGS.verbose
)
@@ -240,17 +234,14 @@ def _start_xmlrpc_server_in_remote_python(self, listen_port: int):
src = inspect.getsource(QuittableXMLRPCServer)
# Lines with only whitespace break the repl if in the middle of a function
# or class, so strip all lines containing only whitespace
- src = "\n".join(
- [line for line in src.splitlines() if not line.isspace() and line != ""]
- )
+ src = "\n".join([line for line in src.splitlines() if not line.isspace() and line != ""])
spacing = "\n" * 4
# execute it in the python terminal
self.session.send_command(spacing + src + spacing)
self.session.send_command(
- f"server = QuittableXMLRPCServer(('0.0.0.0', {listen_port}));"
- f"server.serve_forever()",
+ f"server = QuittableXMLRPCServer(('0.0.0.0', {listen_port}));server.serve_forever()",
"XMLRPC OK",
)
diff --git a/dts/framework/testbed_model/sut_node.py b/dts/framework/testbed_model/sut_node.py
index 202aebfd06..d5d8905be7 100644
--- a/dts/framework/testbed_model/sut_node.py
+++ b/dts/framework/testbed_model/sut_node.py
@@ -129,9 +129,7 @@ def remote_dpdk_build_dir(self) -> PurePath:
@property
def dpdk_version(self) -> str:
if self._dpdk_version is None:
- self._dpdk_version = self.main_session.get_dpdk_version(
- self._remote_dpdk_dir
- )
+ self._dpdk_version = self.main_session.get_dpdk_version(self._remote_dpdk_dir)
return self._dpdk_version
@property
@@ -149,8 +147,7 @@ def compiler_version(self) -> str:
)
else:
self._logger.warning(
- "Failed to get compiler version because"
- "_build_target_config is None."
+ "Failed to get compiler version because _build_target_config is None."
)
return ""
return self._compiler_version
@@ -163,9 +160,7 @@ def get_build_target_info(self) -> BuildTargetInfo:
def _guess_dpdk_remote_dir(self) -> PurePath:
return self.main_session.guess_dpdk_remote_dir(self._remote_tmp_dir)
- def _set_up_build_target(
- self, build_target_config: BuildTargetConfiguration
- ) -> None:
+ def _set_up_build_target(self, build_target_config: BuildTargetConfiguration) -> None:
"""
Setup DPDK on the SUT node.
"""
@@ -177,23 +172,18 @@ def _set_up_build_target(
self._copy_dpdk_tarball()
self._build_dpdk()
- def _configure_build_target(
- self, build_target_config: BuildTargetConfiguration
- ) -> None:
+ def _configure_build_target(self, build_target_config: BuildTargetConfiguration) -> None:
"""
Populate common environment variables and set build target config.
"""
self._env_vars = {}
self._build_target_config = build_target_config
- self._env_vars.update(
- self.main_session.get_dpdk_build_env_vars(build_target_config.arch)
- )
+ self._env_vars.update(self.main_session.get_dpdk_build_env_vars(build_target_config.arch))
self._env_vars["CC"] = build_target_config.compiler.name
if build_target_config.compiler_wrapper:
self._env_vars["CC"] = (
- f"'{build_target_config.compiler_wrapper} "
- f"{build_target_config.compiler.name}'"
- )
+ f"'{build_target_config.compiler_wrapper} {build_target_config.compiler.name}'"
+ ) # fmt: skip
@Node.skip_setup
def _copy_dpdk_tarball(self) -> None:
@@ -224,9 +214,7 @@ def _copy_dpdk_tarball(self) -> None:
self.main_session.remove_remote_dir(self._remote_dpdk_dir)
# then extract to remote path
- self.main_session.extract_remote_tarball(
- remote_tarball_path, self._remote_dpdk_dir
- )
+ self.main_session.extract_remote_tarball(remote_tarball_path, self._remote_dpdk_dir)
@Node.skip_setup
def _build_dpdk(self) -> None:
@@ -263,9 +251,7 @@ def build_dpdk_app(self, app_name: str, **meson_dpdk_args: str | bool) -> PurePa
)
if app_name == "all":
- return self.main_session.join_remote_path(
- self.remote_dpdk_build_dir, "examples"
- )
+ return self.main_session.join_remote_path(self.remote_dpdk_build_dir, "examples")
return self.main_session.join_remote_path(
self.remote_dpdk_build_dir, "examples", f"dpdk-{app_name}"
)
@@ -319,9 +305,7 @@ def create_eal_parameters(
'-c 0xf -a 0000:88:00.0 --file-prefix=dpdk_1112_20190809143420';
"""
- lcore_list = LogicalCoreList(
- self.filter_lcores(lcore_filter_specifier, ascending_cores)
- )
+ lcore_list = LogicalCoreList(self.filter_lcores(lcore_filter_specifier, ascending_cores))
if append_prefix_timestamp:
prefix = f"{prefix}_{self._dpdk_timestamp}"
@@ -386,6 +370,4 @@ def create_interactive_shell(
self.remote_dpdk_build_dir, shell_cls.path
)
- return super().create_interactive_shell(
- shell_cls, timeout, privileged, str(eal_parameters)
- )
+ return super().create_interactive_shell(shell_cls, timeout, privileged, str(eal_parameters))
diff --git a/dts/framework/testbed_model/tg_node.py b/dts/framework/testbed_model/tg_node.py
index 27025cfa31..79a55663b5 100644
--- a/dts/framework/testbed_model/tg_node.py
+++ b/dts/framework/testbed_model/tg_node.py
@@ -45,9 +45,7 @@ class TGNode(Node):
def __init__(self, node_config: TGNodeConfiguration):
super(TGNode, self).__init__(node_config)
- self.traffic_generator = create_traffic_generator(
- self, node_config.traffic_generator
- )
+ self.traffic_generator = create_traffic_generator(self, node_config.traffic_generator)
self._logger.info(f"Created node: {self.name}")
def send_packet_and_capture(
@@ -94,6 +92,5 @@ def create_traffic_generator(
return ScapyTrafficGenerator(tg_node, traffic_generator_config)
case _:
raise ConfigurationError(
- "Unknown traffic generator: "
- f"{traffic_generator_config.traffic_generator_type}"
+ f"Unknown traffic generator: {traffic_generator_config.traffic_generator_type}"
)
diff --git a/dts/framework/utils.py b/dts/framework/utils.py
index d27c2c5b5f..d098d364ff 100644
--- a/dts/framework/utils.py
+++ b/dts/framework/utils.py
@@ -19,9 +19,7 @@
class StrEnum(Enum):
@staticmethod
- def _generate_next_value_(
- name: str, start: int, count: int, last_values: object
- ) -> str:
+ def _generate_next_value_(name: str, start: int, count: int, last_values: object) -> str:
return name
def __str__(self) -> str:
@@ -32,9 +30,7 @@ def __str__(self) -> str:
def check_dts_python_version() -> None:
- if sys.version_info.major < 3 or (
- sys.version_info.major == 3 and sys.version_info.minor < 10
- ):
+ if sys.version_info.major < 3 or (sys.version_info.major == 3 and sys.version_info.minor < 10):
print(
RED(
(
@@ -60,9 +56,7 @@ def expand_range(range_str: str) -> list[int]:
range_boundaries = range_str.split("-")
# will throw an exception when items in range_boundaries can't be converted,
# serving as type check
- expanded_range.extend(
- range(int(range_boundaries[0]), int(range_boundaries[-1]) + 1)
- )
+ expanded_range.extend(range(int(range_boundaries[0]), int(range_boundaries[-1]) + 1))
return expanded_range
@@ -71,9 +65,7 @@ def get_packet_summaries(packets: list[Packet]):
if len(packets) == 1:
packet_summaries = packets[0].summary()
else:
- packet_summaries = json.dumps(
- list(map(lambda pkt: pkt.summary(), packets)), indent=4
- )
+ packet_summaries = json.dumps(list(map(lambda pkt: pkt.summary(), packets)), indent=4)
return f"Packet contents: \n{packet_summaries}"
@@ -94,9 +86,7 @@ class MesonArgs(object):
_default_library: str
def __init__(self, default_library: str | None = None, **dpdk_args: str | bool):
- self._default_library = (
- f"--default-library={default_library}" if default_library else ""
- )
+ self._default_library = f"--default-library={default_library}" if default_library else ""
self._dpdk_args = " ".join(
(
f"-D{dpdk_arg_name}={dpdk_arg_value}"
diff --git a/dts/tests/TestSuite_hello_world.py b/dts/tests/TestSuite_hello_world.py
index 7e3d95c0cf..768ba1cfa8 100644
--- a/dts/tests/TestSuite_hello_world.py
+++ b/dts/tests/TestSuite_hello_world.py
@@ -34,9 +34,7 @@ def test_hello_world_single_core(self) -> None:
# get the first usable core
lcore_amount = LogicalCoreCount(1, 1, 1)
lcores = LogicalCoreCountFilter(self.sut_node.lcores, lcore_amount).filter()
- eal_para = self.sut_node.create_eal_parameters(
- lcore_filter_specifier=lcore_amount
- )
+ eal_para = self.sut_node.create_eal_parameters(lcore_filter_specifier=lcore_amount)
result = self.sut_node.run_dpdk_app(self.app_helloworld_path, eal_para)
self.verify(
f"hello from core {int(lcores[0])}" in result.stdout,
diff --git a/dts/tests/TestSuite_smoke_tests.py b/dts/tests/TestSuite_smoke_tests.py
index 4a269df75b..670053c6a5 100644
--- a/dts/tests/TestSuite_smoke_tests.py
+++ b/dts/tests/TestSuite_smoke_tests.py
@@ -45,13 +45,10 @@ def test_driver_tests(self) -> None:
for dev in self.sut_node.virtual_devices:
vdev_args += f"--vdev {dev} "
vdev_args = vdev_args[:-1]
- driver_tests_command = (
- f"meson test -C {self.dpdk_build_dir_path} --suite driver-tests"
- )
+ driver_tests_command = f"meson test -C {self.dpdk_build_dir_path} --suite driver-tests"
if vdev_args:
self._logger.info(
- "Running driver tests with the following virtual "
- f"devices: {vdev_args}"
+ f"Running driver tests with the following virtual devices: {vdev_args}"
)
driver_tests_command += f' --test-args "{vdev_args}"'
@@ -67,9 +64,7 @@ def test_devices_listed_in_testpmd(self) -> None:
Test:
Uses testpmd driver to verify that devices have been found by testpmd.
"""
- testpmd_driver = self.sut_node.create_interactive_shell(
- TestPmdShell, privileged=True
- )
+ testpmd_driver = self.sut_node.create_interactive_shell(TestPmdShell, privileged=True)
dev_list = [str(x) for x in testpmd_driver.get_devices()]
for nic in self.nics_in_node:
self.verify(
--
2.34.1
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v4 1/2] doc: increase python max line length to 100
2023-10-13 7:58 ` [PATCH v4 1/2] doc: increase python max line length to 100 Juraj Linkeš
2023-10-13 7:58 ` [PATCH v4 2/2] dts: reformat to 100 line length Juraj Linkeš
@ 2023-10-13 16:09 ` Stephen Hemminger
2023-10-16 6:44 ` Juraj Linkeš
1 sibling, 1 reply; 36+ messages in thread
From: Stephen Hemminger @ 2023-10-13 16:09 UTC (permalink / raw)
To: Juraj Linkeš
Cc: thomas, Honnappa.Nagarahalli, bruce.richardson, jspewock, probb, dev
On Fri, 13 Oct 2023 09:58:04 +0200
Juraj Linkeš <juraj.linkes@pantheon.tech> wrote:
> Unify with C recommendations which allow line length of up to 100
> characters.
>
> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
> .editorconfig | 2 +-
> doc/doc_build/meson-private/meson.lock | 0
> doc/guides/contributing/coding_style.rst | 1 +
> dts/pyproject.toml | 4 ++--
> 4 files changed, 4 insertions(+), 3 deletions(-)
> create mode 100644 doc/doc_build/meson-private/meson.loc
Look like meson.lock snuck into this patchset.
Assume that was a mistake.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v4 1/2] doc: increase python max line length to 100
2023-10-13 16:09 ` [PATCH v4 1/2] doc: increase python max line length to 100 Stephen Hemminger
@ 2023-10-16 6:44 ` Juraj Linkeš
0 siblings, 0 replies; 36+ messages in thread
From: Juraj Linkeš @ 2023-10-16 6:44 UTC (permalink / raw)
To: Stephen Hemminger
Cc: thomas, Honnappa.Nagarahalli, bruce.richardson, jspewock, probb, dev
On Fri, Oct 13, 2023 at 6:09 PM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> On Fri, 13 Oct 2023 09:58:04 +0200
> Juraj Linkeš <juraj.linkes@pantheon.tech> wrote:
>
> > Unify with C recommendations which allow line length of up to 100
> > characters.
> >
> > Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> > ---
> > .editorconfig | 2 +-
> > doc/doc_build/meson-private/meson.lock | 0
> > doc/guides/contributing/coding_style.rst | 1 +
> > dts/pyproject.toml | 4 ++--
> > 4 files changed, 4 insertions(+), 3 deletions(-)
> > create mode 100644 doc/doc_build/meson-private/meson.loc
>
> Look like meson.lock snuck into this patchset.
> Assume that was a mistake.
My bad, let me send a fix.
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v5 1/2] doc: increase python max line length to 100
2023-10-13 7:58 ` [PATCH v4 2/2] dts: reformat to 100 line length Juraj Linkeš
@ 2023-10-16 6:45 ` Juraj Linkeš
2023-10-16 6:45 ` [PATCH v5 2/2] dts: reformat to 100 line length Juraj Linkeš
0 siblings, 1 reply; 36+ messages in thread
From: Juraj Linkeš @ 2023-10-16 6:45 UTC (permalink / raw)
To: thomas, Honnappa.Nagarahalli, bruce.richardson, jspewock, probb
Cc: dev, Juraj Linkeš
Unify with C recommendations which allow line length of up to 100
characters.
Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
.editorconfig | 2 +-
doc/guides/contributing/coding_style.rst | 1 +
dts/pyproject.toml | 4 ++--
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/.editorconfig b/.editorconfig
index ab41c95085..1e7d74213f 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -16,7 +16,7 @@ max_line_length = 100
[*.py]
indent_style = space
indent_size = 4
-max_line_length = 79
+max_line_length = 100
[meson.build]
indent_style = space
diff --git a/doc/guides/contributing/coding_style.rst b/doc/guides/contributing/coding_style.rst
index 648849899d..1ebc79ca3c 100644
--- a/doc/guides/contributing/coding_style.rst
+++ b/doc/guides/contributing/coding_style.rst
@@ -880,6 +880,7 @@ All Python code should be compliant with
`PEP8 (Style Guide for Python Code) <https://www.python.org/dev/peps/pep-0008/>`_.
The ``pep8`` tool can be used for testing compliance with the guidelines.
+Note that line lengths are acceptable up to 100 characters, which is in line with C recommendations.
Integrating with the Build System
---------------------------------
diff --git a/dts/pyproject.toml b/dts/pyproject.toml
index 6762edfa6b..980ac3c7db 100644
--- a/dts/pyproject.toml
+++ b/dts/pyproject.toml
@@ -41,7 +41,7 @@ build-backend = "poetry.core.masonry.api"
[tool.pylama]
linters = "mccabe,pycodestyle,pyflakes"
format = "pylint"
-max_line_length = 88 # https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length
+max_line_length = 100
[tool.mypy]
python_version = "3.10"
@@ -55,4 +55,4 @@ profile = "black"
[tool.black]
target-version = ['py310']
include = '\.pyi?$'
-line-length = 88 # https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length
+line-length = 100
--
2.34.1
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v5 2/2] dts: reformat to 100 line length
2023-10-16 6:45 ` [PATCH v5 1/2] doc: increase python max line length to 100 Juraj Linkeš
@ 2023-10-16 6:45 ` Juraj Linkeš
2023-11-20 12:36 ` [PATCH v6 1/2] doc: increase python max line length to 100 Juraj Linkeš
0 siblings, 1 reply; 36+ messages in thread
From: Juraj Linkeš @ 2023-10-16 6:45 UTC (permalink / raw)
To: thomas, Honnappa.Nagarahalli, bruce.richardson, jspewock, probb
Cc: dev, Juraj Linkeš
Reformat to 100 from the previous 88 to unify with C recommendations.
Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
Acked-by: Jeremy Spewock <jspewock@iol.unh.edu>
---
dts/framework/config/__init__.py | 20 ++-----
dts/framework/dts.py | 15 ++---
dts/framework/exception.py | 5 +-
dts/framework/remote_session/__init__.py | 4 +-
dts/framework/remote_session/linux_session.py | 39 ++++---------
dts/framework/remote_session/posix_session.py | 30 +++-------
.../remote/interactive_remote_session.py | 7 +--
.../remote/interactive_shell.py | 4 +-
.../remote_session/remote/remote_session.py | 8 +--
.../remote_session/remote/ssh_session.py | 16 ++----
.../remote_session/remote/testpmd_shell.py | 8 +--
dts/framework/settings.py | 15 ++---
dts/framework/test_result.py | 16 ++----
dts/framework/test_suite.py | 57 +++++--------------
.../capturing_traffic_generator.py | 7 +--
dts/framework/testbed_model/hw/cpu.py | 20 ++-----
dts/framework/testbed_model/node.py | 8 +--
dts/framework/testbed_model/scapy.py | 19 ++-----
dts/framework/testbed_model/sut_node.py | 40 ++++---------
dts/framework/testbed_model/tg_node.py | 7 +--
dts/framework/utils.py | 20 ++-----
dts/tests/TestSuite_hello_world.py | 4 +-
dts/tests/TestSuite_smoke_tests.py | 11 +---
23 files changed, 99 insertions(+), 281 deletions(-)
diff --git a/dts/framework/config/__init__.py b/dts/framework/config/__init__.py
index cb7e00ba34..9b32cf0532 100644
--- a/dts/framework/config/__init__.py
+++ b/dts/framework/config/__init__.py
@@ -140,9 +140,7 @@ def from_dict(d: dict) -> Union["SutNodeConfiguration", "TGNodeConfiguration"]:
if "traffic_generator" in d:
return TGNodeConfiguration(
- traffic_generator=TrafficGeneratorConfig.from_dict(
- d["traffic_generator"]
- ),
+ traffic_generator=TrafficGeneratorConfig.from_dict(d["traffic_generator"]),
**common_config,
)
else:
@@ -249,9 +247,7 @@ def from_dict(
build_targets: list[BuildTargetConfiguration] = list(
map(BuildTargetConfiguration.from_dict, d["build_targets"])
)
- test_suites: list[TestSuiteConfig] = list(
- map(TestSuiteConfig.from_dict, d["test_suites"])
- )
+ test_suites: list[TestSuiteConfig] = list(map(TestSuiteConfig.from_dict, d["test_suites"]))
sut_name = d["system_under_test_node"]["node_name"]
skip_smoke_tests = d.get("skip_smoke_tests", False)
assert sut_name in node_map, f"Unknown SUT {sut_name} in execution {d}"
@@ -268,9 +264,7 @@ def from_dict(
), f"Invalid TG configuration {traffic_generator_node}"
vdevs = (
- d["system_under_test_node"]["vdevs"]
- if "vdevs" in d["system_under_test_node"]
- else []
+ d["system_under_test_node"]["vdevs"] if "vdevs" in d["system_under_test_node"] else []
)
return ExecutionConfiguration(
build_targets=build_targets,
@@ -299,9 +293,7 @@ def from_dict(d: dict) -> "Configuration":
assert len(nodes) == len(node_map), "Duplicate node names are not allowed"
executions: list[ExecutionConfiguration] = list(
- map(
- ExecutionConfiguration.from_dict, d["executions"], [node_map for _ in d]
- )
+ map(ExecutionConfiguration.from_dict, d["executions"], [node_map for _ in d])
)
return Configuration(executions=executions)
@@ -315,9 +307,7 @@ def load_config() -> Configuration:
with open(SETTINGS.config_file_path, "r") as f:
config_data = yaml.safe_load(f)
- schema_path = os.path.join(
- pathlib.Path(__file__).parent.resolve(), "conf_yaml_schema.json"
- )
+ schema_path = os.path.join(pathlib.Path(__file__).parent.resolve(), "conf_yaml_schema.json")
with open(schema_path, "r") as f:
schema = json.load(f)
diff --git a/dts/framework/dts.py b/dts/framework/dts.py
index f773f0c38d..25d6942d81 100644
--- a/dts/framework/dts.py
+++ b/dts/framework/dts.py
@@ -92,9 +92,7 @@ def _run_execution(
Run the given execution. This involves running the execution setup as well as
running all build targets in the given execution.
"""
- dts_logger.info(
- f"Running execution with SUT '{execution.system_under_test_node.name}'."
- )
+ dts_logger.info(f"Running execution with SUT '{execution.system_under_test_node.name}'.")
execution_result = result.add_execution(sut_node.config)
execution_result.add_sut_info(sut_node.node_info)
@@ -107,9 +105,7 @@ def _run_execution(
else:
for build_target in execution.build_targets:
- _run_build_target(
- sut_node, tg_node, build_target, execution, execution_result
- )
+ _run_build_target(sut_node, tg_node, build_target, execution, execution_result)
finally:
try:
@@ -170,13 +166,10 @@ def _run_all_suites(
execution.test_suites[:0] = [TestSuiteConfig.from_dict("smoke_tests")]
for test_suite_config in execution.test_suites:
try:
- _run_single_suite(
- sut_node, tg_node, execution, build_target_result, test_suite_config
- )
+ _run_single_suite(sut_node, tg_node, execution, build_target_result, test_suite_config)
except BlockingTestSuiteError as e:
dts_logger.exception(
- f"An error occurred within {test_suite_config.test_suite}. "
- "Skipping build target..."
+ f"An error occurred within {test_suite_config.test_suite}. Skipping build target."
)
result.add_error(e)
end_build_target = True
diff --git a/dts/framework/exception.py b/dts/framework/exception.py
index 001a5a5496..b362e42924 100644
--- a/dts/framework/exception.py
+++ b/dts/framework/exception.py
@@ -116,10 +116,7 @@ def __init__(self, command: str, command_return_code: int):
self.command_return_code = command_return_code
def __str__(self) -> str:
- return (
- f"Command {self.command} returned a non-zero exit code: "
- f"{self.command_return_code}"
- )
+ return f"Command {self.command} returned a non-zero exit code: {self.command_return_code}"
class RemoteDirectoryExistsError(DTSError):
diff --git a/dts/framework/remote_session/__init__.py b/dts/framework/remote_session/__init__.py
index 00b6d1f03a..6124417bd7 100644
--- a/dts/framework/remote_session/__init__.py
+++ b/dts/framework/remote_session/__init__.py
@@ -30,9 +30,7 @@
)
-def create_session(
- node_config: NodeConfiguration, name: str, logger: DTSLOG
-) -> OSSession:
+def create_session(node_config: NodeConfiguration, name: str, logger: DTSLOG) -> OSSession:
match node_config.os:
case OS.linux:
return LinuxSession(node_config, name, logger)
diff --git a/dts/framework/remote_session/linux_session.py b/dts/framework/remote_session/linux_session.py
index a3f1a6bf3b..fd877fbfae 100644
--- a/dts/framework/remote_session/linux_session.py
+++ b/dts/framework/remote_session/linux_session.py
@@ -82,9 +82,7 @@ def setup_hugepages(self, hugepage_amount: int, force_first_numa: bool) -> None:
self._mount_huge_pages()
def _get_hugepage_size(self) -> int:
- hugepage_size = self.send_command(
- "awk '/Hugepagesize/ {print $2}' /proc/meminfo"
- ).stdout
+ hugepage_size = self.send_command("awk '/Hugepagesize/ {print $2}' /proc/meminfo").stdout
return int(hugepage_size)
def _get_hugepages_total(self) -> int:
@@ -120,13 +118,9 @@ def _supports_numa(self) -> bool:
# there's no reason to do any numa specific configuration)
return len(self._numa_nodes) > 1
- def _configure_huge_pages(
- self, amount: int, size: int, force_first_numa: bool
- ) -> None:
+ def _configure_huge_pages(self, amount: int, size: int, force_first_numa: bool) -> None:
self._logger.info("Configuring Hugepages.")
- hugepage_config_path = (
- f"/sys/kernel/mm/hugepages/hugepages-{size}kB/nr_hugepages"
- )
+ hugepage_config_path = f"/sys/kernel/mm/hugepages/hugepages-{size}kB/nr_hugepages"
if force_first_numa and self._supports_numa():
# clear non-numa hugepages
self.send_command(f"echo 0 | tee {hugepage_config_path}", privileged=True)
@@ -135,24 +129,18 @@ def _configure_huge_pages(
f"/hugepages-{size}kB/nr_hugepages"
)
- self.send_command(
- f"echo {amount} | tee {hugepage_config_path}", privileged=True
- )
+ self.send_command(f"echo {amount} | tee {hugepage_config_path}", privileged=True)
def update_ports(self, ports: list[Port]) -> None:
self._logger.debug("Gathering port info.")
for port in ports:
- assert (
- port.node == self.name
- ), "Attempted to gather port info on the wrong node"
+ assert port.node == self.name, "Attempted to gather port info on the wrong node"
port_info_list = self._get_lshw_info()
for port in ports:
for port_info in port_info_list:
if f"pci@{port.pci}" == port_info.get("businfo"):
- self._update_port_attr(
- port, port_info.get("logicalname"), "logical_name"
- )
+ self._update_port_attr(port, port_info.get("logicalname"), "logical_name")
self._update_port_attr(port, port_info.get("serial"), "mac_address")
port_info_list.remove(port_info)
break
@@ -163,25 +151,18 @@ def _get_lshw_info(self) -> list[LshwOutput]:
output = self.send_command("lshw -quiet -json -C network", verify=True)
return json.loads(output.stdout)
- def _update_port_attr(
- self, port: Port, attr_value: str | None, attr_name: str
- ) -> None:
+ def _update_port_attr(self, port: Port, attr_value: str | None, attr_name: str) -> None:
if attr_value:
setattr(port, attr_name, attr_value)
- self._logger.debug(
- f"Found '{attr_name}' of port {port.pci}: '{attr_value}'."
- )
+ self._logger.debug(f"Found '{attr_name}' of port {port.pci}: '{attr_value}'.")
else:
self._logger.warning(
- f"Attempted to get '{attr_name}' of port {port.pci}, "
- f"but it doesn't exist."
+ f"Attempted to get '{attr_name}' of port {port.pci}, but it doesn't exist."
)
def configure_port_state(self, port: Port, enable: bool) -> None:
state = "up" if enable else "down"
- self.send_command(
- f"ip link set dev {port.logical_name} {state}", privileged=True
- )
+ self.send_command(f"ip link set dev {port.logical_name} {state}", privileged=True)
def configure_port_ip_address(
self,
diff --git a/dts/framework/remote_session/posix_session.py b/dts/framework/remote_session/posix_session.py
index 5da0516e05..a29e2e8280 100644
--- a/dts/framework/remote_session/posix_session.py
+++ b/dts/framework/remote_session/posix_session.py
@@ -94,8 +94,7 @@ def extract_remote_tarball(
expected_dir: str | PurePath | None = None,
) -> None:
self.send_command(
- f"tar xfm {remote_tarball_path} "
- f"-C {PurePosixPath(remote_tarball_path).parent}",
+ f"tar xfm {remote_tarball_path} -C {PurePosixPath(remote_tarball_path).parent}",
60,
)
if expected_dir:
@@ -125,8 +124,7 @@ def build_dpdk(
self._logger.info("Configuring DPDK build from scratch.")
self.remove_remote_dir(remote_dpdk_build_dir)
self.send_command(
- f"meson setup "
- f"{meson_args} {remote_dpdk_dir} {remote_dpdk_build_dir}",
+ f"meson setup {meson_args} {remote_dpdk_dir} {remote_dpdk_build_dir}",
timeout,
verify=True,
env=env_vars,
@@ -140,9 +138,7 @@ def build_dpdk(
raise DPDKBuildError(f"DPDK build failed when doing '{e.command}'.")
def get_dpdk_version(self, build_dir: str | PurePath) -> str:
- out = self.send_command(
- f"cat {self.join_remote_path(build_dir, 'VERSION')}", verify=True
- )
+ out = self.send_command(f"cat {self.join_remote_path(build_dir, 'VERSION')}", verify=True)
return out.stdout
def kill_cleanup_dpdk_apps(self, dpdk_prefix_list: Iterable[str]) -> None:
@@ -156,9 +152,7 @@ def kill_cleanup_dpdk_apps(self, dpdk_prefix_list: Iterable[str]) -> None:
self._check_dpdk_hugepages(dpdk_runtime_dirs)
self._remove_dpdk_runtime_dirs(dpdk_runtime_dirs)
- def _get_dpdk_runtime_dirs(
- self, dpdk_prefix_list: Iterable[str]
- ) -> list[PurePosixPath]:
+ def _get_dpdk_runtime_dirs(self, dpdk_prefix_list: Iterable[str]) -> list[PurePosixPath]:
prefix = PurePosixPath("/var", "run", "dpdk")
if not dpdk_prefix_list:
remote_prefixes = self._list_remote_dirs(prefix)
@@ -174,9 +168,7 @@ def _list_remote_dirs(self, remote_path: str | PurePath) -> list[str] | None:
Return a list of directories of the remote_dir.
If remote_path doesn't exist, return None.
"""
- out = self.send_command(
- f"ls -l {remote_path} | awk '/^d/ {{print $NF}}'"
- ).stdout
+ out = self.send_command(f"ls -l {remote_path} | awk '/^d/ {{print $NF}}'").stdout
if "No such file or directory" in out:
return None
else:
@@ -200,9 +192,7 @@ def _remote_files_exists(self, remote_path: PurePath) -> bool:
result = self.send_command(f"test -e {remote_path}")
return not result.return_code
- def _check_dpdk_hugepages(
- self, dpdk_runtime_dirs: Iterable[str | PurePath]
- ) -> None:
+ def _check_dpdk_hugepages(self, dpdk_runtime_dirs: Iterable[str | PurePath]) -> None:
for dpdk_runtime_dir in dpdk_runtime_dirs:
hugepage_info = PurePosixPath(dpdk_runtime_dir, "hugepage_info")
if self._remote_files_exists(hugepage_info):
@@ -213,9 +203,7 @@ def _check_dpdk_hugepages(
self._logger.warning(out)
self._logger.warning("*******************************************")
- def _remove_dpdk_runtime_dirs(
- self, dpdk_runtime_dirs: Iterable[str | PurePath]
- ) -> None:
+ def _remove_dpdk_runtime_dirs(self, dpdk_runtime_dirs: Iterable[str | PurePath]) -> None:
for dpdk_runtime_dir in dpdk_runtime_dirs:
self.remove_remote_dir(dpdk_runtime_dir)
@@ -245,6 +233,4 @@ def get_node_info(self) -> NodeInfo:
SETTINGS.timeout,
).stdout.split("\n")
kernel_version = self.send_command("uname -r", SETTINGS.timeout).stdout
- return NodeInfo(
- os_release_info[0].strip(), os_release_info[1].strip(), kernel_version
- )
+ return NodeInfo(os_release_info[0].strip(), os_release_info[1].strip(), kernel_version)
diff --git a/dts/framework/remote_session/remote/interactive_remote_session.py b/dts/framework/remote_session/remote/interactive_remote_session.py
index 9085a668e8..098ded1bb0 100644
--- a/dts/framework/remote_session/remote/interactive_remote_session.py
+++ b/dts/framework/remote_session/remote/interactive_remote_session.py
@@ -73,9 +73,7 @@ def __init__(self, node_config: NodeConfiguration, _logger: DTSLOG) -> None:
f"Initializing interactive connection for {self.username}@{self.hostname}"
)
self._connect()
- self._logger.info(
- f"Interactive connection successful for {self.username}@{self.hostname}"
- )
+ self._logger.info(f"Interactive connection successful for {self.username}@{self.hostname}")
def _connect(self) -> None:
"""Establish a connection to the node.
@@ -108,8 +106,7 @@ def _connect(self) -> None:
self._logger.debug(traceback.format_exc())
self._logger.warning(e)
self._logger.info(
- "Retrying interactive session connection: "
- f"retry number {retry_attempt +1}"
+ f"Retrying interactive session connection: retry number {retry_attempt +1}"
)
else:
break
diff --git a/dts/framework/remote_session/remote/interactive_shell.py b/dts/framework/remote_session/remote/interactive_shell.py
index c24376b2a8..4db19fb9b3 100644
--- a/dts/framework/remote_session/remote/interactive_shell.py
+++ b/dts/framework/remote_session/remote/interactive_shell.py
@@ -85,9 +85,7 @@ def __init__(
self._app_args = app_args
self._start_application(get_privileged_command)
- def _start_application(
- self, get_privileged_command: Callable[[str], str] | None
- ) -> None:
+ def _start_application(self, get_privileged_command: Callable[[str], str] | None) -> None:
"""Starts a new interactive application based on the path to the app.
This method is often overridden by subclasses as their process for
diff --git a/dts/framework/remote_session/remote/remote_session.py b/dts/framework/remote_session/remote/remote_session.py
index 0647d93de4..719f7d1ef7 100644
--- a/dts/framework/remote_session/remote/remote_session.py
+++ b/dts/framework/remote_session/remote/remote_session.py
@@ -96,9 +96,7 @@ def send_command(
If verify is True, check the return code of the executed command
and raise a RemoteCommandExecutionError if the command failed.
"""
- self._logger.info(
- f"Sending: '{command}'" + (f" with env vars: '{env}'" if env else "")
- )
+ self._logger.info(f"Sending: '{command}'" + (f" with env vars: '{env}'" if env else ""))
result = self._send_command(command, timeout, env)
if verify and result.return_code:
self._logger.debug(
@@ -112,9 +110,7 @@ def send_command(
return result
@abstractmethod
- def _send_command(
- self, command: str, timeout: float, env: dict | None
- ) -> CommandResult:
+ def _send_command(self, command: str, timeout: float, env: dict | None) -> CommandResult:
"""
Use the underlying protocol to execute the command using optional env vars
and return CommandResult.
diff --git a/dts/framework/remote_session/remote/ssh_session.py b/dts/framework/remote_session/remote/ssh_session.py
index 8d127f1601..1a7ee649ab 100644
--- a/dts/framework/remote_session/remote/ssh_session.py
+++ b/dts/framework/remote_session/remote/ssh_session.py
@@ -80,9 +80,7 @@ def _connect(self) -> None:
if error not in errors:
errors.append(error)
- self._logger.info(
- f"Retrying connection: retry number {retry_attempt + 1}."
- )
+ self._logger.info(f"Retrying connection: retry number {retry_attempt + 1}.")
else:
break
@@ -92,9 +90,7 @@ def _connect(self) -> None:
def is_alive(self) -> bool:
return self.session.is_connected
- def _send_command(
- self, command: str, timeout: float, env: dict | None
- ) -> CommandResult:
+ def _send_command(self, command: str, timeout: float, env: dict | None) -> CommandResult:
"""Send a command and return the result of the execution.
Args:
@@ -107,9 +103,7 @@ def _send_command(
SSHTimeoutError: The command execution timed out.
"""
try:
- output = self.session.run(
- command, env=env, warn=True, hide=True, timeout=timeout
- )
+ output = self.session.run(command, env=env, warn=True, hide=True, timeout=timeout)
except (UnexpectedExit, ThreadException) as e:
self._logger.exception(e)
@@ -119,9 +113,7 @@ def _send_command(
self._logger.exception(e)
raise SSHTimeoutError(command, e.result.stderr) from e
- return CommandResult(
- self.name, command, output.stdout, output.stderr, output.return_code
- )
+ return CommandResult(self.name, command, output.stdout, output.stderr, output.return_code)
def copy_from(
self,
diff --git a/dts/framework/remote_session/remote/testpmd_shell.py b/dts/framework/remote_session/remote/testpmd_shell.py
index 1455b5a199..08ac311016 100644
--- a/dts/framework/remote_session/remote/testpmd_shell.py
+++ b/dts/framework/remote_session/remote/testpmd_shell.py
@@ -21,13 +21,9 @@ class TestPmdShell(InteractiveShell):
path: PurePath = PurePath("app", "dpdk-testpmd")
dpdk_app: bool = True
_default_prompt: str = "testpmd>"
- _command_extra_chars: str = (
- "\n" # We want to append an extra newline to every command
- )
+ _command_extra_chars: str = "\n" # We want to append an extra newline to every command
- def _start_application(
- self, get_privileged_command: Callable[[str], str] | None
- ) -> None:
+ def _start_application(self, get_privileged_command: Callable[[str], str] | None) -> None:
"""See "_start_application" in InteractiveShell."""
self._app_args += " -- -i"
super()._start_application(get_privileged_command)
diff --git a/dts/framework/settings.py b/dts/framework/settings.py
index cfa39d011b..974793a11a 100644
--- a/dts/framework/settings.py
+++ b/dts/framework/settings.py
@@ -72,9 +72,8 @@ class _Settings:
def _get_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(
- description="Run DPDK test suites. All options may be specified with "
- "the environment variables provided in brackets. "
- "Command line arguments have higher priority.",
+ description="Run DPDK test suites. All options may be specified with the environment "
+ "variables provided in brackets. Command line arguments have higher priority.",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
@@ -82,8 +81,7 @@ def _get_parser() -> argparse.ArgumentParser:
"--config-file",
action=_env_arg("DTS_CFG_FILE"),
default="conf.yaml",
- help="[DTS_CFG_FILE] configuration file that describes the test cases, SUTs "
- "and targets.",
+ help="[DTS_CFG_FILE] configuration file that describes the test cases, SUTs and targets.",
)
parser.add_argument(
@@ -100,8 +98,7 @@ def _get_parser() -> argparse.ArgumentParser:
action=_env_arg("DTS_TIMEOUT"),
default=15,
type=float,
- help="[DTS_TIMEOUT] The default timeout for all DTS operations except for "
- "compiling DPDK.",
+ help="[DTS_TIMEOUT] The default timeout for all DTS operations except for compiling DPDK.",
)
parser.add_argument(
@@ -170,9 +167,7 @@ def _get_settings() -> _Settings:
timeout=parsed_args.timeout,
verbose=(parsed_args.verbose == "Y"),
skip_setup=(parsed_args.skip_setup == "Y"),
- dpdk_tarball_path=Path(
- DPDKGitTarball(parsed_args.tarball, parsed_args.output_dir)
- )
+ dpdk_tarball_path=Path(DPDKGitTarball(parsed_args.tarball, parsed_args.output_dir))
if not os.path.exists(parsed_args.tarball)
else Path(parsed_args.tarball),
compile_timeout=parsed_args.compile_timeout,
diff --git a/dts/framework/test_result.py b/dts/framework/test_result.py
index f0fbe80f6f..4c2e7e2418 100644
--- a/dts/framework/test_result.py
+++ b/dts/framework/test_result.py
@@ -83,9 +83,7 @@ def __iadd__(self, other: Result) -> "Statistics":
"""
self[other.name] += 1
self["PASS RATE"] = (
- float(self[Result.PASS.name])
- * 100
- / sum(self[result.name] for result in Result)
+ float(self[Result.PASS.name]) * 100 / sum(self[result.name] for result in Result)
)
return self
@@ -135,9 +133,7 @@ def _get_setup_teardown_errors(self) -> list[Exception]:
def _get_inner_errors(self) -> list[Exception]:
return [
- error
- for inner_result in self._inner_results
- for error in inner_result.get_errors()
+ error for inner_result in self._inner_results for error in inner_result.get_errors()
]
def get_errors(self) -> list[Exception]:
@@ -174,9 +170,7 @@ def add_stats(self, statistics: Statistics) -> None:
statistics += self.result
def __bool__(self) -> bool:
- return (
- bool(self.setup_result) and bool(self.teardown_result) and bool(self.result)
- )
+ return bool(self.setup_result) and bool(self.teardown_result) and bool(self.result)
class TestSuiteResult(BaseResult):
@@ -247,9 +241,7 @@ def __init__(self, sut_node: NodeConfiguration):
super(ExecutionResult, self).__init__()
self.sut_node = sut_node
- def add_build_target(
- self, build_target: BuildTargetConfiguration
- ) -> BuildTargetResult:
+ def add_build_target(self, build_target: BuildTargetConfiguration) -> BuildTargetResult:
build_target_result = BuildTargetResult(build_target)
self._inner_results.append(build_target_result)
return build_target_result
diff --git a/dts/framework/test_suite.py b/dts/framework/test_suite.py
index 3b890c0451..4a7907ec33 100644
--- a/dts/framework/test_suite.py
+++ b/dts/framework/test_suite.py
@@ -102,9 +102,7 @@ def _process_links(self) -> None:
tg_port.peer,
tg_port.identifier,
):
- self._port_links.append(
- PortLink(sut_port=sut_port, tg_port=tg_port)
- )
+ self._port_links.append(PortLink(sut_port=sut_port, tg_port=tg_port))
def set_up_suite(self) -> None:
"""
@@ -151,9 +149,7 @@ def configure_testbed_ipv4(self, restore: bool = False) -> None:
def _configure_ipv4_forwarding(self, enable: bool) -> None:
self.sut_node.configure_ipv4_forwarding(enable)
- def send_packet_and_capture(
- self, packet: Packet, duration: float = 1
- ) -> list[Packet]:
+ def send_packet_and_capture(self, packet: Packet, duration: float = 1) -> list[Packet]:
"""
Send a packet through the appropriate interface and
receive on the appropriate interface.
@@ -202,21 +198,15 @@ def verify(self, condition: bool, failure_description: str) -> None:
self._fail_test_case_verify(failure_description)
def _fail_test_case_verify(self, failure_description: str) -> None:
- self._logger.debug(
- "A test case failed, showing the last 10 commands executed on SUT:"
- )
+ self._logger.debug("A test case failed, showing the last 10 commands executed on SUT:")
for command_res in self.sut_node.main_session.remote_session.history[-10:]:
self._logger.debug(command_res.command)
- self._logger.debug(
- "A test case failed, showing the last 10 commands executed on TG:"
- )
+ self._logger.debug("A test case failed, showing the last 10 commands executed on TG:")
for command_res in self.tg_node.main_session.remote_session.history[-10:]:
self._logger.debug(command_res.command)
raise TestCaseVerifyError(failure_description)
- def verify_packets(
- self, expected_packet: Packet, received_packets: list[Packet]
- ) -> None:
+ def verify_packets(self, expected_packet: Packet, received_packets: list[Packet]) -> None:
for received_packet in received_packets:
if self._compare_packets(expected_packet, received_packet):
break
@@ -225,17 +215,11 @@ def verify_packets(
f"The expected packet {get_packet_summaries(expected_packet)} "
f"not found among received {get_packet_summaries(received_packets)}"
)
- self._fail_test_case_verify(
- "An expected packet not found among received packets."
- )
+ self._fail_test_case_verify("An expected packet not found among received packets.")
- def _compare_packets(
- self, expected_packet: Packet, received_packet: Packet
- ) -> bool:
+ def _compare_packets(self, expected_packet: Packet, received_packet: Packet) -> bool:
self._logger.debug(
- "Comparing packets: \n"
- f"{expected_packet.summary()}\n"
- f"{received_packet.summary()}"
+ f"Comparing packets: \n{expected_packet.summary()}\n{received_packet.summary()}"
)
l3 = IP in expected_packet.layers()
@@ -262,14 +246,10 @@ def _compare_packets(
expected_payload = expected_payload.payload
if expected_payload:
- self._logger.debug(
- f"The expected packet did not contain {expected_payload}."
- )
+ self._logger.debug(f"The expected packet did not contain {expected_payload}.")
return False
if received_payload and received_payload.__class__ != Padding:
- self._logger.debug(
- "The received payload had extra layers which were not padding."
- )
+ self._logger.debug("The received payload had extra layers which were not padding.")
return False
return True
@@ -296,10 +276,7 @@ def _verify_l2_frame(self, received_packet: Ether, l3: bool) -> bool:
def _verify_l3_packet(self, received_packet: IP, expected_packet: IP) -> bool:
self._logger.debug("Looking at the IP layer.")
- if (
- received_packet.src != expected_packet.src
- or received_packet.dst != expected_packet.dst
- ):
+ if received_packet.src != expected_packet.src or received_packet.dst != expected_packet.dst:
return False
return True
@@ -373,9 +350,7 @@ def _get_test_cases(self, test_case_regex: str) -> list[MethodType]:
if self._should_be_executed(test_case_name, test_case_regex):
filtered_test_cases.append(test_case)
cases_str = ", ".join((x.__name__ for x in filtered_test_cases))
- self._logger.debug(
- f"Found test cases '{cases_str}' in {self.__class__.__name__}."
- )
+ self._logger.debug(f"Found test cases '{cases_str}' in {self.__class__.__name__}.")
return filtered_test_cases
def _should_be_executed(self, test_case_name: str, test_case_regex: str) -> bool:
@@ -445,9 +420,7 @@ def _execute_test_case(
self._logger.exception(f"Test case execution ERROR: {test_case_name}")
test_case_result.update(Result.ERROR, e)
except KeyboardInterrupt:
- self._logger.error(
- f"Test case execution INTERRUPTED by user: {test_case_name}"
- )
+ self._logger.error(f"Test case execution INTERRUPTED by user: {test_case_name}")
test_case_result.update(Result.SKIP)
raise KeyboardInterrupt("Stop DTS")
@@ -464,9 +437,7 @@ def is_test_suite(object) -> bool:
try:
testcase_module = importlib.import_module(testsuite_module_path)
except ModuleNotFoundError as e:
- raise ConfigurationError(
- f"Test suite '{testsuite_module_path}' not found."
- ) from e
+ raise ConfigurationError(f"Test suite '{testsuite_module_path}' not found.") from e
return [
test_suite_class
for _, test_suite_class in inspect.getmembers(testcase_module, is_test_suite)
diff --git a/dts/framework/testbed_model/capturing_traffic_generator.py b/dts/framework/testbed_model/capturing_traffic_generator.py
index ab98987f8e..e6512061d7 100644
--- a/dts/framework/testbed_model/capturing_traffic_generator.py
+++ b/dts/framework/testbed_model/capturing_traffic_generator.py
@@ -100,8 +100,7 @@ def send_packets_and_capture(
"""
self._logger.debug(get_packet_summaries(packets))
self._logger.debug(
- f"Sending packet on {send_port.logical_name}, "
- f"receiving on {receive_port.logical_name}."
+ f"Sending packet on {send_port.logical_name}, receiving on {receive_port.logical_name}."
)
received_packets = self._send_packets_and_capture(
packets,
@@ -110,9 +109,7 @@ def send_packets_and_capture(
duration,
)
- self._logger.debug(
- f"Received packets: {get_packet_summaries(received_packets)}"
- )
+ self._logger.debug(f"Received packets: {get_packet_summaries(received_packets)}")
self._write_capture_from_packets(capture_name, received_packets)
return received_packets
diff --git a/dts/framework/testbed_model/hw/cpu.py b/dts/framework/testbed_model/hw/cpu.py
index d1918a12dc..cbc5fe7fff 100644
--- a/dts/framework/testbed_model/hw/cpu.py
+++ b/dts/framework/testbed_model/hw/cpu.py
@@ -54,9 +54,7 @@ def __init__(self, lcore_list: list[int] | list[str] | list[LogicalCore] | str):
# the input lcores may not be sorted
self._lcore_list.sort()
- self._lcore_str = (
- f'{",".join(self._get_consecutive_lcores_range(self._lcore_list))}'
- )
+ self._lcore_str = f'{",".join(self._get_consecutive_lcores_range(self._lcore_list))}'
@property
def lcore_list(self) -> list[int]:
@@ -70,15 +68,11 @@ def _get_consecutive_lcores_range(self, lcore_ids_list: list[int]) -> list[str]:
segment.append(lcore_id)
else:
formatted_core_list.append(
- f"{segment[0]}-{segment[-1]}"
- if len(segment) > 1
- else f"{segment[0]}"
+ f"{segment[0]}-{segment[-1]}" if len(segment) > 1 else f"{segment[0]}"
)
current_core_index = lcore_ids_list.index(lcore_id)
formatted_core_list.extend(
- self._get_consecutive_lcores_range(
- lcore_ids_list[current_core_index:]
- )
+ self._get_consecutive_lcores_range(lcore_ids_list[current_core_index:])
)
segment.clear()
break
@@ -125,9 +119,7 @@ def __init__(
self._filter_specifier = filter_specifier
# sorting by core is needed in case hyperthreading is enabled
- self._lcores_to_filter = sorted(
- lcore_list, key=lambda x: x.core, reverse=not ascending
- )
+ self._lcores_to_filter = sorted(lcore_list, key=lambda x: x.core, reverse=not ascending)
self.filter()
@abstractmethod
@@ -220,9 +212,7 @@ def _filter_cores_from_socket(
else:
# we have enough lcores per this core
continue
- elif self._filter_specifier.cores_per_socket > len(
- lcore_count_per_core_map
- ):
+ elif self._filter_specifier.cores_per_socket > len(lcore_count_per_core_map):
# only add cores if we need more
lcore_count_per_core_map[lcore.core] = 1
filtered_lcores.append(lcore)
diff --git a/dts/framework/testbed_model/node.py b/dts/framework/testbed_model/node.py
index fc01e0bf8e..ef700d8114 100644
--- a/dts/framework/testbed_model/node.py
+++ b/dts/framework/testbed_model/node.py
@@ -103,18 +103,14 @@ def _tear_down_execution(self) -> None:
is not decorated so that the derived class doesn't have to use the decorator.
"""
- def set_up_build_target(
- self, build_target_config: BuildTargetConfiguration
- ) -> None:
+ def set_up_build_target(self, build_target_config: BuildTargetConfiguration) -> None:
"""
Perform the build target setup that will be done for each build target
tested on this node.
"""
self._set_up_build_target(build_target_config)
- def _set_up_build_target(
- self, build_target_config: BuildTargetConfiguration
- ) -> None:
+ def _set_up_build_target(self, build_target_config: BuildTargetConfiguration) -> None:
"""
This method exists to be optionally overwritten by derived classes and
is not decorated so that the derived class doesn't have to use the decorator.
diff --git a/dts/framework/testbed_model/scapy.py b/dts/framework/testbed_model/scapy.py
index af0d4dbb25..9083e92b3d 100644
--- a/dts/framework/testbed_model/scapy.py
+++ b/dts/framework/testbed_model/scapy.py
@@ -96,9 +96,7 @@ def scapy_send_packets_and_capture(
return [scapy_packet.build() for scapy_packet in sniffer.stop(join=True)]
-def scapy_send_packets(
- xmlrpc_packets: list[xmlrpc.client.Binary], send_iface: str
-) -> None:
+def scapy_send_packets(xmlrpc_packets: list[xmlrpc.client.Binary], send_iface: str) -> None:
"""RPC function to send packets.
The function is meant to be executed on the remote TG node.
@@ -197,9 +195,7 @@ class ScapyTrafficGenerator(CapturingTrafficGenerator):
def __init__(self, tg_node: TGNode, config: ScapyTrafficGeneratorConfig):
self._config = config
self._tg_node = tg_node
- self._logger = getLogger(
- f"{self._tg_node.name} {self._config.traffic_generator_type}"
- )
+ self._logger = getLogger(f"{self._tg_node.name} {self._config.traffic_generator_type}")
assert (
self._tg_node.config.os == OS.linux
@@ -218,9 +214,7 @@ def __init__(self, tg_node: TGNode, config: ScapyTrafficGeneratorConfig):
self._start_xmlrpc_server_in_remote_python(xmlrpc_server_listen_port)
# connect to the server
- server_url = (
- f"http://{self._tg_node.config.hostname}:{xmlrpc_server_listen_port}"
- )
+ server_url = f"http://{self._tg_node.config.hostname}:{xmlrpc_server_listen_port}"
self.rpc_server_proxy = xmlrpc.client.ServerProxy(
server_url, allow_none=True, verbose=SETTINGS.verbose
)
@@ -240,17 +234,14 @@ def _start_xmlrpc_server_in_remote_python(self, listen_port: int):
src = inspect.getsource(QuittableXMLRPCServer)
# Lines with only whitespace break the repl if in the middle of a function
# or class, so strip all lines containing only whitespace
- src = "\n".join(
- [line for line in src.splitlines() if not line.isspace() and line != ""]
- )
+ src = "\n".join([line for line in src.splitlines() if not line.isspace() and line != ""])
spacing = "\n" * 4
# execute it in the python terminal
self.session.send_command(spacing + src + spacing)
self.session.send_command(
- f"server = QuittableXMLRPCServer(('0.0.0.0', {listen_port}));"
- f"server.serve_forever()",
+ f"server = QuittableXMLRPCServer(('0.0.0.0', {listen_port}));server.serve_forever()",
"XMLRPC OK",
)
diff --git a/dts/framework/testbed_model/sut_node.py b/dts/framework/testbed_model/sut_node.py
index 202aebfd06..d5d8905be7 100644
--- a/dts/framework/testbed_model/sut_node.py
+++ b/dts/framework/testbed_model/sut_node.py
@@ -129,9 +129,7 @@ def remote_dpdk_build_dir(self) -> PurePath:
@property
def dpdk_version(self) -> str:
if self._dpdk_version is None:
- self._dpdk_version = self.main_session.get_dpdk_version(
- self._remote_dpdk_dir
- )
+ self._dpdk_version = self.main_session.get_dpdk_version(self._remote_dpdk_dir)
return self._dpdk_version
@property
@@ -149,8 +147,7 @@ def compiler_version(self) -> str:
)
else:
self._logger.warning(
- "Failed to get compiler version because"
- "_build_target_config is None."
+ "Failed to get compiler version because _build_target_config is None."
)
return ""
return self._compiler_version
@@ -163,9 +160,7 @@ def get_build_target_info(self) -> BuildTargetInfo:
def _guess_dpdk_remote_dir(self) -> PurePath:
return self.main_session.guess_dpdk_remote_dir(self._remote_tmp_dir)
- def _set_up_build_target(
- self, build_target_config: BuildTargetConfiguration
- ) -> None:
+ def _set_up_build_target(self, build_target_config: BuildTargetConfiguration) -> None:
"""
Setup DPDK on the SUT node.
"""
@@ -177,23 +172,18 @@ def _set_up_build_target(
self._copy_dpdk_tarball()
self._build_dpdk()
- def _configure_build_target(
- self, build_target_config: BuildTargetConfiguration
- ) -> None:
+ def _configure_build_target(self, build_target_config: BuildTargetConfiguration) -> None:
"""
Populate common environment variables and set build target config.
"""
self._env_vars = {}
self._build_target_config = build_target_config
- self._env_vars.update(
- self.main_session.get_dpdk_build_env_vars(build_target_config.arch)
- )
+ self._env_vars.update(self.main_session.get_dpdk_build_env_vars(build_target_config.arch))
self._env_vars["CC"] = build_target_config.compiler.name
if build_target_config.compiler_wrapper:
self._env_vars["CC"] = (
- f"'{build_target_config.compiler_wrapper} "
- f"{build_target_config.compiler.name}'"
- )
+ f"'{build_target_config.compiler_wrapper} {build_target_config.compiler.name}'"
+ ) # fmt: skip
@Node.skip_setup
def _copy_dpdk_tarball(self) -> None:
@@ -224,9 +214,7 @@ def _copy_dpdk_tarball(self) -> None:
self.main_session.remove_remote_dir(self._remote_dpdk_dir)
# then extract to remote path
- self.main_session.extract_remote_tarball(
- remote_tarball_path, self._remote_dpdk_dir
- )
+ self.main_session.extract_remote_tarball(remote_tarball_path, self._remote_dpdk_dir)
@Node.skip_setup
def _build_dpdk(self) -> None:
@@ -263,9 +251,7 @@ def build_dpdk_app(self, app_name: str, **meson_dpdk_args: str | bool) -> PurePa
)
if app_name == "all":
- return self.main_session.join_remote_path(
- self.remote_dpdk_build_dir, "examples"
- )
+ return self.main_session.join_remote_path(self.remote_dpdk_build_dir, "examples")
return self.main_session.join_remote_path(
self.remote_dpdk_build_dir, "examples", f"dpdk-{app_name}"
)
@@ -319,9 +305,7 @@ def create_eal_parameters(
'-c 0xf -a 0000:88:00.0 --file-prefix=dpdk_1112_20190809143420';
"""
- lcore_list = LogicalCoreList(
- self.filter_lcores(lcore_filter_specifier, ascending_cores)
- )
+ lcore_list = LogicalCoreList(self.filter_lcores(lcore_filter_specifier, ascending_cores))
if append_prefix_timestamp:
prefix = f"{prefix}_{self._dpdk_timestamp}"
@@ -386,6 +370,4 @@ def create_interactive_shell(
self.remote_dpdk_build_dir, shell_cls.path
)
- return super().create_interactive_shell(
- shell_cls, timeout, privileged, str(eal_parameters)
- )
+ return super().create_interactive_shell(shell_cls, timeout, privileged, str(eal_parameters))
diff --git a/dts/framework/testbed_model/tg_node.py b/dts/framework/testbed_model/tg_node.py
index 27025cfa31..79a55663b5 100644
--- a/dts/framework/testbed_model/tg_node.py
+++ b/dts/framework/testbed_model/tg_node.py
@@ -45,9 +45,7 @@ class TGNode(Node):
def __init__(self, node_config: TGNodeConfiguration):
super(TGNode, self).__init__(node_config)
- self.traffic_generator = create_traffic_generator(
- self, node_config.traffic_generator
- )
+ self.traffic_generator = create_traffic_generator(self, node_config.traffic_generator)
self._logger.info(f"Created node: {self.name}")
def send_packet_and_capture(
@@ -94,6 +92,5 @@ def create_traffic_generator(
return ScapyTrafficGenerator(tg_node, traffic_generator_config)
case _:
raise ConfigurationError(
- "Unknown traffic generator: "
- f"{traffic_generator_config.traffic_generator_type}"
+ f"Unknown traffic generator: {traffic_generator_config.traffic_generator_type}"
)
diff --git a/dts/framework/utils.py b/dts/framework/utils.py
index d27c2c5b5f..d098d364ff 100644
--- a/dts/framework/utils.py
+++ b/dts/framework/utils.py
@@ -19,9 +19,7 @@
class StrEnum(Enum):
@staticmethod
- def _generate_next_value_(
- name: str, start: int, count: int, last_values: object
- ) -> str:
+ def _generate_next_value_(name: str, start: int, count: int, last_values: object) -> str:
return name
def __str__(self) -> str:
@@ -32,9 +30,7 @@ def __str__(self) -> str:
def check_dts_python_version() -> None:
- if sys.version_info.major < 3 or (
- sys.version_info.major == 3 and sys.version_info.minor < 10
- ):
+ if sys.version_info.major < 3 or (sys.version_info.major == 3 and sys.version_info.minor < 10):
print(
RED(
(
@@ -60,9 +56,7 @@ def expand_range(range_str: str) -> list[int]:
range_boundaries = range_str.split("-")
# will throw an exception when items in range_boundaries can't be converted,
# serving as type check
- expanded_range.extend(
- range(int(range_boundaries[0]), int(range_boundaries[-1]) + 1)
- )
+ expanded_range.extend(range(int(range_boundaries[0]), int(range_boundaries[-1]) + 1))
return expanded_range
@@ -71,9 +65,7 @@ def get_packet_summaries(packets: list[Packet]):
if len(packets) == 1:
packet_summaries = packets[0].summary()
else:
- packet_summaries = json.dumps(
- list(map(lambda pkt: pkt.summary(), packets)), indent=4
- )
+ packet_summaries = json.dumps(list(map(lambda pkt: pkt.summary(), packets)), indent=4)
return f"Packet contents: \n{packet_summaries}"
@@ -94,9 +86,7 @@ class MesonArgs(object):
_default_library: str
def __init__(self, default_library: str | None = None, **dpdk_args: str | bool):
- self._default_library = (
- f"--default-library={default_library}" if default_library else ""
- )
+ self._default_library = f"--default-library={default_library}" if default_library else ""
self._dpdk_args = " ".join(
(
f"-D{dpdk_arg_name}={dpdk_arg_value}"
diff --git a/dts/tests/TestSuite_hello_world.py b/dts/tests/TestSuite_hello_world.py
index 7e3d95c0cf..768ba1cfa8 100644
--- a/dts/tests/TestSuite_hello_world.py
+++ b/dts/tests/TestSuite_hello_world.py
@@ -34,9 +34,7 @@ def test_hello_world_single_core(self) -> None:
# get the first usable core
lcore_amount = LogicalCoreCount(1, 1, 1)
lcores = LogicalCoreCountFilter(self.sut_node.lcores, lcore_amount).filter()
- eal_para = self.sut_node.create_eal_parameters(
- lcore_filter_specifier=lcore_amount
- )
+ eal_para = self.sut_node.create_eal_parameters(lcore_filter_specifier=lcore_amount)
result = self.sut_node.run_dpdk_app(self.app_helloworld_path, eal_para)
self.verify(
f"hello from core {int(lcores[0])}" in result.stdout,
diff --git a/dts/tests/TestSuite_smoke_tests.py b/dts/tests/TestSuite_smoke_tests.py
index 4a269df75b..670053c6a5 100644
--- a/dts/tests/TestSuite_smoke_tests.py
+++ b/dts/tests/TestSuite_smoke_tests.py
@@ -45,13 +45,10 @@ def test_driver_tests(self) -> None:
for dev in self.sut_node.virtual_devices:
vdev_args += f"--vdev {dev} "
vdev_args = vdev_args[:-1]
- driver_tests_command = (
- f"meson test -C {self.dpdk_build_dir_path} --suite driver-tests"
- )
+ driver_tests_command = f"meson test -C {self.dpdk_build_dir_path} --suite driver-tests"
if vdev_args:
self._logger.info(
- "Running driver tests with the following virtual "
- f"devices: {vdev_args}"
+ f"Running driver tests with the following virtual devices: {vdev_args}"
)
driver_tests_command += f' --test-args "{vdev_args}"'
@@ -67,9 +64,7 @@ def test_devices_listed_in_testpmd(self) -> None:
Test:
Uses testpmd driver to verify that devices have been found by testpmd.
"""
- testpmd_driver = self.sut_node.create_interactive_shell(
- TestPmdShell, privileged=True
- )
+ testpmd_driver = self.sut_node.create_interactive_shell(TestPmdShell, privileged=True)
dev_list = [str(x) for x in testpmd_driver.get_devices()]
for nic in self.nics_in_node:
self.verify(
--
2.34.1
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v6 1/2] doc: increase python max line length to 100
2023-10-16 6:45 ` [PATCH v5 2/2] dts: reformat to 100 line length Juraj Linkeš
@ 2023-11-20 12:36 ` Juraj Linkeš
2023-11-20 12:36 ` [PATCH v6 2/2] dts: reformat to 100 line length Juraj Linkeš
0 siblings, 1 reply; 36+ messages in thread
From: Juraj Linkeš @ 2023-11-20 12:36 UTC (permalink / raw)
To: thomas, Honnappa.Nagarahalli, bruce.richardson, jspewock, probb,
paul.szczepanek, yoan.picchi, stephen
Cc: dev, Juraj Linkeš
Unify with C recommendations which allow line length of up to 100
characters.
Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
.editorconfig | 2 +-
doc/guides/contributing/coding_style.rst | 1 +
dts/pyproject.toml | 4 ++--
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/.editorconfig b/.editorconfig
index ab41c95085..1e7d74213f 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -16,7 +16,7 @@ max_line_length = 100
[*.py]
indent_style = space
indent_size = 4
-max_line_length = 79
+max_line_length = 100
[meson.build]
indent_style = space
diff --git a/doc/guides/contributing/coding_style.rst b/doc/guides/contributing/coding_style.rst
index 648849899d..1ebc79ca3c 100644
--- a/doc/guides/contributing/coding_style.rst
+++ b/doc/guides/contributing/coding_style.rst
@@ -880,6 +880,7 @@ All Python code should be compliant with
`PEP8 (Style Guide for Python Code) <https://www.python.org/dev/peps/pep-0008/>`_.
The ``pep8`` tool can be used for testing compliance with the guidelines.
+Note that line lengths are acceptable up to 100 characters, which is in line with C recommendations.
Integrating with the Build System
---------------------------------
diff --git a/dts/pyproject.toml b/dts/pyproject.toml
index 6762edfa6b..980ac3c7db 100644
--- a/dts/pyproject.toml
+++ b/dts/pyproject.toml
@@ -41,7 +41,7 @@ build-backend = "poetry.core.masonry.api"
[tool.pylama]
linters = "mccabe,pycodestyle,pyflakes"
format = "pylint"
-max_line_length = 88 # https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length
+max_line_length = 100
[tool.mypy]
python_version = "3.10"
@@ -55,4 +55,4 @@ profile = "black"
[tool.black]
target-version = ['py310']
include = '\.pyi?$'
-line-length = 88 # https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length
+line-length = 100
--
2.34.1
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v6 2/2] dts: reformat to 100 line length
2023-11-20 12:36 ` [PATCH v6 1/2] doc: increase python max line length to 100 Juraj Linkeš
@ 2023-11-20 12:36 ` Juraj Linkeš
2023-11-20 16:50 ` Thomas Monjalon
0 siblings, 1 reply; 36+ messages in thread
From: Juraj Linkeš @ 2023-11-20 12:36 UTC (permalink / raw)
To: thomas, Honnappa.Nagarahalli, bruce.richardson, jspewock, probb,
paul.szczepanek, yoan.picchi, stephen
Cc: dev, Juraj Linkeš
Reformat to 100 from the previous 88 to unify with C recommendations.
The C recommendation is the maximum with the ideal being 80. The Python
tools are not suitable for this flexibility.
We require all patches with DTS code to be validated with the
devtools/dts-check-format.sh script, part of which is the black
formatting tool. We've set up black to format all of the codebase and
the reformat is needed so that future submitters are not affected.
Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
Acked-by: Jeremy Spewock <jspewock@iol.unh.edu>
---
dts/framework/config/__init__.py | 20 ++-----
dts/framework/dts.py | 15 ++---
dts/framework/exception.py | 5 +-
dts/framework/remote_session/__init__.py | 4 +-
dts/framework/remote_session/linux_session.py | 39 ++++---------
dts/framework/remote_session/posix_session.py | 30 +++-------
.../remote/interactive_remote_session.py | 7 +--
.../remote/interactive_shell.py | 4 +-
.../remote_session/remote/remote_session.py | 8 +--
.../remote_session/remote/ssh_session.py | 16 ++----
.../remote_session/remote/testpmd_shell.py | 8 +--
dts/framework/settings.py | 15 ++---
dts/framework/test_result.py | 16 ++----
dts/framework/test_suite.py | 57 +++++--------------
.../capturing_traffic_generator.py | 7 +--
dts/framework/testbed_model/hw/cpu.py | 20 ++-----
dts/framework/testbed_model/node.py | 8 +--
dts/framework/testbed_model/scapy.py | 19 ++-----
dts/framework/testbed_model/sut_node.py | 40 ++++---------
dts/framework/testbed_model/tg_node.py | 7 +--
dts/framework/utils.py | 20 ++-----
dts/tests/TestSuite_hello_world.py | 4 +-
dts/tests/TestSuite_smoke_tests.py | 11 +---
23 files changed, 99 insertions(+), 281 deletions(-)
diff --git a/dts/framework/config/__init__.py b/dts/framework/config/__init__.py
index cb7e00ba34..9b32cf0532 100644
--- a/dts/framework/config/__init__.py
+++ b/dts/framework/config/__init__.py
@@ -140,9 +140,7 @@ def from_dict(d: dict) -> Union["SutNodeConfiguration", "TGNodeConfiguration"]:
if "traffic_generator" in d:
return TGNodeConfiguration(
- traffic_generator=TrafficGeneratorConfig.from_dict(
- d["traffic_generator"]
- ),
+ traffic_generator=TrafficGeneratorConfig.from_dict(d["traffic_generator"]),
**common_config,
)
else:
@@ -249,9 +247,7 @@ def from_dict(
build_targets: list[BuildTargetConfiguration] = list(
map(BuildTargetConfiguration.from_dict, d["build_targets"])
)
- test_suites: list[TestSuiteConfig] = list(
- map(TestSuiteConfig.from_dict, d["test_suites"])
- )
+ test_suites: list[TestSuiteConfig] = list(map(TestSuiteConfig.from_dict, d["test_suites"]))
sut_name = d["system_under_test_node"]["node_name"]
skip_smoke_tests = d.get("skip_smoke_tests", False)
assert sut_name in node_map, f"Unknown SUT {sut_name} in execution {d}"
@@ -268,9 +264,7 @@ def from_dict(
), f"Invalid TG configuration {traffic_generator_node}"
vdevs = (
- d["system_under_test_node"]["vdevs"]
- if "vdevs" in d["system_under_test_node"]
- else []
+ d["system_under_test_node"]["vdevs"] if "vdevs" in d["system_under_test_node"] else []
)
return ExecutionConfiguration(
build_targets=build_targets,
@@ -299,9 +293,7 @@ def from_dict(d: dict) -> "Configuration":
assert len(nodes) == len(node_map), "Duplicate node names are not allowed"
executions: list[ExecutionConfiguration] = list(
- map(
- ExecutionConfiguration.from_dict, d["executions"], [node_map for _ in d]
- )
+ map(ExecutionConfiguration.from_dict, d["executions"], [node_map for _ in d])
)
return Configuration(executions=executions)
@@ -315,9 +307,7 @@ def load_config() -> Configuration:
with open(SETTINGS.config_file_path, "r") as f:
config_data = yaml.safe_load(f)
- schema_path = os.path.join(
- pathlib.Path(__file__).parent.resolve(), "conf_yaml_schema.json"
- )
+ schema_path = os.path.join(pathlib.Path(__file__).parent.resolve(), "conf_yaml_schema.json")
with open(schema_path, "r") as f:
schema = json.load(f)
diff --git a/dts/framework/dts.py b/dts/framework/dts.py
index f773f0c38d..25d6942d81 100644
--- a/dts/framework/dts.py
+++ b/dts/framework/dts.py
@@ -92,9 +92,7 @@ def _run_execution(
Run the given execution. This involves running the execution setup as well as
running all build targets in the given execution.
"""
- dts_logger.info(
- f"Running execution with SUT '{execution.system_under_test_node.name}'."
- )
+ dts_logger.info(f"Running execution with SUT '{execution.system_under_test_node.name}'.")
execution_result = result.add_execution(sut_node.config)
execution_result.add_sut_info(sut_node.node_info)
@@ -107,9 +105,7 @@ def _run_execution(
else:
for build_target in execution.build_targets:
- _run_build_target(
- sut_node, tg_node, build_target, execution, execution_result
- )
+ _run_build_target(sut_node, tg_node, build_target, execution, execution_result)
finally:
try:
@@ -170,13 +166,10 @@ def _run_all_suites(
execution.test_suites[:0] = [TestSuiteConfig.from_dict("smoke_tests")]
for test_suite_config in execution.test_suites:
try:
- _run_single_suite(
- sut_node, tg_node, execution, build_target_result, test_suite_config
- )
+ _run_single_suite(sut_node, tg_node, execution, build_target_result, test_suite_config)
except BlockingTestSuiteError as e:
dts_logger.exception(
- f"An error occurred within {test_suite_config.test_suite}. "
- "Skipping build target..."
+ f"An error occurred within {test_suite_config.test_suite}. Skipping build target."
)
result.add_error(e)
end_build_target = True
diff --git a/dts/framework/exception.py b/dts/framework/exception.py
index 001a5a5496..b362e42924 100644
--- a/dts/framework/exception.py
+++ b/dts/framework/exception.py
@@ -116,10 +116,7 @@ def __init__(self, command: str, command_return_code: int):
self.command_return_code = command_return_code
def __str__(self) -> str:
- return (
- f"Command {self.command} returned a non-zero exit code: "
- f"{self.command_return_code}"
- )
+ return f"Command {self.command} returned a non-zero exit code: {self.command_return_code}"
class RemoteDirectoryExistsError(DTSError):
diff --git a/dts/framework/remote_session/__init__.py b/dts/framework/remote_session/__init__.py
index 00b6d1f03a..6124417bd7 100644
--- a/dts/framework/remote_session/__init__.py
+++ b/dts/framework/remote_session/__init__.py
@@ -30,9 +30,7 @@
)
-def create_session(
- node_config: NodeConfiguration, name: str, logger: DTSLOG
-) -> OSSession:
+def create_session(node_config: NodeConfiguration, name: str, logger: DTSLOG) -> OSSession:
match node_config.os:
case OS.linux:
return LinuxSession(node_config, name, logger)
diff --git a/dts/framework/remote_session/linux_session.py b/dts/framework/remote_session/linux_session.py
index a3f1a6bf3b..fd877fbfae 100644
--- a/dts/framework/remote_session/linux_session.py
+++ b/dts/framework/remote_session/linux_session.py
@@ -82,9 +82,7 @@ def setup_hugepages(self, hugepage_amount: int, force_first_numa: bool) -> None:
self._mount_huge_pages()
def _get_hugepage_size(self) -> int:
- hugepage_size = self.send_command(
- "awk '/Hugepagesize/ {print $2}' /proc/meminfo"
- ).stdout
+ hugepage_size = self.send_command("awk '/Hugepagesize/ {print $2}' /proc/meminfo").stdout
return int(hugepage_size)
def _get_hugepages_total(self) -> int:
@@ -120,13 +118,9 @@ def _supports_numa(self) -> bool:
# there's no reason to do any numa specific configuration)
return len(self._numa_nodes) > 1
- def _configure_huge_pages(
- self, amount: int, size: int, force_first_numa: bool
- ) -> None:
+ def _configure_huge_pages(self, amount: int, size: int, force_first_numa: bool) -> None:
self._logger.info("Configuring Hugepages.")
- hugepage_config_path = (
- f"/sys/kernel/mm/hugepages/hugepages-{size}kB/nr_hugepages"
- )
+ hugepage_config_path = f"/sys/kernel/mm/hugepages/hugepages-{size}kB/nr_hugepages"
if force_first_numa and self._supports_numa():
# clear non-numa hugepages
self.send_command(f"echo 0 | tee {hugepage_config_path}", privileged=True)
@@ -135,24 +129,18 @@ def _configure_huge_pages(
f"/hugepages-{size}kB/nr_hugepages"
)
- self.send_command(
- f"echo {amount} | tee {hugepage_config_path}", privileged=True
- )
+ self.send_command(f"echo {amount} | tee {hugepage_config_path}", privileged=True)
def update_ports(self, ports: list[Port]) -> None:
self._logger.debug("Gathering port info.")
for port in ports:
- assert (
- port.node == self.name
- ), "Attempted to gather port info on the wrong node"
+ assert port.node == self.name, "Attempted to gather port info on the wrong node"
port_info_list = self._get_lshw_info()
for port in ports:
for port_info in port_info_list:
if f"pci@{port.pci}" == port_info.get("businfo"):
- self._update_port_attr(
- port, port_info.get("logicalname"), "logical_name"
- )
+ self._update_port_attr(port, port_info.get("logicalname"), "logical_name")
self._update_port_attr(port, port_info.get("serial"), "mac_address")
port_info_list.remove(port_info)
break
@@ -163,25 +151,18 @@ def _get_lshw_info(self) -> list[LshwOutput]:
output = self.send_command("lshw -quiet -json -C network", verify=True)
return json.loads(output.stdout)
- def _update_port_attr(
- self, port: Port, attr_value: str | None, attr_name: str
- ) -> None:
+ def _update_port_attr(self, port: Port, attr_value: str | None, attr_name: str) -> None:
if attr_value:
setattr(port, attr_name, attr_value)
- self._logger.debug(
- f"Found '{attr_name}' of port {port.pci}: '{attr_value}'."
- )
+ self._logger.debug(f"Found '{attr_name}' of port {port.pci}: '{attr_value}'.")
else:
self._logger.warning(
- f"Attempted to get '{attr_name}' of port {port.pci}, "
- f"but it doesn't exist."
+ f"Attempted to get '{attr_name}' of port {port.pci}, but it doesn't exist."
)
def configure_port_state(self, port: Port, enable: bool) -> None:
state = "up" if enable else "down"
- self.send_command(
- f"ip link set dev {port.logical_name} {state}", privileged=True
- )
+ self.send_command(f"ip link set dev {port.logical_name} {state}", privileged=True)
def configure_port_ip_address(
self,
diff --git a/dts/framework/remote_session/posix_session.py b/dts/framework/remote_session/posix_session.py
index 5da0516e05..a29e2e8280 100644
--- a/dts/framework/remote_session/posix_session.py
+++ b/dts/framework/remote_session/posix_session.py
@@ -94,8 +94,7 @@ def extract_remote_tarball(
expected_dir: str | PurePath | None = None,
) -> None:
self.send_command(
- f"tar xfm {remote_tarball_path} "
- f"-C {PurePosixPath(remote_tarball_path).parent}",
+ f"tar xfm {remote_tarball_path} -C {PurePosixPath(remote_tarball_path).parent}",
60,
)
if expected_dir:
@@ -125,8 +124,7 @@ def build_dpdk(
self._logger.info("Configuring DPDK build from scratch.")
self.remove_remote_dir(remote_dpdk_build_dir)
self.send_command(
- f"meson setup "
- f"{meson_args} {remote_dpdk_dir} {remote_dpdk_build_dir}",
+ f"meson setup {meson_args} {remote_dpdk_dir} {remote_dpdk_build_dir}",
timeout,
verify=True,
env=env_vars,
@@ -140,9 +138,7 @@ def build_dpdk(
raise DPDKBuildError(f"DPDK build failed when doing '{e.command}'.")
def get_dpdk_version(self, build_dir: str | PurePath) -> str:
- out = self.send_command(
- f"cat {self.join_remote_path(build_dir, 'VERSION')}", verify=True
- )
+ out = self.send_command(f"cat {self.join_remote_path(build_dir, 'VERSION')}", verify=True)
return out.stdout
def kill_cleanup_dpdk_apps(self, dpdk_prefix_list: Iterable[str]) -> None:
@@ -156,9 +152,7 @@ def kill_cleanup_dpdk_apps(self, dpdk_prefix_list: Iterable[str]) -> None:
self._check_dpdk_hugepages(dpdk_runtime_dirs)
self._remove_dpdk_runtime_dirs(dpdk_runtime_dirs)
- def _get_dpdk_runtime_dirs(
- self, dpdk_prefix_list: Iterable[str]
- ) -> list[PurePosixPath]:
+ def _get_dpdk_runtime_dirs(self, dpdk_prefix_list: Iterable[str]) -> list[PurePosixPath]:
prefix = PurePosixPath("/var", "run", "dpdk")
if not dpdk_prefix_list:
remote_prefixes = self._list_remote_dirs(prefix)
@@ -174,9 +168,7 @@ def _list_remote_dirs(self, remote_path: str | PurePath) -> list[str] | None:
Return a list of directories of the remote_dir.
If remote_path doesn't exist, return None.
"""
- out = self.send_command(
- f"ls -l {remote_path} | awk '/^d/ {{print $NF}}'"
- ).stdout
+ out = self.send_command(f"ls -l {remote_path} | awk '/^d/ {{print $NF}}'").stdout
if "No such file or directory" in out:
return None
else:
@@ -200,9 +192,7 @@ def _remote_files_exists(self, remote_path: PurePath) -> bool:
result = self.send_command(f"test -e {remote_path}")
return not result.return_code
- def _check_dpdk_hugepages(
- self, dpdk_runtime_dirs: Iterable[str | PurePath]
- ) -> None:
+ def _check_dpdk_hugepages(self, dpdk_runtime_dirs: Iterable[str | PurePath]) -> None:
for dpdk_runtime_dir in dpdk_runtime_dirs:
hugepage_info = PurePosixPath(dpdk_runtime_dir, "hugepage_info")
if self._remote_files_exists(hugepage_info):
@@ -213,9 +203,7 @@ def _check_dpdk_hugepages(
self._logger.warning(out)
self._logger.warning("*******************************************")
- def _remove_dpdk_runtime_dirs(
- self, dpdk_runtime_dirs: Iterable[str | PurePath]
- ) -> None:
+ def _remove_dpdk_runtime_dirs(self, dpdk_runtime_dirs: Iterable[str | PurePath]) -> None:
for dpdk_runtime_dir in dpdk_runtime_dirs:
self.remove_remote_dir(dpdk_runtime_dir)
@@ -245,6 +233,4 @@ def get_node_info(self) -> NodeInfo:
SETTINGS.timeout,
).stdout.split("\n")
kernel_version = self.send_command("uname -r", SETTINGS.timeout).stdout
- return NodeInfo(
- os_release_info[0].strip(), os_release_info[1].strip(), kernel_version
- )
+ return NodeInfo(os_release_info[0].strip(), os_release_info[1].strip(), kernel_version)
diff --git a/dts/framework/remote_session/remote/interactive_remote_session.py b/dts/framework/remote_session/remote/interactive_remote_session.py
index 9085a668e8..098ded1bb0 100644
--- a/dts/framework/remote_session/remote/interactive_remote_session.py
+++ b/dts/framework/remote_session/remote/interactive_remote_session.py
@@ -73,9 +73,7 @@ def __init__(self, node_config: NodeConfiguration, _logger: DTSLOG) -> None:
f"Initializing interactive connection for {self.username}@{self.hostname}"
)
self._connect()
- self._logger.info(
- f"Interactive connection successful for {self.username}@{self.hostname}"
- )
+ self._logger.info(f"Interactive connection successful for {self.username}@{self.hostname}")
def _connect(self) -> None:
"""Establish a connection to the node.
@@ -108,8 +106,7 @@ def _connect(self) -> None:
self._logger.debug(traceback.format_exc())
self._logger.warning(e)
self._logger.info(
- "Retrying interactive session connection: "
- f"retry number {retry_attempt +1}"
+ f"Retrying interactive session connection: retry number {retry_attempt +1}"
)
else:
break
diff --git a/dts/framework/remote_session/remote/interactive_shell.py b/dts/framework/remote_session/remote/interactive_shell.py
index c24376b2a8..4db19fb9b3 100644
--- a/dts/framework/remote_session/remote/interactive_shell.py
+++ b/dts/framework/remote_session/remote/interactive_shell.py
@@ -85,9 +85,7 @@ def __init__(
self._app_args = app_args
self._start_application(get_privileged_command)
- def _start_application(
- self, get_privileged_command: Callable[[str], str] | None
- ) -> None:
+ def _start_application(self, get_privileged_command: Callable[[str], str] | None) -> None:
"""Starts a new interactive application based on the path to the app.
This method is often overridden by subclasses as their process for
diff --git a/dts/framework/remote_session/remote/remote_session.py b/dts/framework/remote_session/remote/remote_session.py
index 0647d93de4..719f7d1ef7 100644
--- a/dts/framework/remote_session/remote/remote_session.py
+++ b/dts/framework/remote_session/remote/remote_session.py
@@ -96,9 +96,7 @@ def send_command(
If verify is True, check the return code of the executed command
and raise a RemoteCommandExecutionError if the command failed.
"""
- self._logger.info(
- f"Sending: '{command}'" + (f" with env vars: '{env}'" if env else "")
- )
+ self._logger.info(f"Sending: '{command}'" + (f" with env vars: '{env}'" if env else ""))
result = self._send_command(command, timeout, env)
if verify and result.return_code:
self._logger.debug(
@@ -112,9 +110,7 @@ def send_command(
return result
@abstractmethod
- def _send_command(
- self, command: str, timeout: float, env: dict | None
- ) -> CommandResult:
+ def _send_command(self, command: str, timeout: float, env: dict | None) -> CommandResult:
"""
Use the underlying protocol to execute the command using optional env vars
and return CommandResult.
diff --git a/dts/framework/remote_session/remote/ssh_session.py b/dts/framework/remote_session/remote/ssh_session.py
index 8d127f1601..1a7ee649ab 100644
--- a/dts/framework/remote_session/remote/ssh_session.py
+++ b/dts/framework/remote_session/remote/ssh_session.py
@@ -80,9 +80,7 @@ def _connect(self) -> None:
if error not in errors:
errors.append(error)
- self._logger.info(
- f"Retrying connection: retry number {retry_attempt + 1}."
- )
+ self._logger.info(f"Retrying connection: retry number {retry_attempt + 1}.")
else:
break
@@ -92,9 +90,7 @@ def _connect(self) -> None:
def is_alive(self) -> bool:
return self.session.is_connected
- def _send_command(
- self, command: str, timeout: float, env: dict | None
- ) -> CommandResult:
+ def _send_command(self, command: str, timeout: float, env: dict | None) -> CommandResult:
"""Send a command and return the result of the execution.
Args:
@@ -107,9 +103,7 @@ def _send_command(
SSHTimeoutError: The command execution timed out.
"""
try:
- output = self.session.run(
- command, env=env, warn=True, hide=True, timeout=timeout
- )
+ output = self.session.run(command, env=env, warn=True, hide=True, timeout=timeout)
except (UnexpectedExit, ThreadException) as e:
self._logger.exception(e)
@@ -119,9 +113,7 @@ def _send_command(
self._logger.exception(e)
raise SSHTimeoutError(command, e.result.stderr) from e
- return CommandResult(
- self.name, command, output.stdout, output.stderr, output.return_code
- )
+ return CommandResult(self.name, command, output.stdout, output.stderr, output.return_code)
def copy_from(
self,
diff --git a/dts/framework/remote_session/remote/testpmd_shell.py b/dts/framework/remote_session/remote/testpmd_shell.py
index 1455b5a199..08ac311016 100644
--- a/dts/framework/remote_session/remote/testpmd_shell.py
+++ b/dts/framework/remote_session/remote/testpmd_shell.py
@@ -21,13 +21,9 @@ class TestPmdShell(InteractiveShell):
path: PurePath = PurePath("app", "dpdk-testpmd")
dpdk_app: bool = True
_default_prompt: str = "testpmd>"
- _command_extra_chars: str = (
- "\n" # We want to append an extra newline to every command
- )
+ _command_extra_chars: str = "\n" # We want to append an extra newline to every command
- def _start_application(
- self, get_privileged_command: Callable[[str], str] | None
- ) -> None:
+ def _start_application(self, get_privileged_command: Callable[[str], str] | None) -> None:
"""See "_start_application" in InteractiveShell."""
self._app_args += " -- -i"
super()._start_application(get_privileged_command)
diff --git a/dts/framework/settings.py b/dts/framework/settings.py
index cfa39d011b..974793a11a 100644
--- a/dts/framework/settings.py
+++ b/dts/framework/settings.py
@@ -72,9 +72,8 @@ class _Settings:
def _get_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(
- description="Run DPDK test suites. All options may be specified with "
- "the environment variables provided in brackets. "
- "Command line arguments have higher priority.",
+ description="Run DPDK test suites. All options may be specified with the environment "
+ "variables provided in brackets. Command line arguments have higher priority.",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
@@ -82,8 +81,7 @@ def _get_parser() -> argparse.ArgumentParser:
"--config-file",
action=_env_arg("DTS_CFG_FILE"),
default="conf.yaml",
- help="[DTS_CFG_FILE] configuration file that describes the test cases, SUTs "
- "and targets.",
+ help="[DTS_CFG_FILE] configuration file that describes the test cases, SUTs and targets.",
)
parser.add_argument(
@@ -100,8 +98,7 @@ def _get_parser() -> argparse.ArgumentParser:
action=_env_arg("DTS_TIMEOUT"),
default=15,
type=float,
- help="[DTS_TIMEOUT] The default timeout for all DTS operations except for "
- "compiling DPDK.",
+ help="[DTS_TIMEOUT] The default timeout for all DTS operations except for compiling DPDK.",
)
parser.add_argument(
@@ -170,9 +167,7 @@ def _get_settings() -> _Settings:
timeout=parsed_args.timeout,
verbose=(parsed_args.verbose == "Y"),
skip_setup=(parsed_args.skip_setup == "Y"),
- dpdk_tarball_path=Path(
- DPDKGitTarball(parsed_args.tarball, parsed_args.output_dir)
- )
+ dpdk_tarball_path=Path(DPDKGitTarball(parsed_args.tarball, parsed_args.output_dir))
if not os.path.exists(parsed_args.tarball)
else Path(parsed_args.tarball),
compile_timeout=parsed_args.compile_timeout,
diff --git a/dts/framework/test_result.py b/dts/framework/test_result.py
index f0fbe80f6f..4c2e7e2418 100644
--- a/dts/framework/test_result.py
+++ b/dts/framework/test_result.py
@@ -83,9 +83,7 @@ def __iadd__(self, other: Result) -> "Statistics":
"""
self[other.name] += 1
self["PASS RATE"] = (
- float(self[Result.PASS.name])
- * 100
- / sum(self[result.name] for result in Result)
+ float(self[Result.PASS.name]) * 100 / sum(self[result.name] for result in Result)
)
return self
@@ -135,9 +133,7 @@ def _get_setup_teardown_errors(self) -> list[Exception]:
def _get_inner_errors(self) -> list[Exception]:
return [
- error
- for inner_result in self._inner_results
- for error in inner_result.get_errors()
+ error for inner_result in self._inner_results for error in inner_result.get_errors()
]
def get_errors(self) -> list[Exception]:
@@ -174,9 +170,7 @@ def add_stats(self, statistics: Statistics) -> None:
statistics += self.result
def __bool__(self) -> bool:
- return (
- bool(self.setup_result) and bool(self.teardown_result) and bool(self.result)
- )
+ return bool(self.setup_result) and bool(self.teardown_result) and bool(self.result)
class TestSuiteResult(BaseResult):
@@ -247,9 +241,7 @@ def __init__(self, sut_node: NodeConfiguration):
super(ExecutionResult, self).__init__()
self.sut_node = sut_node
- def add_build_target(
- self, build_target: BuildTargetConfiguration
- ) -> BuildTargetResult:
+ def add_build_target(self, build_target: BuildTargetConfiguration) -> BuildTargetResult:
build_target_result = BuildTargetResult(build_target)
self._inner_results.append(build_target_result)
return build_target_result
diff --git a/dts/framework/test_suite.py b/dts/framework/test_suite.py
index 3b890c0451..4a7907ec33 100644
--- a/dts/framework/test_suite.py
+++ b/dts/framework/test_suite.py
@@ -102,9 +102,7 @@ def _process_links(self) -> None:
tg_port.peer,
tg_port.identifier,
):
- self._port_links.append(
- PortLink(sut_port=sut_port, tg_port=tg_port)
- )
+ self._port_links.append(PortLink(sut_port=sut_port, tg_port=tg_port))
def set_up_suite(self) -> None:
"""
@@ -151,9 +149,7 @@ def configure_testbed_ipv4(self, restore: bool = False) -> None:
def _configure_ipv4_forwarding(self, enable: bool) -> None:
self.sut_node.configure_ipv4_forwarding(enable)
- def send_packet_and_capture(
- self, packet: Packet, duration: float = 1
- ) -> list[Packet]:
+ def send_packet_and_capture(self, packet: Packet, duration: float = 1) -> list[Packet]:
"""
Send a packet through the appropriate interface and
receive on the appropriate interface.
@@ -202,21 +198,15 @@ def verify(self, condition: bool, failure_description: str) -> None:
self._fail_test_case_verify(failure_description)
def _fail_test_case_verify(self, failure_description: str) -> None:
- self._logger.debug(
- "A test case failed, showing the last 10 commands executed on SUT:"
- )
+ self._logger.debug("A test case failed, showing the last 10 commands executed on SUT:")
for command_res in self.sut_node.main_session.remote_session.history[-10:]:
self._logger.debug(command_res.command)
- self._logger.debug(
- "A test case failed, showing the last 10 commands executed on TG:"
- )
+ self._logger.debug("A test case failed, showing the last 10 commands executed on TG:")
for command_res in self.tg_node.main_session.remote_session.history[-10:]:
self._logger.debug(command_res.command)
raise TestCaseVerifyError(failure_description)
- def verify_packets(
- self, expected_packet: Packet, received_packets: list[Packet]
- ) -> None:
+ def verify_packets(self, expected_packet: Packet, received_packets: list[Packet]) -> None:
for received_packet in received_packets:
if self._compare_packets(expected_packet, received_packet):
break
@@ -225,17 +215,11 @@ def verify_packets(
f"The expected packet {get_packet_summaries(expected_packet)} "
f"not found among received {get_packet_summaries(received_packets)}"
)
- self._fail_test_case_verify(
- "An expected packet not found among received packets."
- )
+ self._fail_test_case_verify("An expected packet not found among received packets.")
- def _compare_packets(
- self, expected_packet: Packet, received_packet: Packet
- ) -> bool:
+ def _compare_packets(self, expected_packet: Packet, received_packet: Packet) -> bool:
self._logger.debug(
- "Comparing packets: \n"
- f"{expected_packet.summary()}\n"
- f"{received_packet.summary()}"
+ f"Comparing packets: \n{expected_packet.summary()}\n{received_packet.summary()}"
)
l3 = IP in expected_packet.layers()
@@ -262,14 +246,10 @@ def _compare_packets(
expected_payload = expected_payload.payload
if expected_payload:
- self._logger.debug(
- f"The expected packet did not contain {expected_payload}."
- )
+ self._logger.debug(f"The expected packet did not contain {expected_payload}.")
return False
if received_payload and received_payload.__class__ != Padding:
- self._logger.debug(
- "The received payload had extra layers which were not padding."
- )
+ self._logger.debug("The received payload had extra layers which were not padding.")
return False
return True
@@ -296,10 +276,7 @@ def _verify_l2_frame(self, received_packet: Ether, l3: bool) -> bool:
def _verify_l3_packet(self, received_packet: IP, expected_packet: IP) -> bool:
self._logger.debug("Looking at the IP layer.")
- if (
- received_packet.src != expected_packet.src
- or received_packet.dst != expected_packet.dst
- ):
+ if received_packet.src != expected_packet.src or received_packet.dst != expected_packet.dst:
return False
return True
@@ -373,9 +350,7 @@ def _get_test_cases(self, test_case_regex: str) -> list[MethodType]:
if self._should_be_executed(test_case_name, test_case_regex):
filtered_test_cases.append(test_case)
cases_str = ", ".join((x.__name__ for x in filtered_test_cases))
- self._logger.debug(
- f"Found test cases '{cases_str}' in {self.__class__.__name__}."
- )
+ self._logger.debug(f"Found test cases '{cases_str}' in {self.__class__.__name__}.")
return filtered_test_cases
def _should_be_executed(self, test_case_name: str, test_case_regex: str) -> bool:
@@ -445,9 +420,7 @@ def _execute_test_case(
self._logger.exception(f"Test case execution ERROR: {test_case_name}")
test_case_result.update(Result.ERROR, e)
except KeyboardInterrupt:
- self._logger.error(
- f"Test case execution INTERRUPTED by user: {test_case_name}"
- )
+ self._logger.error(f"Test case execution INTERRUPTED by user: {test_case_name}")
test_case_result.update(Result.SKIP)
raise KeyboardInterrupt("Stop DTS")
@@ -464,9 +437,7 @@ def is_test_suite(object) -> bool:
try:
testcase_module = importlib.import_module(testsuite_module_path)
except ModuleNotFoundError as e:
- raise ConfigurationError(
- f"Test suite '{testsuite_module_path}' not found."
- ) from e
+ raise ConfigurationError(f"Test suite '{testsuite_module_path}' not found.") from e
return [
test_suite_class
for _, test_suite_class in inspect.getmembers(testcase_module, is_test_suite)
diff --git a/dts/framework/testbed_model/capturing_traffic_generator.py b/dts/framework/testbed_model/capturing_traffic_generator.py
index ab98987f8e..e6512061d7 100644
--- a/dts/framework/testbed_model/capturing_traffic_generator.py
+++ b/dts/framework/testbed_model/capturing_traffic_generator.py
@@ -100,8 +100,7 @@ def send_packets_and_capture(
"""
self._logger.debug(get_packet_summaries(packets))
self._logger.debug(
- f"Sending packet on {send_port.logical_name}, "
- f"receiving on {receive_port.logical_name}."
+ f"Sending packet on {send_port.logical_name}, receiving on {receive_port.logical_name}."
)
received_packets = self._send_packets_and_capture(
packets,
@@ -110,9 +109,7 @@ def send_packets_and_capture(
duration,
)
- self._logger.debug(
- f"Received packets: {get_packet_summaries(received_packets)}"
- )
+ self._logger.debug(f"Received packets: {get_packet_summaries(received_packets)}")
self._write_capture_from_packets(capture_name, received_packets)
return received_packets
diff --git a/dts/framework/testbed_model/hw/cpu.py b/dts/framework/testbed_model/hw/cpu.py
index d1918a12dc..cbc5fe7fff 100644
--- a/dts/framework/testbed_model/hw/cpu.py
+++ b/dts/framework/testbed_model/hw/cpu.py
@@ -54,9 +54,7 @@ def __init__(self, lcore_list: list[int] | list[str] | list[LogicalCore] | str):
# the input lcores may not be sorted
self._lcore_list.sort()
- self._lcore_str = (
- f'{",".join(self._get_consecutive_lcores_range(self._lcore_list))}'
- )
+ self._lcore_str = f'{",".join(self._get_consecutive_lcores_range(self._lcore_list))}'
@property
def lcore_list(self) -> list[int]:
@@ -70,15 +68,11 @@ def _get_consecutive_lcores_range(self, lcore_ids_list: list[int]) -> list[str]:
segment.append(lcore_id)
else:
formatted_core_list.append(
- f"{segment[0]}-{segment[-1]}"
- if len(segment) > 1
- else f"{segment[0]}"
+ f"{segment[0]}-{segment[-1]}" if len(segment) > 1 else f"{segment[0]}"
)
current_core_index = lcore_ids_list.index(lcore_id)
formatted_core_list.extend(
- self._get_consecutive_lcores_range(
- lcore_ids_list[current_core_index:]
- )
+ self._get_consecutive_lcores_range(lcore_ids_list[current_core_index:])
)
segment.clear()
break
@@ -125,9 +119,7 @@ def __init__(
self._filter_specifier = filter_specifier
# sorting by core is needed in case hyperthreading is enabled
- self._lcores_to_filter = sorted(
- lcore_list, key=lambda x: x.core, reverse=not ascending
- )
+ self._lcores_to_filter = sorted(lcore_list, key=lambda x: x.core, reverse=not ascending)
self.filter()
@abstractmethod
@@ -220,9 +212,7 @@ def _filter_cores_from_socket(
else:
# we have enough lcores per this core
continue
- elif self._filter_specifier.cores_per_socket > len(
- lcore_count_per_core_map
- ):
+ elif self._filter_specifier.cores_per_socket > len(lcore_count_per_core_map):
# only add cores if we need more
lcore_count_per_core_map[lcore.core] = 1
filtered_lcores.append(lcore)
diff --git a/dts/framework/testbed_model/node.py b/dts/framework/testbed_model/node.py
index fc01e0bf8e..ef700d8114 100644
--- a/dts/framework/testbed_model/node.py
+++ b/dts/framework/testbed_model/node.py
@@ -103,18 +103,14 @@ def _tear_down_execution(self) -> None:
is not decorated so that the derived class doesn't have to use the decorator.
"""
- def set_up_build_target(
- self, build_target_config: BuildTargetConfiguration
- ) -> None:
+ def set_up_build_target(self, build_target_config: BuildTargetConfiguration) -> None:
"""
Perform the build target setup that will be done for each build target
tested on this node.
"""
self._set_up_build_target(build_target_config)
- def _set_up_build_target(
- self, build_target_config: BuildTargetConfiguration
- ) -> None:
+ def _set_up_build_target(self, build_target_config: BuildTargetConfiguration) -> None:
"""
This method exists to be optionally overwritten by derived classes and
is not decorated so that the derived class doesn't have to use the decorator.
diff --git a/dts/framework/testbed_model/scapy.py b/dts/framework/testbed_model/scapy.py
index af0d4dbb25..9083e92b3d 100644
--- a/dts/framework/testbed_model/scapy.py
+++ b/dts/framework/testbed_model/scapy.py
@@ -96,9 +96,7 @@ def scapy_send_packets_and_capture(
return [scapy_packet.build() for scapy_packet in sniffer.stop(join=True)]
-def scapy_send_packets(
- xmlrpc_packets: list[xmlrpc.client.Binary], send_iface: str
-) -> None:
+def scapy_send_packets(xmlrpc_packets: list[xmlrpc.client.Binary], send_iface: str) -> None:
"""RPC function to send packets.
The function is meant to be executed on the remote TG node.
@@ -197,9 +195,7 @@ class ScapyTrafficGenerator(CapturingTrafficGenerator):
def __init__(self, tg_node: TGNode, config: ScapyTrafficGeneratorConfig):
self._config = config
self._tg_node = tg_node
- self._logger = getLogger(
- f"{self._tg_node.name} {self._config.traffic_generator_type}"
- )
+ self._logger = getLogger(f"{self._tg_node.name} {self._config.traffic_generator_type}")
assert (
self._tg_node.config.os == OS.linux
@@ -218,9 +214,7 @@ def __init__(self, tg_node: TGNode, config: ScapyTrafficGeneratorConfig):
self._start_xmlrpc_server_in_remote_python(xmlrpc_server_listen_port)
# connect to the server
- server_url = (
- f"http://{self._tg_node.config.hostname}:{xmlrpc_server_listen_port}"
- )
+ server_url = f"http://{self._tg_node.config.hostname}:{xmlrpc_server_listen_port}"
self.rpc_server_proxy = xmlrpc.client.ServerProxy(
server_url, allow_none=True, verbose=SETTINGS.verbose
)
@@ -240,17 +234,14 @@ def _start_xmlrpc_server_in_remote_python(self, listen_port: int):
src = inspect.getsource(QuittableXMLRPCServer)
# Lines with only whitespace break the repl if in the middle of a function
# or class, so strip all lines containing only whitespace
- src = "\n".join(
- [line for line in src.splitlines() if not line.isspace() and line != ""]
- )
+ src = "\n".join([line for line in src.splitlines() if not line.isspace() and line != ""])
spacing = "\n" * 4
# execute it in the python terminal
self.session.send_command(spacing + src + spacing)
self.session.send_command(
- f"server = QuittableXMLRPCServer(('0.0.0.0', {listen_port}));"
- f"server.serve_forever()",
+ f"server = QuittableXMLRPCServer(('0.0.0.0', {listen_port}));server.serve_forever()",
"XMLRPC OK",
)
diff --git a/dts/framework/testbed_model/sut_node.py b/dts/framework/testbed_model/sut_node.py
index 4161d3a4d5..7f75043bd3 100644
--- a/dts/framework/testbed_model/sut_node.py
+++ b/dts/framework/testbed_model/sut_node.py
@@ -131,9 +131,7 @@ def remote_dpdk_build_dir(self) -> PurePath:
@property
def dpdk_version(self) -> str:
if self._dpdk_version is None:
- self._dpdk_version = self.main_session.get_dpdk_version(
- self._remote_dpdk_dir
- )
+ self._dpdk_version = self.main_session.get_dpdk_version(self._remote_dpdk_dir)
return self._dpdk_version
@property
@@ -151,8 +149,7 @@ def compiler_version(self) -> str:
)
else:
self._logger.warning(
- "Failed to get compiler version because"
- "_build_target_config is None."
+ "Failed to get compiler version because _build_target_config is None."
)
return ""
return self._compiler_version
@@ -173,9 +170,7 @@ def get_build_target_info(self) -> BuildTargetInfo:
def _guess_dpdk_remote_dir(self) -> PurePath:
return self.main_session.guess_dpdk_remote_dir(self._remote_tmp_dir)
- def _set_up_build_target(
- self, build_target_config: BuildTargetConfiguration
- ) -> None:
+ def _set_up_build_target(self, build_target_config: BuildTargetConfiguration) -> None:
"""
Setup DPDK on the SUT node.
"""
@@ -195,23 +190,18 @@ def _tear_down_build_target(self) -> None:
"""
self.bind_ports_to_driver(for_dpdk=False)
- def _configure_build_target(
- self, build_target_config: BuildTargetConfiguration
- ) -> None:
+ def _configure_build_target(self, build_target_config: BuildTargetConfiguration) -> None:
"""
Populate common environment variables and set build target config.
"""
self._env_vars = {}
self._build_target_config = build_target_config
- self._env_vars.update(
- self.main_session.get_dpdk_build_env_vars(build_target_config.arch)
- )
+ self._env_vars.update(self.main_session.get_dpdk_build_env_vars(build_target_config.arch))
self._env_vars["CC"] = build_target_config.compiler.name
if build_target_config.compiler_wrapper:
self._env_vars["CC"] = (
- f"'{build_target_config.compiler_wrapper} "
- f"{build_target_config.compiler.name}'"
- )
+ f"'{build_target_config.compiler_wrapper} {build_target_config.compiler.name}'"
+ ) # fmt: skip
@Node.skip_setup
def _copy_dpdk_tarball(self) -> None:
@@ -242,9 +232,7 @@ def _copy_dpdk_tarball(self) -> None:
self.main_session.remove_remote_dir(self._remote_dpdk_dir)
# then extract to remote path
- self.main_session.extract_remote_tarball(
- remote_tarball_path, self._remote_dpdk_dir
- )
+ self.main_session.extract_remote_tarball(remote_tarball_path, self._remote_dpdk_dir)
@Node.skip_setup
def _build_dpdk(self) -> None:
@@ -281,9 +269,7 @@ def build_dpdk_app(self, app_name: str, **meson_dpdk_args: str | bool) -> PurePa
)
if app_name == "all":
- return self.main_session.join_remote_path(
- self.remote_dpdk_build_dir, "examples"
- )
+ return self.main_session.join_remote_path(self.remote_dpdk_build_dir, "examples")
return self.main_session.join_remote_path(
self.remote_dpdk_build_dir, "examples", f"dpdk-{app_name}"
)
@@ -337,9 +323,7 @@ def create_eal_parameters(
'-c 0xf -a 0000:88:00.0 --file-prefix=dpdk_1112_20190809143420';
"""
- lcore_list = LogicalCoreList(
- self.filter_lcores(lcore_filter_specifier, ascending_cores)
- )
+ lcore_list = LogicalCoreList(self.filter_lcores(lcore_filter_specifier, ascending_cores))
if append_prefix_timestamp:
prefix = f"{prefix}_{self._dpdk_timestamp}"
@@ -404,9 +388,7 @@ def create_interactive_shell(
self.remote_dpdk_build_dir, shell_cls.path
)
- return super().create_interactive_shell(
- shell_cls, timeout, privileged, str(eal_parameters)
- )
+ return super().create_interactive_shell(shell_cls, timeout, privileged, str(eal_parameters))
def bind_ports_to_driver(self, for_dpdk: bool = True) -> None:
"""Bind all ports on the SUT to a driver.
diff --git a/dts/framework/testbed_model/tg_node.py b/dts/framework/testbed_model/tg_node.py
index 27025cfa31..79a55663b5 100644
--- a/dts/framework/testbed_model/tg_node.py
+++ b/dts/framework/testbed_model/tg_node.py
@@ -45,9 +45,7 @@ class TGNode(Node):
def __init__(self, node_config: TGNodeConfiguration):
super(TGNode, self).__init__(node_config)
- self.traffic_generator = create_traffic_generator(
- self, node_config.traffic_generator
- )
+ self.traffic_generator = create_traffic_generator(self, node_config.traffic_generator)
self._logger.info(f"Created node: {self.name}")
def send_packet_and_capture(
@@ -94,6 +92,5 @@ def create_traffic_generator(
return ScapyTrafficGenerator(tg_node, traffic_generator_config)
case _:
raise ConfigurationError(
- "Unknown traffic generator: "
- f"{traffic_generator_config.traffic_generator_type}"
+ f"Unknown traffic generator: {traffic_generator_config.traffic_generator_type}"
)
diff --git a/dts/framework/utils.py b/dts/framework/utils.py
index d27c2c5b5f..d098d364ff 100644
--- a/dts/framework/utils.py
+++ b/dts/framework/utils.py
@@ -19,9 +19,7 @@
class StrEnum(Enum):
@staticmethod
- def _generate_next_value_(
- name: str, start: int, count: int, last_values: object
- ) -> str:
+ def _generate_next_value_(name: str, start: int, count: int, last_values: object) -> str:
return name
def __str__(self) -> str:
@@ -32,9 +30,7 @@ def __str__(self) -> str:
def check_dts_python_version() -> None:
- if sys.version_info.major < 3 or (
- sys.version_info.major == 3 and sys.version_info.minor < 10
- ):
+ if sys.version_info.major < 3 or (sys.version_info.major == 3 and sys.version_info.minor < 10):
print(
RED(
(
@@ -60,9 +56,7 @@ def expand_range(range_str: str) -> list[int]:
range_boundaries = range_str.split("-")
# will throw an exception when items in range_boundaries can't be converted,
# serving as type check
- expanded_range.extend(
- range(int(range_boundaries[0]), int(range_boundaries[-1]) + 1)
- )
+ expanded_range.extend(range(int(range_boundaries[0]), int(range_boundaries[-1]) + 1))
return expanded_range
@@ -71,9 +65,7 @@ def get_packet_summaries(packets: list[Packet]):
if len(packets) == 1:
packet_summaries = packets[0].summary()
else:
- packet_summaries = json.dumps(
- list(map(lambda pkt: pkt.summary(), packets)), indent=4
- )
+ packet_summaries = json.dumps(list(map(lambda pkt: pkt.summary(), packets)), indent=4)
return f"Packet contents: \n{packet_summaries}"
@@ -94,9 +86,7 @@ class MesonArgs(object):
_default_library: str
def __init__(self, default_library: str | None = None, **dpdk_args: str | bool):
- self._default_library = (
- f"--default-library={default_library}" if default_library else ""
- )
+ self._default_library = f"--default-library={default_library}" if default_library else ""
self._dpdk_args = " ".join(
(
f"-D{dpdk_arg_name}={dpdk_arg_value}"
diff --git a/dts/tests/TestSuite_hello_world.py b/dts/tests/TestSuite_hello_world.py
index 7e3d95c0cf..768ba1cfa8 100644
--- a/dts/tests/TestSuite_hello_world.py
+++ b/dts/tests/TestSuite_hello_world.py
@@ -34,9 +34,7 @@ def test_hello_world_single_core(self) -> None:
# get the first usable core
lcore_amount = LogicalCoreCount(1, 1, 1)
lcores = LogicalCoreCountFilter(self.sut_node.lcores, lcore_amount).filter()
- eal_para = self.sut_node.create_eal_parameters(
- lcore_filter_specifier=lcore_amount
- )
+ eal_para = self.sut_node.create_eal_parameters(lcore_filter_specifier=lcore_amount)
result = self.sut_node.run_dpdk_app(self.app_helloworld_path, eal_para)
self.verify(
f"hello from core {int(lcores[0])}" in result.stdout,
diff --git a/dts/tests/TestSuite_smoke_tests.py b/dts/tests/TestSuite_smoke_tests.py
index e8016d1b54..8958f58dac 100644
--- a/dts/tests/TestSuite_smoke_tests.py
+++ b/dts/tests/TestSuite_smoke_tests.py
@@ -45,13 +45,10 @@ def test_driver_tests(self) -> None:
for dev in self.sut_node.virtual_devices:
vdev_args += f"--vdev {dev} "
vdev_args = vdev_args[:-1]
- driver_tests_command = (
- f"meson test -C {self.dpdk_build_dir_path} --suite driver-tests"
- )
+ driver_tests_command = f"meson test -C {self.dpdk_build_dir_path} --suite driver-tests"
if vdev_args:
self._logger.info(
- "Running driver tests with the following virtual "
- f"devices: {vdev_args}"
+ f"Running driver tests with the following virtual devices: {vdev_args}"
)
driver_tests_command += f' --test-args "{vdev_args}"'
@@ -67,9 +64,7 @@ def test_devices_listed_in_testpmd(self) -> None:
Test:
Uses testpmd driver to verify that devices have been found by testpmd.
"""
- testpmd_driver = self.sut_node.create_interactive_shell(
- TestPmdShell, privileged=True
- )
+ testpmd_driver = self.sut_node.create_interactive_shell(TestPmdShell, privileged=True)
dev_list = [str(x) for x in testpmd_driver.get_devices()]
for nic in self.nics_in_node:
self.verify(
--
2.34.1
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v6 2/2] dts: reformat to 100 line length
2023-11-20 12:36 ` [PATCH v6 2/2] dts: reformat to 100 line length Juraj Linkeš
@ 2023-11-20 16:50 ` Thomas Monjalon
2023-11-21 9:27 ` Juraj Linkeš
0 siblings, 1 reply; 36+ messages in thread
From: Thomas Monjalon @ 2023-11-20 16:50 UTC (permalink / raw)
To: Juraj Linkeš
Cc: Honnappa.Nagarahalli, bruce.richardson, jspewock, probb,
paul.szczepanek, yoan.picchi, stephen, dev
20/11/2023 13:36, Juraj Linkeš:
> Reformat to 100 from the previous 88 to unify with C recommendations.
>
> The C recommendation is the maximum with the ideal being 80. The Python
> tools are not suitable for this flexibility.
>
> We require all patches with DTS code to be validated with the
> devtools/dts-check-format.sh script, part of which is the black
> formatting tool. We've set up black to format all of the codebase and
> the reformat is needed so that future submitters are not affected.
>
> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Acked-by: Jeremy Spewock <jspewock@iol.unh.edu>
In general, I don't like doing large cosmetic changes,
but it looks mandatory to allow automatic formatting with black.
Applied, thanks.
Note that my pylama is still emitting warning when it goes longer than 79.
It may be a problem in my environment but something to check.
By the way, why are we using pylama in the script
instead of directly calling the linters we are interested in?
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v6 2/2] dts: reformat to 100 line length
2023-11-20 16:50 ` Thomas Monjalon
@ 2023-11-21 9:27 ` Juraj Linkeš
0 siblings, 0 replies; 36+ messages in thread
From: Juraj Linkeš @ 2023-11-21 9:27 UTC (permalink / raw)
To: Thomas Monjalon
Cc: Honnappa.Nagarahalli, bruce.richardson, jspewock, probb,
paul.szczepanek, yoan.picchi, stephen, dev
On Mon, Nov 20, 2023 at 5:50 PM Thomas Monjalon <thomas@monjalon.net> wrote:
>
> 20/11/2023 13:36, Juraj Linkeš:
> > Reformat to 100 from the previous 88 to unify with C recommendations.
> >
> > The C recommendation is the maximum with the ideal being 80. The Python
> > tools are not suitable for this flexibility.
> >
> > We require all patches with DTS code to be validated with the
> > devtools/dts-check-format.sh script, part of which is the black
> > formatting tool. We've set up black to format all of the codebase and
> > the reformat is needed so that future submitters are not affected.
> >
> > Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > Acked-by: Jeremy Spewock <jspewock@iol.unh.edu>
>
> In general, I don't like doing large cosmetic changes,
> but it looks mandatory to allow automatic formatting with black.
>
> Applied, thanks.
>
> Note that my pylama is still emitting warning when it goes longer than 79.
> It may be a problem in my environment but something to check.
> By the way, why are we using pylama in the script
> instead of directly calling the linters we are interested in?
>
This is a good point. It's mainly a little bit of convenience, as it's
easier to run just one tool instead of multiples (and possibly
different config files). But seeing as Pylama doesn't seem to be
maintained well (it doesn't work with mypy properly and there are
issues with pydocstyle as well), we may eschew it and go with running
the linters individually - I'll note this for the future.
>
>
^ permalink raw reply [flat|nested] 36+ messages in thread
end of thread, other threads:[~2023-11-21 9:27 UTC | newest]
Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-03 13:29 [PATCH v1 0/2] python gitignore and line length Juraj Linkeš
2022-11-03 13:29 ` [PATCH v1 1/2] git: ignore standard python files Juraj Linkeš
2022-11-04 9:16 ` Juraj Linkeš
2022-11-04 9:26 ` Bruce Richardson
2023-07-16 18:11 ` [PATCH] doc: fix description of runtime directories Stephen Hemminger
2023-07-20 3:26 ` Thomas Monjalon
2022-11-03 13:29 ` [PATCH v1 2/2] doc: increase python max line to 88 Juraj Linkeš
2022-11-04 9:16 ` Juraj Linkeš
2022-11-04 9:28 ` Bruce Richardson
2022-11-04 16:57 ` Stephen Hemminger
2022-11-10 9:15 ` Juraj Linkeš
2022-11-10 16:27 ` Stephen Hemminger
2023-09-26 12:10 ` [PATCH v2 1/2] doc: increase python max line length to 100 Juraj Linkeš
2023-09-26 12:10 ` [PATCH v2 2/2] dts: reformat to 100 line length Juraj Linkeš
2023-09-26 21:52 ` Jeremy Spewock
2023-09-28 7:27 ` Juraj Linkeš
2023-09-27 8:08 ` Bruce Richardson
2023-09-28 7:33 ` Juraj Linkeš
2023-09-28 8:42 ` Bruce Richardson
2023-09-26 13:00 ` [PATCH v2 1/2] doc: increase python max line length to 100 Bruce Richardson
2023-09-28 12:18 ` [PATCH v3 " Juraj Linkeš
2023-09-28 12:18 ` [PATCH v3 2/2] dts: reformat to 100 line length Juraj Linkeš
2023-09-29 16:53 ` Jeremy Spewock
2023-10-13 7:58 ` [PATCH v4 1/2] doc: increase python max line length to 100 Juraj Linkeš
2023-10-13 7:58 ` [PATCH v4 2/2] dts: reformat to 100 line length Juraj Linkeš
2023-10-16 6:45 ` [PATCH v5 1/2] doc: increase python max line length to 100 Juraj Linkeš
2023-10-16 6:45 ` [PATCH v5 2/2] dts: reformat to 100 line length Juraj Linkeš
2023-11-20 12:36 ` [PATCH v6 1/2] doc: increase python max line length to 100 Juraj Linkeš
2023-11-20 12:36 ` [PATCH v6 2/2] dts: reformat to 100 line length Juraj Linkeš
2023-11-20 16:50 ` Thomas Monjalon
2023-11-21 9:27 ` Juraj Linkeš
2023-10-13 16:09 ` [PATCH v4 1/2] doc: increase python max line length to 100 Stephen Hemminger
2023-10-16 6:44 ` Juraj Linkeš
2023-10-12 12:52 ` [PATCH v3 " Paul Szczepanek
2023-10-13 7:56 ` Juraj Linkeš
2022-11-04 9:15 ` [PATCH v1 0/2] python gitignore and line length Juraj Linkeš
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).