DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Juraj Linkeš" <juraj.linkes@pantheon.tech>
Cc: dev@dpdk.org, "Juraj Linkeš" <juraj.linkes@pantheon.tech>
Subject: [PATCH v7 2/9] dts: add developer tools
Date: Thu,  3 Nov 2022 15:19:27 +0000	[thread overview]
Message-ID: <20221103151934.450887-3-juraj.linkes@pantheon.tech> (raw)
In-Reply-To: <20221103151934.450887-1-juraj.linkes@pantheon.tech>

The devtools that check Python code are Black and Isort to format the
code and Pylama to do static analysis.

Signed-off-by: Owen Hilyard <ohilyard@iol.unh.edu>
Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
 devtools/dts-check-format.sh | 87 ++++++++++++++++++++++++++++++++++++
 doc/guides/tools/dts.rst     | 67 +++++++++++++++++++++++++++
 2 files changed, 154 insertions(+)
 create mode 100755 devtools/dts-check-format.sh

diff --git a/devtools/dts-check-format.sh b/devtools/dts-check-format.sh
new file mode 100755
index 0000000000..5a1e495634
--- /dev/null
+++ b/devtools/dts-check-format.sh
@@ -0,0 +1,87 @@
+#!/bin/sh
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2022 University of New Hampshire
+
+usage() {
+    echo "Run formatting and linting programs for DTS. Usage:"
+
+    # Get source code comments after getopts arguments and print them both
+    grep -E '[a-zA-Z]+\) +#' "$0" | tr -d '#'
+    exit 0
+}
+
+format=true
+lint=true
+
+# Comments after args serve as documentation; must be present
+while getopts "hfl" arg; do
+    case $arg in
+    h) # Display this message
+        usage
+        ;;
+    f) # Don't run formatters
+        format=false
+        ;;
+    l) # Don't run linter
+        lint=false
+        ;;
+    *)
+    esac
+done
+
+
+errors=0
+
+if $format; then
+    if command -v git > /dev/null; then
+        if git rev-parse --is-inside-work-tree >&-; then
+            echo "Formatting:"
+            if command -v black > /dev/null; then
+                echo "Formatting code with black:"
+                black .
+            else
+                echo "black is not installed, not formatting"
+                errors=$((errors + 1))
+            fi
+            if command -v isort > /dev/null; then
+                echo "Sorting imports with isort:"
+                isort .
+            else
+                echo "isort is not installed, not sorting imports"
+                errors=$((errors + 1))
+            fi
+
+            git update-index --refresh
+            retval=$?
+            if [ $retval -ne 0 ]; then
+                echo 'The "needs update" files have been reformatted.'
+                echo 'Please update your commit.'
+            fi
+            errors=$((errors + retval))
+        else
+            echo ".git directory not found, not formatting code"
+            errors=$((errors + 1))
+        fi
+    else
+        echo "git command not found, not formatting code"
+        errors=$((errors + 1))
+    fi
+fi
+
+if $lint; then
+    if $format; then
+        echo
+    fi
+    echo "Linting:"
+    if command -v pylama > /dev/null; then
+        pylama .
+        errors=$((errors + $?))
+    else
+        echo "pylama not found, unable to run linter"
+        errors=$((errors + 1))
+    fi
+fi
+
+echo
+echo "Found $errors errors"
+exit $errors
diff --git a/doc/guides/tools/dts.rst b/doc/guides/tools/dts.rst
index 7913693a1c..0b9bcbdaac 100644
--- a/doc/guides/tools/dts.rst
+++ b/doc/guides/tools/dts.rst
@@ -8,6 +8,44 @@ The DPDK Test Suite, abbreviated DTS, is a Python test framework with test suite
 implementing functional and performance tests used to test DPDK.
 
 
+DTS Terminology
+---------------
+
+DTS node
+   A generic description of any host/server DTS connects to.
+
+DTS runtime environment
+   An environment containing Python with packages needed to run DTS.
+
+DTS runtime environment node
+  A node where at least one DTS runtime environment is present.
+  This is the node where we run DTS and from which DTS connects to other nodes.
+
+System under test
+  An SUT is the combination of DPDK and the hardware we're testing
+  in conjunction with DPDK (NICs, crypto and other devices).
+
+System under test node
+  A node where at least one SUT is present.
+
+Traffic generator
+  A TG is either software or hardware capable of sending packets.
+
+Traffic generator node
+  A node where at least one TG is present.
+  In case of hardware traffic generators, the TG and the node are literally the same.
+
+
+In most cases, interchangeably referring to a runtime environment, SUT, TG or the node
+they're running on (e.g. using SUT and SUT node interchangeably) doesn't cause confusion.
+There could theoretically be more than of these running on the same node and in that case
+it's useful to have stricter definitions.
+An example would be two different traffic generators (such as Trex and Scapy)
+running on the same node.
+A different example would be a node containing both a DTS runtime environment
+and a traffic generator, in which case it's both a DTS runtime environment node and a TG node.
+
+
 DTS Environment
 ---------------
 
@@ -54,3 +92,32 @@ Setting up DTS environment
 
       poetry install
       poetry shell
+
+
+DTS Developer Tools
+-------------------
+
+There are three tools used in DTS to help with code checking, style and formatting:
+
+* `isort <https://pycqa.github.io/isort/>`_
+
+  Alphabetically sorts python imports within blocks.
+
+* `black <https://github.com/psf/black>`_
+
+  Does most of the actual formatting (whitespaces, comments, line length etc.)
+  and works similarly to clang-format.
+
+* `pylama <https://github.com/klen/pylama>`_
+
+  Runs a collection of python linters and aggregates output.
+  It will run these tools over the repository:
+
+  .. literalinclude:: ../../../dts/pyproject.toml
+     :language: toml
+     :start-after: [tool.pylama]
+     :end-at: linters
+
+These three tools are all used in ``devtools/dts-check-format.sh``,
+the DTS code check and format script.
+Refer to the script for usage: ``devtools/dts-check-format.sh -h``
-- 
2.30.2


  parent reply	other threads:[~2022-11-03 15:19 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-13 10:35 [PATCH v6 00/10] dts: ssh connection to a node Juraj Linkeš
2022-10-13 10:35 ` [PATCH v6 01/10] dts: add project tools config Juraj Linkeš
2022-10-13 10:35 ` [PATCH v6 02/10] dts: add developer tools Juraj Linkeš
2022-10-13 10:35 ` [PATCH v6 03/10] dts: add config parser module Juraj Linkeš
2022-10-13 10:35 ` [PATCH v6 04/10] dts: add basic logging facility Juraj Linkeš
2022-10-13 10:35 ` [PATCH v6 05/10] dts: add remote session abstraction Juraj Linkeš
2022-10-13 10:35 ` [PATCH v6 06/10] dts: add ssh session module Juraj Linkeš
2022-10-13 10:35 ` [PATCH v6 07/10] dts: add node base class Juraj Linkeš
2022-10-13 10:35 ` [PATCH v6 08/10] dts: add dts workflow module Juraj Linkeš
2022-10-13 10:35 ` [PATCH v6 09/10] dts: add dts executable script Juraj Linkeš
2022-10-13 10:35 ` [PATCH v6 10/10] maintainers: add dts maintainers Juraj Linkeš
2022-10-13 10:45 ` [PATCH v6 00/10] dts: ssh connection to a node Bruce Richardson
2022-10-31 19:01 ` Thomas Monjalon
2022-11-02 12:58   ` Owen Hilyard
2022-11-02 13:15     ` Thomas Monjalon
2022-11-03 15:19 ` [PATCH v7 0/9] " Juraj Linkeš
2022-11-03 15:19   ` [PATCH v7 1/9] dts: add project tools config Juraj Linkeš
2022-11-03 15:19   ` Juraj Linkeš [this message]
2022-11-03 15:19   ` [PATCH v7 3/9] dts: add config parser module Juraj Linkeš
2022-11-03 15:19   ` [PATCH v7 4/9] dts: add basic logging facility Juraj Linkeš
2022-11-03 15:19   ` [PATCH v7 5/9] dts: add remote session abstraction Juraj Linkeš
2022-11-03 15:19   ` [PATCH v7 6/9] dts: add ssh session module Juraj Linkeš
2022-11-03 15:19   ` [PATCH v7 7/9] dts: add node base class Juraj Linkeš
2022-11-03 15:19   ` [PATCH v7 8/9] dts: add dts workflow module Juraj Linkeš
2022-11-03 15:19   ` [PATCH v7 9/9] dts: add dts executable script Juraj Linkeš
2022-11-04 11:05   ` [PATCH v8 0/9] dts: ssh connection to a node Juraj Linkeš
2022-11-04 11:05     ` [PATCH v8 1/9] dts: add project tools config Juraj Linkeš
2022-11-04 11:05     ` [PATCH v8 2/9] dts: add developer tools Juraj Linkeš
2022-11-04 11:05     ` [PATCH v8 3/9] dts: add config parser module Juraj Linkeš
2022-11-04 11:05     ` [PATCH v8 4/9] dts: add basic logging facility Juraj Linkeš
2022-11-04 11:05     ` [PATCH v8 5/9] dts: add remote session abstraction Juraj Linkeš
2022-11-04 11:05     ` [PATCH v8 6/9] dts: add ssh session module Juraj Linkeš
2022-11-04 11:05     ` [PATCH v8 7/9] dts: add node base class Juraj Linkeš
2022-11-04 11:05     ` [PATCH v8 8/9] dts: add dts workflow module Juraj Linkeš
2022-11-04 11:05     ` [PATCH v8 9/9] dts: add dts executable script Juraj Linkeš
2022-11-09 16:11     ` [PATCH v8 0/9] dts: ssh connection to a node Thomas Monjalon
2022-11-09 16:23       ` Honnappa Nagarahalli
2022-11-09 17:05         ` Owen Hilyard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221103151934.450887-3-juraj.linkes@pantheon.tech \
    --to=juraj.linkes@pantheon.tech \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).