Skip to content

Commit

Permalink
dts: rework arguments framework
Browse files Browse the repository at this point in the history
The existing argument handling in the code relies on basic argparse
functionality and a custom argparse action to integrate environment
variables. This commit improves the current handling by augmenting
argparse.

This rework implements the following improvements:
- There are duplicate expressions scattered throughout the code. To
  improve readability and maintainability, these are refactored
  into list/dict comprehensions or factory functions.
- Instead of relying solely on argument flags, error messages now
  accurately reference environment variables when applicable, enhancing
  user experience. For instance:

    error: environment variable DTS_DPDK_TARBALL: Invalid file

- Knowing the number of environment variables and arguments set
  allow for a useful help page display when none are provided.
- A display of which environment variables have been detected and their
  corresponding values in the help page, aiding user awareness.

Signed-off-by: Luca Vizzarro <luca.vizzarro@arm.com>
Signed-off-by: 0-day Robot <robot@bytheb.org>
  • Loading branch information
Sevenarth authored and ovsrobot committed May 14, 2024
1 parent c51ebc2 commit 93ecad1
Show file tree
Hide file tree
Showing 2 changed files with 235 additions and 98 deletions.
53 changes: 32 additions & 21 deletions doc/guides/tools/dts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -215,30 +215,41 @@ DTS is run with ``main.py`` located in the ``dts`` directory after entering Poet
.. code-block:: console
(dts-py3.10) $ ./main.py --help
usage: main.py [-h] [--config-file CONFIG_FILE] [--output-dir OUTPUT_DIR] [-t TIMEOUT] [-v] [-s] [--tarball TARBALL] [--compile-timeout COMPILE_TIMEOUT] [--test-suite TEST_SUITE [TEST_CASES ...]] [--re-run RE_RUN]
usage: main.py [-h] [--config-file FILE_PATH] [--output-dir DIR_PATH] [-t SECONDS] [-v] [-s] [--tarball FILE_PATH]
[--compile-timeout SECONDS] [--test-suite TEST_SUITE [TEST_CASES ...]] [--re-run N_TIMES]
Run DPDK test suites. All options may be specified with the environment variables provided in brackets. Command line arguments have higher priority.
Run DPDK test suites. All options may be specified with the environment variables provided in brackets. Command
line arguments have higher priority.
options:
-h, --help show this help message and exit
--config-file CONFIG_FILE
[DTS_CFG_FILE] The configuration file that describes the test cases, SUTs and targets. (default: ./conf.yaml)
--output-dir OUTPUT_DIR, --output OUTPUT_DIR
[DTS_OUTPUT_DIR] Output directory where DTS logs and results are saved. (default: output)
-t TIMEOUT, --timeout TIMEOUT
[DTS_TIMEOUT] The default timeout for all DTS operations except for compiling DPDK. (default: 15)
-v, --verbose [DTS_VERBOSE] Specify to enable verbose output, logging all messages to the console. (default: False)
-s, --skip-setup [DTS_SKIP_SETUP] Specify to skip all setup steps on SUT and TG nodes. (default: False)
--tarball TARBALL, --snapshot TARBALL, --git-ref TARBALL
[DTS_DPDK_TARBALL] Path to DPDK source code tarball or a git commit ID, tag ID or tree ID to test. To test local changes, first commit them, then use the commit ID with this option. (default: dpdk.tar.xz)
--compile-timeout COMPILE_TIMEOUT
[DTS_COMPILE_TIMEOUT] The timeout for compiling DPDK. (default: 1200)
--test-suite TEST_SUITE [TEST_CASES ...]
[DTS_TEST_SUITES] A list containing a test suite with test cases. The first parameter is the test suite name, and the rest are test case names, which are optional. May be specified multiple times. To specify multiple test suites in the environment
variable, join the lists with a comma. Examples: --test-suite suite case case --test-suite suite case ... | DTS_TEST_SUITES='suite case case, suite case, ...' | --test-suite suite --test-suite suite case ... | DTS_TEST_SUITES='suite, suite case, ...'
(default: [])
--re-run RE_RUN, --re_run RE_RUN
[DTS_RERUN] Re-run each test case the specified number of times if a test failure occurs. (default: 0)
-h, --help show this help message and exit
--config-file FILE_PATH
[DTS_CFG_FILE] The configuration file that describes the test cases, SUTs and targets.
(default: conf.yaml)
--output-dir DIR_PATH, --output DIR_PATH
[DTS_OUTPUT_DIR] Output directory where DTS logs and results are saved. (default: output)
-t SECONDS, --timeout SECONDS
[DTS_TIMEOUT] The default timeout for all DTS operations except for compiling DPDK.
(default: 15)
-v, --verbose [DTS_VERBOSE] Specify to enable verbose output, logging all messages to the console.
(default: False)
-s, --skip-setup [DTS_SKIP_SETUP] Specify to skip all setup steps on SUT and TG nodes. (default: False)
--tarball FILE_PATH, --snapshot FILE_PATH, --git-ref FILE_PATH
[DTS_DPDK_TARBALL] Path to DPDK source code tarball or a git commit ID,tag ID or tree ID to
test. To test local changes, first commit them, then use the commit ID with this option.
(default: dpdk.tar.xz)
--compile-timeout SECONDS
[DTS_COMPILE_TIMEOUT] The timeout for compiling DPDK. (default: 1200)
--test-suite TEST_SUITE [TEST_CASES ...]
[DTS_TEST_SUITES] A list containing a test suite with test cases. The first parameter is
the test suite name, and the rest are test case names, which are optional. May be specified
multiple times. To specify multiple test suites in the environment variable, join the lists
with a comma. Examples: --test-suite SUITE1 CASE1 CASE2 --test-suite SUITE2 CASE1 ... |
DTS_TEST_SUITES='SUITE1 CASE1 CASE2, SUITE2 CASE1, ...' | --test-suite SUITE1 --test-suite SUITE2
CASE1 ... | DTS_TEST_SUITES='SUITE1, SUITE2 CASE1, ...' (default: [])
--re-run N_TIMES, --re_run N_TIMES
[DTS_RERUN] Re-run each test case the specified number of times if a test failure occurs.
(default: 0)
The brackets contain the names of environment variables that set the same thing.
Expand Down

0 comments on commit 93ecad1

Please sign in to comment.